documentation.d.ts 2.9 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384
  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. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * A class serves as a medium between the observable and its observers
  52. */
  53. export class EventState {
  54. /**
  55. * Create a new EventState
  56. * @param mask defines the mask associated with this state
  57. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  58. * @param target defines the original target of the state
  59. * @param currentTarget defines the current target of the state
  60. */
  61. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62. /**
  63. * Initialize the current event state
  64. * @param mask defines the mask associated with this state
  65. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66. * @param target defines the original target of the state
  67. * @param currentTarget defines the current target of the state
  68. * @returns the current event state
  69. */
  70. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  71. /**
  72. * An Observer can set this property to true to prevent subsequent observers of being notified
  73. */
  74. skipNextObservers: boolean;
  75. /**
  76. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77. */
  78. mask: number;
  79. /**
  80. * The object that originally notified the event
  81. */
  82. target?: any;
  83. /**
  84. * The current object in the bubbling phase
  85. */
  86. currentTarget?: any;
  87. /**
  88. * This will be populated with the return value of the last function that was executed.
  89. * If it is the first function in the callback chain it will be the event data.
  90. */
  91. lastReturnValue?: any;
  92. }
  93. /**
  94. * Represent an Observer registered to a given Observable object.
  95. */
  96. export class Observer<T> {
  97. /**
  98. * Defines the callback to call when the observer is notified
  99. */
  100. callback: (eventData: T, eventState: EventState) => void;
  101. /**
  102. * Defines the mask of the observer (used to filter notifications)
  103. */
  104. mask: number;
  105. /**
  106. * Defines the current scope used to restore the JS context
  107. */
  108. scope: any;
  109. /** @hidden */
  110. _willBeUnregistered: boolean;
  111. /**
  112. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  113. */
  114. unregisterOnNextCall: boolean;
  115. /**
  116. * Creates a new observer
  117. * @param callback defines the callback to call when the observer is notified
  118. * @param mask defines the mask of the observer (used to filter notifications)
  119. * @param scope defines the current scope used to restore the JS context
  120. */
  121. constructor(
  122. /**
  123. * Defines the callback to call when the observer is notified
  124. */
  125. callback: (eventData: T, eventState: EventState) => void,
  126. /**
  127. * Defines the mask of the observer (used to filter notifications)
  128. */
  129. mask: number,
  130. /**
  131. * Defines the current scope used to restore the JS context
  132. */
  133. scope?: any);
  134. }
  135. /**
  136. * Represent a list of observers registered to multiple Observables object.
  137. */
  138. export class MultiObserver<T> {
  139. private _observers;
  140. private _observables;
  141. /**
  142. * Release associated resources
  143. */
  144. dispose(): void;
  145. /**
  146. * Raise a callback when one of the observable will notify
  147. * @param observables defines a list of observables to watch
  148. * @param callback defines the callback to call on notification
  149. * @param mask defines the mask used to filter notifications
  150. * @param scope defines the current scope used to restore the JS context
  151. * @returns the new MultiObserver
  152. */
  153. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  154. }
  155. /**
  156. * The Observable class is a simple implementation of the Observable pattern.
  157. *
  158. * 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.
  159. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  160. * 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).
  161. * 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.
  162. */
  163. export class Observable<T> {
  164. private _observers;
  165. private _eventState;
  166. private _onObserverAdded;
  167. /**
  168. * Gets the list of observers
  169. */
  170. readonly observers: Array<Observer<T>>;
  171. /**
  172. * Creates a new observable
  173. * @param onObserverAdded defines a callback to call when a new observer is added
  174. */
  175. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  176. /**
  177. * Create a new Observer with the specified callback
  178. * @param callback the callback that will be executed for that Observer
  179. * @param mask the mask used to filter observers
  180. * @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.
  181. * @param scope optional scope for the callback to be called from
  182. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  183. * @returns the new observer created for the callback
  184. */
  185. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  186. /**
  187. * Create a new Observer with the specified callback and unregisters after the next notification
  188. * @param callback the callback that will be executed for that Observer
  189. * @returns the new observer created for the callback
  190. */
  191. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  192. /**
  193. * Remove an Observer from the Observable object
  194. * @param observer the instance of the Observer to remove
  195. * @returns false if it doesn't belong to this Observable
  196. */
  197. remove(observer: Nullable<Observer<T>>): boolean;
  198. /**
  199. * Remove a callback from the Observable object
  200. * @param callback the callback to remove
  201. * @param scope optional scope. If used only the callbacks with this scope will be removed
  202. * @returns false if it doesn't belong to this Observable
  203. */
  204. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  205. private _deferUnregister;
  206. private _remove;
  207. /**
  208. * Moves the observable to the top of the observer list making it get called first when notified
  209. * @param observer the observer to move
  210. */
  211. makeObserverTopPriority(observer: Observer<T>): void;
  212. /**
  213. * Moves the observable to the bottom of the observer list making it get called last when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverBottomPriority(observer: Observer<T>): void;
  217. /**
  218. * Notify all Observers by calling their respective callback with the given data
  219. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  220. * @param eventData defines the data to send to all observers
  221. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  222. * @param target defines the original target of the state
  223. * @param currentTarget defines the current target of the state
  224. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  225. */
  226. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  227. /**
  228. * Calling this will execute each callback, expecting it to be a promise or return a value.
  229. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  230. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  231. * and it is crucial that all callbacks will be executed.
  232. * The order of the callbacks is kept, callbacks are not executed parallel.
  233. *
  234. * @param eventData The data to be sent to each callback
  235. * @param mask is used to filter observers defaults to -1
  236. * @param target defines the callback target (see EventState)
  237. * @param currentTarget defines he current object in the bubbling phase
  238. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  239. */
  240. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  241. /**
  242. * Notify a specific observer
  243. * @param observer defines the observer to notify
  244. * @param eventData defines the data to be sent to each callback
  245. * @param mask is used to filter observers defaults to -1
  246. */
  247. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  248. /**
  249. * Gets a boolean indicating if the observable has at least one observer
  250. * @returns true is the Observable has at least one Observer registered
  251. */
  252. hasObservers(): boolean;
  253. /**
  254. * Clear the list of observers
  255. */
  256. clear(): void;
  257. /**
  258. * Clone the current observable
  259. * @returns a new observable
  260. */
  261. clone(): Observable<T>;
  262. /**
  263. * Does this observable handles observer registered with a given mask
  264. * @param mask defines the mask to be tested
  265. * @return whether or not one observer registered with the given mask is handeled
  266. **/
  267. hasSpecificMask(mask?: number): boolean;
  268. }
  269. }
  270. declare module BABYLON {
  271. /**
  272. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  273. * Babylon.js
  274. */
  275. export class DomManagement {
  276. /**
  277. * Checks if the window object exists
  278. * @returns true if the window object exists
  279. */
  280. static IsWindowObjectExist(): boolean;
  281. /**
  282. * Extracts text content from a DOM element hierarchy
  283. * @param element defines the root element
  284. * @returns a string
  285. */
  286. static GetDOMTextContent(element: HTMLElement): string;
  287. }
  288. }
  289. declare module BABYLON {
  290. /**
  291. * Logger used througouht the application to allow configuration of
  292. * the log level required for the messages.
  293. */
  294. export class Logger {
  295. /**
  296. * No log
  297. */
  298. static readonly NoneLogLevel: number;
  299. /**
  300. * Only message logs
  301. */
  302. static readonly MessageLogLevel: number;
  303. /**
  304. * Only warning logs
  305. */
  306. static readonly WarningLogLevel: number;
  307. /**
  308. * Only error logs
  309. */
  310. static readonly ErrorLogLevel: number;
  311. /**
  312. * All logs
  313. */
  314. static readonly AllLogLevel: number;
  315. private static _LogCache;
  316. /**
  317. * Gets a value indicating the number of loading errors
  318. * @ignorenaming
  319. */
  320. static errorsCount: number;
  321. /**
  322. * Callback called when a new log is added
  323. */
  324. static OnNewCacheEntry: (entry: string) => void;
  325. private static _AddLogEntry;
  326. private static _FormatMessage;
  327. private static _LogDisabled;
  328. private static _LogEnabled;
  329. private static _WarnDisabled;
  330. private static _WarnEnabled;
  331. private static _ErrorDisabled;
  332. private static _ErrorEnabled;
  333. /**
  334. * Log a message to the console
  335. */
  336. static Log: (message: string) => void;
  337. /**
  338. * Write a warning message to the console
  339. */
  340. static Warn: (message: string) => void;
  341. /**
  342. * Write an error message to the console
  343. */
  344. static Error: (message: string) => void;
  345. /**
  346. * Gets current log cache (list of logs)
  347. */
  348. static readonly LogCache: string;
  349. /**
  350. * Clears the log cache
  351. */
  352. static ClearLogCache(): void;
  353. /**
  354. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  355. */
  356. static LogLevels: number;
  357. }
  358. }
  359. declare module BABYLON {
  360. /** @hidden */
  361. export class _TypeStore {
  362. /** @hidden */
  363. static RegisteredTypes: {
  364. [key: string]: Object;
  365. };
  366. /** @hidden */
  367. static GetClass(fqdn: string): any;
  368. }
  369. }
  370. declare module BABYLON {
  371. /**
  372. * Class containing a set of static utilities functions for deep copy.
  373. */
  374. export class DeepCopier {
  375. /**
  376. * Tries to copy an object by duplicating every property
  377. * @param source defines the source object
  378. * @param destination defines the target object
  379. * @param doNotCopyList defines a list of properties to avoid
  380. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  381. */
  382. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  383. }
  384. }
  385. declare module BABYLON {
  386. /**
  387. * Class containing a set of static utilities functions for precision date
  388. */
  389. export class PrecisionDate {
  390. /**
  391. * Gets either window.performance.now() if supported or Date.now() else
  392. */
  393. static readonly Now: number;
  394. }
  395. }
  396. declare module BABYLON {
  397. /** @hidden */
  398. export class _DevTools {
  399. static WarnImport(name: string): string;
  400. }
  401. }
  402. declare module BABYLON {
  403. /**
  404. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  405. */
  406. export class WebRequest {
  407. private _xhr;
  408. /**
  409. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  410. * i.e. when loading files, where the server/service expects an Authorization header
  411. */
  412. static CustomRequestHeaders: {
  413. [key: string]: string;
  414. };
  415. /**
  416. * Add callback functions in this array to update all the requests before they get sent to the network
  417. */
  418. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  419. private _injectCustomRequestHeaders;
  420. /**
  421. * Gets or sets a function to be called when loading progress changes
  422. */
  423. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  424. /**
  425. * Returns client's state
  426. */
  427. readonly readyState: number;
  428. /**
  429. * Returns client's status
  430. */
  431. readonly status: number;
  432. /**
  433. * Returns client's status as a text
  434. */
  435. readonly statusText: string;
  436. /**
  437. * Returns client's response
  438. */
  439. readonly response: any;
  440. /**
  441. * Returns client's response url
  442. */
  443. readonly responseURL: string;
  444. /**
  445. * Returns client's response as text
  446. */
  447. readonly responseText: string;
  448. /**
  449. * Gets or sets the expected response type
  450. */
  451. responseType: XMLHttpRequestResponseType;
  452. /** @hidden */
  453. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  454. /** @hidden */
  455. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  456. /**
  457. * Cancels any network activity
  458. */
  459. abort(): void;
  460. /**
  461. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  462. * @param body defines an optional request body
  463. */
  464. send(body?: Document | BodyInit | null): void;
  465. /**
  466. * Sets the request method, request URL
  467. * @param method defines the method to use (GET, POST, etc..)
  468. * @param url defines the url to connect with
  469. */
  470. open(method: string, url: string): void;
  471. }
  472. }
  473. declare module BABYLON {
  474. /**
  475. * File request interface
  476. */
  477. export interface IFileRequest {
  478. /**
  479. * Raised when the request is complete (success or error).
  480. */
  481. onCompleteObservable: Observable<IFileRequest>;
  482. /**
  483. * Aborts the request for a file.
  484. */
  485. abort: () => void;
  486. }
  487. }
  488. declare module BABYLON {
  489. /**
  490. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  491. */
  492. export class PerformanceMonitor {
  493. private _enabled;
  494. private _rollingFrameTime;
  495. private _lastFrameTimeMs;
  496. /**
  497. * constructor
  498. * @param frameSampleSize The number of samples required to saturate the sliding window
  499. */
  500. constructor(frameSampleSize?: number);
  501. /**
  502. * Samples current frame
  503. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  504. */
  505. sampleFrame(timeMs?: number): void;
  506. /**
  507. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  508. */
  509. readonly averageFrameTime: number;
  510. /**
  511. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  512. */
  513. readonly averageFrameTimeVariance: number;
  514. /**
  515. * Returns the frame time of the most recent frame
  516. */
  517. readonly instantaneousFrameTime: number;
  518. /**
  519. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  520. */
  521. readonly averageFPS: number;
  522. /**
  523. * Returns the average framerate in frames per second using the most recent frame time
  524. */
  525. readonly instantaneousFPS: number;
  526. /**
  527. * Returns true if enough samples have been taken to completely fill the sliding window
  528. */
  529. readonly isSaturated: boolean;
  530. /**
  531. * Enables contributions to the sliding window sample set
  532. */
  533. enable(): void;
  534. /**
  535. * Disables contributions to the sliding window sample set
  536. * Samples will not be interpolated over the disabled period
  537. */
  538. disable(): void;
  539. /**
  540. * Returns true if sampling is enabled
  541. */
  542. readonly isEnabled: boolean;
  543. /**
  544. * Resets performance monitor
  545. */
  546. reset(): void;
  547. }
  548. /**
  549. * RollingAverage
  550. *
  551. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  552. */
  553. export class RollingAverage {
  554. /**
  555. * Current average
  556. */
  557. average: number;
  558. /**
  559. * Current variance
  560. */
  561. variance: number;
  562. protected _samples: Array<number>;
  563. protected _sampleCount: number;
  564. protected _pos: number;
  565. protected _m2: number;
  566. /**
  567. * constructor
  568. * @param length The number of samples required to saturate the sliding window
  569. */
  570. constructor(length: number);
  571. /**
  572. * Adds a sample to the sample set
  573. * @param v The sample value
  574. */
  575. add(v: number): void;
  576. /**
  577. * Returns previously added values or null if outside of history or outside the sliding window domain
  578. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  579. * @return Value previously recorded with add() or null if outside of range
  580. */
  581. history(i: number): number;
  582. /**
  583. * Returns true if enough samples have been taken to completely fill the sliding window
  584. * @return true if sample-set saturated
  585. */
  586. isSaturated(): boolean;
  587. /**
  588. * Resets the rolling average (equivalent to 0 samples taken so far)
  589. */
  590. reset(): void;
  591. /**
  592. * Wraps a value around the sample range boundaries
  593. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  594. * @return Wrapped position in sample range
  595. */
  596. protected _wrapPosition(i: number): number;
  597. }
  598. }
  599. declare module BABYLON {
  600. /**
  601. * This class implement a typical dictionary using a string as key and the generic type T as value.
  602. * The underlying implementation relies on an associative array to ensure the best performances.
  603. * The value can be anything including 'null' but except 'undefined'
  604. */
  605. export class StringDictionary<T> {
  606. /**
  607. * This will clear this dictionary and copy the content from the 'source' one.
  608. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  609. * @param source the dictionary to take the content from and copy to this dictionary
  610. */
  611. copyFrom(source: StringDictionary<T>): void;
  612. /**
  613. * Get a value based from its key
  614. * @param key the given key to get the matching value from
  615. * @return the value if found, otherwise undefined is returned
  616. */
  617. get(key: string): T | undefined;
  618. /**
  619. * Get a value from its key or add it if it doesn't exist.
  620. * This method will ensure you that a given key/data will be present in the dictionary.
  621. * @param key the given key to get the matching value from
  622. * @param factory the factory that will create the value if the key is not present in the dictionary.
  623. * The factory will only be invoked if there's no data for the given key.
  624. * @return the value corresponding to the key.
  625. */
  626. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  627. /**
  628. * Get a value from its key if present in the dictionary otherwise add it
  629. * @param key the key to get the value from
  630. * @param val if there's no such key/value pair in the dictionary add it with this value
  631. * @return the value corresponding to the key
  632. */
  633. getOrAdd(key: string, val: T): T;
  634. /**
  635. * Check if there's a given key in the dictionary
  636. * @param key the key to check for
  637. * @return true if the key is present, false otherwise
  638. */
  639. contains(key: string): boolean;
  640. /**
  641. * Add a new key and its corresponding value
  642. * @param key the key to add
  643. * @param value the value corresponding to the key
  644. * @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
  645. */
  646. add(key: string, value: T): boolean;
  647. /**
  648. * Update a specific value associated to a key
  649. * @param key defines the key to use
  650. * @param value defines the value to store
  651. * @returns true if the value was updated (or false if the key was not found)
  652. */
  653. set(key: string, value: T): boolean;
  654. /**
  655. * Get the element of the given key and remove it from the dictionary
  656. * @param key defines the key to search
  657. * @returns the value associated with the key or null if not found
  658. */
  659. getAndRemove(key: string): Nullable<T>;
  660. /**
  661. * Remove a key/value from the dictionary.
  662. * @param key the key to remove
  663. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  664. */
  665. remove(key: string): boolean;
  666. /**
  667. * Clear the whole content of the dictionary
  668. */
  669. clear(): void;
  670. /**
  671. * Gets the current count
  672. */
  673. readonly count: number;
  674. /**
  675. * Execute a callback on each key/val of the dictionary.
  676. * Note that you can remove any element in this dictionary in the callback implementation
  677. * @param callback the callback to execute on a given key/value pair
  678. */
  679. forEach(callback: (key: string, val: T) => void): void;
  680. /**
  681. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  682. * If the callback returns null or undefined the method will iterate to the next key/value pair
  683. * Note that you can remove any element in this dictionary in the callback implementation
  684. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  685. * @returns the first item
  686. */
  687. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  688. private _count;
  689. private _data;
  690. }
  691. }
  692. declare module BABYLON {
  693. /**
  694. * Class used to store gfx data (like WebGLBuffer)
  695. */
  696. export class DataBuffer {
  697. /**
  698. * Gets or sets the number of objects referencing this buffer
  699. */
  700. references: number;
  701. /** Gets or sets the size of the underlying buffer */
  702. capacity: number;
  703. /**
  704. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  705. */
  706. is32Bits: boolean;
  707. /**
  708. * Gets the underlying buffer
  709. */
  710. readonly underlyingResource: any;
  711. }
  712. }
  713. declare module BABYLON {
  714. /**
  715. * Class used to store data that will be store in GPU memory
  716. */
  717. export class Buffer {
  718. private _engine;
  719. private _buffer;
  720. /** @hidden */
  721. _data: Nullable<DataArray>;
  722. private _updatable;
  723. private _instanced;
  724. /**
  725. * Gets the byte stride.
  726. */
  727. readonly byteStride: number;
  728. /**
  729. * Constructor
  730. * @param engine the engine
  731. * @param data the data to use for this buffer
  732. * @param updatable whether the data is updatable
  733. * @param stride the stride (optional)
  734. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  735. * @param instanced whether the buffer is instanced (optional)
  736. * @param useBytes set to true if the stride in in bytes (optional)
  737. */
  738. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  739. /**
  740. * Create a new VertexBuffer based on the current buffer
  741. * @param kind defines the vertex buffer kind (position, normal, etc.)
  742. * @param offset defines offset in the buffer (0 by default)
  743. * @param size defines the size in floats of attributes (position is 3 for instance)
  744. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  745. * @param instanced defines if the vertex buffer contains indexed data
  746. * @param useBytes defines if the offset and stride are in bytes
  747. * @returns the new vertex buffer
  748. */
  749. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  750. /**
  751. * Gets a boolean indicating if the Buffer is updatable?
  752. * @returns true if the buffer is updatable
  753. */
  754. isUpdatable(): boolean;
  755. /**
  756. * Gets current buffer's data
  757. * @returns a DataArray or null
  758. */
  759. getData(): Nullable<DataArray>;
  760. /**
  761. * Gets underlying native buffer
  762. * @returns underlying native buffer
  763. */
  764. getBuffer(): Nullable<DataBuffer>;
  765. /**
  766. * Gets the stride in float32 units (i.e. byte stride / 4).
  767. * May not be an integer if the byte stride is not divisible by 4.
  768. * DEPRECATED. Use byteStride instead.
  769. * @returns the stride in float32 units
  770. */
  771. getStrideSize(): number;
  772. /**
  773. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  774. * @param data defines the data to store
  775. */
  776. create(data?: Nullable<DataArray>): void;
  777. /** @hidden */
  778. _rebuild(): void;
  779. /**
  780. * Update current buffer data
  781. * @param data defines the data to store
  782. */
  783. update(data: DataArray): void;
  784. /**
  785. * Updates the data directly.
  786. * @param data the new data
  787. * @param offset the new offset
  788. * @param vertexCount the vertex count (optional)
  789. * @param useBytes set to true if the offset is in bytes
  790. */
  791. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  792. /**
  793. * Release all resources
  794. */
  795. dispose(): void;
  796. }
  797. /**
  798. * Specialized buffer used to store vertex data
  799. */
  800. export class VertexBuffer {
  801. /** @hidden */
  802. _buffer: Buffer;
  803. private _kind;
  804. private _size;
  805. private _ownsBuffer;
  806. private _instanced;
  807. private _instanceDivisor;
  808. /**
  809. * The byte type.
  810. */
  811. static readonly BYTE: number;
  812. /**
  813. * The unsigned byte type.
  814. */
  815. static readonly UNSIGNED_BYTE: number;
  816. /**
  817. * The short type.
  818. */
  819. static readonly SHORT: number;
  820. /**
  821. * The unsigned short type.
  822. */
  823. static readonly UNSIGNED_SHORT: number;
  824. /**
  825. * The integer type.
  826. */
  827. static readonly INT: number;
  828. /**
  829. * The unsigned integer type.
  830. */
  831. static readonly UNSIGNED_INT: number;
  832. /**
  833. * The float type.
  834. */
  835. static readonly FLOAT: number;
  836. /**
  837. * Gets or sets the instance divisor when in instanced mode
  838. */
  839. instanceDivisor: number;
  840. /**
  841. * Gets the byte stride.
  842. */
  843. readonly byteStride: number;
  844. /**
  845. * Gets the byte offset.
  846. */
  847. readonly byteOffset: number;
  848. /**
  849. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  850. */
  851. readonly normalized: boolean;
  852. /**
  853. * Gets the data type of each component in the array.
  854. */
  855. readonly type: number;
  856. /**
  857. * Constructor
  858. * @param engine the engine
  859. * @param data the data to use for this vertex buffer
  860. * @param kind the vertex buffer kind
  861. * @param updatable whether the data is updatable
  862. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  863. * @param stride the stride (optional)
  864. * @param instanced whether the buffer is instanced (optional)
  865. * @param offset the offset of the data (optional)
  866. * @param size the number of components (optional)
  867. * @param type the type of the component (optional)
  868. * @param normalized whether the data contains normalized data (optional)
  869. * @param useBytes set to true if stride and offset are in bytes (optional)
  870. */
  871. 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);
  872. /** @hidden */
  873. _rebuild(): void;
  874. /**
  875. * Returns the kind of the VertexBuffer (string)
  876. * @returns a string
  877. */
  878. getKind(): string;
  879. /**
  880. * Gets a boolean indicating if the VertexBuffer is updatable?
  881. * @returns true if the buffer is updatable
  882. */
  883. isUpdatable(): boolean;
  884. /**
  885. * Gets current buffer's data
  886. * @returns a DataArray or null
  887. */
  888. getData(): Nullable<DataArray>;
  889. /**
  890. * Gets underlying native buffer
  891. * @returns underlying native buffer
  892. */
  893. getBuffer(): Nullable<DataBuffer>;
  894. /**
  895. * Gets the stride in float32 units (i.e. byte stride / 4).
  896. * May not be an integer if the byte stride is not divisible by 4.
  897. * DEPRECATED. Use byteStride instead.
  898. * @returns the stride in float32 units
  899. */
  900. getStrideSize(): number;
  901. /**
  902. * Returns the offset as a multiple of the type byte length.
  903. * DEPRECATED. Use byteOffset instead.
  904. * @returns the offset in bytes
  905. */
  906. getOffset(): number;
  907. /**
  908. * Returns the number of components per vertex attribute (integer)
  909. * @returns the size in float
  910. */
  911. getSize(): number;
  912. /**
  913. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  914. * @returns true if this buffer is instanced
  915. */
  916. getIsInstanced(): boolean;
  917. /**
  918. * Returns the instancing divisor, zero for non-instanced (integer).
  919. * @returns a number
  920. */
  921. getInstanceDivisor(): number;
  922. /**
  923. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  924. * @param data defines the data to store
  925. */
  926. create(data?: DataArray): void;
  927. /**
  928. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  929. * This function will create a new buffer if the current one is not updatable
  930. * @param data defines the data to store
  931. */
  932. update(data: DataArray): void;
  933. /**
  934. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  935. * Returns the directly updated WebGLBuffer.
  936. * @param data the new data
  937. * @param offset the new offset
  938. * @param useBytes set to true if the offset is in bytes
  939. */
  940. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  941. /**
  942. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  943. */
  944. dispose(): void;
  945. /**
  946. * Enumerates each value of this vertex buffer as numbers.
  947. * @param count the number of values to enumerate
  948. * @param callback the callback function called for each value
  949. */
  950. forEach(count: number, callback: (value: number, index: number) => void): void;
  951. /**
  952. * Positions
  953. */
  954. static readonly PositionKind: string;
  955. /**
  956. * Normals
  957. */
  958. static readonly NormalKind: string;
  959. /**
  960. * Tangents
  961. */
  962. static readonly TangentKind: string;
  963. /**
  964. * Texture coordinates
  965. */
  966. static readonly UVKind: string;
  967. /**
  968. * Texture coordinates 2
  969. */
  970. static readonly UV2Kind: string;
  971. /**
  972. * Texture coordinates 3
  973. */
  974. static readonly UV3Kind: string;
  975. /**
  976. * Texture coordinates 4
  977. */
  978. static readonly UV4Kind: string;
  979. /**
  980. * Texture coordinates 5
  981. */
  982. static readonly UV5Kind: string;
  983. /**
  984. * Texture coordinates 6
  985. */
  986. static readonly UV6Kind: string;
  987. /**
  988. * Colors
  989. */
  990. static readonly ColorKind: string;
  991. /**
  992. * Matrix indices (for bones)
  993. */
  994. static readonly MatricesIndicesKind: string;
  995. /**
  996. * Matrix weights (for bones)
  997. */
  998. static readonly MatricesWeightsKind: string;
  999. /**
  1000. * Additional matrix indices (for bones)
  1001. */
  1002. static readonly MatricesIndicesExtraKind: string;
  1003. /**
  1004. * Additional matrix weights (for bones)
  1005. */
  1006. static readonly MatricesWeightsExtraKind: string;
  1007. /**
  1008. * Deduces the stride given a kind.
  1009. * @param kind The kind string to deduce
  1010. * @returns The deduced stride
  1011. */
  1012. static DeduceStride(kind: string): number;
  1013. /**
  1014. * Gets the byte length of the given type.
  1015. * @param type the type
  1016. * @returns the number of bytes
  1017. */
  1018. static GetTypeByteLength(type: number): number;
  1019. /**
  1020. * Enumerates each value of the given parameters as numbers.
  1021. * @param data the data to enumerate
  1022. * @param byteOffset the byte offset of the data
  1023. * @param byteStride the byte stride of the data
  1024. * @param componentCount the number of components per element
  1025. * @param componentType the type of the component
  1026. * @param count the number of values to enumerate
  1027. * @param normalized whether the data is normalized
  1028. * @param callback the callback function called for each value
  1029. */
  1030. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1031. private static _GetFloatValue;
  1032. }
  1033. }
  1034. declare module BABYLON {
  1035. /**
  1036. * Scalar computation library
  1037. */
  1038. export class Scalar {
  1039. /**
  1040. * Two pi constants convenient for computation.
  1041. */
  1042. static TwoPi: number;
  1043. /**
  1044. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1045. * @param a number
  1046. * @param b number
  1047. * @param epsilon (default = 1.401298E-45)
  1048. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1049. */
  1050. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1051. /**
  1052. * Returns a string : the upper case translation of the number i to hexadecimal.
  1053. * @param i number
  1054. * @returns the upper case translation of the number i to hexadecimal.
  1055. */
  1056. static ToHex(i: number): string;
  1057. /**
  1058. * Returns -1 if value is negative and +1 is value is positive.
  1059. * @param value the value
  1060. * @returns the value itself if it's equal to zero.
  1061. */
  1062. static Sign(value: number): number;
  1063. /**
  1064. * Returns the value itself if it's between min and max.
  1065. * Returns min if the value is lower than min.
  1066. * Returns max if the value is greater than max.
  1067. * @param value the value to clmap
  1068. * @param min the min value to clamp to (default: 0)
  1069. * @param max the max value to clamp to (default: 1)
  1070. * @returns the clamped value
  1071. */
  1072. static Clamp(value: number, min?: number, max?: number): number;
  1073. /**
  1074. * the log2 of value.
  1075. * @param value the value to compute log2 of
  1076. * @returns the log2 of value.
  1077. */
  1078. static Log2(value: number): number;
  1079. /**
  1080. * Loops the value, so that it is never larger than length and never smaller than 0.
  1081. *
  1082. * This is similar to the modulo operator but it works with floating point numbers.
  1083. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1084. * With t = 5 and length = 2.5, the result would be 0.0.
  1085. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1086. * @param value the value
  1087. * @param length the length
  1088. * @returns the looped value
  1089. */
  1090. static Repeat(value: number, length: number): number;
  1091. /**
  1092. * Normalize the value between 0.0 and 1.0 using min and max values
  1093. * @param value value to normalize
  1094. * @param min max to normalize between
  1095. * @param max min to normalize between
  1096. * @returns the normalized value
  1097. */
  1098. static Normalize(value: number, min: number, max: number): number;
  1099. /**
  1100. * Denormalize the value from 0.0 and 1.0 using min and max values
  1101. * @param normalized value to denormalize
  1102. * @param min max to denormalize between
  1103. * @param max min to denormalize between
  1104. * @returns the denormalized value
  1105. */
  1106. static Denormalize(normalized: number, min: number, max: number): number;
  1107. /**
  1108. * Calculates the shortest difference between two given angles given in degrees.
  1109. * @param current current angle in degrees
  1110. * @param target target angle in degrees
  1111. * @returns the delta
  1112. */
  1113. static DeltaAngle(current: number, target: number): number;
  1114. /**
  1115. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1116. * @param tx value
  1117. * @param length length
  1118. * @returns The returned value will move back and forth between 0 and length
  1119. */
  1120. static PingPong(tx: number, length: number): number;
  1121. /**
  1122. * Interpolates between min and max with smoothing at the limits.
  1123. *
  1124. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1125. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1126. * @param from from
  1127. * @param to to
  1128. * @param tx value
  1129. * @returns the smooth stepped value
  1130. */
  1131. static SmoothStep(from: number, to: number, tx: number): number;
  1132. /**
  1133. * Moves a value current towards target.
  1134. *
  1135. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1136. * Negative values of maxDelta pushes the value away from target.
  1137. * @param current current value
  1138. * @param target target value
  1139. * @param maxDelta max distance to move
  1140. * @returns resulting value
  1141. */
  1142. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1143. /**
  1144. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1145. *
  1146. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1147. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1148. * @param current current value
  1149. * @param target target value
  1150. * @param maxDelta max distance to move
  1151. * @returns resulting angle
  1152. */
  1153. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1154. /**
  1155. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1156. * @param start start value
  1157. * @param end target value
  1158. * @param amount amount to lerp between
  1159. * @returns the lerped value
  1160. */
  1161. static Lerp(start: number, end: number, amount: number): number;
  1162. /**
  1163. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1164. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1165. * @param start start value
  1166. * @param end target value
  1167. * @param amount amount to lerp between
  1168. * @returns the lerped value
  1169. */
  1170. static LerpAngle(start: number, end: number, amount: number): number;
  1171. /**
  1172. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1173. * @param a start value
  1174. * @param b target value
  1175. * @param value value between a and b
  1176. * @returns the inverseLerp value
  1177. */
  1178. static InverseLerp(a: number, b: number, value: number): number;
  1179. /**
  1180. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1181. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1182. * @param value1 spline value
  1183. * @param tangent1 spline value
  1184. * @param value2 spline value
  1185. * @param tangent2 spline value
  1186. * @param amount input value
  1187. * @returns hermite result
  1188. */
  1189. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1190. /**
  1191. * Returns a random float number between and min and max values
  1192. * @param min min value of random
  1193. * @param max max value of random
  1194. * @returns random value
  1195. */
  1196. static RandomRange(min: number, max: number): number;
  1197. /**
  1198. * This function returns percentage of a number in a given range.
  1199. *
  1200. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1201. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1202. * @param number to convert to percentage
  1203. * @param min min range
  1204. * @param max max range
  1205. * @returns the percentage
  1206. */
  1207. static RangeToPercent(number: number, min: number, max: number): number;
  1208. /**
  1209. * This function returns number that corresponds to the percentage in a given range.
  1210. *
  1211. * PercentToRange(0.34,0,100) will return 34.
  1212. * @param percent to convert to number
  1213. * @param min min range
  1214. * @param max max range
  1215. * @returns the number
  1216. */
  1217. static PercentToRange(percent: number, min: number, max: number): number;
  1218. /**
  1219. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1220. * @param angle The angle to normalize in radian.
  1221. * @return The converted angle.
  1222. */
  1223. static NormalizeRadians(angle: number): number;
  1224. }
  1225. }
  1226. declare module BABYLON {
  1227. /**
  1228. * Constant used to convert a value to gamma space
  1229. * @ignorenaming
  1230. */
  1231. export const ToGammaSpace: number;
  1232. /**
  1233. * Constant used to convert a value to linear space
  1234. * @ignorenaming
  1235. */
  1236. export const ToLinearSpace = 2.2;
  1237. /**
  1238. * Constant used to define the minimal number value in Babylon.js
  1239. * @ignorenaming
  1240. */
  1241. let Epsilon: number;
  1242. }
  1243. declare module BABYLON {
  1244. /**
  1245. * Class used to represent a viewport on screen
  1246. */
  1247. export class Viewport {
  1248. /** viewport left coordinate */
  1249. x: number;
  1250. /** viewport top coordinate */
  1251. y: number;
  1252. /**viewport width */
  1253. width: number;
  1254. /** viewport height */
  1255. height: number;
  1256. /**
  1257. * Creates a Viewport object located at (x, y) and sized (width, height)
  1258. * @param x defines viewport left coordinate
  1259. * @param y defines viewport top coordinate
  1260. * @param width defines the viewport width
  1261. * @param height defines the viewport height
  1262. */
  1263. constructor(
  1264. /** viewport left coordinate */
  1265. x: number,
  1266. /** viewport top coordinate */
  1267. y: number,
  1268. /**viewport width */
  1269. width: number,
  1270. /** viewport height */
  1271. height: number);
  1272. /**
  1273. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1274. * @param renderWidth defines the rendering width
  1275. * @param renderHeight defines the rendering height
  1276. * @returns a new Viewport
  1277. */
  1278. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1279. /**
  1280. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1281. * @param renderWidth defines the rendering width
  1282. * @param renderHeight defines the rendering height
  1283. * @param ref defines the target viewport
  1284. * @returns the current viewport
  1285. */
  1286. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1287. /**
  1288. * Returns a new Viewport copied from the current one
  1289. * @returns a new Viewport
  1290. */
  1291. clone(): Viewport;
  1292. }
  1293. }
  1294. declare module BABYLON {
  1295. /**
  1296. * Class containing a set of static utilities functions for arrays.
  1297. */
  1298. export class ArrayTools {
  1299. /**
  1300. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1301. * @param size the number of element to construct and put in the array
  1302. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1303. * @returns a new array filled with new objects
  1304. */
  1305. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1306. }
  1307. }
  1308. declare module BABYLON {
  1309. /**
  1310. * @hidden
  1311. */
  1312. export interface IColor4Like {
  1313. r: float;
  1314. g: float;
  1315. b: float;
  1316. a: float;
  1317. }
  1318. /**
  1319. * @hidden
  1320. */
  1321. export interface IColor3Like {
  1322. r: float;
  1323. g: float;
  1324. b: float;
  1325. }
  1326. /**
  1327. * @hidden
  1328. */
  1329. export interface IVector4Like {
  1330. x: float;
  1331. y: float;
  1332. z: float;
  1333. w: float;
  1334. }
  1335. /**
  1336. * @hidden
  1337. */
  1338. export interface IVector3Like {
  1339. x: float;
  1340. y: float;
  1341. z: float;
  1342. }
  1343. /**
  1344. * @hidden
  1345. */
  1346. export interface IVector2Like {
  1347. x: float;
  1348. y: float;
  1349. }
  1350. /**
  1351. * @hidden
  1352. */
  1353. export interface IMatrixLike {
  1354. toArray(): DeepImmutable<Float32Array>;
  1355. updateFlag: int;
  1356. }
  1357. /**
  1358. * @hidden
  1359. */
  1360. export interface IViewportLike {
  1361. x: float;
  1362. y: float;
  1363. width: float;
  1364. height: float;
  1365. }
  1366. /**
  1367. * @hidden
  1368. */
  1369. export interface IPlaneLike {
  1370. normal: IVector3Like;
  1371. d: float;
  1372. normalize(): void;
  1373. }
  1374. }
  1375. declare module BABYLON {
  1376. /**
  1377. * Class representing a vector containing 2 coordinates
  1378. */
  1379. export class Vector2 {
  1380. /** defines the first coordinate */
  1381. x: number;
  1382. /** defines the second coordinate */
  1383. y: number;
  1384. /**
  1385. * Creates a new Vector2 from the given x and y coordinates
  1386. * @param x defines the first coordinate
  1387. * @param y defines the second coordinate
  1388. */
  1389. constructor(
  1390. /** defines the first coordinate */
  1391. x?: number,
  1392. /** defines the second coordinate */
  1393. y?: number);
  1394. /**
  1395. * Gets a string with the Vector2 coordinates
  1396. * @returns a string with the Vector2 coordinates
  1397. */
  1398. toString(): string;
  1399. /**
  1400. * Gets class name
  1401. * @returns the string "Vector2"
  1402. */
  1403. getClassName(): string;
  1404. /**
  1405. * Gets current vector hash code
  1406. * @returns the Vector2 hash code as a number
  1407. */
  1408. getHashCode(): number;
  1409. /**
  1410. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1411. * @param array defines the source array
  1412. * @param index defines the offset in source array
  1413. * @returns the current Vector2
  1414. */
  1415. toArray(array: FloatArray, index?: number): Vector2;
  1416. /**
  1417. * Copy the current vector to an array
  1418. * @returns a new array with 2 elements: the Vector2 coordinates.
  1419. */
  1420. asArray(): number[];
  1421. /**
  1422. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1423. * @param source defines the source Vector2
  1424. * @returns the current updated Vector2
  1425. */
  1426. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1427. /**
  1428. * Sets the Vector2 coordinates with the given floats
  1429. * @param x defines the first coordinate
  1430. * @param y defines the second coordinate
  1431. * @returns the current updated Vector2
  1432. */
  1433. copyFromFloats(x: number, y: number): Vector2;
  1434. /**
  1435. * Sets the Vector2 coordinates with the given floats
  1436. * @param x defines the first coordinate
  1437. * @param y defines the second coordinate
  1438. * @returns the current updated Vector2
  1439. */
  1440. set(x: number, y: number): Vector2;
  1441. /**
  1442. * Add another vector with the current one
  1443. * @param otherVector defines the other vector
  1444. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1445. */
  1446. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1447. /**
  1448. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1449. * @param otherVector defines the other vector
  1450. * @param result defines the target vector
  1451. * @returns the unmodified current Vector2
  1452. */
  1453. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1454. /**
  1455. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1456. * @param otherVector defines the other vector
  1457. * @returns the current updated Vector2
  1458. */
  1459. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1460. /**
  1461. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1462. * @param otherVector defines the other vector
  1463. * @returns a new Vector2
  1464. */
  1465. addVector3(otherVector: Vector3): Vector2;
  1466. /**
  1467. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1468. * @param otherVector defines the other vector
  1469. * @returns a new Vector2
  1470. */
  1471. subtract(otherVector: Vector2): Vector2;
  1472. /**
  1473. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1474. * @param otherVector defines the other vector
  1475. * @param result defines the target vector
  1476. * @returns the unmodified current Vector2
  1477. */
  1478. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1479. /**
  1480. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1481. * @param otherVector defines the other vector
  1482. * @returns the current updated Vector2
  1483. */
  1484. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1485. /**
  1486. * Multiplies in place the current Vector2 coordinates by the given ones
  1487. * @param otherVector defines the other vector
  1488. * @returns the current updated Vector2
  1489. */
  1490. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1491. /**
  1492. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1493. * @param otherVector defines the other vector
  1494. * @returns a new Vector2
  1495. */
  1496. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1497. /**
  1498. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1499. * @param otherVector defines the other vector
  1500. * @param result defines the target vector
  1501. * @returns the unmodified current Vector2
  1502. */
  1503. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1504. /**
  1505. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1506. * @param x defines the first coordinate
  1507. * @param y defines the second coordinate
  1508. * @returns a new Vector2
  1509. */
  1510. multiplyByFloats(x: number, y: number): Vector2;
  1511. /**
  1512. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1513. * @param otherVector defines the other vector
  1514. * @returns a new Vector2
  1515. */
  1516. divide(otherVector: Vector2): Vector2;
  1517. /**
  1518. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1519. * @param otherVector defines the other vector
  1520. * @param result defines the target vector
  1521. * @returns the unmodified current Vector2
  1522. */
  1523. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1524. /**
  1525. * Divides the current Vector2 coordinates by the given ones
  1526. * @param otherVector defines the other vector
  1527. * @returns the current updated Vector2
  1528. */
  1529. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1530. /**
  1531. * Gets a new Vector2 with current Vector2 negated coordinates
  1532. * @returns a new Vector2
  1533. */
  1534. negate(): Vector2;
  1535. /**
  1536. * Multiply the Vector2 coordinates by scale
  1537. * @param scale defines the scaling factor
  1538. * @returns the current updated Vector2
  1539. */
  1540. scaleInPlace(scale: number): Vector2;
  1541. /**
  1542. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1543. * @param scale defines the scaling factor
  1544. * @returns a new Vector2
  1545. */
  1546. scale(scale: number): Vector2;
  1547. /**
  1548. * Scale the current Vector2 values by a factor to a given Vector2
  1549. * @param scale defines the scale factor
  1550. * @param result defines the Vector2 object where to store the result
  1551. * @returns the unmodified current Vector2
  1552. */
  1553. scaleToRef(scale: number, result: Vector2): Vector2;
  1554. /**
  1555. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1556. * @param scale defines the scale factor
  1557. * @param result defines the Vector2 object where to store the result
  1558. * @returns the unmodified current Vector2
  1559. */
  1560. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1561. /**
  1562. * Gets a boolean if two vectors are equals
  1563. * @param otherVector defines the other vector
  1564. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1565. */
  1566. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1567. /**
  1568. * Gets a boolean if two vectors are equals (using an epsilon value)
  1569. * @param otherVector defines the other vector
  1570. * @param epsilon defines the minimal distance to consider equality
  1571. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1572. */
  1573. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1574. /**
  1575. * Gets a new Vector2 from current Vector2 floored values
  1576. * @returns a new Vector2
  1577. */
  1578. floor(): Vector2;
  1579. /**
  1580. * Gets a new Vector2 from current Vector2 floored values
  1581. * @returns a new Vector2
  1582. */
  1583. fract(): Vector2;
  1584. /**
  1585. * Gets the length of the vector
  1586. * @returns the vector length (float)
  1587. */
  1588. length(): number;
  1589. /**
  1590. * Gets the vector squared length
  1591. * @returns the vector squared length (float)
  1592. */
  1593. lengthSquared(): number;
  1594. /**
  1595. * Normalize the vector
  1596. * @returns the current updated Vector2
  1597. */
  1598. normalize(): Vector2;
  1599. /**
  1600. * Gets a new Vector2 copied from the Vector2
  1601. * @returns a new Vector2
  1602. */
  1603. clone(): Vector2;
  1604. /**
  1605. * Gets a new Vector2(0, 0)
  1606. * @returns a new Vector2
  1607. */
  1608. static Zero(): Vector2;
  1609. /**
  1610. * Gets a new Vector2(1, 1)
  1611. * @returns a new Vector2
  1612. */
  1613. static One(): Vector2;
  1614. /**
  1615. * Gets a new Vector2 set from the given index element of the given array
  1616. * @param array defines the data source
  1617. * @param offset defines the offset in the data source
  1618. * @returns a new Vector2
  1619. */
  1620. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1621. /**
  1622. * Sets "result" from the given index element of the given array
  1623. * @param array defines the data source
  1624. * @param offset defines the offset in the data source
  1625. * @param result defines the target vector
  1626. */
  1627. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1628. /**
  1629. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1630. * @param value1 defines 1st point of control
  1631. * @param value2 defines 2nd point of control
  1632. * @param value3 defines 3rd point of control
  1633. * @param value4 defines 4th point of control
  1634. * @param amount defines the interpolation factor
  1635. * @returns a new Vector2
  1636. */
  1637. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1638. /**
  1639. * 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".
  1640. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1641. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1642. * @param value defines the value to clamp
  1643. * @param min defines the lower limit
  1644. * @param max defines the upper limit
  1645. * @returns a new Vector2
  1646. */
  1647. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1648. /**
  1649. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1650. * @param value1 defines the 1st control point
  1651. * @param tangent1 defines the outgoing tangent
  1652. * @param value2 defines the 2nd control point
  1653. * @param tangent2 defines the incoming tangent
  1654. * @param amount defines the interpolation factor
  1655. * @returns a new Vector2
  1656. */
  1657. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1658. /**
  1659. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1660. * @param start defines the start vector
  1661. * @param end defines the end vector
  1662. * @param amount defines the interpolation factor
  1663. * @returns a new Vector2
  1664. */
  1665. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1666. /**
  1667. * Gets the dot product of the vector "left" and the vector "right"
  1668. * @param left defines first vector
  1669. * @param right defines second vector
  1670. * @returns the dot product (float)
  1671. */
  1672. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1673. /**
  1674. * Returns a new Vector2 equal to the normalized given vector
  1675. * @param vector defines the vector to normalize
  1676. * @returns a new Vector2
  1677. */
  1678. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1679. /**
  1680. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1681. * @param left defines 1st vector
  1682. * @param right defines 2nd vector
  1683. * @returns a new Vector2
  1684. */
  1685. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1686. /**
  1687. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1688. * @param left defines 1st vector
  1689. * @param right defines 2nd vector
  1690. * @returns a new Vector2
  1691. */
  1692. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1693. /**
  1694. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1695. * @param vector defines the vector to transform
  1696. * @param transformation defines the matrix to apply
  1697. * @returns a new Vector2
  1698. */
  1699. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1700. /**
  1701. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1702. * @param vector defines the vector to transform
  1703. * @param transformation defines the matrix to apply
  1704. * @param result defines the target vector
  1705. */
  1706. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1707. /**
  1708. * Determines if a given vector is included in a triangle
  1709. * @param p defines the vector to test
  1710. * @param p0 defines 1st triangle point
  1711. * @param p1 defines 2nd triangle point
  1712. * @param p2 defines 3rd triangle point
  1713. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1714. */
  1715. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1716. /**
  1717. * Gets the distance between the vectors "value1" and "value2"
  1718. * @param value1 defines first vector
  1719. * @param value2 defines second vector
  1720. * @returns the distance between vectors
  1721. */
  1722. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1723. /**
  1724. * Returns the squared distance between the vectors "value1" and "value2"
  1725. * @param value1 defines first vector
  1726. * @param value2 defines second vector
  1727. * @returns the squared distance between vectors
  1728. */
  1729. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1730. /**
  1731. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1732. * @param value1 defines first vector
  1733. * @param value2 defines second vector
  1734. * @returns a new Vector2
  1735. */
  1736. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1737. /**
  1738. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1739. * @param p defines the middle point
  1740. * @param segA defines one point of the segment
  1741. * @param segB defines the other point of the segment
  1742. * @returns the shortest distance
  1743. */
  1744. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1745. }
  1746. /**
  1747. * Classed used to store (x,y,z) vector representation
  1748. * A Vector3 is the main object used in 3D geometry
  1749. * It can represent etiher the coordinates of a point the space, either a direction
  1750. * Reminder: js uses a left handed forward facing system
  1751. */
  1752. export class Vector3 {
  1753. /**
  1754. * Defines the first coordinates (on X axis)
  1755. */
  1756. x: number;
  1757. /**
  1758. * Defines the second coordinates (on Y axis)
  1759. */
  1760. y: number;
  1761. /**
  1762. * Defines the third coordinates (on Z axis)
  1763. */
  1764. z: number;
  1765. private static _UpReadOnly;
  1766. private static _ZeroReadOnly;
  1767. /**
  1768. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1769. * @param x defines the first coordinates (on X axis)
  1770. * @param y defines the second coordinates (on Y axis)
  1771. * @param z defines the third coordinates (on Z axis)
  1772. */
  1773. constructor(
  1774. /**
  1775. * Defines the first coordinates (on X axis)
  1776. */
  1777. x?: number,
  1778. /**
  1779. * Defines the second coordinates (on Y axis)
  1780. */
  1781. y?: number,
  1782. /**
  1783. * Defines the third coordinates (on Z axis)
  1784. */
  1785. z?: number);
  1786. /**
  1787. * Creates a string representation of the Vector3
  1788. * @returns a string with the Vector3 coordinates.
  1789. */
  1790. toString(): string;
  1791. /**
  1792. * Gets the class name
  1793. * @returns the string "Vector3"
  1794. */
  1795. getClassName(): string;
  1796. /**
  1797. * Creates the Vector3 hash code
  1798. * @returns a number which tends to be unique between Vector3 instances
  1799. */
  1800. getHashCode(): number;
  1801. /**
  1802. * Creates an array containing three elements : the coordinates of the Vector3
  1803. * @returns a new array of numbers
  1804. */
  1805. asArray(): number[];
  1806. /**
  1807. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1808. * @param array defines the destination array
  1809. * @param index defines the offset in the destination array
  1810. * @returns the current Vector3
  1811. */
  1812. toArray(array: FloatArray, index?: number): Vector3;
  1813. /**
  1814. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1815. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1816. */
  1817. toQuaternion(): Quaternion;
  1818. /**
  1819. * Adds the given vector to the current Vector3
  1820. * @param otherVector defines the second operand
  1821. * @returns the current updated Vector3
  1822. */
  1823. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1824. /**
  1825. * Adds the given coordinates to the current Vector3
  1826. * @param x defines the x coordinate of the operand
  1827. * @param y defines the y coordinate of the operand
  1828. * @param z defines the z coordinate of the operand
  1829. * @returns the current updated Vector3
  1830. */
  1831. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1832. /**
  1833. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1834. * @param otherVector defines the second operand
  1835. * @returns the resulting Vector3
  1836. */
  1837. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1838. /**
  1839. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1840. * @param otherVector defines the second operand
  1841. * @param result defines the Vector3 object where to store the result
  1842. * @returns the current Vector3
  1843. */
  1844. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1845. /**
  1846. * Subtract the given vector from the current Vector3
  1847. * @param otherVector defines the second operand
  1848. * @returns the current updated Vector3
  1849. */
  1850. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1851. /**
  1852. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1853. * @param otherVector defines the second operand
  1854. * @returns the resulting Vector3
  1855. */
  1856. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1857. /**
  1858. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1859. * @param otherVector defines the second operand
  1860. * @param result defines the Vector3 object where to store the result
  1861. * @returns the current Vector3
  1862. */
  1863. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1864. /**
  1865. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1866. * @param x defines the x coordinate of the operand
  1867. * @param y defines the y coordinate of the operand
  1868. * @param z defines the z coordinate of the operand
  1869. * @returns the resulting Vector3
  1870. */
  1871. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1872. /**
  1873. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1874. * @param x defines the x coordinate of the operand
  1875. * @param y defines the y coordinate of the operand
  1876. * @param z defines the z coordinate of the operand
  1877. * @param result defines the Vector3 object where to store the result
  1878. * @returns the current Vector3
  1879. */
  1880. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1881. /**
  1882. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1883. * @returns a new Vector3
  1884. */
  1885. negate(): Vector3;
  1886. /**
  1887. * Multiplies the Vector3 coordinates by the float "scale"
  1888. * @param scale defines the multiplier factor
  1889. * @returns the current updated Vector3
  1890. */
  1891. scaleInPlace(scale: number): Vector3;
  1892. /**
  1893. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1894. * @param scale defines the multiplier factor
  1895. * @returns a new Vector3
  1896. */
  1897. scale(scale: number): Vector3;
  1898. /**
  1899. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1900. * @param scale defines the multiplier factor
  1901. * @param result defines the Vector3 object where to store the result
  1902. * @returns the current Vector3
  1903. */
  1904. scaleToRef(scale: number, result: Vector3): Vector3;
  1905. /**
  1906. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1907. * @param scale defines the scale factor
  1908. * @param result defines the Vector3 object where to store the result
  1909. * @returns the unmodified current Vector3
  1910. */
  1911. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1912. /**
  1913. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1914. * @param otherVector defines the second operand
  1915. * @returns true if both vectors are equals
  1916. */
  1917. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1918. /**
  1919. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1920. * @param otherVector defines the second operand
  1921. * @param epsilon defines the minimal distance to define values as equals
  1922. * @returns true if both vectors are distant less than epsilon
  1923. */
  1924. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1925. /**
  1926. * Returns true if the current Vector3 coordinates equals the given floats
  1927. * @param x defines the x coordinate of the operand
  1928. * @param y defines the y coordinate of the operand
  1929. * @param z defines the z coordinate of the operand
  1930. * @returns true if both vectors are equals
  1931. */
  1932. equalsToFloats(x: number, y: number, z: number): boolean;
  1933. /**
  1934. * Multiplies the current Vector3 coordinates by the given ones
  1935. * @param otherVector defines the second operand
  1936. * @returns the current updated Vector3
  1937. */
  1938. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1939. /**
  1940. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1941. * @param otherVector defines the second operand
  1942. * @returns the new Vector3
  1943. */
  1944. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1945. /**
  1946. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1947. * @param otherVector defines the second operand
  1948. * @param result defines the Vector3 object where to store the result
  1949. * @returns the current Vector3
  1950. */
  1951. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1952. /**
  1953. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1954. * @param x defines the x coordinate of the operand
  1955. * @param y defines the y coordinate of the operand
  1956. * @param z defines the z coordinate of the operand
  1957. * @returns the new Vector3
  1958. */
  1959. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1960. /**
  1961. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1962. * @param otherVector defines the second operand
  1963. * @returns the new Vector3
  1964. */
  1965. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1966. /**
  1967. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1968. * @param otherVector defines the second operand
  1969. * @param result defines the Vector3 object where to store the result
  1970. * @returns the current Vector3
  1971. */
  1972. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1973. /**
  1974. * Divides the current Vector3 coordinates by the given ones.
  1975. * @param otherVector defines the second operand
  1976. * @returns the current updated Vector3
  1977. */
  1978. divideInPlace(otherVector: Vector3): Vector3;
  1979. /**
  1980. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1981. * @param other defines the second operand
  1982. * @returns the current updated Vector3
  1983. */
  1984. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1985. /**
  1986. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1987. * @param other defines the second operand
  1988. * @returns the current updated Vector3
  1989. */
  1990. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1991. /**
  1992. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1993. * @param x defines the x coordinate of the operand
  1994. * @param y defines the y coordinate of the operand
  1995. * @param z defines the z coordinate of the operand
  1996. * @returns the current updated Vector3
  1997. */
  1998. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1999. /**
  2000. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2001. * @param x defines the x coordinate of the operand
  2002. * @param y defines the y coordinate of the operand
  2003. * @param z defines the z coordinate of the operand
  2004. * @returns the current updated Vector3
  2005. */
  2006. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2007. /**
  2008. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2009. * Check if is non uniform within a certain amount of decimal places to account for this
  2010. * @param epsilon the amount the values can differ
  2011. * @returns if the the vector is non uniform to a certain number of decimal places
  2012. */
  2013. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2014. /**
  2015. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2016. */
  2017. readonly isNonUniform: boolean;
  2018. /**
  2019. * Gets a new Vector3 from current Vector3 floored values
  2020. * @returns a new Vector3
  2021. */
  2022. floor(): Vector3;
  2023. /**
  2024. * Gets a new Vector3 from current Vector3 floored values
  2025. * @returns a new Vector3
  2026. */
  2027. fract(): Vector3;
  2028. /**
  2029. * Gets the length of the Vector3
  2030. * @returns the length of the Vector3
  2031. */
  2032. length(): number;
  2033. /**
  2034. * Gets the squared length of the Vector3
  2035. * @returns squared length of the Vector3
  2036. */
  2037. lengthSquared(): number;
  2038. /**
  2039. * Normalize the current Vector3.
  2040. * Please note that this is an in place operation.
  2041. * @returns the current updated Vector3
  2042. */
  2043. normalize(): Vector3;
  2044. /**
  2045. * Reorders the x y z properties of the vector in place
  2046. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2047. * @returns the current updated vector
  2048. */
  2049. reorderInPlace(order: string): this;
  2050. /**
  2051. * Rotates the vector around 0,0,0 by a quaternion
  2052. * @param quaternion the rotation quaternion
  2053. * @param result vector to store the result
  2054. * @returns the resulting vector
  2055. */
  2056. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2057. /**
  2058. * Rotates a vector around a given point
  2059. * @param quaternion the rotation quaternion
  2060. * @param point the point to rotate around
  2061. * @param result vector to store the result
  2062. * @returns the resulting vector
  2063. */
  2064. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2065. /**
  2066. * Normalize the current Vector3 with the given input length.
  2067. * Please note that this is an in place operation.
  2068. * @param len the length of the vector
  2069. * @returns the current updated Vector3
  2070. */
  2071. normalizeFromLength(len: number): Vector3;
  2072. /**
  2073. * Normalize the current Vector3 to a new vector
  2074. * @returns the new Vector3
  2075. */
  2076. normalizeToNew(): Vector3;
  2077. /**
  2078. * Normalize the current Vector3 to the reference
  2079. * @param reference define the Vector3 to update
  2080. * @returns the updated Vector3
  2081. */
  2082. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2083. /**
  2084. * Creates a new Vector3 copied from the current Vector3
  2085. * @returns the new Vector3
  2086. */
  2087. clone(): Vector3;
  2088. /**
  2089. * Copies the given vector coordinates to the current Vector3 ones
  2090. * @param source defines the source Vector3
  2091. * @returns the current updated Vector3
  2092. */
  2093. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2094. /**
  2095. * Copies the given floats to the current Vector3 coordinates
  2096. * @param x defines the x coordinate of the operand
  2097. * @param y defines the y coordinate of the operand
  2098. * @param z defines the z coordinate of the operand
  2099. * @returns the current updated Vector3
  2100. */
  2101. copyFromFloats(x: number, y: number, z: number): Vector3;
  2102. /**
  2103. * Copies the given floats to the current Vector3 coordinates
  2104. * @param x defines the x coordinate of the operand
  2105. * @param y defines the y coordinate of the operand
  2106. * @param z defines the z coordinate of the operand
  2107. * @returns the current updated Vector3
  2108. */
  2109. set(x: number, y: number, z: number): Vector3;
  2110. /**
  2111. * Copies the given float to the current Vector3 coordinates
  2112. * @param v defines the x, y and z coordinates of the operand
  2113. * @returns the current updated Vector3
  2114. */
  2115. setAll(v: number): Vector3;
  2116. /**
  2117. * Get the clip factor between two vectors
  2118. * @param vector0 defines the first operand
  2119. * @param vector1 defines the second operand
  2120. * @param axis defines the axis to use
  2121. * @param size defines the size along the axis
  2122. * @returns the clip factor
  2123. */
  2124. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2125. /**
  2126. * Get angle between two vectors
  2127. * @param vector0 angle between vector0 and vector1
  2128. * @param vector1 angle between vector0 and vector1
  2129. * @param normal direction of the normal
  2130. * @return the angle between vector0 and vector1
  2131. */
  2132. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2133. /**
  2134. * Returns a new Vector3 set from the index "offset" of the given array
  2135. * @param array defines the source array
  2136. * @param offset defines the offset in the source array
  2137. * @returns the new Vector3
  2138. */
  2139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2140. /**
  2141. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2142. * This function is deprecated. Use FromArray instead
  2143. * @param array defines the source array
  2144. * @param offset defines the offset in the source array
  2145. * @returns the new Vector3
  2146. */
  2147. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2148. /**
  2149. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2150. * @param array defines the source array
  2151. * @param offset defines the offset in the source array
  2152. * @param result defines the Vector3 where to store the result
  2153. */
  2154. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2155. /**
  2156. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2157. * This function is deprecated. Use FromArrayToRef instead.
  2158. * @param array defines the source array
  2159. * @param offset defines the offset in the source array
  2160. * @param result defines the Vector3 where to store the result
  2161. */
  2162. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2163. /**
  2164. * Sets the given vector "result" with the given floats.
  2165. * @param x defines the x coordinate of the source
  2166. * @param y defines the y coordinate of the source
  2167. * @param z defines the z coordinate of the source
  2168. * @param result defines the Vector3 where to store the result
  2169. */
  2170. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2171. /**
  2172. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2173. * @returns a new empty Vector3
  2174. */
  2175. static Zero(): Vector3;
  2176. /**
  2177. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2178. * @returns a new unit Vector3
  2179. */
  2180. static One(): Vector3;
  2181. /**
  2182. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2183. * @returns a new up Vector3
  2184. */
  2185. static Up(): Vector3;
  2186. /**
  2187. * Gets a up Vector3 that must not be updated
  2188. */
  2189. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2190. /**
  2191. * Gets a zero Vector3 that must not be updated
  2192. */
  2193. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2194. /**
  2195. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2196. * @returns a new down Vector3
  2197. */
  2198. static Down(): Vector3;
  2199. /**
  2200. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2201. * @returns a new forward Vector3
  2202. */
  2203. static Forward(): Vector3;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2206. * @returns a new forward Vector3
  2207. */
  2208. static Backward(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2211. * @returns a new right Vector3
  2212. */
  2213. static Right(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2216. * @returns a new left Vector3
  2217. */
  2218. static Left(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2221. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2222. * @param vector defines the Vector3 to transform
  2223. * @param transformation defines the transformation matrix
  2224. * @returns the transformed Vector3
  2225. */
  2226. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2227. /**
  2228. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2229. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2230. * @param vector defines the Vector3 to transform
  2231. * @param transformation defines the transformation matrix
  2232. * @param result defines the Vector3 where to store the result
  2233. */
  2234. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2235. /**
  2236. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2237. * This method computes tranformed coordinates only, not transformed direction vectors
  2238. * @param x define the x coordinate of the source vector
  2239. * @param y define the y coordinate of the source vector
  2240. * @param z define the z coordinate of the source vector
  2241. * @param transformation defines the transformation matrix
  2242. * @param result defines the Vector3 where to store the result
  2243. */
  2244. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2245. /**
  2246. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2247. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2248. * @param vector defines the Vector3 to transform
  2249. * @param transformation defines the transformation matrix
  2250. * @returns the new Vector3
  2251. */
  2252. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2253. /**
  2254. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2255. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2256. * @param vector defines the Vector3 to transform
  2257. * @param transformation defines the transformation matrix
  2258. * @param result defines the Vector3 where to store the result
  2259. */
  2260. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2261. /**
  2262. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2263. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2264. * @param x define the x coordinate of the source vector
  2265. * @param y define the y coordinate of the source vector
  2266. * @param z define the z coordinate of the source vector
  2267. * @param transformation defines the transformation matrix
  2268. * @param result defines the Vector3 where to store the result
  2269. */
  2270. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2271. /**
  2272. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2273. * @param value1 defines the first control point
  2274. * @param value2 defines the second control point
  2275. * @param value3 defines the third control point
  2276. * @param value4 defines the fourth control point
  2277. * @param amount defines the amount on the spline to use
  2278. * @returns the new Vector3
  2279. */
  2280. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2281. /**
  2282. * 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"
  2283. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2284. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2285. * @param value defines the current value
  2286. * @param min defines the lower range value
  2287. * @param max defines the upper range value
  2288. * @returns the new Vector3
  2289. */
  2290. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2291. /**
  2292. * 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"
  2293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2295. * @param value defines the current value
  2296. * @param min defines the lower range value
  2297. * @param max defines the upper range value
  2298. * @param result defines the Vector3 where to store the result
  2299. */
  2300. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2301. /**
  2302. * Checks if a given vector is inside a specific range
  2303. * @param v defines the vector to test
  2304. * @param min defines the minimum range
  2305. * @param max defines the maximum range
  2306. */
  2307. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2308. /**
  2309. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2310. * @param value1 defines the first control point
  2311. * @param tangent1 defines the first tangent vector
  2312. * @param value2 defines the second control point
  2313. * @param tangent2 defines the second tangent vector
  2314. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2315. * @returns the new Vector3
  2316. */
  2317. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2318. /**
  2319. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2320. * @param start defines the start value
  2321. * @param end defines the end value
  2322. * @param amount max defines amount between both (between 0 and 1)
  2323. * @returns the new Vector3
  2324. */
  2325. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2326. /**
  2327. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2328. * @param start defines the start value
  2329. * @param end defines the end value
  2330. * @param amount max defines amount between both (between 0 and 1)
  2331. * @param result defines the Vector3 where to store the result
  2332. */
  2333. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2334. /**
  2335. * Returns the dot product (float) between the vectors "left" and "right"
  2336. * @param left defines the left operand
  2337. * @param right defines the right operand
  2338. * @returns the dot product
  2339. */
  2340. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2341. /**
  2342. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2343. * The cross product is then orthogonal to both "left" and "right"
  2344. * @param left defines the left operand
  2345. * @param right defines the right operand
  2346. * @returns the cross product
  2347. */
  2348. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2349. /**
  2350. * Sets the given vector "result" with the cross product of "left" and "right"
  2351. * The cross product is then orthogonal to both "left" and "right"
  2352. * @param left defines the left operand
  2353. * @param right defines the right operand
  2354. * @param result defines the Vector3 where to store the result
  2355. */
  2356. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2357. /**
  2358. * Returns a new Vector3 as the normalization of the given vector
  2359. * @param vector defines the Vector3 to normalize
  2360. * @returns the new Vector3
  2361. */
  2362. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2363. /**
  2364. * Sets the given vector "result" with the normalization of the given first vector
  2365. * @param vector defines the Vector3 to normalize
  2366. * @param result defines the Vector3 where to store the result
  2367. */
  2368. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2369. /**
  2370. * Project a Vector3 onto screen space
  2371. * @param vector defines the Vector3 to project
  2372. * @param world defines the world matrix to use
  2373. * @param transform defines the transform (view x projection) matrix to use
  2374. * @param viewport defines the screen viewport to use
  2375. * @returns the new Vector3
  2376. */
  2377. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2378. /** @hidden */
  2379. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2380. /**
  2381. * Unproject from screen space to object space
  2382. * @param source defines the screen space Vector3 to use
  2383. * @param viewportWidth defines the current width of the viewport
  2384. * @param viewportHeight defines the current height of the viewport
  2385. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2386. * @param transform defines the transform (view x projection) matrix to use
  2387. * @returns the new Vector3
  2388. */
  2389. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2390. /**
  2391. * Unproject from screen space to object space
  2392. * @param source defines the screen space Vector3 to use
  2393. * @param viewportWidth defines the current width of the viewport
  2394. * @param viewportHeight defines the current height of the viewport
  2395. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2396. * @param view defines the view matrix to use
  2397. * @param projection defines the projection matrix to use
  2398. * @returns the new Vector3
  2399. */
  2400. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2401. /**
  2402. * Unproject from screen space to object space
  2403. * @param source defines the screen space Vector3 to use
  2404. * @param viewportWidth defines the current width of the viewport
  2405. * @param viewportHeight defines the current height of the viewport
  2406. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2407. * @param view defines the view matrix to use
  2408. * @param projection defines the projection matrix to use
  2409. * @param result defines the Vector3 where to store the result
  2410. */
  2411. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2412. /**
  2413. * Unproject from screen space to object space
  2414. * @param sourceX defines the screen space x coordinate to use
  2415. * @param sourceY defines the screen space y coordinate to use
  2416. * @param sourceZ defines the screen space z coordinate to use
  2417. * @param viewportWidth defines the current width of the viewport
  2418. * @param viewportHeight defines the current height of the viewport
  2419. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2420. * @param view defines the view matrix to use
  2421. * @param projection defines the projection matrix to use
  2422. * @param result defines the Vector3 where to store the result
  2423. */
  2424. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2425. /**
  2426. * Gets the minimal coordinate values between two Vector3
  2427. * @param left defines the first operand
  2428. * @param right defines the second operand
  2429. * @returns the new Vector3
  2430. */
  2431. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2432. /**
  2433. * Gets the maximal coordinate values between two Vector3
  2434. * @param left defines the first operand
  2435. * @param right defines the second operand
  2436. * @returns the new Vector3
  2437. */
  2438. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2439. /**
  2440. * Returns the distance between the vectors "value1" and "value2"
  2441. * @param value1 defines the first operand
  2442. * @param value2 defines the second operand
  2443. * @returns the distance
  2444. */
  2445. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2446. /**
  2447. * Returns the squared distance between the vectors "value1" and "value2"
  2448. * @param value1 defines the first operand
  2449. * @param value2 defines the second operand
  2450. * @returns the squared distance
  2451. */
  2452. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2453. /**
  2454. * Returns a new Vector3 located at the center between "value1" and "value2"
  2455. * @param value1 defines the first operand
  2456. * @param value2 defines the second operand
  2457. * @returns the new Vector3
  2458. */
  2459. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2460. /**
  2461. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2462. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2463. * to something in order to rotate it from its local system to the given target system
  2464. * Note: axis1, axis2 and axis3 are normalized during this operation
  2465. * @param axis1 defines the first axis
  2466. * @param axis2 defines the second axis
  2467. * @param axis3 defines the third axis
  2468. * @returns a new Vector3
  2469. */
  2470. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2471. /**
  2472. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2473. * @param axis1 defines the first axis
  2474. * @param axis2 defines the second axis
  2475. * @param axis3 defines the third axis
  2476. * @param ref defines the Vector3 where to store the result
  2477. */
  2478. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2479. }
  2480. /**
  2481. * Vector4 class created for EulerAngle class conversion to Quaternion
  2482. */
  2483. export class Vector4 {
  2484. /** x value of the vector */
  2485. x: number;
  2486. /** y value of the vector */
  2487. y: number;
  2488. /** z value of the vector */
  2489. z: number;
  2490. /** w value of the vector */
  2491. w: number;
  2492. /**
  2493. * Creates a Vector4 object from the given floats.
  2494. * @param x x value of the vector
  2495. * @param y y value of the vector
  2496. * @param z z value of the vector
  2497. * @param w w value of the vector
  2498. */
  2499. constructor(
  2500. /** x value of the vector */
  2501. x: number,
  2502. /** y value of the vector */
  2503. y: number,
  2504. /** z value of the vector */
  2505. z: number,
  2506. /** w value of the vector */
  2507. w: number);
  2508. /**
  2509. * Returns the string with the Vector4 coordinates.
  2510. * @returns a string containing all the vector values
  2511. */
  2512. toString(): string;
  2513. /**
  2514. * Returns the string "Vector4".
  2515. * @returns "Vector4"
  2516. */
  2517. getClassName(): string;
  2518. /**
  2519. * Returns the Vector4 hash code.
  2520. * @returns a unique hash code
  2521. */
  2522. getHashCode(): number;
  2523. /**
  2524. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2525. * @returns the resulting array
  2526. */
  2527. asArray(): number[];
  2528. /**
  2529. * Populates the given array from the given index with the Vector4 coordinates.
  2530. * @param array array to populate
  2531. * @param index index of the array to start at (default: 0)
  2532. * @returns the Vector4.
  2533. */
  2534. toArray(array: FloatArray, index?: number): Vector4;
  2535. /**
  2536. * Adds the given vector to the current Vector4.
  2537. * @param otherVector the vector to add
  2538. * @returns the updated Vector4.
  2539. */
  2540. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2541. /**
  2542. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2543. * @param otherVector the vector to add
  2544. * @returns the resulting vector
  2545. */
  2546. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2547. /**
  2548. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2549. * @param otherVector the vector to add
  2550. * @param result the vector to store the result
  2551. * @returns the current Vector4.
  2552. */
  2553. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2554. /**
  2555. * Subtract in place the given vector from the current Vector4.
  2556. * @param otherVector the vector to subtract
  2557. * @returns the updated Vector4.
  2558. */
  2559. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2560. /**
  2561. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2562. * @param otherVector the vector to add
  2563. * @returns the new vector with the result
  2564. */
  2565. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2566. /**
  2567. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2568. * @param otherVector the vector to subtract
  2569. * @param result the vector to store the result
  2570. * @returns the current Vector4.
  2571. */
  2572. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2573. /**
  2574. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2575. */
  2576. /**
  2577. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2578. * @param x value to subtract
  2579. * @param y value to subtract
  2580. * @param z value to subtract
  2581. * @param w value to subtract
  2582. * @returns new vector containing the result
  2583. */
  2584. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2585. /**
  2586. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2587. * @param x value to subtract
  2588. * @param y value to subtract
  2589. * @param z value to subtract
  2590. * @param w value to subtract
  2591. * @param result the vector to store the result in
  2592. * @returns the current Vector4.
  2593. */
  2594. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2595. /**
  2596. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2597. * @returns a new vector with the negated values
  2598. */
  2599. negate(): Vector4;
  2600. /**
  2601. * Multiplies the current Vector4 coordinates by scale (float).
  2602. * @param scale the number to scale with
  2603. * @returns the updated Vector4.
  2604. */
  2605. scaleInPlace(scale: number): Vector4;
  2606. /**
  2607. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2608. * @param scale the number to scale with
  2609. * @returns a new vector with the result
  2610. */
  2611. scale(scale: number): Vector4;
  2612. /**
  2613. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2614. * @param scale the number to scale with
  2615. * @param result a vector to store the result in
  2616. * @returns the current Vector4.
  2617. */
  2618. scaleToRef(scale: number, result: Vector4): Vector4;
  2619. /**
  2620. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2621. * @param scale defines the scale factor
  2622. * @param result defines the Vector4 object where to store the result
  2623. * @returns the unmodified current Vector4
  2624. */
  2625. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2626. /**
  2627. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2628. * @param otherVector the vector to compare against
  2629. * @returns true if they are equal
  2630. */
  2631. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2632. /**
  2633. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2634. * @param otherVector vector to compare against
  2635. * @param epsilon (Default: very small number)
  2636. * @returns true if they are equal
  2637. */
  2638. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2639. /**
  2640. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2641. * @param x x value to compare against
  2642. * @param y y value to compare against
  2643. * @param z z value to compare against
  2644. * @param w w value to compare against
  2645. * @returns true if equal
  2646. */
  2647. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2648. /**
  2649. * Multiplies in place the current Vector4 by the given one.
  2650. * @param otherVector vector to multiple with
  2651. * @returns the updated Vector4.
  2652. */
  2653. multiplyInPlace(otherVector: Vector4): Vector4;
  2654. /**
  2655. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2656. * @param otherVector vector to multiple with
  2657. * @returns resulting new vector
  2658. */
  2659. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2660. /**
  2661. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2662. * @param otherVector vector to multiple with
  2663. * @param result vector to store the result
  2664. * @returns the current Vector4.
  2665. */
  2666. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2667. /**
  2668. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2669. * @param x x value multiply with
  2670. * @param y y value multiply with
  2671. * @param z z value multiply with
  2672. * @param w w value multiply with
  2673. * @returns resulting new vector
  2674. */
  2675. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2676. /**
  2677. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2678. * @param otherVector vector to devide with
  2679. * @returns resulting new vector
  2680. */
  2681. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2682. /**
  2683. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2684. * @param otherVector vector to devide with
  2685. * @param result vector to store the result
  2686. * @returns the current Vector4.
  2687. */
  2688. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2689. /**
  2690. * Divides the current Vector3 coordinates by the given ones.
  2691. * @param otherVector vector to devide with
  2692. * @returns the updated Vector3.
  2693. */
  2694. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2695. /**
  2696. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2697. * @param other defines the second operand
  2698. * @returns the current updated Vector4
  2699. */
  2700. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2701. /**
  2702. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2703. * @param other defines the second operand
  2704. * @returns the current updated Vector4
  2705. */
  2706. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2707. /**
  2708. * Gets a new Vector4 from current Vector4 floored values
  2709. * @returns a new Vector4
  2710. */
  2711. floor(): Vector4;
  2712. /**
  2713. * Gets a new Vector4 from current Vector3 floored values
  2714. * @returns a new Vector4
  2715. */
  2716. fract(): Vector4;
  2717. /**
  2718. * Returns the Vector4 length (float).
  2719. * @returns the length
  2720. */
  2721. length(): number;
  2722. /**
  2723. * Returns the Vector4 squared length (float).
  2724. * @returns the length squared
  2725. */
  2726. lengthSquared(): number;
  2727. /**
  2728. * Normalizes in place the Vector4.
  2729. * @returns the updated Vector4.
  2730. */
  2731. normalize(): Vector4;
  2732. /**
  2733. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2734. * @returns this converted to a new vector3
  2735. */
  2736. toVector3(): Vector3;
  2737. /**
  2738. * Returns a new Vector4 copied from the current one.
  2739. * @returns the new cloned vector
  2740. */
  2741. clone(): Vector4;
  2742. /**
  2743. * Updates the current Vector4 with the given one coordinates.
  2744. * @param source the source vector to copy from
  2745. * @returns the updated Vector4.
  2746. */
  2747. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2748. /**
  2749. * Updates the current Vector4 coordinates with the given floats.
  2750. * @param x float to copy from
  2751. * @param y float to copy from
  2752. * @param z float to copy from
  2753. * @param w float to copy from
  2754. * @returns the updated Vector4.
  2755. */
  2756. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2757. /**
  2758. * Updates the current Vector4 coordinates with the given floats.
  2759. * @param x float to set from
  2760. * @param y float to set from
  2761. * @param z float to set from
  2762. * @param w float to set from
  2763. * @returns the updated Vector4.
  2764. */
  2765. set(x: number, y: number, z: number, w: number): Vector4;
  2766. /**
  2767. * Copies the given float to the current Vector3 coordinates
  2768. * @param v defines the x, y, z and w coordinates of the operand
  2769. * @returns the current updated Vector3
  2770. */
  2771. setAll(v: number): Vector4;
  2772. /**
  2773. * Returns a new Vector4 set from the starting index of the given array.
  2774. * @param array the array to pull values from
  2775. * @param offset the offset into the array to start at
  2776. * @returns the new vector
  2777. */
  2778. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2779. /**
  2780. * Updates the given vector "result" from the starting index of the given array.
  2781. * @param array the array to pull values from
  2782. * @param offset the offset into the array to start at
  2783. * @param result the vector to store the result in
  2784. */
  2785. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2786. /**
  2787. * Updates the given vector "result" from the starting index of the given Float32Array.
  2788. * @param array the array to pull values from
  2789. * @param offset the offset into the array to start at
  2790. * @param result the vector to store the result in
  2791. */
  2792. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2793. /**
  2794. * Updates the given vector "result" coordinates from the given floats.
  2795. * @param x float to set from
  2796. * @param y float to set from
  2797. * @param z float to set from
  2798. * @param w float to set from
  2799. * @param result the vector to the floats in
  2800. */
  2801. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2802. /**
  2803. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2804. * @returns the new vector
  2805. */
  2806. static Zero(): Vector4;
  2807. /**
  2808. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2809. * @returns the new vector
  2810. */
  2811. static One(): Vector4;
  2812. /**
  2813. * Returns a new normalized Vector4 from the given one.
  2814. * @param vector the vector to normalize
  2815. * @returns the vector
  2816. */
  2817. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2818. /**
  2819. * Updates the given vector "result" from the normalization of the given one.
  2820. * @param vector the vector to normalize
  2821. * @param result the vector to store the result in
  2822. */
  2823. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2824. /**
  2825. * Returns a vector with the minimum values from the left and right vectors
  2826. * @param left left vector to minimize
  2827. * @param right right vector to minimize
  2828. * @returns a new vector with the minimum of the left and right vector values
  2829. */
  2830. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2831. /**
  2832. * Returns a vector with the maximum values from the left and right vectors
  2833. * @param left left vector to maximize
  2834. * @param right right vector to maximize
  2835. * @returns a new vector with the maximum of the left and right vector values
  2836. */
  2837. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2838. /**
  2839. * Returns the distance (float) between the vectors "value1" and "value2".
  2840. * @param value1 value to calulate the distance between
  2841. * @param value2 value to calulate the distance between
  2842. * @return the distance between the two vectors
  2843. */
  2844. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2845. /**
  2846. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2847. * @param value1 value to calulate the distance between
  2848. * @param value2 value to calulate the distance between
  2849. * @return the distance between the two vectors squared
  2850. */
  2851. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2852. /**
  2853. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2854. * @param value1 value to calulate the center between
  2855. * @param value2 value to calulate the center between
  2856. * @return the center between the two vectors
  2857. */
  2858. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2859. /**
  2860. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2861. * This methods computes transformed normalized direction vectors only.
  2862. * @param vector the vector to transform
  2863. * @param transformation the transformation matrix to apply
  2864. * @returns the new vector
  2865. */
  2866. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2867. /**
  2868. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2869. * This methods computes transformed normalized direction vectors only.
  2870. * @param vector the vector to transform
  2871. * @param transformation the transformation matrix to apply
  2872. * @param result the vector to store the result in
  2873. */
  2874. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2875. /**
  2876. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2877. * This methods computes transformed normalized direction vectors only.
  2878. * @param x value to transform
  2879. * @param y value to transform
  2880. * @param z value to transform
  2881. * @param w value to transform
  2882. * @param transformation the transformation matrix to apply
  2883. * @param result the vector to store the results in
  2884. */
  2885. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2886. /**
  2887. * Creates a new Vector4 from a Vector3
  2888. * @param source defines the source data
  2889. * @param w defines the 4th component (default is 0)
  2890. * @returns a new Vector4
  2891. */
  2892. static FromVector3(source: Vector3, w?: number): Vector4;
  2893. }
  2894. /**
  2895. * Class used to store quaternion data
  2896. * @see https://en.wikipedia.org/wiki/Quaternion
  2897. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2898. */
  2899. export class Quaternion {
  2900. /** defines the first component (0 by default) */
  2901. x: number;
  2902. /** defines the second component (0 by default) */
  2903. y: number;
  2904. /** defines the third component (0 by default) */
  2905. z: number;
  2906. /** defines the fourth component (1.0 by default) */
  2907. w: number;
  2908. /**
  2909. * Creates a new Quaternion from the given floats
  2910. * @param x defines the first component (0 by default)
  2911. * @param y defines the second component (0 by default)
  2912. * @param z defines the third component (0 by default)
  2913. * @param w defines the fourth component (1.0 by default)
  2914. */
  2915. constructor(
  2916. /** defines the first component (0 by default) */
  2917. x?: number,
  2918. /** defines the second component (0 by default) */
  2919. y?: number,
  2920. /** defines the third component (0 by default) */
  2921. z?: number,
  2922. /** defines the fourth component (1.0 by default) */
  2923. w?: number);
  2924. /**
  2925. * Gets a string representation for the current quaternion
  2926. * @returns a string with the Quaternion coordinates
  2927. */
  2928. toString(): string;
  2929. /**
  2930. * Gets the class name of the quaternion
  2931. * @returns the string "Quaternion"
  2932. */
  2933. getClassName(): string;
  2934. /**
  2935. * Gets a hash code for this quaternion
  2936. * @returns the quaternion hash code
  2937. */
  2938. getHashCode(): number;
  2939. /**
  2940. * Copy the quaternion to an array
  2941. * @returns a new array populated with 4 elements from the quaternion coordinates
  2942. */
  2943. asArray(): number[];
  2944. /**
  2945. * Check if two quaternions are equals
  2946. * @param otherQuaternion defines the second operand
  2947. * @return true if the current quaternion and the given one coordinates are strictly equals
  2948. */
  2949. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2950. /**
  2951. * Clone the current quaternion
  2952. * @returns a new quaternion copied from the current one
  2953. */
  2954. clone(): Quaternion;
  2955. /**
  2956. * Copy a quaternion to the current one
  2957. * @param other defines the other quaternion
  2958. * @returns the updated current quaternion
  2959. */
  2960. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2961. /**
  2962. * Updates the current quaternion with the given float coordinates
  2963. * @param x defines the x coordinate
  2964. * @param y defines the y coordinate
  2965. * @param z defines the z coordinate
  2966. * @param w defines the w coordinate
  2967. * @returns the updated current quaternion
  2968. */
  2969. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2970. /**
  2971. * Updates the current quaternion from the given float coordinates
  2972. * @param x defines the x coordinate
  2973. * @param y defines the y coordinate
  2974. * @param z defines the z coordinate
  2975. * @param w defines the w coordinate
  2976. * @returns the updated current quaternion
  2977. */
  2978. set(x: number, y: number, z: number, w: number): Quaternion;
  2979. /**
  2980. * Adds two quaternions
  2981. * @param other defines the second operand
  2982. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2983. */
  2984. add(other: DeepImmutable<Quaternion>): Quaternion;
  2985. /**
  2986. * Add a quaternion to the current one
  2987. * @param other defines the quaternion to add
  2988. * @returns the current quaternion
  2989. */
  2990. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2991. /**
  2992. * Subtract two quaternions
  2993. * @param other defines the second operand
  2994. * @returns a new quaternion as the subtraction result of the given one from the current one
  2995. */
  2996. subtract(other: Quaternion): Quaternion;
  2997. /**
  2998. * Multiplies the current quaternion by a scale factor
  2999. * @param value defines the scale factor
  3000. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3001. */
  3002. scale(value: number): Quaternion;
  3003. /**
  3004. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3005. * @param scale defines the scale factor
  3006. * @param result defines the Quaternion object where to store the result
  3007. * @returns the unmodified current quaternion
  3008. */
  3009. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3010. /**
  3011. * Multiplies in place the current quaternion by a scale factor
  3012. * @param value defines the scale factor
  3013. * @returns the current modified quaternion
  3014. */
  3015. scaleInPlace(value: number): Quaternion;
  3016. /**
  3017. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3018. * @param scale defines the scale factor
  3019. * @param result defines the Quaternion object where to store the result
  3020. * @returns the unmodified current quaternion
  3021. */
  3022. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3023. /**
  3024. * Multiplies two quaternions
  3025. * @param q1 defines the second operand
  3026. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3027. */
  3028. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3029. /**
  3030. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3031. * @param q1 defines the second operand
  3032. * @param result defines the target quaternion
  3033. * @returns the current quaternion
  3034. */
  3035. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3036. /**
  3037. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3038. * @param q1 defines the second operand
  3039. * @returns the currentupdated quaternion
  3040. */
  3041. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3042. /**
  3043. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3044. * @param ref defines the target quaternion
  3045. * @returns the current quaternion
  3046. */
  3047. conjugateToRef(ref: Quaternion): Quaternion;
  3048. /**
  3049. * Conjugates in place (1-q) the current quaternion
  3050. * @returns the current updated quaternion
  3051. */
  3052. conjugateInPlace(): Quaternion;
  3053. /**
  3054. * Conjugates in place (1-q) the current quaternion
  3055. * @returns a new quaternion
  3056. */
  3057. conjugate(): Quaternion;
  3058. /**
  3059. * Gets length of current quaternion
  3060. * @returns the quaternion length (float)
  3061. */
  3062. length(): number;
  3063. /**
  3064. * Normalize in place the current quaternion
  3065. * @returns the current updated quaternion
  3066. */
  3067. normalize(): Quaternion;
  3068. /**
  3069. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3070. * @param order is a reserved parameter and is ignore for now
  3071. * @returns a new Vector3 containing the Euler angles
  3072. */
  3073. toEulerAngles(order?: string): Vector3;
  3074. /**
  3075. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3076. * @param result defines the vector which will be filled with the Euler angles
  3077. * @param order is a reserved parameter and is ignore for now
  3078. * @returns the current unchanged quaternion
  3079. */
  3080. toEulerAnglesToRef(result: Vector3): Quaternion;
  3081. /**
  3082. * Updates the given rotation matrix with the current quaternion values
  3083. * @param result defines the target matrix
  3084. * @returns the current unchanged quaternion
  3085. */
  3086. toRotationMatrix(result: Matrix): Quaternion;
  3087. /**
  3088. * Updates the current quaternion from the given rotation matrix values
  3089. * @param matrix defines the source matrix
  3090. * @returns the current updated quaternion
  3091. */
  3092. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3093. /**
  3094. * Creates a new quaternion from a rotation matrix
  3095. * @param matrix defines the source matrix
  3096. * @returns a new quaternion created from the given rotation matrix values
  3097. */
  3098. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3099. /**
  3100. * Updates the given quaternion with the given rotation matrix values
  3101. * @param matrix defines the source matrix
  3102. * @param result defines the target quaternion
  3103. */
  3104. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3105. /**
  3106. * Returns the dot product (float) between the quaternions "left" and "right"
  3107. * @param left defines the left operand
  3108. * @param right defines the right operand
  3109. * @returns the dot product
  3110. */
  3111. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3112. /**
  3113. * Checks if the two quaternions are close to each other
  3114. * @param quat0 defines the first quaternion to check
  3115. * @param quat1 defines the second quaternion to check
  3116. * @returns true if the two quaternions are close to each other
  3117. */
  3118. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3119. /**
  3120. * Creates an empty quaternion
  3121. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3122. */
  3123. static Zero(): Quaternion;
  3124. /**
  3125. * Inverse a given quaternion
  3126. * @param q defines the source quaternion
  3127. * @returns a new quaternion as the inverted current quaternion
  3128. */
  3129. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3130. /**
  3131. * Inverse a given quaternion
  3132. * @param q defines the source quaternion
  3133. * @param result the quaternion the result will be stored in
  3134. * @returns the result quaternion
  3135. */
  3136. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3137. /**
  3138. * Creates an identity quaternion
  3139. * @returns the identity quaternion
  3140. */
  3141. static Identity(): Quaternion;
  3142. /**
  3143. * Gets a boolean indicating if the given quaternion is identity
  3144. * @param quaternion defines the quaternion to check
  3145. * @returns true if the quaternion is identity
  3146. */
  3147. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3148. /**
  3149. * Creates a quaternion from a rotation around an axis
  3150. * @param axis defines the axis to use
  3151. * @param angle defines the angle to use
  3152. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3153. */
  3154. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3155. /**
  3156. * Creates a rotation around an axis and stores it into the given quaternion
  3157. * @param axis defines the axis to use
  3158. * @param angle defines the angle to use
  3159. * @param result defines the target quaternion
  3160. * @returns the target quaternion
  3161. */
  3162. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3163. /**
  3164. * Creates a new quaternion from data stored into an array
  3165. * @param array defines the data source
  3166. * @param offset defines the offset in the source array where the data starts
  3167. * @returns a new quaternion
  3168. */
  3169. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3170. /**
  3171. * Create a quaternion from Euler rotation angles
  3172. * @param x Pitch
  3173. * @param y Yaw
  3174. * @param z Roll
  3175. * @returns the new Quaternion
  3176. */
  3177. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3178. /**
  3179. * Updates a quaternion from Euler rotation angles
  3180. * @param x Pitch
  3181. * @param y Yaw
  3182. * @param z Roll
  3183. * @param result the quaternion to store the result
  3184. * @returns the updated quaternion
  3185. */
  3186. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3187. /**
  3188. * Create a quaternion from Euler rotation vector
  3189. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3190. * @returns the new Quaternion
  3191. */
  3192. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3193. /**
  3194. * Updates a quaternion from Euler rotation vector
  3195. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3196. * @param result the quaternion to store the result
  3197. * @returns the updated quaternion
  3198. */
  3199. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3200. /**
  3201. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3202. * @param yaw defines the rotation around Y axis
  3203. * @param pitch defines the rotation around X axis
  3204. * @param roll defines the rotation around Z axis
  3205. * @returns the new quaternion
  3206. */
  3207. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3208. /**
  3209. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3210. * @param yaw defines the rotation around Y axis
  3211. * @param pitch defines the rotation around X axis
  3212. * @param roll defines the rotation around Z axis
  3213. * @param result defines the target quaternion
  3214. */
  3215. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3216. /**
  3217. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3218. * @param alpha defines the rotation around first axis
  3219. * @param beta defines the rotation around second axis
  3220. * @param gamma defines the rotation around third axis
  3221. * @returns the new quaternion
  3222. */
  3223. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3224. /**
  3225. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3226. * @param alpha defines the rotation around first axis
  3227. * @param beta defines the rotation around second axis
  3228. * @param gamma defines the rotation around third axis
  3229. * @param result defines the target quaternion
  3230. */
  3231. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3232. /**
  3233. * 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)
  3234. * @param axis1 defines the first axis
  3235. * @param axis2 defines the second axis
  3236. * @param axis3 defines the third axis
  3237. * @returns the new quaternion
  3238. */
  3239. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3240. /**
  3241. * 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
  3242. * @param axis1 defines the first axis
  3243. * @param axis2 defines the second axis
  3244. * @param axis3 defines the third axis
  3245. * @param ref defines the target quaternion
  3246. */
  3247. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3248. /**
  3249. * Interpolates between two quaternions
  3250. * @param left defines first quaternion
  3251. * @param right defines second quaternion
  3252. * @param amount defines the gradient to use
  3253. * @returns the new interpolated quaternion
  3254. */
  3255. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3256. /**
  3257. * Interpolates between two quaternions and stores it into a target quaternion
  3258. * @param left defines first quaternion
  3259. * @param right defines second quaternion
  3260. * @param amount defines the gradient to use
  3261. * @param result defines the target quaternion
  3262. */
  3263. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3264. /**
  3265. * Interpolate between two quaternions using Hermite interpolation
  3266. * @param value1 defines first quaternion
  3267. * @param tangent1 defines the incoming tangent
  3268. * @param value2 defines second quaternion
  3269. * @param tangent2 defines the outgoing tangent
  3270. * @param amount defines the target quaternion
  3271. * @returns the new interpolated quaternion
  3272. */
  3273. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3274. }
  3275. /**
  3276. * Class used to store matrix data (4x4)
  3277. */
  3278. export class Matrix {
  3279. private static _updateFlagSeed;
  3280. private static _identityReadOnly;
  3281. private _isIdentity;
  3282. private _isIdentityDirty;
  3283. private _isIdentity3x2;
  3284. private _isIdentity3x2Dirty;
  3285. /**
  3286. * Gets the update flag of the matrix which is an unique number for the matrix.
  3287. * It will be incremented every time the matrix data change.
  3288. * You can use it to speed the comparison between two versions of the same matrix.
  3289. */
  3290. updateFlag: number;
  3291. private readonly _m;
  3292. /**
  3293. * Gets the internal data of the matrix
  3294. */
  3295. readonly m: DeepImmutable<Float32Array>;
  3296. /** @hidden */
  3297. _markAsUpdated(): void;
  3298. /** @hidden */
  3299. private _updateIdentityStatus;
  3300. /**
  3301. * Creates an empty matrix (filled with zeros)
  3302. */
  3303. constructor();
  3304. /**
  3305. * Check if the current matrix is identity
  3306. * @returns true is the matrix is the identity matrix
  3307. */
  3308. isIdentity(): boolean;
  3309. /**
  3310. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3311. * @returns true is the matrix is the identity matrix
  3312. */
  3313. isIdentityAs3x2(): boolean;
  3314. /**
  3315. * Gets the determinant of the matrix
  3316. * @returns the matrix determinant
  3317. */
  3318. determinant(): number;
  3319. /**
  3320. * Returns the matrix as a Float32Array
  3321. * @returns the matrix underlying array
  3322. */
  3323. toArray(): DeepImmutable<Float32Array>;
  3324. /**
  3325. * Returns the matrix as a Float32Array
  3326. * @returns the matrix underlying array.
  3327. */
  3328. asArray(): DeepImmutable<Float32Array>;
  3329. /**
  3330. * Inverts the current matrix in place
  3331. * @returns the current inverted matrix
  3332. */
  3333. invert(): Matrix;
  3334. /**
  3335. * Sets all the matrix elements to zero
  3336. * @returns the current matrix
  3337. */
  3338. reset(): Matrix;
  3339. /**
  3340. * Adds the current matrix with a second one
  3341. * @param other defines the matrix to add
  3342. * @returns a new matrix as the addition of the current matrix and the given one
  3343. */
  3344. add(other: DeepImmutable<Matrix>): Matrix;
  3345. /**
  3346. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3347. * @param other defines the matrix to add
  3348. * @param result defines the target matrix
  3349. * @returns the current matrix
  3350. */
  3351. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3352. /**
  3353. * Adds in place the given matrix to the current matrix
  3354. * @param other defines the second operand
  3355. * @returns the current updated matrix
  3356. */
  3357. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3358. /**
  3359. * Sets the given matrix to the current inverted Matrix
  3360. * @param other defines the target matrix
  3361. * @returns the unmodified current matrix
  3362. */
  3363. invertToRef(other: Matrix): Matrix;
  3364. /**
  3365. * add a value at the specified position in the current Matrix
  3366. * @param index the index of the value within the matrix. between 0 and 15.
  3367. * @param value the value to be added
  3368. * @returns the current updated matrix
  3369. */
  3370. addAtIndex(index: number, value: number): Matrix;
  3371. /**
  3372. * mutiply the specified position in the current Matrix by a value
  3373. * @param index the index of the value within the matrix. between 0 and 15.
  3374. * @param value the value to be added
  3375. * @returns the current updated matrix
  3376. */
  3377. multiplyAtIndex(index: number, value: number): Matrix;
  3378. /**
  3379. * Inserts the translation vector (using 3 floats) in the current matrix
  3380. * @param x defines the 1st component of the translation
  3381. * @param y defines the 2nd component of the translation
  3382. * @param z defines the 3rd component of the translation
  3383. * @returns the current updated matrix
  3384. */
  3385. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3386. /**
  3387. * Adds the translation vector (using 3 floats) in the current matrix
  3388. * @param x defines the 1st component of the translation
  3389. * @param y defines the 2nd component of the translation
  3390. * @param z defines the 3rd component of the translation
  3391. * @returns the current updated matrix
  3392. */
  3393. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3394. /**
  3395. * Inserts the translation vector in the current matrix
  3396. * @param vector3 defines the translation to insert
  3397. * @returns the current updated matrix
  3398. */
  3399. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3400. /**
  3401. * Gets the translation value of the current matrix
  3402. * @returns a new Vector3 as the extracted translation from the matrix
  3403. */
  3404. getTranslation(): Vector3;
  3405. /**
  3406. * Fill a Vector3 with the extracted translation from the matrix
  3407. * @param result defines the Vector3 where to store the translation
  3408. * @returns the current matrix
  3409. */
  3410. getTranslationToRef(result: Vector3): Matrix;
  3411. /**
  3412. * Remove rotation and scaling part from the matrix
  3413. * @returns the updated matrix
  3414. */
  3415. removeRotationAndScaling(): Matrix;
  3416. /**
  3417. * Multiply two matrices
  3418. * @param other defines the second operand
  3419. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3420. */
  3421. multiply(other: DeepImmutable<Matrix>): Matrix;
  3422. /**
  3423. * Copy the current matrix from the given one
  3424. * @param other defines the source matrix
  3425. * @returns the current updated matrix
  3426. */
  3427. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3428. /**
  3429. * Populates the given array from the starting index with the current matrix values
  3430. * @param array defines the target array
  3431. * @param offset defines the offset in the target array where to start storing values
  3432. * @returns the current matrix
  3433. */
  3434. copyToArray(array: Float32Array, offset?: number): Matrix;
  3435. /**
  3436. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3437. * @param other defines the second operand
  3438. * @param result defines the matrix where to store the multiplication
  3439. * @returns the current matrix
  3440. */
  3441. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3442. /**
  3443. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3444. * @param other defines the second operand
  3445. * @param result defines the array where to store the multiplication
  3446. * @param offset defines the offset in the target array where to start storing values
  3447. * @returns the current matrix
  3448. */
  3449. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3450. /**
  3451. * Check equality between this matrix and a second one
  3452. * @param value defines the second matrix to compare
  3453. * @returns true is the current matrix and the given one values are strictly equal
  3454. */
  3455. equals(value: DeepImmutable<Matrix>): boolean;
  3456. /**
  3457. * Clone the current matrix
  3458. * @returns a new matrix from the current matrix
  3459. */
  3460. clone(): Matrix;
  3461. /**
  3462. * Returns the name of the current matrix class
  3463. * @returns the string "Matrix"
  3464. */
  3465. getClassName(): string;
  3466. /**
  3467. * Gets the hash code of the current matrix
  3468. * @returns the hash code
  3469. */
  3470. getHashCode(): number;
  3471. /**
  3472. * Decomposes the current Matrix into a translation, rotation and scaling components
  3473. * @param scale defines the scale vector3 given as a reference to update
  3474. * @param rotation defines the rotation quaternion given as a reference to update
  3475. * @param translation defines the translation vector3 given as a reference to update
  3476. * @returns true if operation was successful
  3477. */
  3478. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3479. /**
  3480. * Gets specific row of the matrix
  3481. * @param index defines the number of the row to get
  3482. * @returns the index-th row of the current matrix as a new Vector4
  3483. */
  3484. getRow(index: number): Nullable<Vector4>;
  3485. /**
  3486. * Sets the index-th row of the current matrix to the vector4 values
  3487. * @param index defines the number of the row to set
  3488. * @param row defines the target vector4
  3489. * @returns the updated current matrix
  3490. */
  3491. setRow(index: number, row: Vector4): Matrix;
  3492. /**
  3493. * Compute the transpose of the matrix
  3494. * @returns the new transposed matrix
  3495. */
  3496. transpose(): Matrix;
  3497. /**
  3498. * Compute the transpose of the matrix and store it in a given matrix
  3499. * @param result defines the target matrix
  3500. * @returns the current matrix
  3501. */
  3502. transposeToRef(result: Matrix): Matrix;
  3503. /**
  3504. * Sets the index-th row of the current matrix with the given 4 x float values
  3505. * @param index defines the row index
  3506. * @param x defines the x component to set
  3507. * @param y defines the y component to set
  3508. * @param z defines the z component to set
  3509. * @param w defines the w component to set
  3510. * @returns the updated current matrix
  3511. */
  3512. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3513. /**
  3514. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3515. * @param scale defines the scale factor
  3516. * @returns a new matrix
  3517. */
  3518. scale(scale: number): Matrix;
  3519. /**
  3520. * Scale the current matrix values by a factor to a given result matrix
  3521. * @param scale defines the scale factor
  3522. * @param result defines the matrix to store the result
  3523. * @returns the current matrix
  3524. */
  3525. scaleToRef(scale: number, result: Matrix): Matrix;
  3526. /**
  3527. * Scale the current matrix values by a factor and add the result to a given matrix
  3528. * @param scale defines the scale factor
  3529. * @param result defines the Matrix to store the result
  3530. * @returns the current matrix
  3531. */
  3532. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3533. /**
  3534. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3535. * @param ref matrix to store the result
  3536. */
  3537. toNormalMatrix(ref: Matrix): void;
  3538. /**
  3539. * Gets only rotation part of the current matrix
  3540. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3541. */
  3542. getRotationMatrix(): Matrix;
  3543. /**
  3544. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3545. * @param result defines the target matrix to store data to
  3546. * @returns the current matrix
  3547. */
  3548. getRotationMatrixToRef(result: Matrix): Matrix;
  3549. /**
  3550. * Toggles model matrix from being right handed to left handed in place and vice versa
  3551. */
  3552. toggleModelMatrixHandInPlace(): void;
  3553. /**
  3554. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3555. */
  3556. toggleProjectionMatrixHandInPlace(): void;
  3557. /**
  3558. * Creates a matrix from an array
  3559. * @param array defines the source array
  3560. * @param offset defines an offset in the source array
  3561. * @returns a new Matrix set from the starting index of the given array
  3562. */
  3563. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3564. /**
  3565. * Copy the content of an array into a given matrix
  3566. * @param array defines the source array
  3567. * @param offset defines an offset in the source array
  3568. * @param result defines the target matrix
  3569. */
  3570. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3571. /**
  3572. * Stores an array into a matrix after having multiplied each component by a given factor
  3573. * @param array defines the source array
  3574. * @param offset defines the offset in the source array
  3575. * @param scale defines the scaling factor
  3576. * @param result defines the target matrix
  3577. */
  3578. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3579. /**
  3580. * Gets an identity matrix that must not be updated
  3581. */
  3582. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3583. /**
  3584. * Stores a list of values (16) inside a given matrix
  3585. * @param initialM11 defines 1st value of 1st row
  3586. * @param initialM12 defines 2nd value of 1st row
  3587. * @param initialM13 defines 3rd value of 1st row
  3588. * @param initialM14 defines 4th value of 1st row
  3589. * @param initialM21 defines 1st value of 2nd row
  3590. * @param initialM22 defines 2nd value of 2nd row
  3591. * @param initialM23 defines 3rd value of 2nd row
  3592. * @param initialM24 defines 4th value of 2nd row
  3593. * @param initialM31 defines 1st value of 3rd row
  3594. * @param initialM32 defines 2nd value of 3rd row
  3595. * @param initialM33 defines 3rd value of 3rd row
  3596. * @param initialM34 defines 4th value of 3rd row
  3597. * @param initialM41 defines 1st value of 4th row
  3598. * @param initialM42 defines 2nd value of 4th row
  3599. * @param initialM43 defines 3rd value of 4th row
  3600. * @param initialM44 defines 4th value of 4th row
  3601. * @param result defines the target matrix
  3602. */
  3603. 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;
  3604. /**
  3605. * Creates new matrix from a list of values (16)
  3606. * @param initialM11 defines 1st value of 1st row
  3607. * @param initialM12 defines 2nd value of 1st row
  3608. * @param initialM13 defines 3rd value of 1st row
  3609. * @param initialM14 defines 4th value of 1st row
  3610. * @param initialM21 defines 1st value of 2nd row
  3611. * @param initialM22 defines 2nd value of 2nd row
  3612. * @param initialM23 defines 3rd value of 2nd row
  3613. * @param initialM24 defines 4th value of 2nd row
  3614. * @param initialM31 defines 1st value of 3rd row
  3615. * @param initialM32 defines 2nd value of 3rd row
  3616. * @param initialM33 defines 3rd value of 3rd row
  3617. * @param initialM34 defines 4th value of 3rd row
  3618. * @param initialM41 defines 1st value of 4th row
  3619. * @param initialM42 defines 2nd value of 4th row
  3620. * @param initialM43 defines 3rd value of 4th row
  3621. * @param initialM44 defines 4th value of 4th row
  3622. * @returns the new matrix
  3623. */
  3624. 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;
  3625. /**
  3626. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3627. * @param scale defines the scale vector3
  3628. * @param rotation defines the rotation quaternion
  3629. * @param translation defines the translation vector3
  3630. * @returns a new matrix
  3631. */
  3632. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3633. /**
  3634. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3635. * @param scale defines the scale vector3
  3636. * @param rotation defines the rotation quaternion
  3637. * @param translation defines the translation vector3
  3638. * @param result defines the target matrix
  3639. */
  3640. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3641. /**
  3642. * Creates a new identity matrix
  3643. * @returns a new identity matrix
  3644. */
  3645. static Identity(): Matrix;
  3646. /**
  3647. * Creates a new identity matrix and stores the result in a given matrix
  3648. * @param result defines the target matrix
  3649. */
  3650. static IdentityToRef(result: Matrix): void;
  3651. /**
  3652. * Creates a new zero matrix
  3653. * @returns a new zero matrix
  3654. */
  3655. static Zero(): Matrix;
  3656. /**
  3657. * Creates a new rotation matrix for "angle" radians around the X axis
  3658. * @param angle defines the angle (in radians) to use
  3659. * @return the new matrix
  3660. */
  3661. static RotationX(angle: number): Matrix;
  3662. /**
  3663. * Creates a new matrix as the invert of a given matrix
  3664. * @param source defines the source matrix
  3665. * @returns the new matrix
  3666. */
  3667. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3668. /**
  3669. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3670. * @param angle defines the angle (in radians) to use
  3671. * @param result defines the target matrix
  3672. */
  3673. static RotationXToRef(angle: number, result: Matrix): void;
  3674. /**
  3675. * Creates a new rotation matrix for "angle" radians around the Y axis
  3676. * @param angle defines the angle (in radians) to use
  3677. * @return the new matrix
  3678. */
  3679. static RotationY(angle: number): Matrix;
  3680. /**
  3681. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3682. * @param angle defines the angle (in radians) to use
  3683. * @param result defines the target matrix
  3684. */
  3685. static RotationYToRef(angle: number, result: Matrix): void;
  3686. /**
  3687. * Creates a new rotation matrix for "angle" radians around the Z axis
  3688. * @param angle defines the angle (in radians) to use
  3689. * @return the new matrix
  3690. */
  3691. static RotationZ(angle: number): Matrix;
  3692. /**
  3693. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3694. * @param angle defines the angle (in radians) to use
  3695. * @param result defines the target matrix
  3696. */
  3697. static RotationZToRef(angle: number, result: Matrix): void;
  3698. /**
  3699. * Creates a new rotation matrix for "angle" radians around the given axis
  3700. * @param axis defines the axis to use
  3701. * @param angle defines the angle (in radians) to use
  3702. * @return the new matrix
  3703. */
  3704. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3705. /**
  3706. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3707. * @param axis defines the axis to use
  3708. * @param angle defines the angle (in radians) to use
  3709. * @param result defines the target matrix
  3710. */
  3711. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3712. /**
  3713. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3714. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3715. * @param from defines the vector to align
  3716. * @param to defines the vector to align to
  3717. * @param result defines the target matrix
  3718. */
  3719. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3720. /**
  3721. * Creates a rotation matrix
  3722. * @param yaw defines the yaw angle in radians (Y axis)
  3723. * @param pitch defines the pitch angle in radians (X axis)
  3724. * @param roll defines the roll angle in radians (X axis)
  3725. * @returns the new rotation matrix
  3726. */
  3727. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3728. /**
  3729. * Creates a rotation matrix and stores it in a given matrix
  3730. * @param yaw defines the yaw angle in radians (Y axis)
  3731. * @param pitch defines the pitch angle in radians (X axis)
  3732. * @param roll defines the roll angle in radians (X axis)
  3733. * @param result defines the target matrix
  3734. */
  3735. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3736. /**
  3737. * Creates a scaling matrix
  3738. * @param x defines the scale factor on X axis
  3739. * @param y defines the scale factor on Y axis
  3740. * @param z defines the scale factor on Z axis
  3741. * @returns the new matrix
  3742. */
  3743. static Scaling(x: number, y: number, z: number): Matrix;
  3744. /**
  3745. * Creates a scaling matrix and stores it in a given matrix
  3746. * @param x defines the scale factor on X axis
  3747. * @param y defines the scale factor on Y axis
  3748. * @param z defines the scale factor on Z axis
  3749. * @param result defines the target matrix
  3750. */
  3751. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3752. /**
  3753. * Creates a translation matrix
  3754. * @param x defines the translation on X axis
  3755. * @param y defines the translation on Y axis
  3756. * @param z defines the translationon Z axis
  3757. * @returns the new matrix
  3758. */
  3759. static Translation(x: number, y: number, z: number): Matrix;
  3760. /**
  3761. * Creates a translation matrix and stores it in a given matrix
  3762. * @param x defines the translation on X axis
  3763. * @param y defines the translation on Y axis
  3764. * @param z defines the translationon Z axis
  3765. * @param result defines the target matrix
  3766. */
  3767. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3768. /**
  3769. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3770. * @param startValue defines the start value
  3771. * @param endValue defines the end value
  3772. * @param gradient defines the gradient factor
  3773. * @returns the new matrix
  3774. */
  3775. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3776. /**
  3777. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3778. * @param startValue defines the start value
  3779. * @param endValue defines the end value
  3780. * @param gradient defines the gradient factor
  3781. * @param result defines the Matrix object where to store data
  3782. */
  3783. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3784. /**
  3785. * Builds a new matrix whose values are computed by:
  3786. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3787. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3788. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3789. * @param startValue defines the first matrix
  3790. * @param endValue defines the second matrix
  3791. * @param gradient defines the gradient between the two matrices
  3792. * @returns the new matrix
  3793. */
  3794. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3795. /**
  3796. * Update a matrix to values which are computed by:
  3797. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3798. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3799. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3800. * @param startValue defines the first matrix
  3801. * @param endValue defines the second matrix
  3802. * @param gradient defines the gradient between the two matrices
  3803. * @param result defines the target matrix
  3804. */
  3805. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3806. /**
  3807. * 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"
  3808. * This function works in left handed mode
  3809. * @param eye defines the final position of the entity
  3810. * @param target defines where the entity should look at
  3811. * @param up defines the up vector for the entity
  3812. * @returns the new matrix
  3813. */
  3814. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3815. /**
  3816. * 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".
  3817. * This function works in left handed mode
  3818. * @param eye defines the final position of the entity
  3819. * @param target defines where the entity should look at
  3820. * @param up defines the up vector for the entity
  3821. * @param result defines the target matrix
  3822. */
  3823. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3824. /**
  3825. * 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"
  3826. * This function works in right handed mode
  3827. * @param eye defines the final position of the entity
  3828. * @param target defines where the entity should look at
  3829. * @param up defines the up vector for the entity
  3830. * @returns the new matrix
  3831. */
  3832. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3833. /**
  3834. * 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".
  3835. * This function works in right handed mode
  3836. * @param eye defines the final position of the entity
  3837. * @param target defines where the entity should look at
  3838. * @param up defines the up vector for the entity
  3839. * @param result defines the target matrix
  3840. */
  3841. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3842. /**
  3843. * Create a left-handed orthographic projection matrix
  3844. * @param width defines the viewport width
  3845. * @param height defines the viewport height
  3846. * @param znear defines the near clip plane
  3847. * @param zfar defines the far clip plane
  3848. * @returns a new matrix as a left-handed orthographic projection matrix
  3849. */
  3850. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3851. /**
  3852. * Store a left-handed orthographic projection to a given matrix
  3853. * @param width defines the viewport width
  3854. * @param height defines the viewport height
  3855. * @param znear defines the near clip plane
  3856. * @param zfar defines the far clip plane
  3857. * @param result defines the target matrix
  3858. */
  3859. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3860. /**
  3861. * Create a left-handed orthographic projection matrix
  3862. * @param left defines the viewport left coordinate
  3863. * @param right defines the viewport right coordinate
  3864. * @param bottom defines the viewport bottom coordinate
  3865. * @param top defines the viewport top coordinate
  3866. * @param znear defines the near clip plane
  3867. * @param zfar defines the far clip plane
  3868. * @returns a new matrix as a left-handed orthographic projection matrix
  3869. */
  3870. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3871. /**
  3872. * Stores a left-handed orthographic projection into a given matrix
  3873. * @param left defines the viewport left coordinate
  3874. * @param right defines the viewport right coordinate
  3875. * @param bottom defines the viewport bottom coordinate
  3876. * @param top defines the viewport top coordinate
  3877. * @param znear defines the near clip plane
  3878. * @param zfar defines the far clip plane
  3879. * @param result defines the target matrix
  3880. */
  3881. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3882. /**
  3883. * Creates a right-handed orthographic projection matrix
  3884. * @param left defines the viewport left coordinate
  3885. * @param right defines the viewport right coordinate
  3886. * @param bottom defines the viewport bottom coordinate
  3887. * @param top defines the viewport top coordinate
  3888. * @param znear defines the near clip plane
  3889. * @param zfar defines the far clip plane
  3890. * @returns a new matrix as a right-handed orthographic projection matrix
  3891. */
  3892. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3893. /**
  3894. * Stores a right-handed orthographic projection into a given matrix
  3895. * @param left defines the viewport left coordinate
  3896. * @param right defines the viewport right coordinate
  3897. * @param bottom defines the viewport bottom coordinate
  3898. * @param top defines the viewport top coordinate
  3899. * @param znear defines the near clip plane
  3900. * @param zfar defines the far clip plane
  3901. * @param result defines the target matrix
  3902. */
  3903. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3904. /**
  3905. * Creates a left-handed perspective projection matrix
  3906. * @param width defines the viewport width
  3907. * @param height defines the viewport height
  3908. * @param znear defines the near clip plane
  3909. * @param zfar defines the far clip plane
  3910. * @returns a new matrix as a left-handed perspective projection matrix
  3911. */
  3912. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3913. /**
  3914. * Creates a left-handed perspective projection matrix
  3915. * @param fov defines the horizontal field of view
  3916. * @param aspect defines the aspect ratio
  3917. * @param znear defines the near clip plane
  3918. * @param zfar defines the far clip plane
  3919. * @returns a new matrix as a left-handed perspective projection matrix
  3920. */
  3921. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3922. /**
  3923. * Stores a left-handed perspective projection into a given matrix
  3924. * @param fov defines the horizontal field of view
  3925. * @param aspect defines the aspect ratio
  3926. * @param znear defines the near clip plane
  3927. * @param zfar defines the far clip plane
  3928. * @param result defines the target matrix
  3929. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3930. */
  3931. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3932. /**
  3933. * Creates a right-handed perspective projection matrix
  3934. * @param fov defines the horizontal field of view
  3935. * @param aspect defines the aspect ratio
  3936. * @param znear defines the near clip plane
  3937. * @param zfar defines the far clip plane
  3938. * @returns a new matrix as a right-handed perspective projection matrix
  3939. */
  3940. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3941. /**
  3942. * Stores a right-handed perspective projection into a given matrix
  3943. * @param fov defines the horizontal field of view
  3944. * @param aspect defines the aspect ratio
  3945. * @param znear defines the near clip plane
  3946. * @param zfar defines the far clip plane
  3947. * @param result defines the target matrix
  3948. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3949. */
  3950. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3951. /**
  3952. * Stores a perspective projection for WebVR info a given matrix
  3953. * @param fov defines the field of view
  3954. * @param znear defines the near clip plane
  3955. * @param zfar defines the far clip plane
  3956. * @param result defines the target matrix
  3957. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3958. */
  3959. static PerspectiveFovWebVRToRef(fov: {
  3960. upDegrees: number;
  3961. downDegrees: number;
  3962. leftDegrees: number;
  3963. rightDegrees: number;
  3964. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3965. /**
  3966. * Computes a complete transformation matrix
  3967. * @param viewport defines the viewport to use
  3968. * @param world defines the world matrix
  3969. * @param view defines the view matrix
  3970. * @param projection defines the projection matrix
  3971. * @param zmin defines the near clip plane
  3972. * @param zmax defines the far clip plane
  3973. * @returns the transformation matrix
  3974. */
  3975. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3976. /**
  3977. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3978. * @param matrix defines the matrix to use
  3979. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3980. */
  3981. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3982. /**
  3983. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3984. * @param matrix defines the matrix to use
  3985. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3986. */
  3987. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3988. /**
  3989. * Compute the transpose of a given matrix
  3990. * @param matrix defines the matrix to transpose
  3991. * @returns the new matrix
  3992. */
  3993. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3994. /**
  3995. * Compute the transpose of a matrix and store it in a target matrix
  3996. * @param matrix defines the matrix to transpose
  3997. * @param result defines the target matrix
  3998. */
  3999. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4000. /**
  4001. * Computes a reflection matrix from a plane
  4002. * @param plane defines the reflection plane
  4003. * @returns a new matrix
  4004. */
  4005. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4006. /**
  4007. * Computes a reflection matrix from a plane
  4008. * @param plane defines the reflection plane
  4009. * @param result defines the target matrix
  4010. */
  4011. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4012. /**
  4013. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4014. * @param xaxis defines the value of the 1st axis
  4015. * @param yaxis defines the value of the 2nd axis
  4016. * @param zaxis defines the value of the 3rd axis
  4017. * @param result defines the target matrix
  4018. */
  4019. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4020. /**
  4021. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4022. * @param quat defines the quaternion to use
  4023. * @param result defines the target matrix
  4024. */
  4025. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4026. }
  4027. /**
  4028. * @hidden
  4029. */
  4030. export class TmpVectors {
  4031. static Vector2: Vector2[];
  4032. static Vector3: Vector3[];
  4033. static Vector4: Vector4[];
  4034. static Quaternion: Quaternion[];
  4035. static Matrix: Matrix[];
  4036. }
  4037. }
  4038. declare module BABYLON {
  4039. /** Defines the cross module used constants to avoid circular dependncies */
  4040. export class Constants {
  4041. /** Defines that alpha blending is disabled */
  4042. static readonly ALPHA_DISABLE: number;
  4043. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4044. static readonly ALPHA_ADD: number;
  4045. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4046. static readonly ALPHA_COMBINE: number;
  4047. /** Defines that alpha blending to DEST - SRC * DEST */
  4048. static readonly ALPHA_SUBTRACT: number;
  4049. /** Defines that alpha blending to SRC * DEST */
  4050. static readonly ALPHA_MULTIPLY: number;
  4051. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4052. static readonly ALPHA_MAXIMIZED: number;
  4053. /** Defines that alpha blending to SRC + DEST */
  4054. static readonly ALPHA_ONEONE: number;
  4055. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4056. static readonly ALPHA_PREMULTIPLIED: number;
  4057. /**
  4058. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4059. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4060. */
  4061. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4062. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4063. static readonly ALPHA_INTERPOLATE: number;
  4064. /**
  4065. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4066. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4067. */
  4068. static readonly ALPHA_SCREENMODE: number;
  4069. /** Defines that the ressource is not delayed*/
  4070. static readonly DELAYLOADSTATE_NONE: number;
  4071. /** Defines that the ressource was successfully delay loaded */
  4072. static readonly DELAYLOADSTATE_LOADED: number;
  4073. /** Defines that the ressource is currently delay loading */
  4074. static readonly DELAYLOADSTATE_LOADING: number;
  4075. /** Defines that the ressource is delayed and has not started loading */
  4076. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4077. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4078. static readonly NEVER: number;
  4079. /** 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 */
  4080. static readonly ALWAYS: number;
  4081. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4082. static readonly LESS: number;
  4083. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4084. static readonly EQUAL: number;
  4085. /** 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 */
  4086. static readonly LEQUAL: number;
  4087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4088. static readonly GREATER: number;
  4089. /** 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 */
  4090. static readonly GEQUAL: number;
  4091. /** 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 */
  4092. static readonly NOTEQUAL: number;
  4093. /** Passed to stencilOperation to specify that stencil value must be kept */
  4094. static readonly KEEP: number;
  4095. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4096. static readonly REPLACE: number;
  4097. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4098. static readonly INCR: number;
  4099. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4100. static readonly DECR: number;
  4101. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4102. static readonly INVERT: number;
  4103. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4104. static readonly INCR_WRAP: number;
  4105. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4106. static readonly DECR_WRAP: number;
  4107. /** Texture is not repeating outside of 0..1 UVs */
  4108. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4109. /** Texture is repeating outside of 0..1 UVs */
  4110. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4111. /** Texture is repeating and mirrored */
  4112. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4113. /** ALPHA */
  4114. static readonly TEXTUREFORMAT_ALPHA: number;
  4115. /** LUMINANCE */
  4116. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4117. /** LUMINANCE_ALPHA */
  4118. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4119. /** RGB */
  4120. static readonly TEXTUREFORMAT_RGB: number;
  4121. /** RGBA */
  4122. static readonly TEXTUREFORMAT_RGBA: number;
  4123. /** RED */
  4124. static readonly TEXTUREFORMAT_RED: number;
  4125. /** RED (2nd reference) */
  4126. static readonly TEXTUREFORMAT_R: number;
  4127. /** RG */
  4128. static readonly TEXTUREFORMAT_RG: number;
  4129. /** RED_INTEGER */
  4130. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4131. /** RED_INTEGER (2nd reference) */
  4132. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4133. /** RG_INTEGER */
  4134. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4135. /** RGB_INTEGER */
  4136. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4137. /** RGBA_INTEGER */
  4138. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4139. /** UNSIGNED_BYTE */
  4140. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4141. /** UNSIGNED_BYTE (2nd reference) */
  4142. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4143. /** FLOAT */
  4144. static readonly TEXTURETYPE_FLOAT: number;
  4145. /** HALF_FLOAT */
  4146. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4147. /** BYTE */
  4148. static readonly TEXTURETYPE_BYTE: number;
  4149. /** SHORT */
  4150. static readonly TEXTURETYPE_SHORT: number;
  4151. /** UNSIGNED_SHORT */
  4152. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4153. /** INT */
  4154. static readonly TEXTURETYPE_INT: number;
  4155. /** UNSIGNED_INT */
  4156. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4157. /** UNSIGNED_SHORT_4_4_4_4 */
  4158. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4159. /** UNSIGNED_SHORT_5_5_5_1 */
  4160. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4161. /** UNSIGNED_SHORT_5_6_5 */
  4162. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4163. /** UNSIGNED_INT_2_10_10_10_REV */
  4164. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4165. /** UNSIGNED_INT_24_8 */
  4166. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4167. /** UNSIGNED_INT_10F_11F_11F_REV */
  4168. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4169. /** UNSIGNED_INT_5_9_9_9_REV */
  4170. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4171. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4172. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4173. /** nearest is mag = nearest and min = nearest and mip = linear */
  4174. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4175. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4176. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4177. /** Trilinear is mag = linear and min = linear and mip = linear */
  4178. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4179. /** nearest is mag = nearest and min = nearest and mip = linear */
  4180. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4181. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4182. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4183. /** Trilinear is mag = linear and min = linear and mip = linear */
  4184. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4185. /** mag = nearest and min = nearest and mip = nearest */
  4186. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4187. /** mag = nearest and min = linear and mip = nearest */
  4188. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4189. /** mag = nearest and min = linear and mip = linear */
  4190. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4191. /** mag = nearest and min = linear and mip = none */
  4192. static readonly TEXTURE_NEAREST_LINEAR: number;
  4193. /** mag = nearest and min = nearest and mip = none */
  4194. static readonly TEXTURE_NEAREST_NEAREST: number;
  4195. /** mag = linear and min = nearest and mip = nearest */
  4196. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4197. /** mag = linear and min = nearest and mip = linear */
  4198. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4199. /** mag = linear and min = linear and mip = none */
  4200. static readonly TEXTURE_LINEAR_LINEAR: number;
  4201. /** mag = linear and min = nearest and mip = none */
  4202. static readonly TEXTURE_LINEAR_NEAREST: number;
  4203. /** Explicit coordinates mode */
  4204. static readonly TEXTURE_EXPLICIT_MODE: number;
  4205. /** Spherical coordinates mode */
  4206. static readonly TEXTURE_SPHERICAL_MODE: number;
  4207. /** Planar coordinates mode */
  4208. static readonly TEXTURE_PLANAR_MODE: number;
  4209. /** Cubic coordinates mode */
  4210. static readonly TEXTURE_CUBIC_MODE: number;
  4211. /** Projection coordinates mode */
  4212. static readonly TEXTURE_PROJECTION_MODE: number;
  4213. /** Skybox coordinates mode */
  4214. static readonly TEXTURE_SKYBOX_MODE: number;
  4215. /** Inverse Cubic coordinates mode */
  4216. static readonly TEXTURE_INVCUBIC_MODE: number;
  4217. /** Equirectangular coordinates mode */
  4218. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4219. /** Equirectangular Fixed coordinates mode */
  4220. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4221. /** Equirectangular Fixed Mirrored coordinates mode */
  4222. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4223. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4224. static readonly SCALEMODE_FLOOR: number;
  4225. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4226. static readonly SCALEMODE_NEAREST: number;
  4227. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4228. static readonly SCALEMODE_CEILING: number;
  4229. /**
  4230. * The dirty texture flag value
  4231. */
  4232. static readonly MATERIAL_TextureDirtyFlag: number;
  4233. /**
  4234. * The dirty light flag value
  4235. */
  4236. static readonly MATERIAL_LightDirtyFlag: number;
  4237. /**
  4238. * The dirty fresnel flag value
  4239. */
  4240. static readonly MATERIAL_FresnelDirtyFlag: number;
  4241. /**
  4242. * The dirty attribute flag value
  4243. */
  4244. static readonly MATERIAL_AttributesDirtyFlag: number;
  4245. /**
  4246. * The dirty misc flag value
  4247. */
  4248. static readonly MATERIAL_MiscDirtyFlag: number;
  4249. /**
  4250. * The all dirty flag value
  4251. */
  4252. static readonly MATERIAL_AllDirtyFlag: number;
  4253. /**
  4254. * Returns the triangle fill mode
  4255. */
  4256. static readonly MATERIAL_TriangleFillMode: number;
  4257. /**
  4258. * Returns the wireframe mode
  4259. */
  4260. static readonly MATERIAL_WireFrameFillMode: number;
  4261. /**
  4262. * Returns the point fill mode
  4263. */
  4264. static readonly MATERIAL_PointFillMode: number;
  4265. /**
  4266. * Returns the point list draw mode
  4267. */
  4268. static readonly MATERIAL_PointListDrawMode: number;
  4269. /**
  4270. * Returns the line list draw mode
  4271. */
  4272. static readonly MATERIAL_LineListDrawMode: number;
  4273. /**
  4274. * Returns the line loop draw mode
  4275. */
  4276. static readonly MATERIAL_LineLoopDrawMode: number;
  4277. /**
  4278. * Returns the line strip draw mode
  4279. */
  4280. static readonly MATERIAL_LineStripDrawMode: number;
  4281. /**
  4282. * Returns the triangle strip draw mode
  4283. */
  4284. static readonly MATERIAL_TriangleStripDrawMode: number;
  4285. /**
  4286. * Returns the triangle fan draw mode
  4287. */
  4288. static readonly MATERIAL_TriangleFanDrawMode: number;
  4289. /**
  4290. * Stores the clock-wise side orientation
  4291. */
  4292. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4293. /**
  4294. * Stores the counter clock-wise side orientation
  4295. */
  4296. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4297. /**
  4298. * Nothing
  4299. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4300. */
  4301. static readonly ACTION_NothingTrigger: number;
  4302. /**
  4303. * On pick
  4304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4305. */
  4306. static readonly ACTION_OnPickTrigger: number;
  4307. /**
  4308. * On left pick
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_OnLeftPickTrigger: number;
  4312. /**
  4313. * On right pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnRightPickTrigger: number;
  4317. /**
  4318. * On center pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnCenterPickTrigger: number;
  4322. /**
  4323. * On pick down
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnPickDownTrigger: number;
  4327. /**
  4328. * On double pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnDoublePickTrigger: number;
  4332. /**
  4333. * On pick up
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnPickUpTrigger: number;
  4337. /**
  4338. * On pick out.
  4339. * This trigger will only be raised if you also declared a OnPickDown
  4340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4341. */
  4342. static readonly ACTION_OnPickOutTrigger: number;
  4343. /**
  4344. * On long press
  4345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4346. */
  4347. static readonly ACTION_OnLongPressTrigger: number;
  4348. /**
  4349. * On pointer over
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnPointerOverTrigger: number;
  4353. /**
  4354. * On pointer out
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnPointerOutTrigger: number;
  4358. /**
  4359. * On every frame
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnEveryFrameTrigger: number;
  4363. /**
  4364. * On intersection enter
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4368. /**
  4369. * On intersection exit
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnIntersectionExitTrigger: number;
  4373. /**
  4374. * On key down
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnKeyDownTrigger: number;
  4378. /**
  4379. * On key up
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnKeyUpTrigger: number;
  4383. /**
  4384. * Billboard mode will only apply to Y axis
  4385. */
  4386. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4387. /**
  4388. * Billboard mode will apply to all axes
  4389. */
  4390. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4391. /**
  4392. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4393. */
  4394. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4395. /**
  4396. * Gets or sets base Assets URL
  4397. */
  4398. static PARTICLES_BaseAssetsUrl: string;
  4399. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4400. * Test order :
  4401. * Is the bounding sphere outside the frustum ?
  4402. * If not, are the bounding box vertices outside the frustum ?
  4403. * It not, then the cullable object is in the frustum.
  4404. */
  4405. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4406. /** Culling strategy : Bounding Sphere Only.
  4407. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4408. * It's also less accurate than the standard because some not visible objects can still be selected.
  4409. * Test : is the bounding sphere outside the frustum ?
  4410. * If not, then the cullable object is in the frustum.
  4411. */
  4412. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4413. /** Culling strategy : Optimistic Inclusion.
  4414. * This in an inclusion test first, then the standard exclusion test.
  4415. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4416. * 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.
  4417. * Anyway, it's as accurate as the standard strategy.
  4418. * Test :
  4419. * Is the cullable object bounding sphere center in the frustum ?
  4420. * If not, apply the default culling strategy.
  4421. */
  4422. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4423. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4424. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4425. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4426. * 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.
  4427. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4428. * Test :
  4429. * Is the cullable object bounding sphere center in the frustum ?
  4430. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4431. */
  4432. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4433. /**
  4434. * No logging while loading
  4435. */
  4436. static readonly SCENELOADER_NO_LOGGING: number;
  4437. /**
  4438. * Minimal logging while loading
  4439. */
  4440. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4441. /**
  4442. * Summary logging while loading
  4443. */
  4444. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4445. /**
  4446. * Detailled logging while loading
  4447. */
  4448. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4449. }
  4450. }
  4451. declare module BABYLON {
  4452. /**
  4453. * Class used to store and describe the pipeline context associated with an effect
  4454. */
  4455. export interface IPipelineContext {
  4456. /**
  4457. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4458. */
  4459. isAsync: boolean;
  4460. /**
  4461. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4462. */
  4463. isReady: boolean;
  4464. /** @hidden */
  4465. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4466. }
  4467. }
  4468. declare module BABYLON {
  4469. /** @hidden */
  4470. export interface IShaderProcessor {
  4471. attributeProcessor?: (attribute: string) => string;
  4472. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4473. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4474. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4475. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4476. lineProcessor?: (line: string, isFragment: boolean) => string;
  4477. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4478. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4479. }
  4480. }
  4481. declare module BABYLON {
  4482. /** @hidden */
  4483. export interface ProcessingOptions {
  4484. defines: string[];
  4485. indexParameters: any;
  4486. isFragment: boolean;
  4487. shouldUseHighPrecisionShader: boolean;
  4488. supportsUniformBuffers: boolean;
  4489. shadersRepository: string;
  4490. includesShadersStore: {
  4491. [key: string]: string;
  4492. };
  4493. processor?: IShaderProcessor;
  4494. version: string;
  4495. platformName: string;
  4496. lookForClosingBracketForUniformBuffer?: boolean;
  4497. }
  4498. }
  4499. declare module BABYLON {
  4500. /**
  4501. * Helper to manipulate strings
  4502. */
  4503. export class StringTools {
  4504. /**
  4505. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4506. * @param str Source string
  4507. * @param suffix Suffix to search for in the source string
  4508. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4509. */
  4510. static EndsWith(str: string, suffix: string): boolean;
  4511. /**
  4512. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4513. * @param str Source string
  4514. * @param suffix Suffix to search for in the source string
  4515. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4516. */
  4517. static StartsWith(str: string, suffix: string): boolean;
  4518. }
  4519. }
  4520. declare module BABYLON {
  4521. /** @hidden */
  4522. export class ShaderCodeNode {
  4523. line: string;
  4524. children: ShaderCodeNode[];
  4525. additionalDefineKey?: string;
  4526. additionalDefineValue?: string;
  4527. isValid(preprocessors: {
  4528. [key: string]: string;
  4529. }): boolean;
  4530. process(preprocessors: {
  4531. [key: string]: string;
  4532. }, options: ProcessingOptions): string;
  4533. }
  4534. }
  4535. declare module BABYLON {
  4536. /** @hidden */
  4537. export class ShaderCodeCursor {
  4538. private _lines;
  4539. lineIndex: number;
  4540. readonly currentLine: string;
  4541. readonly canRead: boolean;
  4542. lines: string[];
  4543. }
  4544. }
  4545. declare module BABYLON {
  4546. /** @hidden */
  4547. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4548. process(preprocessors: {
  4549. [key: string]: string;
  4550. }, options: ProcessingOptions): string;
  4551. }
  4552. }
  4553. declare module BABYLON {
  4554. /** @hidden */
  4555. export class ShaderDefineExpression {
  4556. isTrue(preprocessors: {
  4557. [key: string]: string;
  4558. }): boolean;
  4559. }
  4560. }
  4561. declare module BABYLON {
  4562. /** @hidden */
  4563. export class ShaderCodeTestNode extends ShaderCodeNode {
  4564. testExpression: ShaderDefineExpression;
  4565. isValid(preprocessors: {
  4566. [key: string]: string;
  4567. }): boolean;
  4568. }
  4569. }
  4570. declare module BABYLON {
  4571. /** @hidden */
  4572. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4573. define: string;
  4574. not: boolean;
  4575. constructor(define: string, not?: boolean);
  4576. isTrue(preprocessors: {
  4577. [key: string]: string;
  4578. }): boolean;
  4579. }
  4580. }
  4581. declare module BABYLON {
  4582. /** @hidden */
  4583. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4584. leftOperand: ShaderDefineExpression;
  4585. rightOperand: ShaderDefineExpression;
  4586. isTrue(preprocessors: {
  4587. [key: string]: string;
  4588. }): boolean;
  4589. }
  4590. }
  4591. declare module BABYLON {
  4592. /** @hidden */
  4593. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4594. leftOperand: ShaderDefineExpression;
  4595. rightOperand: ShaderDefineExpression;
  4596. isTrue(preprocessors: {
  4597. [key: string]: string;
  4598. }): boolean;
  4599. }
  4600. }
  4601. declare module BABYLON {
  4602. /** @hidden */
  4603. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4604. define: string;
  4605. operand: string;
  4606. testValue: string;
  4607. constructor(define: string, operand: string, testValue: string);
  4608. isTrue(preprocessors: {
  4609. [key: string]: string;
  4610. }): boolean;
  4611. }
  4612. }
  4613. declare module BABYLON {
  4614. /**
  4615. * @ignore
  4616. * Application error to support additional information when loading a file
  4617. */
  4618. export class LoadFileError extends Error {
  4619. /** defines the optional web request */
  4620. request?: WebRequest | undefined;
  4621. private static _setPrototypeOf;
  4622. /**
  4623. * Creates a new LoadFileError
  4624. * @param message defines the message of the error
  4625. * @param request defines the optional web request
  4626. */
  4627. constructor(message: string,
  4628. /** defines the optional web request */
  4629. request?: WebRequest | undefined);
  4630. }
  4631. }
  4632. declare module BABYLON {
  4633. /**
  4634. * Class used to enable access to offline support
  4635. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4636. */
  4637. export interface IOfflineProvider {
  4638. /**
  4639. * Gets a boolean indicating if scene must be saved in the database
  4640. */
  4641. enableSceneOffline: boolean;
  4642. /**
  4643. * Gets a boolean indicating if textures must be saved in the database
  4644. */
  4645. enableTexturesOffline: boolean;
  4646. /**
  4647. * Open the offline support and make it available
  4648. * @param successCallback defines the callback to call on success
  4649. * @param errorCallback defines the callback to call on error
  4650. */
  4651. open(successCallback: () => void, errorCallback: () => void): void;
  4652. /**
  4653. * Loads an image from the offline support
  4654. * @param url defines the url to load from
  4655. * @param image defines the target DOM image
  4656. */
  4657. loadImage(url: string, image: HTMLImageElement): void;
  4658. /**
  4659. * Loads a file from offline support
  4660. * @param url defines the URL to load from
  4661. * @param sceneLoaded defines a callback to call on success
  4662. * @param progressCallBack defines a callback to call when progress changed
  4663. * @param errorCallback defines a callback to call on error
  4664. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4665. */
  4666. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4667. }
  4668. }
  4669. declare module BABYLON {
  4670. /**
  4671. * Class used to help managing file picking and drag'n'drop
  4672. * File Storage
  4673. */
  4674. export class FilesInputStore {
  4675. /**
  4676. * List of files ready to be loaded
  4677. */
  4678. static FilesToLoad: {
  4679. [key: string]: File;
  4680. };
  4681. }
  4682. }
  4683. declare module BABYLON {
  4684. /**
  4685. * Class used to define a retry strategy when error happens while loading assets
  4686. */
  4687. export class RetryStrategy {
  4688. /**
  4689. * Function used to defines an exponential back off strategy
  4690. * @param maxRetries defines the maximum number of retries (3 by default)
  4691. * @param baseInterval defines the interval between retries
  4692. * @returns the strategy function to use
  4693. */
  4694. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4695. }
  4696. }
  4697. declare module BABYLON {
  4698. /**
  4699. * @hidden
  4700. */
  4701. export class FileTools {
  4702. /**
  4703. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4704. */
  4705. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4706. /**
  4707. * Gets or sets the base URL to use to load assets
  4708. */
  4709. static BaseUrl: string;
  4710. /**
  4711. * Default behaviour for cors in the application.
  4712. * It can be a string if the expected behavior is identical in the entire app.
  4713. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4714. */
  4715. static CorsBehavior: string | ((url: string | string[]) => string);
  4716. /**
  4717. * Gets or sets a function used to pre-process url before using them to load assets
  4718. */
  4719. static PreprocessUrl: (url: string) => string;
  4720. /**
  4721. * Removes unwanted characters from an url
  4722. * @param url defines the url to clean
  4723. * @returns the cleaned url
  4724. */
  4725. private static _CleanUrl;
  4726. /**
  4727. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4728. * @param url define the url we are trying
  4729. * @param element define the dom element where to configure the cors policy
  4730. */
  4731. static SetCorsBehavior(url: string | string[], element: {
  4732. crossOrigin: string | null;
  4733. }): void;
  4734. /**
  4735. * Loads an image as an HTMLImageElement.
  4736. * @param input url string, ArrayBuffer, or Blob to load
  4737. * @param onLoad callback called when the image successfully loads
  4738. * @param onError callback called when the image fails to load
  4739. * @param offlineProvider offline provider for caching
  4740. * @returns the HTMLImageElement of the loaded image
  4741. */
  4742. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4743. /**
  4744. * Loads a file
  4745. * @param fileToLoad defines the file to load
  4746. * @param callback defines the callback to call when data is loaded
  4747. * @param progressCallBack defines the callback to call during loading process
  4748. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4749. * @returns a file request object
  4750. */
  4751. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4752. /**
  4753. * Loads a file
  4754. * @param url url string, ArrayBuffer, or Blob to load
  4755. * @param onSuccess callback called when the file successfully loads
  4756. * @param onProgress callback called while file is loading (if the server supports this mode)
  4757. * @param offlineProvider defines the offline provider for caching
  4758. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4759. * @param onError callback called when the file fails to load
  4760. * @returns a file request object
  4761. */
  4762. 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;
  4763. /**
  4764. * Checks if the loaded document was accessed via `file:`-Protocol.
  4765. * @returns boolean
  4766. */
  4767. static IsFileURL(): boolean;
  4768. }
  4769. }
  4770. declare module BABYLON {
  4771. /** @hidden */
  4772. export class ShaderProcessor {
  4773. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4774. private static _ProcessPrecision;
  4775. private static _ExtractOperation;
  4776. private static _BuildSubExpression;
  4777. private static _BuildExpression;
  4778. private static _MoveCursorWithinIf;
  4779. private static _MoveCursor;
  4780. private static _EvaluatePreProcessors;
  4781. private static _PreparePreProcessors;
  4782. private static _ProcessShaderConversion;
  4783. private static _ProcessIncludes;
  4784. }
  4785. }
  4786. declare module BABYLON {
  4787. /**
  4788. * Class used to hold a RBG color
  4789. */
  4790. export class Color3 {
  4791. /**
  4792. * Defines the red component (between 0 and 1, default is 0)
  4793. */
  4794. r: number;
  4795. /**
  4796. * Defines the green component (between 0 and 1, default is 0)
  4797. */
  4798. g: number;
  4799. /**
  4800. * Defines the blue component (between 0 and 1, default is 0)
  4801. */
  4802. b: number;
  4803. /**
  4804. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4805. * @param r defines the red component (between 0 and 1, default is 0)
  4806. * @param g defines the green component (between 0 and 1, default is 0)
  4807. * @param b defines the blue component (between 0 and 1, default is 0)
  4808. */
  4809. constructor(
  4810. /**
  4811. * Defines the red component (between 0 and 1, default is 0)
  4812. */
  4813. r?: number,
  4814. /**
  4815. * Defines the green component (between 0 and 1, default is 0)
  4816. */
  4817. g?: number,
  4818. /**
  4819. * Defines the blue component (between 0 and 1, default is 0)
  4820. */
  4821. b?: number);
  4822. /**
  4823. * Creates a string with the Color3 current values
  4824. * @returns the string representation of the Color3 object
  4825. */
  4826. toString(): string;
  4827. /**
  4828. * Returns the string "Color3"
  4829. * @returns "Color3"
  4830. */
  4831. getClassName(): string;
  4832. /**
  4833. * Compute the Color3 hash code
  4834. * @returns an unique number that can be used to hash Color3 objects
  4835. */
  4836. getHashCode(): number;
  4837. /**
  4838. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4839. * @param array defines the array where to store the r,g,b components
  4840. * @param index defines an optional index in the target array to define where to start storing values
  4841. * @returns the current Color3 object
  4842. */
  4843. toArray(array: FloatArray, index?: number): Color3;
  4844. /**
  4845. * Returns a new Color4 object from the current Color3 and the given alpha
  4846. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4847. * @returns a new Color4 object
  4848. */
  4849. toColor4(alpha?: number): Color4;
  4850. /**
  4851. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4852. * @returns the new array
  4853. */
  4854. asArray(): number[];
  4855. /**
  4856. * Returns the luminance value
  4857. * @returns a float value
  4858. */
  4859. toLuminance(): number;
  4860. /**
  4861. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4862. * @param otherColor defines the second operand
  4863. * @returns the new Color3 object
  4864. */
  4865. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4866. /**
  4867. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4868. * @param otherColor defines the second operand
  4869. * @param result defines the Color3 object where to store the result
  4870. * @returns the current Color3
  4871. */
  4872. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4873. /**
  4874. * Determines equality between Color3 objects
  4875. * @param otherColor defines the second operand
  4876. * @returns true if the rgb values are equal to the given ones
  4877. */
  4878. equals(otherColor: DeepImmutable<Color3>): boolean;
  4879. /**
  4880. * Determines equality between the current Color3 object and a set of r,b,g values
  4881. * @param r defines the red component to check
  4882. * @param g defines the green component to check
  4883. * @param b defines the blue component to check
  4884. * @returns true if the rgb values are equal to the given ones
  4885. */
  4886. equalsFloats(r: number, g: number, b: number): boolean;
  4887. /**
  4888. * Multiplies in place each rgb value by scale
  4889. * @param scale defines the scaling factor
  4890. * @returns the updated Color3
  4891. */
  4892. scale(scale: number): Color3;
  4893. /**
  4894. * Multiplies the rgb values by scale and stores the result into "result"
  4895. * @param scale defines the scaling factor
  4896. * @param result defines the Color3 object where to store the result
  4897. * @returns the unmodified current Color3
  4898. */
  4899. scaleToRef(scale: number, result: Color3): Color3;
  4900. /**
  4901. * Scale the current Color3 values by a factor and add the result to a given Color3
  4902. * @param scale defines the scale factor
  4903. * @param result defines color to store the result into
  4904. * @returns the unmodified current Color3
  4905. */
  4906. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4907. /**
  4908. * Clamps the rgb values by the min and max values and stores the result into "result"
  4909. * @param min defines minimum clamping value (default is 0)
  4910. * @param max defines maximum clamping value (default is 1)
  4911. * @param result defines color to store the result into
  4912. * @returns the original Color3
  4913. */
  4914. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4915. /**
  4916. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4917. * @param otherColor defines the second operand
  4918. * @returns the new Color3
  4919. */
  4920. add(otherColor: DeepImmutable<Color3>): Color3;
  4921. /**
  4922. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4923. * @param otherColor defines the second operand
  4924. * @param result defines Color3 object to store the result into
  4925. * @returns the unmodified current Color3
  4926. */
  4927. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4928. /**
  4929. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4930. * @param otherColor defines the second operand
  4931. * @returns the new Color3
  4932. */
  4933. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4934. /**
  4935. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4936. * @param otherColor defines the second operand
  4937. * @param result defines Color3 object to store the result into
  4938. * @returns the unmodified current Color3
  4939. */
  4940. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4941. /**
  4942. * Copy the current object
  4943. * @returns a new Color3 copied the current one
  4944. */
  4945. clone(): Color3;
  4946. /**
  4947. * Copies the rgb values from the source in the current Color3
  4948. * @param source defines the source Color3 object
  4949. * @returns the updated Color3 object
  4950. */
  4951. copyFrom(source: DeepImmutable<Color3>): Color3;
  4952. /**
  4953. * Updates the Color3 rgb values from the given floats
  4954. * @param r defines the red component to read from
  4955. * @param g defines the green component to read from
  4956. * @param b defines the blue component to read from
  4957. * @returns the current Color3 object
  4958. */
  4959. copyFromFloats(r: number, g: number, b: number): Color3;
  4960. /**
  4961. * Updates the Color3 rgb values from the given floats
  4962. * @param r defines the red component to read from
  4963. * @param g defines the green component to read from
  4964. * @param b defines the blue component to read from
  4965. * @returns the current Color3 object
  4966. */
  4967. set(r: number, g: number, b: number): Color3;
  4968. /**
  4969. * Compute the Color3 hexadecimal code as a string
  4970. * @returns a string containing the hexadecimal representation of the Color3 object
  4971. */
  4972. toHexString(): string;
  4973. /**
  4974. * Computes a new Color3 converted from the current one to linear space
  4975. * @returns a new Color3 object
  4976. */
  4977. toLinearSpace(): Color3;
  4978. /**
  4979. * Converts current color in rgb space to HSV values
  4980. * @returns a new color3 representing the HSV values
  4981. */
  4982. toHSV(): Color3;
  4983. /**
  4984. * Converts current color in rgb space to HSV values
  4985. * @param result defines the Color3 where to store the HSV values
  4986. */
  4987. toHSVToRef(result: Color3): void;
  4988. /**
  4989. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  4990. * @param convertedColor defines the Color3 object where to store the linear space version
  4991. * @returns the unmodified Color3
  4992. */
  4993. toLinearSpaceToRef(convertedColor: Color3): Color3;
  4994. /**
  4995. * Computes a new Color3 converted from the current one to gamma space
  4996. * @returns a new Color3 object
  4997. */
  4998. toGammaSpace(): Color3;
  4999. /**
  5000. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5001. * @param convertedColor defines the Color3 object where to store the gamma space version
  5002. * @returns the unmodified Color3
  5003. */
  5004. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5005. private static _BlackReadOnly;
  5006. /**
  5007. * Convert Hue, saturation and value to a Color3 (RGB)
  5008. * @param hue defines the hue
  5009. * @param saturation defines the saturation
  5010. * @param value defines the value
  5011. * @param result defines the Color3 where to store the RGB values
  5012. */
  5013. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5014. /**
  5015. * Creates a new Color3 from the string containing valid hexadecimal values
  5016. * @param hex defines a string containing valid hexadecimal values
  5017. * @returns a new Color3 object
  5018. */
  5019. static FromHexString(hex: string): Color3;
  5020. /**
  5021. * Creates a new Color3 from the starting index of the given array
  5022. * @param array defines the source array
  5023. * @param offset defines an offset in the source array
  5024. * @returns a new Color3 object
  5025. */
  5026. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5027. /**
  5028. * Creates a new Color3 from integer values (< 256)
  5029. * @param r defines the red component to read from (value between 0 and 255)
  5030. * @param g defines the green component to read from (value between 0 and 255)
  5031. * @param b defines the blue component to read from (value between 0 and 255)
  5032. * @returns a new Color3 object
  5033. */
  5034. static FromInts(r: number, g: number, b: number): Color3;
  5035. /**
  5036. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5037. * @param start defines the start Color3 value
  5038. * @param end defines the end Color3 value
  5039. * @param amount defines the gradient value between start and end
  5040. * @returns a new Color3 object
  5041. */
  5042. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5043. /**
  5044. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5045. * @param left defines the start value
  5046. * @param right defines the end value
  5047. * @param amount defines the gradient factor
  5048. * @param result defines the Color3 object where to store the result
  5049. */
  5050. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5051. /**
  5052. * Returns a Color3 value containing a red color
  5053. * @returns a new Color3 object
  5054. */
  5055. static Red(): Color3;
  5056. /**
  5057. * Returns a Color3 value containing a green color
  5058. * @returns a new Color3 object
  5059. */
  5060. static Green(): Color3;
  5061. /**
  5062. * Returns a Color3 value containing a blue color
  5063. * @returns a new Color3 object
  5064. */
  5065. static Blue(): Color3;
  5066. /**
  5067. * Returns a Color3 value containing a black color
  5068. * @returns a new Color3 object
  5069. */
  5070. static Black(): Color3;
  5071. /**
  5072. * Gets a Color3 value containing a black color that must not be updated
  5073. */
  5074. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5075. /**
  5076. * Returns a Color3 value containing a white color
  5077. * @returns a new Color3 object
  5078. */
  5079. static White(): Color3;
  5080. /**
  5081. * Returns a Color3 value containing a purple color
  5082. * @returns a new Color3 object
  5083. */
  5084. static Purple(): Color3;
  5085. /**
  5086. * Returns a Color3 value containing a magenta color
  5087. * @returns a new Color3 object
  5088. */
  5089. static Magenta(): Color3;
  5090. /**
  5091. * Returns a Color3 value containing a yellow color
  5092. * @returns a new Color3 object
  5093. */
  5094. static Yellow(): Color3;
  5095. /**
  5096. * Returns a Color3 value containing a gray color
  5097. * @returns a new Color3 object
  5098. */
  5099. static Gray(): Color3;
  5100. /**
  5101. * Returns a Color3 value containing a teal color
  5102. * @returns a new Color3 object
  5103. */
  5104. static Teal(): Color3;
  5105. /**
  5106. * Returns a Color3 value containing a random color
  5107. * @returns a new Color3 object
  5108. */
  5109. static Random(): Color3;
  5110. }
  5111. /**
  5112. * Class used to hold a RBGA color
  5113. */
  5114. export class Color4 {
  5115. /**
  5116. * Defines the red component (between 0 and 1, default is 0)
  5117. */
  5118. r: number;
  5119. /**
  5120. * Defines the green component (between 0 and 1, default is 0)
  5121. */
  5122. g: number;
  5123. /**
  5124. * Defines the blue component (between 0 and 1, default is 0)
  5125. */
  5126. b: number;
  5127. /**
  5128. * Defines the alpha component (between 0 and 1, default is 1)
  5129. */
  5130. a: number;
  5131. /**
  5132. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5133. * @param r defines the red component (between 0 and 1, default is 0)
  5134. * @param g defines the green component (between 0 and 1, default is 0)
  5135. * @param b defines the blue component (between 0 and 1, default is 0)
  5136. * @param a defines the alpha component (between 0 and 1, default is 1)
  5137. */
  5138. constructor(
  5139. /**
  5140. * Defines the red component (between 0 and 1, default is 0)
  5141. */
  5142. r?: number,
  5143. /**
  5144. * Defines the green component (between 0 and 1, default is 0)
  5145. */
  5146. g?: number,
  5147. /**
  5148. * Defines the blue component (between 0 and 1, default is 0)
  5149. */
  5150. b?: number,
  5151. /**
  5152. * Defines the alpha component (between 0 and 1, default is 1)
  5153. */
  5154. a?: number);
  5155. /**
  5156. * Adds in place the given Color4 values to the current Color4 object
  5157. * @param right defines the second operand
  5158. * @returns the current updated Color4 object
  5159. */
  5160. addInPlace(right: DeepImmutable<Color4>): Color4;
  5161. /**
  5162. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5163. * @returns the new array
  5164. */
  5165. asArray(): number[];
  5166. /**
  5167. * Stores from the starting index in the given array the Color4 successive values
  5168. * @param array defines the array where to store the r,g,b components
  5169. * @param index defines an optional index in the target array to define where to start storing values
  5170. * @returns the current Color4 object
  5171. */
  5172. toArray(array: number[], index?: number): Color4;
  5173. /**
  5174. * Determines equality between Color4 objects
  5175. * @param otherColor defines the second operand
  5176. * @returns true if the rgba values are equal to the given ones
  5177. */
  5178. equals(otherColor: DeepImmutable<Color4>): boolean;
  5179. /**
  5180. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5181. * @param right defines the second operand
  5182. * @returns a new Color4 object
  5183. */
  5184. add(right: DeepImmutable<Color4>): Color4;
  5185. /**
  5186. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5187. * @param right defines the second operand
  5188. * @returns a new Color4 object
  5189. */
  5190. subtract(right: DeepImmutable<Color4>): Color4;
  5191. /**
  5192. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5193. * @param right defines the second operand
  5194. * @param result defines the Color4 object where to store the result
  5195. * @returns the current Color4 object
  5196. */
  5197. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5198. /**
  5199. * Creates a new Color4 with the current Color4 values multiplied by scale
  5200. * @param scale defines the scaling factor to apply
  5201. * @returns a new Color4 object
  5202. */
  5203. scale(scale: number): Color4;
  5204. /**
  5205. * Multiplies the current Color4 values by scale and stores the result in "result"
  5206. * @param scale defines the scaling factor to apply
  5207. * @param result defines the Color4 object where to store the result
  5208. * @returns the current unmodified Color4
  5209. */
  5210. scaleToRef(scale: number, result: Color4): Color4;
  5211. /**
  5212. * Scale the current Color4 values by a factor and add the result to a given Color4
  5213. * @param scale defines the scale factor
  5214. * @param result defines the Color4 object where to store the result
  5215. * @returns the unmodified current Color4
  5216. */
  5217. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5218. /**
  5219. * Clamps the rgb values by the min and max values and stores the result into "result"
  5220. * @param min defines minimum clamping value (default is 0)
  5221. * @param max defines maximum clamping value (default is 1)
  5222. * @param result defines color to store the result into.
  5223. * @returns the cuurent Color4
  5224. */
  5225. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5226. /**
  5227. * Multipy an Color4 value by another and return a new Color4 object
  5228. * @param color defines the Color4 value to multiply by
  5229. * @returns a new Color4 object
  5230. */
  5231. multiply(color: Color4): Color4;
  5232. /**
  5233. * Multipy a Color4 value by another and push the result in a reference value
  5234. * @param color defines the Color4 value to multiply by
  5235. * @param result defines the Color4 to fill the result in
  5236. * @returns the result Color4
  5237. */
  5238. multiplyToRef(color: Color4, result: Color4): Color4;
  5239. /**
  5240. * Creates a string with the Color4 current values
  5241. * @returns the string representation of the Color4 object
  5242. */
  5243. toString(): string;
  5244. /**
  5245. * Returns the string "Color4"
  5246. * @returns "Color4"
  5247. */
  5248. getClassName(): string;
  5249. /**
  5250. * Compute the Color4 hash code
  5251. * @returns an unique number that can be used to hash Color4 objects
  5252. */
  5253. getHashCode(): number;
  5254. /**
  5255. * Creates a new Color4 copied from the current one
  5256. * @returns a new Color4 object
  5257. */
  5258. clone(): Color4;
  5259. /**
  5260. * Copies the given Color4 values into the current one
  5261. * @param source defines the source Color4 object
  5262. * @returns the current updated Color4 object
  5263. */
  5264. copyFrom(source: Color4): Color4;
  5265. /**
  5266. * Copies the given float values into the current one
  5267. * @param r defines the red component to read from
  5268. * @param g defines the green component to read from
  5269. * @param b defines the blue component to read from
  5270. * @param a defines the alpha component to read from
  5271. * @returns the current updated Color4 object
  5272. */
  5273. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5274. /**
  5275. * Copies the given float values into the current one
  5276. * @param r defines the red component to read from
  5277. * @param g defines the green component to read from
  5278. * @param b defines the blue component to read from
  5279. * @param a defines the alpha component to read from
  5280. * @returns the current updated Color4 object
  5281. */
  5282. set(r: number, g: number, b: number, a: number): Color4;
  5283. /**
  5284. * Compute the Color4 hexadecimal code as a string
  5285. * @returns a string containing the hexadecimal representation of the Color4 object
  5286. */
  5287. toHexString(): string;
  5288. /**
  5289. * Computes a new Color4 converted from the current one to linear space
  5290. * @returns a new Color4 object
  5291. */
  5292. toLinearSpace(): Color4;
  5293. /**
  5294. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5295. * @param convertedColor defines the Color4 object where to store the linear space version
  5296. * @returns the unmodified Color4
  5297. */
  5298. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5299. /**
  5300. * Computes a new Color4 converted from the current one to gamma space
  5301. * @returns a new Color4 object
  5302. */
  5303. toGammaSpace(): Color4;
  5304. /**
  5305. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5306. * @param convertedColor defines the Color4 object where to store the gamma space version
  5307. * @returns the unmodified Color4
  5308. */
  5309. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5310. /**
  5311. * Creates a new Color4 from the string containing valid hexadecimal values
  5312. * @param hex defines a string containing valid hexadecimal values
  5313. * @returns a new Color4 object
  5314. */
  5315. static FromHexString(hex: string): Color4;
  5316. /**
  5317. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5318. * @param left defines the start value
  5319. * @param right defines the end value
  5320. * @param amount defines the gradient factor
  5321. * @returns a new Color4 object
  5322. */
  5323. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5324. /**
  5325. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5326. * @param left defines the start value
  5327. * @param right defines the end value
  5328. * @param amount defines the gradient factor
  5329. * @param result defines the Color4 object where to store data
  5330. */
  5331. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5332. /**
  5333. * Creates a new Color4 from a Color3 and an alpha value
  5334. * @param color3 defines the source Color3 to read from
  5335. * @param alpha defines the alpha component (1.0 by default)
  5336. * @returns a new Color4 object
  5337. */
  5338. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5339. /**
  5340. * Creates a new Color4 from the starting index element of the given array
  5341. * @param array defines the source array to read from
  5342. * @param offset defines the offset in the source array
  5343. * @returns a new Color4 object
  5344. */
  5345. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5346. /**
  5347. * Creates a new Color3 from integer values (< 256)
  5348. * @param r defines the red component to read from (value between 0 and 255)
  5349. * @param g defines the green component to read from (value between 0 and 255)
  5350. * @param b defines the blue component to read from (value between 0 and 255)
  5351. * @param a defines the alpha component to read from (value between 0 and 255)
  5352. * @returns a new Color3 object
  5353. */
  5354. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5355. /**
  5356. * Check the content of a given array and convert it to an array containing RGBA data
  5357. * If the original array was already containing count * 4 values then it is returned directly
  5358. * @param colors defines the array to check
  5359. * @param count defines the number of RGBA data to expect
  5360. * @returns an array containing count * 4 values (RGBA)
  5361. */
  5362. static CheckColors4(colors: number[], count: number): number[];
  5363. }
  5364. /**
  5365. * @hidden
  5366. */
  5367. export class TmpColors {
  5368. static Color3: Color3[];
  5369. static Color4: Color4[];
  5370. }
  5371. }
  5372. declare module BABYLON {
  5373. /**
  5374. * Class representing spherical harmonics coefficients to the 3rd degree
  5375. */
  5376. export class SphericalHarmonics {
  5377. /**
  5378. * Defines whether or not the harmonics have been prescaled for rendering.
  5379. */
  5380. preScaled: boolean;
  5381. /**
  5382. * The l0,0 coefficients of the spherical harmonics
  5383. */
  5384. l00: Vector3;
  5385. /**
  5386. * The l1,-1 coefficients of the spherical harmonics
  5387. */
  5388. l1_1: Vector3;
  5389. /**
  5390. * The l1,0 coefficients of the spherical harmonics
  5391. */
  5392. l10: Vector3;
  5393. /**
  5394. * The l1,1 coefficients of the spherical harmonics
  5395. */
  5396. l11: Vector3;
  5397. /**
  5398. * The l2,-2 coefficients of the spherical harmonics
  5399. */
  5400. l2_2: Vector3;
  5401. /**
  5402. * The l2,-1 coefficients of the spherical harmonics
  5403. */
  5404. l2_1: Vector3;
  5405. /**
  5406. * The l2,0 coefficients of the spherical harmonics
  5407. */
  5408. l20: Vector3;
  5409. /**
  5410. * The l2,1 coefficients of the spherical harmonics
  5411. */
  5412. l21: Vector3;
  5413. /**
  5414. * The l2,2 coefficients of the spherical harmonics
  5415. */
  5416. l22: Vector3;
  5417. /**
  5418. * Adds a light to the spherical harmonics
  5419. * @param direction the direction of the light
  5420. * @param color the color of the light
  5421. * @param deltaSolidAngle the delta solid angle of the light
  5422. */
  5423. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5424. /**
  5425. * Scales the spherical harmonics by the given amount
  5426. * @param scale the amount to scale
  5427. */
  5428. scaleInPlace(scale: number): void;
  5429. /**
  5430. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5431. *
  5432. * ```
  5433. * E_lm = A_l * L_lm
  5434. * ```
  5435. *
  5436. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5437. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5438. * the scaling factors are given in equation 9.
  5439. */
  5440. convertIncidentRadianceToIrradiance(): void;
  5441. /**
  5442. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5443. *
  5444. * ```
  5445. * L = (1/pi) * E * rho
  5446. * ```
  5447. *
  5448. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5449. */
  5450. convertIrradianceToLambertianRadiance(): void;
  5451. /**
  5452. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5453. * required operations at run time.
  5454. *
  5455. * This is simply done by scaling back the SH with Ylm constants parameter.
  5456. * The trigonometric part being applied by the shader at run time.
  5457. */
  5458. preScaleForRendering(): void;
  5459. /**
  5460. * Constructs a spherical harmonics from an array.
  5461. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5462. * @returns the spherical harmonics
  5463. */
  5464. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5465. /**
  5466. * Gets the spherical harmonics from polynomial
  5467. * @param polynomial the spherical polynomial
  5468. * @returns the spherical harmonics
  5469. */
  5470. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5471. }
  5472. /**
  5473. * Class representing spherical polynomial coefficients to the 3rd degree
  5474. */
  5475. export class SphericalPolynomial {
  5476. private _harmonics;
  5477. /**
  5478. * The spherical harmonics used to create the polynomials.
  5479. */
  5480. readonly preScaledHarmonics: SphericalHarmonics;
  5481. /**
  5482. * The x coefficients of the spherical polynomial
  5483. */
  5484. x: Vector3;
  5485. /**
  5486. * The y coefficients of the spherical polynomial
  5487. */
  5488. y: Vector3;
  5489. /**
  5490. * The z coefficients of the spherical polynomial
  5491. */
  5492. z: Vector3;
  5493. /**
  5494. * The xx coefficients of the spherical polynomial
  5495. */
  5496. xx: Vector3;
  5497. /**
  5498. * The yy coefficients of the spherical polynomial
  5499. */
  5500. yy: Vector3;
  5501. /**
  5502. * The zz coefficients of the spherical polynomial
  5503. */
  5504. zz: Vector3;
  5505. /**
  5506. * The xy coefficients of the spherical polynomial
  5507. */
  5508. xy: Vector3;
  5509. /**
  5510. * The yz coefficients of the spherical polynomial
  5511. */
  5512. yz: Vector3;
  5513. /**
  5514. * The zx coefficients of the spherical polynomial
  5515. */
  5516. zx: Vector3;
  5517. /**
  5518. * Adds an ambient color to the spherical polynomial
  5519. * @param color the color to add
  5520. */
  5521. addAmbient(color: Color3): void;
  5522. /**
  5523. * Scales the spherical polynomial by the given amount
  5524. * @param scale the amount to scale
  5525. */
  5526. scaleInPlace(scale: number): void;
  5527. /**
  5528. * Gets the spherical polynomial from harmonics
  5529. * @param harmonics the spherical harmonics
  5530. * @returns the spherical polynomial
  5531. */
  5532. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5533. /**
  5534. * Constructs a spherical polynomial from an array.
  5535. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5536. * @returns the spherical polynomial
  5537. */
  5538. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5539. }
  5540. }
  5541. declare module BABYLON {
  5542. /**
  5543. * Define options used to create a render target texture
  5544. */
  5545. export class RenderTargetCreationOptions {
  5546. /**
  5547. * Specifies is mipmaps must be generated
  5548. */
  5549. generateMipMaps?: boolean;
  5550. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5551. generateDepthBuffer?: boolean;
  5552. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5553. generateStencilBuffer?: boolean;
  5554. /** Defines texture type (int by default) */
  5555. type?: number;
  5556. /** Defines sampling mode (trilinear by default) */
  5557. samplingMode?: number;
  5558. /** Defines format (RGBA by default) */
  5559. format?: number;
  5560. }
  5561. }
  5562. declare module BABYLON {
  5563. /**
  5564. * @hidden
  5565. **/
  5566. export class _AlphaState {
  5567. private _isAlphaBlendDirty;
  5568. private _isBlendFunctionParametersDirty;
  5569. private _isBlendEquationParametersDirty;
  5570. private _isBlendConstantsDirty;
  5571. private _alphaBlend;
  5572. private _blendFunctionParameters;
  5573. private _blendEquationParameters;
  5574. private _blendConstants;
  5575. /**
  5576. * Initializes the state.
  5577. */
  5578. constructor();
  5579. readonly isDirty: boolean;
  5580. alphaBlend: boolean;
  5581. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5582. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5583. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5584. reset(): void;
  5585. apply(gl: WebGLRenderingContext): void;
  5586. }
  5587. }
  5588. declare module BABYLON {
  5589. /**
  5590. * @hidden
  5591. **/
  5592. export class _DepthCullingState {
  5593. private _isDepthTestDirty;
  5594. private _isDepthMaskDirty;
  5595. private _isDepthFuncDirty;
  5596. private _isCullFaceDirty;
  5597. private _isCullDirty;
  5598. private _isZOffsetDirty;
  5599. private _isFrontFaceDirty;
  5600. private _depthTest;
  5601. private _depthMask;
  5602. private _depthFunc;
  5603. private _cull;
  5604. private _cullFace;
  5605. private _zOffset;
  5606. private _frontFace;
  5607. /**
  5608. * Initializes the state.
  5609. */
  5610. constructor();
  5611. readonly isDirty: boolean;
  5612. zOffset: number;
  5613. cullFace: Nullable<number>;
  5614. cull: Nullable<boolean>;
  5615. depthFunc: Nullable<number>;
  5616. depthMask: boolean;
  5617. depthTest: boolean;
  5618. frontFace: Nullable<number>;
  5619. reset(): void;
  5620. apply(gl: WebGLRenderingContext): void;
  5621. }
  5622. }
  5623. declare module BABYLON {
  5624. /**
  5625. * @hidden
  5626. **/
  5627. export class _StencilState {
  5628. /** 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 */
  5629. static readonly ALWAYS: number;
  5630. /** Passed to stencilOperation to specify that stencil value must be kept */
  5631. static readonly KEEP: number;
  5632. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5633. static readonly REPLACE: number;
  5634. private _isStencilTestDirty;
  5635. private _isStencilMaskDirty;
  5636. private _isStencilFuncDirty;
  5637. private _isStencilOpDirty;
  5638. private _stencilTest;
  5639. private _stencilMask;
  5640. private _stencilFunc;
  5641. private _stencilFuncRef;
  5642. private _stencilFuncMask;
  5643. private _stencilOpStencilFail;
  5644. private _stencilOpDepthFail;
  5645. private _stencilOpStencilDepthPass;
  5646. readonly isDirty: boolean;
  5647. stencilFunc: number;
  5648. stencilFuncRef: number;
  5649. stencilFuncMask: number;
  5650. stencilOpStencilFail: number;
  5651. stencilOpDepthFail: number;
  5652. stencilOpStencilDepthPass: number;
  5653. stencilMask: number;
  5654. stencilTest: boolean;
  5655. constructor();
  5656. reset(): void;
  5657. apply(gl: WebGLRenderingContext): void;
  5658. }
  5659. }
  5660. declare module BABYLON {
  5661. /**
  5662. * @hidden
  5663. **/
  5664. export class _TimeToken {
  5665. _startTimeQuery: Nullable<WebGLQuery>;
  5666. _endTimeQuery: Nullable<WebGLQuery>;
  5667. _timeElapsedQuery: Nullable<WebGLQuery>;
  5668. _timeElapsedQueryEnded: boolean;
  5669. }
  5670. }
  5671. declare module BABYLON {
  5672. /**
  5673. * Class used to evalaute queries containing `and` and `or` operators
  5674. */
  5675. export class AndOrNotEvaluator {
  5676. /**
  5677. * Evaluate a query
  5678. * @param query defines the query to evaluate
  5679. * @param evaluateCallback defines the callback used to filter result
  5680. * @returns true if the query matches
  5681. */
  5682. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5683. private static _HandleParenthesisContent;
  5684. private static _SimplifyNegation;
  5685. }
  5686. }
  5687. declare module BABYLON {
  5688. /**
  5689. * Class used to store custom tags
  5690. */
  5691. export class Tags {
  5692. /**
  5693. * Adds support for tags on the given object
  5694. * @param obj defines the object to use
  5695. */
  5696. static EnableFor(obj: any): void;
  5697. /**
  5698. * Removes tags support
  5699. * @param obj defines the object to use
  5700. */
  5701. static DisableFor(obj: any): void;
  5702. /**
  5703. * Gets a boolean indicating if the given object has tags
  5704. * @param obj defines the object to use
  5705. * @returns a boolean
  5706. */
  5707. static HasTags(obj: any): boolean;
  5708. /**
  5709. * Gets the tags available on a given object
  5710. * @param obj defines the object to use
  5711. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5712. * @returns the tags
  5713. */
  5714. static GetTags(obj: any, asString?: boolean): any;
  5715. /**
  5716. * Adds tags to an object
  5717. * @param obj defines the object to use
  5718. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5719. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5720. */
  5721. static AddTagsTo(obj: any, tagsString: string): void;
  5722. /**
  5723. * @hidden
  5724. */
  5725. static _AddTagTo(obj: any, tag: string): void;
  5726. /**
  5727. * Removes specific tags from a specific object
  5728. * @param obj defines the object to use
  5729. * @param tagsString defines the tags to remove
  5730. */
  5731. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5732. /**
  5733. * @hidden
  5734. */
  5735. static _RemoveTagFrom(obj: any, tag: string): void;
  5736. /**
  5737. * Defines if tags hosted on an object match a given query
  5738. * @param obj defines the object to use
  5739. * @param tagsQuery defines the tag query
  5740. * @returns a boolean
  5741. */
  5742. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5743. }
  5744. }
  5745. declare module BABYLON {
  5746. /**
  5747. * Defines potential orientation for back face culling
  5748. */
  5749. export enum Orientation {
  5750. /**
  5751. * Clockwise
  5752. */
  5753. CW = 0,
  5754. /** Counter clockwise */
  5755. CCW = 1
  5756. }
  5757. /** Class used to represent a Bezier curve */
  5758. export class BezierCurve {
  5759. /**
  5760. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5761. * @param t defines the time
  5762. * @param x1 defines the left coordinate on X axis
  5763. * @param y1 defines the left coordinate on Y axis
  5764. * @param x2 defines the right coordinate on X axis
  5765. * @param y2 defines the right coordinate on Y axis
  5766. * @returns the interpolated value
  5767. */
  5768. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5769. }
  5770. /**
  5771. * Defines angle representation
  5772. */
  5773. export class Angle {
  5774. private _radians;
  5775. /**
  5776. * Creates an Angle object of "radians" radians (float).
  5777. * @param radians the angle in radians
  5778. */
  5779. constructor(radians: number);
  5780. /**
  5781. * Get value in degrees
  5782. * @returns the Angle value in degrees (float)
  5783. */
  5784. degrees(): number;
  5785. /**
  5786. * Get value in radians
  5787. * @returns the Angle value in radians (float)
  5788. */
  5789. radians(): number;
  5790. /**
  5791. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5792. * @param a defines first vector
  5793. * @param b defines second vector
  5794. * @returns a new Angle
  5795. */
  5796. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5797. /**
  5798. * Gets a new Angle object from the given float in radians
  5799. * @param radians defines the angle value in radians
  5800. * @returns a new Angle
  5801. */
  5802. static FromRadians(radians: number): Angle;
  5803. /**
  5804. * Gets a new Angle object from the given float in degrees
  5805. * @param degrees defines the angle value in degrees
  5806. * @returns a new Angle
  5807. */
  5808. static FromDegrees(degrees: number): Angle;
  5809. }
  5810. /**
  5811. * This represents an arc in a 2d space.
  5812. */
  5813. export class Arc2 {
  5814. /** Defines the start point of the arc */
  5815. startPoint: Vector2;
  5816. /** Defines the mid point of the arc */
  5817. midPoint: Vector2;
  5818. /** Defines the end point of the arc */
  5819. endPoint: Vector2;
  5820. /**
  5821. * Defines the center point of the arc.
  5822. */
  5823. centerPoint: Vector2;
  5824. /**
  5825. * Defines the radius of the arc.
  5826. */
  5827. radius: number;
  5828. /**
  5829. * Defines the angle of the arc (from mid point to end point).
  5830. */
  5831. angle: Angle;
  5832. /**
  5833. * Defines the start angle of the arc (from start point to middle point).
  5834. */
  5835. startAngle: Angle;
  5836. /**
  5837. * Defines the orientation of the arc (clock wise/counter clock wise).
  5838. */
  5839. orientation: Orientation;
  5840. /**
  5841. * Creates an Arc object from the three given points : start, middle and end.
  5842. * @param startPoint Defines the start point of the arc
  5843. * @param midPoint Defines the midlle point of the arc
  5844. * @param endPoint Defines the end point of the arc
  5845. */
  5846. constructor(
  5847. /** Defines the start point of the arc */
  5848. startPoint: Vector2,
  5849. /** Defines the mid point of the arc */
  5850. midPoint: Vector2,
  5851. /** Defines the end point of the arc */
  5852. endPoint: Vector2);
  5853. }
  5854. /**
  5855. * Represents a 2D path made up of multiple 2D points
  5856. */
  5857. export class Path2 {
  5858. private _points;
  5859. private _length;
  5860. /**
  5861. * If the path start and end point are the same
  5862. */
  5863. closed: boolean;
  5864. /**
  5865. * Creates a Path2 object from the starting 2D coordinates x and y.
  5866. * @param x the starting points x value
  5867. * @param y the starting points y value
  5868. */
  5869. constructor(x: number, y: number);
  5870. /**
  5871. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5872. * @param x the added points x value
  5873. * @param y the added points y value
  5874. * @returns the updated Path2.
  5875. */
  5876. addLineTo(x: number, y: number): Path2;
  5877. /**
  5878. * 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.
  5879. * @param midX middle point x value
  5880. * @param midY middle point y value
  5881. * @param endX end point x value
  5882. * @param endY end point y value
  5883. * @param numberOfSegments (default: 36)
  5884. * @returns the updated Path2.
  5885. */
  5886. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5887. /**
  5888. * Closes the Path2.
  5889. * @returns the Path2.
  5890. */
  5891. close(): Path2;
  5892. /**
  5893. * Gets the sum of the distance between each sequential point in the path
  5894. * @returns the Path2 total length (float).
  5895. */
  5896. length(): number;
  5897. /**
  5898. * Gets the points which construct the path
  5899. * @returns the Path2 internal array of points.
  5900. */
  5901. getPoints(): Vector2[];
  5902. /**
  5903. * Retreives the point at the distance aways from the starting point
  5904. * @param normalizedLengthPosition the length along the path to retreive the point from
  5905. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5906. */
  5907. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5908. /**
  5909. * Creates a new path starting from an x and y position
  5910. * @param x starting x value
  5911. * @param y starting y value
  5912. * @returns a new Path2 starting at the coordinates (x, y).
  5913. */
  5914. static StartingAt(x: number, y: number): Path2;
  5915. }
  5916. /**
  5917. * Represents a 3D path made up of multiple 3D points
  5918. */
  5919. export class Path3D {
  5920. /**
  5921. * an array of Vector3, the curve axis of the Path3D
  5922. */
  5923. path: Vector3[];
  5924. private _curve;
  5925. private _distances;
  5926. private _tangents;
  5927. private _normals;
  5928. private _binormals;
  5929. private _raw;
  5930. /**
  5931. * new Path3D(path, normal, raw)
  5932. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5933. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5934. * @param path an array of Vector3, the curve axis of the Path3D
  5935. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5936. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5937. */
  5938. constructor(
  5939. /**
  5940. * an array of Vector3, the curve axis of the Path3D
  5941. */
  5942. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5943. /**
  5944. * Returns the Path3D array of successive Vector3 designing its curve.
  5945. * @returns the Path3D array of successive Vector3 designing its curve.
  5946. */
  5947. getCurve(): Vector3[];
  5948. /**
  5949. * Returns an array populated with tangent vectors on each Path3D curve point.
  5950. * @returns an array populated with tangent vectors on each Path3D curve point.
  5951. */
  5952. getTangents(): Vector3[];
  5953. /**
  5954. * Returns an array populated with normal vectors on each Path3D curve point.
  5955. * @returns an array populated with normal vectors on each Path3D curve point.
  5956. */
  5957. getNormals(): Vector3[];
  5958. /**
  5959. * Returns an array populated with binormal vectors on each Path3D curve point.
  5960. * @returns an array populated with binormal vectors on each Path3D curve point.
  5961. */
  5962. getBinormals(): Vector3[];
  5963. /**
  5964. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5965. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5966. */
  5967. getDistances(): number[];
  5968. /**
  5969. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5970. * @param path path which all values are copied into the curves points
  5971. * @param firstNormal which should be projected onto the curve
  5972. * @returns the same object updated.
  5973. */
  5974. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5975. private _compute;
  5976. private _getFirstNonNullVector;
  5977. private _getLastNonNullVector;
  5978. private _normalVector;
  5979. }
  5980. /**
  5981. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5982. * A Curve3 is designed from a series of successive Vector3.
  5983. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5984. */
  5985. export class Curve3 {
  5986. private _points;
  5987. private _length;
  5988. /**
  5989. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5990. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5991. * @param v1 (Vector3) the control point
  5992. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5993. * @param nbPoints (integer) the wanted number of points in the curve
  5994. * @returns the created Curve3
  5995. */
  5996. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5997. /**
  5998. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5999. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6000. * @param v1 (Vector3) the first control point
  6001. * @param v2 (Vector3) the second control point
  6002. * @param v3 (Vector3) the end point of the Cubic Bezier
  6003. * @param nbPoints (integer) the wanted number of points in the curve
  6004. * @returns the created Curve3
  6005. */
  6006. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6007. /**
  6008. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6009. * @param p1 (Vector3) the origin point of the Hermite Spline
  6010. * @param t1 (Vector3) the tangent vector at the origin point
  6011. * @param p2 (Vector3) the end point of the Hermite Spline
  6012. * @param t2 (Vector3) the tangent vector at the end point
  6013. * @param nbPoints (integer) the wanted number of points in the curve
  6014. * @returns the created Curve3
  6015. */
  6016. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6017. /**
  6018. * Returns a Curve3 object along a CatmullRom Spline curve :
  6019. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6020. * @param nbPoints (integer) the wanted number of points between each curve control points
  6021. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6022. * @returns the created Curve3
  6023. */
  6024. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6025. /**
  6026. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6027. * A Curve3 is designed from a series of successive Vector3.
  6028. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6029. * @param points points which make up the curve
  6030. */
  6031. constructor(points: Vector3[]);
  6032. /**
  6033. * @returns the Curve3 stored array of successive Vector3
  6034. */
  6035. getPoints(): Vector3[];
  6036. /**
  6037. * @returns the computed length (float) of the curve.
  6038. */
  6039. length(): number;
  6040. /**
  6041. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6042. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6043. * curveA and curveB keep unchanged.
  6044. * @param curve the curve to continue from this curve
  6045. * @returns the newly constructed curve
  6046. */
  6047. continue(curve: DeepImmutable<Curve3>): Curve3;
  6048. private _computeLength;
  6049. }
  6050. }
  6051. declare module BABYLON {
  6052. /**
  6053. * This represents the main contract an easing function should follow.
  6054. * Easing functions are used throughout the animation system.
  6055. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6056. */
  6057. export interface IEasingFunction {
  6058. /**
  6059. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6060. * of the easing function.
  6061. * The link below provides some of the most common examples of easing functions.
  6062. * @see https://easings.net/
  6063. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6064. * @returns the corresponding value on the curve defined by the easing function
  6065. */
  6066. ease(gradient: number): number;
  6067. }
  6068. /**
  6069. * Base class used for every default easing function.
  6070. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6071. */
  6072. export class EasingFunction implements IEasingFunction {
  6073. /**
  6074. * Interpolation follows the mathematical formula associated with the easing function.
  6075. */
  6076. static readonly EASINGMODE_EASEIN: number;
  6077. /**
  6078. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6079. */
  6080. static readonly EASINGMODE_EASEOUT: number;
  6081. /**
  6082. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6083. */
  6084. static readonly EASINGMODE_EASEINOUT: number;
  6085. private _easingMode;
  6086. /**
  6087. * Sets the easing mode of the current function.
  6088. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6089. */
  6090. setEasingMode(easingMode: number): void;
  6091. /**
  6092. * Gets the current easing mode.
  6093. * @returns the easing mode
  6094. */
  6095. getEasingMode(): number;
  6096. /**
  6097. * @hidden
  6098. */
  6099. easeInCore(gradient: number): number;
  6100. /**
  6101. * Given an input gradient between 0 and 1, this returns the corresponding value
  6102. * of the easing function.
  6103. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6104. * @returns the corresponding value on the curve defined by the easing function
  6105. */
  6106. ease(gradient: number): number;
  6107. }
  6108. /**
  6109. * Easing function with a circle shape (see link below).
  6110. * @see https://easings.net/#easeInCirc
  6111. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6112. */
  6113. export class CircleEase extends EasingFunction implements IEasingFunction {
  6114. /** @hidden */
  6115. easeInCore(gradient: number): number;
  6116. }
  6117. /**
  6118. * Easing function with a ease back shape (see link below).
  6119. * @see https://easings.net/#easeInBack
  6120. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6121. */
  6122. export class BackEase extends EasingFunction implements IEasingFunction {
  6123. /** Defines the amplitude of the function */
  6124. amplitude: number;
  6125. /**
  6126. * Instantiates a back ease easing
  6127. * @see https://easings.net/#easeInBack
  6128. * @param amplitude Defines the amplitude of the function
  6129. */
  6130. constructor(
  6131. /** Defines the amplitude of the function */
  6132. amplitude?: number);
  6133. /** @hidden */
  6134. easeInCore(gradient: number): number;
  6135. }
  6136. /**
  6137. * Easing function with a bouncing shape (see link below).
  6138. * @see https://easings.net/#easeInBounce
  6139. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6140. */
  6141. export class BounceEase extends EasingFunction implements IEasingFunction {
  6142. /** Defines the number of bounces */
  6143. bounces: number;
  6144. /** Defines the amplitude of the bounce */
  6145. bounciness: number;
  6146. /**
  6147. * Instantiates a bounce easing
  6148. * @see https://easings.net/#easeInBounce
  6149. * @param bounces Defines the number of bounces
  6150. * @param bounciness Defines the amplitude of the bounce
  6151. */
  6152. constructor(
  6153. /** Defines the number of bounces */
  6154. bounces?: number,
  6155. /** Defines the amplitude of the bounce */
  6156. bounciness?: number);
  6157. /** @hidden */
  6158. easeInCore(gradient: number): number;
  6159. }
  6160. /**
  6161. * Easing function with a power of 3 shape (see link below).
  6162. * @see https://easings.net/#easeInCubic
  6163. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6164. */
  6165. export class CubicEase extends EasingFunction implements IEasingFunction {
  6166. /** @hidden */
  6167. easeInCore(gradient: number): number;
  6168. }
  6169. /**
  6170. * Easing function with an elastic shape (see link below).
  6171. * @see https://easings.net/#easeInElastic
  6172. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6173. */
  6174. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6175. /** Defines the number of oscillations*/
  6176. oscillations: number;
  6177. /** Defines the amplitude of the oscillations*/
  6178. springiness: number;
  6179. /**
  6180. * Instantiates an elastic easing function
  6181. * @see https://easings.net/#easeInElastic
  6182. * @param oscillations Defines the number of oscillations
  6183. * @param springiness Defines the amplitude of the oscillations
  6184. */
  6185. constructor(
  6186. /** Defines the number of oscillations*/
  6187. oscillations?: number,
  6188. /** Defines the amplitude of the oscillations*/
  6189. springiness?: number);
  6190. /** @hidden */
  6191. easeInCore(gradient: number): number;
  6192. }
  6193. /**
  6194. * Easing function with an exponential shape (see link below).
  6195. * @see https://easings.net/#easeInExpo
  6196. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6197. */
  6198. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6199. /** Defines the exponent of the function */
  6200. exponent: number;
  6201. /**
  6202. * Instantiates an exponential easing function
  6203. * @see https://easings.net/#easeInExpo
  6204. * @param exponent Defines the exponent of the function
  6205. */
  6206. constructor(
  6207. /** Defines the exponent of the function */
  6208. exponent?: number);
  6209. /** @hidden */
  6210. easeInCore(gradient: number): number;
  6211. }
  6212. /**
  6213. * Easing function with a power shape (see link below).
  6214. * @see https://easings.net/#easeInQuad
  6215. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6216. */
  6217. export class PowerEase extends EasingFunction implements IEasingFunction {
  6218. /** Defines the power of the function */
  6219. power: number;
  6220. /**
  6221. * Instantiates an power base easing function
  6222. * @see https://easings.net/#easeInQuad
  6223. * @param power Defines the power of the function
  6224. */
  6225. constructor(
  6226. /** Defines the power of the function */
  6227. power?: number);
  6228. /** @hidden */
  6229. easeInCore(gradient: number): number;
  6230. }
  6231. /**
  6232. * Easing function with a power of 2 shape (see link below).
  6233. * @see https://easings.net/#easeInQuad
  6234. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6235. */
  6236. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6237. /** @hidden */
  6238. easeInCore(gradient: number): number;
  6239. }
  6240. /**
  6241. * Easing function with a power of 4 shape (see link below).
  6242. * @see https://easings.net/#easeInQuart
  6243. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6244. */
  6245. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6246. /** @hidden */
  6247. easeInCore(gradient: number): number;
  6248. }
  6249. /**
  6250. * Easing function with a power of 5 shape (see link below).
  6251. * @see https://easings.net/#easeInQuint
  6252. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6253. */
  6254. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6255. /** @hidden */
  6256. easeInCore(gradient: number): number;
  6257. }
  6258. /**
  6259. * Easing function with a sin shape (see link below).
  6260. * @see https://easings.net/#easeInSine
  6261. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6262. */
  6263. export class SineEase extends EasingFunction implements IEasingFunction {
  6264. /** @hidden */
  6265. easeInCore(gradient: number): number;
  6266. }
  6267. /**
  6268. * Easing function with a bezier shape (see link below).
  6269. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6270. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6271. */
  6272. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6273. /** Defines the x component of the start tangent in the bezier curve */
  6274. x1: number;
  6275. /** Defines the y component of the start tangent in the bezier curve */
  6276. y1: number;
  6277. /** Defines the x component of the end tangent in the bezier curve */
  6278. x2: number;
  6279. /** Defines the y component of the end tangent in the bezier curve */
  6280. y2: number;
  6281. /**
  6282. * Instantiates a bezier function
  6283. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6284. * @param x1 Defines the x component of the start tangent in the bezier curve
  6285. * @param y1 Defines the y component of the start tangent in the bezier curve
  6286. * @param x2 Defines the x component of the end tangent in the bezier curve
  6287. * @param y2 Defines the y component of the end tangent in the bezier curve
  6288. */
  6289. constructor(
  6290. /** Defines the x component of the start tangent in the bezier curve */
  6291. x1?: number,
  6292. /** Defines the y component of the start tangent in the bezier curve */
  6293. y1?: number,
  6294. /** Defines the x component of the end tangent in the bezier curve */
  6295. x2?: number,
  6296. /** Defines the y component of the end tangent in the bezier curve */
  6297. y2?: number);
  6298. /** @hidden */
  6299. easeInCore(gradient: number): number;
  6300. }
  6301. }
  6302. declare module BABYLON {
  6303. /**
  6304. * Defines an interface which represents an animation key frame
  6305. */
  6306. export interface IAnimationKey {
  6307. /**
  6308. * Frame of the key frame
  6309. */
  6310. frame: number;
  6311. /**
  6312. * Value at the specifies key frame
  6313. */
  6314. value: any;
  6315. /**
  6316. * The input tangent for the cubic hermite spline
  6317. */
  6318. inTangent?: any;
  6319. /**
  6320. * The output tangent for the cubic hermite spline
  6321. */
  6322. outTangent?: any;
  6323. /**
  6324. * The animation interpolation type
  6325. */
  6326. interpolation?: AnimationKeyInterpolation;
  6327. }
  6328. /**
  6329. * Enum for the animation key frame interpolation type
  6330. */
  6331. export enum AnimationKeyInterpolation {
  6332. /**
  6333. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6334. */
  6335. STEP = 1
  6336. }
  6337. }
  6338. declare module BABYLON {
  6339. /**
  6340. * Represents the range of an animation
  6341. */
  6342. export class AnimationRange {
  6343. /**The name of the animation range**/
  6344. name: string;
  6345. /**The starting frame of the animation */
  6346. from: number;
  6347. /**The ending frame of the animation*/
  6348. to: number;
  6349. /**
  6350. * Initializes the range of an animation
  6351. * @param name The name of the animation range
  6352. * @param from The starting frame of the animation
  6353. * @param to The ending frame of the animation
  6354. */
  6355. constructor(
  6356. /**The name of the animation range**/
  6357. name: string,
  6358. /**The starting frame of the animation */
  6359. from: number,
  6360. /**The ending frame of the animation*/
  6361. to: number);
  6362. /**
  6363. * Makes a copy of the animation range
  6364. * @returns A copy of the animation range
  6365. */
  6366. clone(): AnimationRange;
  6367. }
  6368. }
  6369. declare module BABYLON {
  6370. /**
  6371. * Composed of a frame, and an action function
  6372. */
  6373. export class AnimationEvent {
  6374. /** The frame for which the event is triggered **/
  6375. frame: number;
  6376. /** The event to perform when triggered **/
  6377. action: (currentFrame: number) => void;
  6378. /** Specifies if the event should be triggered only once**/
  6379. onlyOnce?: boolean | undefined;
  6380. /**
  6381. * Specifies if the animation event is done
  6382. */
  6383. isDone: boolean;
  6384. /**
  6385. * Initializes the animation event
  6386. * @param frame The frame for which the event is triggered
  6387. * @param action The event to perform when triggered
  6388. * @param onlyOnce Specifies if the event should be triggered only once
  6389. */
  6390. constructor(
  6391. /** The frame for which the event is triggered **/
  6392. frame: number,
  6393. /** The event to perform when triggered **/
  6394. action: (currentFrame: number) => void,
  6395. /** Specifies if the event should be triggered only once**/
  6396. onlyOnce?: boolean | undefined);
  6397. /** @hidden */
  6398. _clone(): AnimationEvent;
  6399. }
  6400. }
  6401. declare module BABYLON {
  6402. /**
  6403. * Interface used to define a behavior
  6404. */
  6405. export interface Behavior<T> {
  6406. /** gets or sets behavior's name */
  6407. name: string;
  6408. /**
  6409. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6410. */
  6411. init(): void;
  6412. /**
  6413. * Called when the behavior is attached to a target
  6414. * @param target defines the target where the behavior is attached to
  6415. */
  6416. attach(target: T): void;
  6417. /**
  6418. * Called when the behavior is detached from its target
  6419. */
  6420. detach(): void;
  6421. }
  6422. /**
  6423. * Interface implemented by classes supporting behaviors
  6424. */
  6425. export interface IBehaviorAware<T> {
  6426. /**
  6427. * Attach a behavior
  6428. * @param behavior defines the behavior to attach
  6429. * @returns the current host
  6430. */
  6431. addBehavior(behavior: Behavior<T>): T;
  6432. /**
  6433. * Remove a behavior from the current object
  6434. * @param behavior defines the behavior to detach
  6435. * @returns the current host
  6436. */
  6437. removeBehavior(behavior: Behavior<T>): T;
  6438. /**
  6439. * Gets a behavior using its name to search
  6440. * @param name defines the name to search
  6441. * @returns the behavior or null if not found
  6442. */
  6443. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6444. }
  6445. }
  6446. declare module BABYLON {
  6447. /**
  6448. * Defines an array and its length.
  6449. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6450. */
  6451. export interface ISmartArrayLike<T> {
  6452. /**
  6453. * The data of the array.
  6454. */
  6455. data: Array<T>;
  6456. /**
  6457. * The active length of the array.
  6458. */
  6459. length: number;
  6460. }
  6461. /**
  6462. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6463. */
  6464. export class SmartArray<T> implements ISmartArrayLike<T> {
  6465. /**
  6466. * The full set of data from the array.
  6467. */
  6468. data: Array<T>;
  6469. /**
  6470. * The active length of the array.
  6471. */
  6472. length: number;
  6473. protected _id: number;
  6474. /**
  6475. * Instantiates a Smart Array.
  6476. * @param capacity defines the default capacity of the array.
  6477. */
  6478. constructor(capacity: number);
  6479. /**
  6480. * Pushes a value at the end of the active data.
  6481. * @param value defines the object to push in the array.
  6482. */
  6483. push(value: T): void;
  6484. /**
  6485. * Iterates over the active data and apply the lambda to them.
  6486. * @param func defines the action to apply on each value.
  6487. */
  6488. forEach(func: (content: T) => void): void;
  6489. /**
  6490. * Sorts the full sets of data.
  6491. * @param compareFn defines the comparison function to apply.
  6492. */
  6493. sort(compareFn: (a: T, b: T) => number): void;
  6494. /**
  6495. * Resets the active data to an empty array.
  6496. */
  6497. reset(): void;
  6498. /**
  6499. * Releases all the data from the array as well as the array.
  6500. */
  6501. dispose(): void;
  6502. /**
  6503. * Concats the active data with a given array.
  6504. * @param array defines the data to concatenate with.
  6505. */
  6506. concat(array: any): void;
  6507. /**
  6508. * Returns the position of a value in the active data.
  6509. * @param value defines the value to find the index for
  6510. * @returns the index if found in the active data otherwise -1
  6511. */
  6512. indexOf(value: T): number;
  6513. /**
  6514. * Returns whether an element is part of the active data.
  6515. * @param value defines the value to look for
  6516. * @returns true if found in the active data otherwise false
  6517. */
  6518. contains(value: T): boolean;
  6519. private static _GlobalId;
  6520. }
  6521. /**
  6522. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6523. * The data in this array can only be present once
  6524. */
  6525. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6526. private _duplicateId;
  6527. /**
  6528. * Pushes a value at the end of the active data.
  6529. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6530. * @param value defines the object to push in the array.
  6531. */
  6532. push(value: T): void;
  6533. /**
  6534. * Pushes a value at the end of the active data.
  6535. * If the data is already present, it won t be added again
  6536. * @param value defines the object to push in the array.
  6537. * @returns true if added false if it was already present
  6538. */
  6539. pushNoDuplicate(value: T): boolean;
  6540. /**
  6541. * Resets the active data to an empty array.
  6542. */
  6543. reset(): void;
  6544. /**
  6545. * Concats the active data with a given array.
  6546. * This ensures no dupplicate will be present in the result.
  6547. * @param array defines the data to concatenate with.
  6548. */
  6549. concatWithNoDuplicate(array: any): void;
  6550. }
  6551. }
  6552. declare module BABYLON {
  6553. /**
  6554. * @ignore
  6555. * This is a list of all the different input types that are available in the application.
  6556. * Fo instance: ArcRotateCameraGamepadInput...
  6557. */
  6558. export var CameraInputTypes: {};
  6559. /**
  6560. * This is the contract to implement in order to create a new input class.
  6561. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6562. */
  6563. export interface ICameraInput<TCamera extends Camera> {
  6564. /**
  6565. * Defines the camera the input is attached to.
  6566. */
  6567. camera: Nullable<TCamera>;
  6568. /**
  6569. * Gets the class name of the current intput.
  6570. * @returns the class name
  6571. */
  6572. getClassName(): string;
  6573. /**
  6574. * Get the friendly name associated with the input class.
  6575. * @returns the input friendly name
  6576. */
  6577. getSimpleName(): string;
  6578. /**
  6579. * Attach the input controls to a specific dom element to get the input from.
  6580. * @param element Defines the element the controls should be listened from
  6581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6582. */
  6583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6584. /**
  6585. * Detach the current controls from the specified dom element.
  6586. * @param element Defines the element to stop listening the inputs from
  6587. */
  6588. detachControl(element: Nullable<HTMLElement>): void;
  6589. /**
  6590. * Update the current camera state depending on the inputs that have been used this frame.
  6591. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6592. */
  6593. checkInputs?: () => void;
  6594. }
  6595. /**
  6596. * Represents a map of input types to input instance or input index to input instance.
  6597. */
  6598. export interface CameraInputsMap<TCamera extends Camera> {
  6599. /**
  6600. * Accessor to the input by input type.
  6601. */
  6602. [name: string]: ICameraInput<TCamera>;
  6603. /**
  6604. * Accessor to the input by input index.
  6605. */
  6606. [idx: number]: ICameraInput<TCamera>;
  6607. }
  6608. /**
  6609. * This represents the input manager used within a camera.
  6610. * It helps dealing with all the different kind of input attached to a camera.
  6611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6612. */
  6613. export class CameraInputsManager<TCamera extends Camera> {
  6614. /**
  6615. * Defines the list of inputs attahed to the camera.
  6616. */
  6617. attached: CameraInputsMap<TCamera>;
  6618. /**
  6619. * Defines the dom element the camera is collecting inputs from.
  6620. * This is null if the controls have not been attached.
  6621. */
  6622. attachedElement: Nullable<HTMLElement>;
  6623. /**
  6624. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6625. */
  6626. noPreventDefault: boolean;
  6627. /**
  6628. * Defined the camera the input manager belongs to.
  6629. */
  6630. camera: TCamera;
  6631. /**
  6632. * Update the current camera state depending on the inputs that have been used this frame.
  6633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6634. */
  6635. checkInputs: () => void;
  6636. /**
  6637. * Instantiate a new Camera Input Manager.
  6638. * @param camera Defines the camera the input manager blongs to
  6639. */
  6640. constructor(camera: TCamera);
  6641. /**
  6642. * Add an input method to a camera
  6643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6644. * @param input camera input method
  6645. */
  6646. add(input: ICameraInput<TCamera>): void;
  6647. /**
  6648. * Remove a specific input method from a camera
  6649. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6650. * @param inputToRemove camera input method
  6651. */
  6652. remove(inputToRemove: ICameraInput<TCamera>): void;
  6653. /**
  6654. * Remove a specific input type from a camera
  6655. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6656. * @param inputType the type of the input to remove
  6657. */
  6658. removeByType(inputType: string): void;
  6659. private _addCheckInputs;
  6660. /**
  6661. * Attach the input controls to the currently attached dom element to listen the events from.
  6662. * @param input Defines the input to attach
  6663. */
  6664. attachInput(input: ICameraInput<TCamera>): void;
  6665. /**
  6666. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6667. * @param element Defines the dom element to collect the events from
  6668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6669. */
  6670. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6671. /**
  6672. * Detach the current manager inputs controls from a specific dom element.
  6673. * @param element Defines the dom element to collect the events from
  6674. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6675. */
  6676. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6677. /**
  6678. * Rebuild the dynamic inputCheck function from the current list of
  6679. * defined inputs in the manager.
  6680. */
  6681. rebuildInputCheck(): void;
  6682. /**
  6683. * Remove all attached input methods from a camera
  6684. */
  6685. clear(): void;
  6686. /**
  6687. * Serialize the current input manager attached to a camera.
  6688. * This ensures than once parsed,
  6689. * the input associated to the camera will be identical to the current ones
  6690. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6691. */
  6692. serialize(serializedCamera: any): void;
  6693. /**
  6694. * Parses an input manager serialized JSON to restore the previous list of inputs
  6695. * and states associated to a camera.
  6696. * @param parsedCamera Defines the JSON to parse
  6697. */
  6698. parse(parsedCamera: any): void;
  6699. }
  6700. }
  6701. declare module BABYLON {
  6702. /**
  6703. * @hidden
  6704. */
  6705. export class IntersectionInfo {
  6706. bu: Nullable<number>;
  6707. bv: Nullable<number>;
  6708. distance: number;
  6709. faceId: number;
  6710. subMeshId: number;
  6711. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6712. }
  6713. }
  6714. declare module BABYLON {
  6715. /**
  6716. * Represens a plane by the equation ax + by + cz + d = 0
  6717. */
  6718. export class Plane {
  6719. private static _TmpMatrix;
  6720. /**
  6721. * Normal of the plane (a,b,c)
  6722. */
  6723. normal: Vector3;
  6724. /**
  6725. * d component of the plane
  6726. */
  6727. d: number;
  6728. /**
  6729. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6730. * @param a a component of the plane
  6731. * @param b b component of the plane
  6732. * @param c c component of the plane
  6733. * @param d d component of the plane
  6734. */
  6735. constructor(a: number, b: number, c: number, d: number);
  6736. /**
  6737. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6738. */
  6739. asArray(): number[];
  6740. /**
  6741. * @returns a new plane copied from the current Plane.
  6742. */
  6743. clone(): Plane;
  6744. /**
  6745. * @returns the string "Plane".
  6746. */
  6747. getClassName(): string;
  6748. /**
  6749. * @returns the Plane hash code.
  6750. */
  6751. getHashCode(): number;
  6752. /**
  6753. * Normalize the current Plane in place.
  6754. * @returns the updated Plane.
  6755. */
  6756. normalize(): Plane;
  6757. /**
  6758. * Applies a transformation the plane and returns the result
  6759. * @param transformation the transformation matrix to be applied to the plane
  6760. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6761. */
  6762. transform(transformation: DeepImmutable<Matrix>): Plane;
  6763. /**
  6764. * Calcualtte the dot product between the point and the plane normal
  6765. * @param point point to calculate the dot product with
  6766. * @returns the dot product (float) of the point coordinates and the plane normal.
  6767. */
  6768. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6769. /**
  6770. * Updates the current Plane from the plane defined by the three given points.
  6771. * @param point1 one of the points used to contruct the plane
  6772. * @param point2 one of the points used to contruct the plane
  6773. * @param point3 one of the points used to contruct the plane
  6774. * @returns the updated Plane.
  6775. */
  6776. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6777. /**
  6778. * Checks if the plane is facing a given direction
  6779. * @param direction the direction to check if the plane is facing
  6780. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6781. * @returns True is the vector "direction" is the same side than the plane normal.
  6782. */
  6783. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6784. /**
  6785. * Calculates the distance to a point
  6786. * @param point point to calculate distance to
  6787. * @returns the signed distance (float) from the given point to the Plane.
  6788. */
  6789. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6790. /**
  6791. * Creates a plane from an array
  6792. * @param array the array to create a plane from
  6793. * @returns a new Plane from the given array.
  6794. */
  6795. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6796. /**
  6797. * Creates a plane from three points
  6798. * @param point1 point used to create the plane
  6799. * @param point2 point used to create the plane
  6800. * @param point3 point used to create the plane
  6801. * @returns a new Plane defined by the three given points.
  6802. */
  6803. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6804. /**
  6805. * Creates a plane from an origin point and a normal
  6806. * @param origin origin of the plane to be constructed
  6807. * @param normal normal of the plane to be constructed
  6808. * @returns a new Plane the normal vector to this plane at the given origin point.
  6809. * Note : the vector "normal" is updated because normalized.
  6810. */
  6811. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6812. /**
  6813. * Calculates the distance from a plane and a point
  6814. * @param origin origin of the plane to be constructed
  6815. * @param normal normal of the plane to be constructed
  6816. * @param point point to calculate distance to
  6817. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6818. */
  6819. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6820. }
  6821. }
  6822. declare module BABYLON {
  6823. /**
  6824. * Class used to store bounding sphere information
  6825. */
  6826. export class BoundingSphere {
  6827. /**
  6828. * Gets the center of the bounding sphere in local space
  6829. */
  6830. readonly center: Vector3;
  6831. /**
  6832. * Radius of the bounding sphere in local space
  6833. */
  6834. radius: number;
  6835. /**
  6836. * Gets the center of the bounding sphere in world space
  6837. */
  6838. readonly centerWorld: Vector3;
  6839. /**
  6840. * Radius of the bounding sphere in world space
  6841. */
  6842. radiusWorld: number;
  6843. /**
  6844. * Gets the minimum vector in local space
  6845. */
  6846. readonly minimum: Vector3;
  6847. /**
  6848. * Gets the maximum vector in local space
  6849. */
  6850. readonly maximum: Vector3;
  6851. private _worldMatrix;
  6852. private static readonly TmpVector3;
  6853. /**
  6854. * Creates a new bounding sphere
  6855. * @param min defines the minimum vector (in local space)
  6856. * @param max defines the maximum vector (in local space)
  6857. * @param worldMatrix defines the new world matrix
  6858. */
  6859. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6860. /**
  6861. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6862. * @param min defines the new minimum vector (in local space)
  6863. * @param max defines the new maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6867. /**
  6868. * Scale the current bounding sphere by applying a scale factor
  6869. * @param factor defines the scale factor to apply
  6870. * @returns the current bounding box
  6871. */
  6872. scale(factor: number): BoundingSphere;
  6873. /**
  6874. * Gets the world matrix of the bounding box
  6875. * @returns a matrix
  6876. */
  6877. getWorldMatrix(): DeepImmutable<Matrix>;
  6878. /** @hidden */
  6879. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6880. /**
  6881. * Tests if the bounding sphere is intersecting the frustum planes
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if the bounding sphere center is in between the frustum planes.
  6888. * Used for optimistic fast inclusion.
  6889. * @param frustumPlanes defines the frustum planes to test
  6890. * @returns true if the sphere center is in between the frustum planes
  6891. */
  6892. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6893. /**
  6894. * Tests if a point is inside the bounding sphere
  6895. * @param point defines the point to test
  6896. * @returns true if the point is inside the bounding sphere
  6897. */
  6898. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6899. /**
  6900. * Checks if two sphere intersct
  6901. * @param sphere0 sphere 0
  6902. * @param sphere1 sphere 1
  6903. * @returns true if the speres intersect
  6904. */
  6905. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6906. }
  6907. }
  6908. declare module BABYLON {
  6909. /**
  6910. * Class used to store bounding box information
  6911. */
  6912. export class BoundingBox implements ICullable {
  6913. /**
  6914. * Gets the 8 vectors representing the bounding box in local space
  6915. */
  6916. readonly vectors: Vector3[];
  6917. /**
  6918. * Gets the center of the bounding box in local space
  6919. */
  6920. readonly center: Vector3;
  6921. /**
  6922. * Gets the center of the bounding box in world space
  6923. */
  6924. readonly centerWorld: Vector3;
  6925. /**
  6926. * Gets the extend size in local space
  6927. */
  6928. readonly extendSize: Vector3;
  6929. /**
  6930. * Gets the extend size in world space
  6931. */
  6932. readonly extendSizeWorld: Vector3;
  6933. /**
  6934. * Gets the OBB (object bounding box) directions
  6935. */
  6936. readonly directions: Vector3[];
  6937. /**
  6938. * Gets the 8 vectors representing the bounding box in world space
  6939. */
  6940. readonly vectorsWorld: Vector3[];
  6941. /**
  6942. * Gets the minimum vector in world space
  6943. */
  6944. readonly minimumWorld: Vector3;
  6945. /**
  6946. * Gets the maximum vector in world space
  6947. */
  6948. readonly maximumWorld: Vector3;
  6949. /**
  6950. * Gets the minimum vector in local space
  6951. */
  6952. readonly minimum: Vector3;
  6953. /**
  6954. * Gets the maximum vector in local space
  6955. */
  6956. readonly maximum: Vector3;
  6957. private _worldMatrix;
  6958. private static readonly TmpVector3;
  6959. /**
  6960. * @hidden
  6961. */
  6962. _tag: number;
  6963. /**
  6964. * Creates a new bounding box
  6965. * @param min defines the minimum vector (in local space)
  6966. * @param max defines the maximum vector (in local space)
  6967. * @param worldMatrix defines the new world matrix
  6968. */
  6969. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6970. /**
  6971. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6972. * @param min defines the new minimum vector (in local space)
  6973. * @param max defines the new maximum vector (in local space)
  6974. * @param worldMatrix defines the new world matrix
  6975. */
  6976. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6977. /**
  6978. * Scale the current bounding box by applying a scale factor
  6979. * @param factor defines the scale factor to apply
  6980. * @returns the current bounding box
  6981. */
  6982. scale(factor: number): BoundingBox;
  6983. /**
  6984. * Gets the world matrix of the bounding box
  6985. * @returns a matrix
  6986. */
  6987. getWorldMatrix(): DeepImmutable<Matrix>;
  6988. /** @hidden */
  6989. _update(world: DeepImmutable<Matrix>): void;
  6990. /**
  6991. * Tests if the bounding box is intersecting the frustum planes
  6992. * @param frustumPlanes defines the frustum planes to test
  6993. * @returns true if there is an intersection
  6994. */
  6995. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6996. /**
  6997. * Tests if the bounding box is entirely inside the frustum planes
  6998. * @param frustumPlanes defines the frustum planes to test
  6999. * @returns true if there is an inclusion
  7000. */
  7001. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7002. /**
  7003. * Tests if a point is inside the bounding box
  7004. * @param point defines the point to test
  7005. * @returns true if the point is inside the bounding box
  7006. */
  7007. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7008. /**
  7009. * Tests if the bounding box intersects with a bounding sphere
  7010. * @param sphere defines the sphere to test
  7011. * @returns true if there is an intersection
  7012. */
  7013. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7014. /**
  7015. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7016. * @param min defines the min vector to use
  7017. * @param max defines the max vector to use
  7018. * @returns true if there is an intersection
  7019. */
  7020. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7021. /**
  7022. * Tests if two bounding boxes are intersections
  7023. * @param box0 defines the first box to test
  7024. * @param box1 defines the second box to test
  7025. * @returns true if there is an intersection
  7026. */
  7027. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7028. /**
  7029. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7030. * @param minPoint defines the minimum vector of the bounding box
  7031. * @param maxPoint defines the maximum vector of the bounding box
  7032. * @param sphereCenter defines the sphere center
  7033. * @param sphereRadius defines the sphere radius
  7034. * @returns true if there is an intersection
  7035. */
  7036. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7037. /**
  7038. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7039. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7040. * @param frustumPlanes defines the frustum planes to test
  7041. * @return true if there is an inclusion
  7042. */
  7043. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7044. /**
  7045. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7046. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7047. * @param frustumPlanes defines the frustum planes to test
  7048. * @return true if there is an intersection
  7049. */
  7050. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7051. }
  7052. }
  7053. declare module BABYLON {
  7054. /** @hidden */
  7055. export class Collider {
  7056. /** Define if a collision was found */
  7057. collisionFound: boolean;
  7058. /**
  7059. * Define last intersection point in local space
  7060. */
  7061. intersectionPoint: Vector3;
  7062. /**
  7063. * Define last collided mesh
  7064. */
  7065. collidedMesh: Nullable<AbstractMesh>;
  7066. private _collisionPoint;
  7067. private _planeIntersectionPoint;
  7068. private _tempVector;
  7069. private _tempVector2;
  7070. private _tempVector3;
  7071. private _tempVector4;
  7072. private _edge;
  7073. private _baseToVertex;
  7074. private _destinationPoint;
  7075. private _slidePlaneNormal;
  7076. private _displacementVector;
  7077. /** @hidden */
  7078. _radius: Vector3;
  7079. /** @hidden */
  7080. _retry: number;
  7081. private _velocity;
  7082. private _basePoint;
  7083. private _epsilon;
  7084. /** @hidden */
  7085. _velocityWorldLength: number;
  7086. /** @hidden */
  7087. _basePointWorld: Vector3;
  7088. private _velocityWorld;
  7089. private _normalizedVelocity;
  7090. /** @hidden */
  7091. _initialVelocity: Vector3;
  7092. /** @hidden */
  7093. _initialPosition: Vector3;
  7094. private _nearestDistance;
  7095. private _collisionMask;
  7096. collisionMask: number;
  7097. /**
  7098. * Gets the plane normal used to compute the sliding response (in local space)
  7099. */
  7100. readonly slidePlaneNormal: Vector3;
  7101. /** @hidden */
  7102. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7103. /** @hidden */
  7104. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7105. /** @hidden */
  7106. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7107. /** @hidden */
  7108. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7109. /** @hidden */
  7110. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7111. /** @hidden */
  7112. _getResponse(pos: Vector3, vel: Vector3): void;
  7113. }
  7114. }
  7115. declare module BABYLON {
  7116. /**
  7117. * Interface for cullable objects
  7118. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7119. */
  7120. export interface ICullable {
  7121. /**
  7122. * Checks if the object or part of the object is in the frustum
  7123. * @param frustumPlanes Camera near/planes
  7124. * @returns true if the object is in frustum otherwise false
  7125. */
  7126. isInFrustum(frustumPlanes: Plane[]): boolean;
  7127. /**
  7128. * Checks if a cullable object (mesh...) is in the camera frustum
  7129. * Unlike isInFrustum this cheks the full bounding box
  7130. * @param frustumPlanes Camera near/planes
  7131. * @returns true if the object is in frustum otherwise false
  7132. */
  7133. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7134. }
  7135. /**
  7136. * Info for a bounding data of a mesh
  7137. */
  7138. export class BoundingInfo implements ICullable {
  7139. /**
  7140. * Bounding box for the mesh
  7141. */
  7142. readonly boundingBox: BoundingBox;
  7143. /**
  7144. * Bounding sphere for the mesh
  7145. */
  7146. readonly boundingSphere: BoundingSphere;
  7147. private _isLocked;
  7148. private static readonly TmpVector3;
  7149. /**
  7150. * Constructs bounding info
  7151. * @param minimum min vector of the bounding box/sphere
  7152. * @param maximum max vector of the bounding box/sphere
  7153. * @param worldMatrix defines the new world matrix
  7154. */
  7155. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7156. /**
  7157. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7158. * @param min defines the new minimum vector (in local space)
  7159. * @param max defines the new maximum vector (in local space)
  7160. * @param worldMatrix defines the new world matrix
  7161. */
  7162. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7163. /**
  7164. * min vector of the bounding box/sphere
  7165. */
  7166. readonly minimum: Vector3;
  7167. /**
  7168. * max vector of the bounding box/sphere
  7169. */
  7170. readonly maximum: Vector3;
  7171. /**
  7172. * If the info is locked and won't be updated to avoid perf overhead
  7173. */
  7174. isLocked: boolean;
  7175. /**
  7176. * Updates the bounding sphere and box
  7177. * @param world world matrix to be used to update
  7178. */
  7179. update(world: DeepImmutable<Matrix>): void;
  7180. /**
  7181. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7182. * @param center New center of the bounding info
  7183. * @param extend New extend of the bounding info
  7184. * @returns the current bounding info
  7185. */
  7186. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7187. /**
  7188. * Scale the current bounding info by applying a scale factor
  7189. * @param factor defines the scale factor to apply
  7190. * @returns the current bounding info
  7191. */
  7192. scale(factor: number): BoundingInfo;
  7193. /**
  7194. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7195. * @param frustumPlanes defines the frustum to test
  7196. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7197. * @returns true if the bounding info is in the frustum planes
  7198. */
  7199. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7200. /**
  7201. * Gets the world distance between the min and max points of the bounding box
  7202. */
  7203. readonly diagonalLength: number;
  7204. /**
  7205. * Checks if a cullable object (mesh...) is in the camera frustum
  7206. * Unlike isInFrustum this cheks the full bounding box
  7207. * @param frustumPlanes Camera near/planes
  7208. * @returns true if the object is in frustum otherwise false
  7209. */
  7210. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7211. /** @hidden */
  7212. _checkCollision(collider: Collider): boolean;
  7213. /**
  7214. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7215. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7216. * @param point the point to check intersection with
  7217. * @returns if the point intersects
  7218. */
  7219. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7220. /**
  7221. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7222. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7223. * @param boundingInfo the bounding info to check intersection with
  7224. * @param precise if the intersection should be done using OBB
  7225. * @returns if the bounding info intersects
  7226. */
  7227. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7228. }
  7229. }
  7230. declare module BABYLON {
  7231. /**
  7232. * Extracts minimum and maximum values from a list of indexed positions
  7233. * @param positions defines the positions to use
  7234. * @param indices defines the indices to the positions
  7235. * @param indexStart defines the start index
  7236. * @param indexCount defines the end index
  7237. * @param bias defines bias value to add to the result
  7238. * @return minimum and maximum values
  7239. */
  7240. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7241. minimum: Vector3;
  7242. maximum: Vector3;
  7243. };
  7244. /**
  7245. * Extracts minimum and maximum values from a list of positions
  7246. * @param positions defines the positions to use
  7247. * @param start defines the start index in the positions array
  7248. * @param count defines the number of positions to handle
  7249. * @param bias defines bias value to add to the result
  7250. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7251. * @return minimum and maximum values
  7252. */
  7253. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7254. minimum: Vector3;
  7255. maximum: Vector3;
  7256. };
  7257. }
  7258. declare module BABYLON {
  7259. /**
  7260. * Enum that determines the text-wrapping mode to use.
  7261. */
  7262. export enum InspectableType {
  7263. /**
  7264. * Checkbox for booleans
  7265. */
  7266. Checkbox = 0,
  7267. /**
  7268. * Sliders for numbers
  7269. */
  7270. Slider = 1,
  7271. /**
  7272. * Vector3
  7273. */
  7274. Vector3 = 2,
  7275. /**
  7276. * Quaternions
  7277. */
  7278. Quaternion = 3,
  7279. /**
  7280. * Color3
  7281. */
  7282. Color3 = 4,
  7283. /**
  7284. * String
  7285. */
  7286. String = 5
  7287. }
  7288. /**
  7289. * Interface used to define custom inspectable properties.
  7290. * This interface is used by the inspector to display custom property grids
  7291. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7292. */
  7293. export interface IInspectable {
  7294. /**
  7295. * Gets the label to display
  7296. */
  7297. label: string;
  7298. /**
  7299. * Gets the name of the property to edit
  7300. */
  7301. propertyName: string;
  7302. /**
  7303. * Gets the type of the editor to use
  7304. */
  7305. type: InspectableType;
  7306. /**
  7307. * Gets the minimum value of the property when using in "slider" mode
  7308. */
  7309. min?: number;
  7310. /**
  7311. * Gets the maximum value of the property when using in "slider" mode
  7312. */
  7313. max?: number;
  7314. /**
  7315. * Gets the setp to use when using in "slider" mode
  7316. */
  7317. step?: number;
  7318. }
  7319. }
  7320. declare module BABYLON {
  7321. /**
  7322. * Class used to provide helper for timing
  7323. */
  7324. export class TimingTools {
  7325. /**
  7326. * Polyfill for setImmediate
  7327. * @param action defines the action to execute after the current execution block
  7328. */
  7329. static SetImmediate(action: () => void): void;
  7330. }
  7331. }
  7332. declare module BABYLON {
  7333. /**
  7334. * Class used to enable instatition of objects by class name
  7335. */
  7336. export class InstantiationTools {
  7337. /**
  7338. * Use this object to register external classes like custom textures or material
  7339. * to allow the laoders to instantiate them
  7340. */
  7341. static RegisteredExternalClasses: {
  7342. [key: string]: Object;
  7343. };
  7344. /**
  7345. * Tries to instantiate a new object from a given class name
  7346. * @param className defines the class name to instantiate
  7347. * @returns the new object or null if the system was not able to do the instantiation
  7348. */
  7349. static Instantiate(className: string): any;
  7350. }
  7351. }
  7352. declare module BABYLON {
  7353. /**
  7354. * This represents the required contract to create a new type of texture loader.
  7355. */
  7356. export interface IInternalTextureLoader {
  7357. /**
  7358. * Defines wether the loader supports cascade loading the different faces.
  7359. */
  7360. supportCascades: boolean;
  7361. /**
  7362. * This returns if the loader support the current file information.
  7363. * @param extension defines the file extension of the file being loaded
  7364. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7365. * @param fallback defines the fallback internal texture if any
  7366. * @param isBase64 defines whether the texture is encoded as a base64
  7367. * @param isBuffer defines whether the texture data are stored as a buffer
  7368. * @returns true if the loader can load the specified file
  7369. */
  7370. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7371. /**
  7372. * Transform the url before loading if required.
  7373. * @param rootUrl the url of the texture
  7374. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7375. * @returns the transformed texture
  7376. */
  7377. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7378. /**
  7379. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7380. * @param rootUrl the url of the texture
  7381. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7382. * @returns the fallback texture
  7383. */
  7384. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7385. /**
  7386. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7387. * @param data contains the texture data
  7388. * @param texture defines the BabylonJS internal texture
  7389. * @param createPolynomials will be true if polynomials have been requested
  7390. * @param onLoad defines the callback to trigger once the texture is ready
  7391. * @param onError defines the callback to trigger in case of error
  7392. */
  7393. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7394. /**
  7395. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7396. * @param data contains the texture data
  7397. * @param texture defines the BabylonJS internal texture
  7398. * @param callback defines the method to call once ready to upload
  7399. */
  7400. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7401. }
  7402. }
  7403. declare module BABYLON {
  7404. interface Engine {
  7405. /**
  7406. * Creates a depth stencil cube texture.
  7407. * This is only available in WebGL 2.
  7408. * @param size The size of face edge in the cube texture.
  7409. * @param options The options defining the cube texture.
  7410. * @returns The cube texture
  7411. */
  7412. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7413. /**
  7414. * Creates a cube texture
  7415. * @param rootUrl defines the url where the files to load is located
  7416. * @param scene defines the current scene
  7417. * @param files defines the list of files to load (1 per face)
  7418. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7419. * @param onLoad defines an optional callback raised when the texture is loaded
  7420. * @param onError defines an optional callback raised if there is an issue to load the texture
  7421. * @param format defines the format of the data
  7422. * @param forcedExtension defines the extension to use to pick the right loader
  7423. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7424. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7425. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7426. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7427. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7428. * @returns the cube texture as an InternalTexture
  7429. */
  7430. 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;
  7431. /**
  7432. * Creates a cube texture
  7433. * @param rootUrl defines the url where the files to load is located
  7434. * @param scene defines the current scene
  7435. * @param files defines the list of files to load (1 per face)
  7436. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7437. * @param onLoad defines an optional callback raised when the texture is loaded
  7438. * @param onError defines an optional callback raised if there is an issue to load the texture
  7439. * @param format defines the format of the data
  7440. * @param forcedExtension defines the extension to use to pick the right loader
  7441. * @returns the cube texture as an InternalTexture
  7442. */
  7443. 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;
  7444. /**
  7445. * Creates a cube texture
  7446. * @param rootUrl defines the url where the files to load is located
  7447. * @param scene defines the current scene
  7448. * @param files defines the list of files to load (1 per face)
  7449. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7450. * @param onLoad defines an optional callback raised when the texture is loaded
  7451. * @param onError defines an optional callback raised if there is an issue to load the texture
  7452. * @param format defines the format of the data
  7453. * @param forcedExtension defines the extension to use to pick the right loader
  7454. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7455. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7456. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7457. * @returns the cube texture as an InternalTexture
  7458. */
  7459. 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;
  7460. /** @hidden */
  7461. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7462. /** @hidden */
  7463. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7464. /** @hidden */
  7465. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7466. /** @hidden */
  7467. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7468. }
  7469. }
  7470. declare module BABYLON {
  7471. /**
  7472. * Class for creating a cube texture
  7473. */
  7474. export class CubeTexture extends BaseTexture {
  7475. private _delayedOnLoad;
  7476. /**
  7477. * The url of the texture
  7478. */
  7479. url: string;
  7480. /**
  7481. * Gets or sets the center of the bounding box associated with the cube texture.
  7482. * It must define where the camera used to render the texture was set
  7483. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7484. */
  7485. boundingBoxPosition: Vector3;
  7486. private _boundingBoxSize;
  7487. /**
  7488. * Gets or sets the size of the bounding box associated with the cube texture
  7489. * When defined, the cubemap will switch to local mode
  7490. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7491. * @example https://www.babylonjs-playground.com/#RNASML
  7492. */
  7493. /**
  7494. * Returns the bounding box size
  7495. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7496. */
  7497. boundingBoxSize: Vector3;
  7498. protected _rotationY: number;
  7499. /**
  7500. * Sets texture matrix rotation angle around Y axis in radians.
  7501. */
  7502. /**
  7503. * Gets texture matrix rotation angle around Y axis radians.
  7504. */
  7505. rotationY: number;
  7506. /**
  7507. * Are mip maps generated for this texture or not.
  7508. */
  7509. readonly noMipmap: boolean;
  7510. private _noMipmap;
  7511. private _files;
  7512. private _extensions;
  7513. private _textureMatrix;
  7514. private _format;
  7515. private _createPolynomials;
  7516. /** @hidden */
  7517. _prefiltered: boolean;
  7518. /**
  7519. * Creates a cube texture from an array of image urls
  7520. * @param files defines an array of image urls
  7521. * @param scene defines the hosting scene
  7522. * @param noMipmap specifies if mip maps are not used
  7523. * @returns a cube texture
  7524. */
  7525. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7526. /**
  7527. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7528. * @param url defines the url of the prefiltered texture
  7529. * @param scene defines the scene the texture is attached to
  7530. * @param forcedExtension defines the extension of the file if different from the url
  7531. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7532. * @return the prefiltered texture
  7533. */
  7534. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7535. /**
  7536. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7537. * as prefiltered data.
  7538. * @param rootUrl defines the url of the texture or the root name of the six images
  7539. * @param scene defines the scene the texture is attached to
  7540. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7541. * @param noMipmap defines if mipmaps should be created or not
  7542. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7543. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7544. * @param onError defines a callback triggered in case of error during load
  7545. * @param format defines the internal format to use for the texture once loaded
  7546. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7547. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7548. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7549. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7550. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7551. * @return the cube texture
  7552. */
  7553. 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);
  7554. /**
  7555. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7556. */
  7557. readonly isPrefiltered: boolean;
  7558. /**
  7559. * Get the current class name of the texture useful for serialization or dynamic coding.
  7560. * @returns "CubeTexture"
  7561. */
  7562. getClassName(): string;
  7563. /**
  7564. * Update the url (and optional buffer) of this texture if url was null during construction.
  7565. * @param url the url of the texture
  7566. * @param forcedExtension defines the extension to use
  7567. * @param onLoad callback called when the texture is loaded (defaults to null)
  7568. */
  7569. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7570. /**
  7571. * Delays loading of the cube texture
  7572. * @param forcedExtension defines the extension to use
  7573. */
  7574. delayLoad(forcedExtension?: string): void;
  7575. /**
  7576. * Returns the reflection texture matrix
  7577. * @returns the reflection texture matrix
  7578. */
  7579. getReflectionTextureMatrix(): Matrix;
  7580. /**
  7581. * Sets the reflection texture matrix
  7582. * @param value Reflection texture matrix
  7583. */
  7584. setReflectionTextureMatrix(value: Matrix): void;
  7585. /**
  7586. * Parses text to create a cube texture
  7587. * @param parsedTexture define the serialized text to read from
  7588. * @param scene defines the hosting scene
  7589. * @param rootUrl defines the root url of the cube texture
  7590. * @returns a cube texture
  7591. */
  7592. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7593. /**
  7594. * Makes a clone, or deep copy, of the cube texture
  7595. * @returns a new cube texture
  7596. */
  7597. clone(): CubeTexture;
  7598. }
  7599. }
  7600. declare module BABYLON {
  7601. /**
  7602. * Manages the defines for the Material
  7603. */
  7604. export class MaterialDefines {
  7605. /** @hidden */
  7606. protected _keys: string[];
  7607. private _isDirty;
  7608. /** @hidden */
  7609. _renderId: number;
  7610. /** @hidden */
  7611. _areLightsDirty: boolean;
  7612. /** @hidden */
  7613. _areAttributesDirty: boolean;
  7614. /** @hidden */
  7615. _areTexturesDirty: boolean;
  7616. /** @hidden */
  7617. _areFresnelDirty: boolean;
  7618. /** @hidden */
  7619. _areMiscDirty: boolean;
  7620. /** @hidden */
  7621. _areImageProcessingDirty: boolean;
  7622. /** @hidden */
  7623. _normals: boolean;
  7624. /** @hidden */
  7625. _uvs: boolean;
  7626. /** @hidden */
  7627. _needNormals: boolean;
  7628. /** @hidden */
  7629. _needUVs: boolean;
  7630. [id: string]: any;
  7631. /**
  7632. * Specifies if the material needs to be re-calculated
  7633. */
  7634. readonly isDirty: boolean;
  7635. /**
  7636. * Marks the material to indicate that it has been re-calculated
  7637. */
  7638. markAsProcessed(): void;
  7639. /**
  7640. * Marks the material to indicate that it needs to be re-calculated
  7641. */
  7642. markAsUnprocessed(): void;
  7643. /**
  7644. * Marks the material to indicate all of its defines need to be re-calculated
  7645. */
  7646. markAllAsDirty(): void;
  7647. /**
  7648. * Marks the material to indicate that image processing needs to be re-calculated
  7649. */
  7650. markAsImageProcessingDirty(): void;
  7651. /**
  7652. * Marks the material to indicate the lights need to be re-calculated
  7653. */
  7654. markAsLightDirty(): void;
  7655. /**
  7656. * Marks the attribute state as changed
  7657. */
  7658. markAsAttributesDirty(): void;
  7659. /**
  7660. * Marks the texture state as changed
  7661. */
  7662. markAsTexturesDirty(): void;
  7663. /**
  7664. * Marks the fresnel state as changed
  7665. */
  7666. markAsFresnelDirty(): void;
  7667. /**
  7668. * Marks the misc state as changed
  7669. */
  7670. markAsMiscDirty(): void;
  7671. /**
  7672. * Rebuilds the material defines
  7673. */
  7674. rebuild(): void;
  7675. /**
  7676. * Specifies if two material defines are equal
  7677. * @param other - A material define instance to compare to
  7678. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7679. */
  7680. isEqual(other: MaterialDefines): boolean;
  7681. /**
  7682. * Clones this instance's defines to another instance
  7683. * @param other - material defines to clone values to
  7684. */
  7685. cloneTo(other: MaterialDefines): void;
  7686. /**
  7687. * Resets the material define values
  7688. */
  7689. reset(): void;
  7690. /**
  7691. * Converts the material define values to a string
  7692. * @returns - String of material define information
  7693. */
  7694. toString(): string;
  7695. }
  7696. }
  7697. declare module BABYLON {
  7698. /**
  7699. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7700. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7701. * 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;
  7702. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7703. */
  7704. export class ColorCurves {
  7705. private _dirty;
  7706. private _tempColor;
  7707. private _globalCurve;
  7708. private _highlightsCurve;
  7709. private _midtonesCurve;
  7710. private _shadowsCurve;
  7711. private _positiveCurve;
  7712. private _negativeCurve;
  7713. private _globalHue;
  7714. private _globalDensity;
  7715. private _globalSaturation;
  7716. private _globalExposure;
  7717. /**
  7718. * Gets the global Hue value.
  7719. * 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).
  7720. */
  7721. /**
  7722. * Sets the global Hue value.
  7723. * 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).
  7724. */
  7725. globalHue: number;
  7726. /**
  7727. * Gets the global Density value.
  7728. * 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.
  7729. * Values less than zero provide a filter of opposite hue.
  7730. */
  7731. /**
  7732. * Sets the global Density value.
  7733. * 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.
  7734. * Values less than zero provide a filter of opposite hue.
  7735. */
  7736. globalDensity: number;
  7737. /**
  7738. * Gets the global Saturation value.
  7739. * 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.
  7740. */
  7741. /**
  7742. * Sets the global Saturation value.
  7743. * 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.
  7744. */
  7745. globalSaturation: number;
  7746. /**
  7747. * Gets the global Exposure value.
  7748. * 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.
  7749. */
  7750. /**
  7751. * Sets the global Exposure value.
  7752. * 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.
  7753. */
  7754. globalExposure: number;
  7755. private _highlightsHue;
  7756. private _highlightsDensity;
  7757. private _highlightsSaturation;
  7758. private _highlightsExposure;
  7759. /**
  7760. * Gets the highlights Hue value.
  7761. * 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).
  7762. */
  7763. /**
  7764. * Sets the highlights Hue value.
  7765. * 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).
  7766. */
  7767. highlightsHue: number;
  7768. /**
  7769. * Gets the highlights Density value.
  7770. * 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.
  7771. * Values less than zero provide a filter of opposite hue.
  7772. */
  7773. /**
  7774. * Sets the highlights Density value.
  7775. * 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.
  7776. * Values less than zero provide a filter of opposite hue.
  7777. */
  7778. highlightsDensity: number;
  7779. /**
  7780. * Gets the highlights Saturation value.
  7781. * 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.
  7782. */
  7783. /**
  7784. * Sets the highlights Saturation value.
  7785. * 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.
  7786. */
  7787. highlightsSaturation: number;
  7788. /**
  7789. * Gets the highlights Exposure value.
  7790. * 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.
  7791. */
  7792. /**
  7793. * Sets the highlights Exposure value.
  7794. * 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.
  7795. */
  7796. highlightsExposure: number;
  7797. private _midtonesHue;
  7798. private _midtonesDensity;
  7799. private _midtonesSaturation;
  7800. private _midtonesExposure;
  7801. /**
  7802. * Gets the midtones Hue value.
  7803. * 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).
  7804. */
  7805. /**
  7806. * Sets the midtones Hue value.
  7807. * 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).
  7808. */
  7809. midtonesHue: number;
  7810. /**
  7811. * Gets the midtones Density value.
  7812. * 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.
  7813. * Values less than zero provide a filter of opposite hue.
  7814. */
  7815. /**
  7816. * Sets the midtones Density value.
  7817. * 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.
  7818. * Values less than zero provide a filter of opposite hue.
  7819. */
  7820. midtonesDensity: number;
  7821. /**
  7822. * Gets the midtones Saturation value.
  7823. * 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.
  7824. */
  7825. /**
  7826. * Sets the midtones Saturation value.
  7827. * 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.
  7828. */
  7829. midtonesSaturation: number;
  7830. /**
  7831. * Gets the midtones Exposure value.
  7832. * 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.
  7833. */
  7834. /**
  7835. * Sets the midtones Exposure value.
  7836. * 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.
  7837. */
  7838. midtonesExposure: number;
  7839. private _shadowsHue;
  7840. private _shadowsDensity;
  7841. private _shadowsSaturation;
  7842. private _shadowsExposure;
  7843. /**
  7844. * Gets the shadows Hue value.
  7845. * 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).
  7846. */
  7847. /**
  7848. * Sets the shadows Hue value.
  7849. * 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).
  7850. */
  7851. shadowsHue: number;
  7852. /**
  7853. * Gets the shadows Density value.
  7854. * 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.
  7855. * Values less than zero provide a filter of opposite hue.
  7856. */
  7857. /**
  7858. * Sets the shadows Density value.
  7859. * 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.
  7860. * Values less than zero provide a filter of opposite hue.
  7861. */
  7862. shadowsDensity: number;
  7863. /**
  7864. * Gets the shadows Saturation value.
  7865. * 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.
  7866. */
  7867. /**
  7868. * Sets the shadows Saturation value.
  7869. * 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.
  7870. */
  7871. shadowsSaturation: number;
  7872. /**
  7873. * Gets the shadows Exposure value.
  7874. * 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.
  7875. */
  7876. /**
  7877. * Sets the shadows Exposure value.
  7878. * 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.
  7879. */
  7880. shadowsExposure: number;
  7881. /**
  7882. * Returns the class name
  7883. * @returns The class name
  7884. */
  7885. getClassName(): string;
  7886. /**
  7887. * Binds the color curves to the shader.
  7888. * @param colorCurves The color curve to bind
  7889. * @param effect The effect to bind to
  7890. * @param positiveUniform The positive uniform shader parameter
  7891. * @param neutralUniform The neutral uniform shader parameter
  7892. * @param negativeUniform The negative uniform shader parameter
  7893. */
  7894. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7895. /**
  7896. * Prepare the list of uniforms associated with the ColorCurves effects.
  7897. * @param uniformsList The list of uniforms used in the effect
  7898. */
  7899. static PrepareUniforms(uniformsList: string[]): void;
  7900. /**
  7901. * Returns color grading data based on a hue, density, saturation and exposure value.
  7902. * @param filterHue The hue of the color filter.
  7903. * @param filterDensity The density of the color filter.
  7904. * @param saturation The saturation.
  7905. * @param exposure The exposure.
  7906. * @param result The result data container.
  7907. */
  7908. private getColorGradingDataToRef;
  7909. /**
  7910. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7911. * @param value The input slider value in range [-100,100].
  7912. * @returns Adjusted value.
  7913. */
  7914. private static applyColorGradingSliderNonlinear;
  7915. /**
  7916. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7917. * @param hue The hue (H) input.
  7918. * @param saturation The saturation (S) input.
  7919. * @param brightness The brightness (B) input.
  7920. * @result An RGBA color represented as Vector4.
  7921. */
  7922. private static fromHSBToRef;
  7923. /**
  7924. * Returns a value clamped between min and max
  7925. * @param value The value to clamp
  7926. * @param min The minimum of value
  7927. * @param max The maximum of value
  7928. * @returns The clamped value.
  7929. */
  7930. private static clamp;
  7931. /**
  7932. * Clones the current color curve instance.
  7933. * @return The cloned curves
  7934. */
  7935. clone(): ColorCurves;
  7936. /**
  7937. * Serializes the current color curve instance to a json representation.
  7938. * @return a JSON representation
  7939. */
  7940. serialize(): any;
  7941. /**
  7942. * Parses the color curve from a json representation.
  7943. * @param source the JSON source to parse
  7944. * @return The parsed curves
  7945. */
  7946. static Parse(source: any): ColorCurves;
  7947. }
  7948. }
  7949. declare module BABYLON {
  7950. /**
  7951. * Interface to follow in your material defines to integrate easily the
  7952. * Image proccessing functions.
  7953. * @hidden
  7954. */
  7955. export interface IImageProcessingConfigurationDefines {
  7956. IMAGEPROCESSING: boolean;
  7957. VIGNETTE: boolean;
  7958. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7959. VIGNETTEBLENDMODEOPAQUE: boolean;
  7960. TONEMAPPING: boolean;
  7961. TONEMAPPING_ACES: boolean;
  7962. CONTRAST: boolean;
  7963. EXPOSURE: boolean;
  7964. COLORCURVES: boolean;
  7965. COLORGRADING: boolean;
  7966. COLORGRADING3D: boolean;
  7967. SAMPLER3DGREENDEPTH: boolean;
  7968. SAMPLER3DBGRMAP: boolean;
  7969. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7970. }
  7971. /**
  7972. * @hidden
  7973. */
  7974. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7975. IMAGEPROCESSING: boolean;
  7976. VIGNETTE: boolean;
  7977. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7978. VIGNETTEBLENDMODEOPAQUE: boolean;
  7979. TONEMAPPING: boolean;
  7980. TONEMAPPING_ACES: boolean;
  7981. CONTRAST: boolean;
  7982. COLORCURVES: boolean;
  7983. COLORGRADING: boolean;
  7984. COLORGRADING3D: boolean;
  7985. SAMPLER3DGREENDEPTH: boolean;
  7986. SAMPLER3DBGRMAP: boolean;
  7987. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7988. EXPOSURE: boolean;
  7989. constructor();
  7990. }
  7991. /**
  7992. * This groups together the common properties used for image processing either in direct forward pass
  7993. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7994. * or not.
  7995. */
  7996. export class ImageProcessingConfiguration {
  7997. /**
  7998. * Default tone mapping applied in BabylonJS.
  7999. */
  8000. static readonly TONEMAPPING_STANDARD: number;
  8001. /**
  8002. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8003. * to other engines rendering to increase portability.
  8004. */
  8005. static readonly TONEMAPPING_ACES: number;
  8006. /**
  8007. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8008. */
  8009. colorCurves: Nullable<ColorCurves>;
  8010. private _colorCurvesEnabled;
  8011. /**
  8012. * Gets wether the color curves effect is enabled.
  8013. */
  8014. /**
  8015. * Sets wether the color curves effect is enabled.
  8016. */
  8017. colorCurvesEnabled: boolean;
  8018. private _colorGradingTexture;
  8019. /**
  8020. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8021. */
  8022. /**
  8023. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8024. */
  8025. colorGradingTexture: Nullable<BaseTexture>;
  8026. private _colorGradingEnabled;
  8027. /**
  8028. * Gets wether the color grading effect is enabled.
  8029. */
  8030. /**
  8031. * Sets wether the color grading effect is enabled.
  8032. */
  8033. colorGradingEnabled: boolean;
  8034. private _colorGradingWithGreenDepth;
  8035. /**
  8036. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8037. */
  8038. /**
  8039. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8040. */
  8041. colorGradingWithGreenDepth: boolean;
  8042. private _colorGradingBGR;
  8043. /**
  8044. * Gets wether the color grading texture contains BGR values.
  8045. */
  8046. /**
  8047. * Sets wether the color grading texture contains BGR values.
  8048. */
  8049. colorGradingBGR: boolean;
  8050. /** @hidden */
  8051. _exposure: number;
  8052. /**
  8053. * Gets the Exposure used in the effect.
  8054. */
  8055. /**
  8056. * Sets the Exposure used in the effect.
  8057. */
  8058. exposure: number;
  8059. private _toneMappingEnabled;
  8060. /**
  8061. * Gets wether the tone mapping effect is enabled.
  8062. */
  8063. /**
  8064. * Sets wether the tone mapping effect is enabled.
  8065. */
  8066. toneMappingEnabled: boolean;
  8067. private _toneMappingType;
  8068. /**
  8069. * Gets the type of tone mapping effect.
  8070. */
  8071. /**
  8072. * Sets the type of tone mapping effect used in BabylonJS.
  8073. */
  8074. toneMappingType: number;
  8075. protected _contrast: number;
  8076. /**
  8077. * Gets the contrast used in the effect.
  8078. */
  8079. /**
  8080. * Sets the contrast used in the effect.
  8081. */
  8082. contrast: number;
  8083. /**
  8084. * Vignette stretch size.
  8085. */
  8086. vignetteStretch: number;
  8087. /**
  8088. * Vignette centre X Offset.
  8089. */
  8090. vignetteCentreX: number;
  8091. /**
  8092. * Vignette centre Y Offset.
  8093. */
  8094. vignetteCentreY: number;
  8095. /**
  8096. * Vignette weight or intensity of the vignette effect.
  8097. */
  8098. vignetteWeight: number;
  8099. /**
  8100. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8101. * if vignetteEnabled is set to true.
  8102. */
  8103. vignetteColor: Color4;
  8104. /**
  8105. * Camera field of view used by the Vignette effect.
  8106. */
  8107. vignetteCameraFov: number;
  8108. private _vignetteBlendMode;
  8109. /**
  8110. * Gets the vignette blend mode allowing different kind of effect.
  8111. */
  8112. /**
  8113. * Sets the vignette blend mode allowing different kind of effect.
  8114. */
  8115. vignetteBlendMode: number;
  8116. private _vignetteEnabled;
  8117. /**
  8118. * Gets wether the vignette effect is enabled.
  8119. */
  8120. /**
  8121. * Sets wether the vignette effect is enabled.
  8122. */
  8123. vignetteEnabled: boolean;
  8124. private _applyByPostProcess;
  8125. /**
  8126. * Gets wether the image processing is applied through a post process or not.
  8127. */
  8128. /**
  8129. * Sets wether the image processing is applied through a post process or not.
  8130. */
  8131. applyByPostProcess: boolean;
  8132. private _isEnabled;
  8133. /**
  8134. * Gets wether the image processing is enabled or not.
  8135. */
  8136. /**
  8137. * Sets wether the image processing is enabled or not.
  8138. */
  8139. isEnabled: boolean;
  8140. /**
  8141. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8142. */
  8143. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8144. /**
  8145. * Method called each time the image processing information changes requires to recompile the effect.
  8146. */
  8147. protected _updateParameters(): void;
  8148. /**
  8149. * Gets the current class name.
  8150. * @return "ImageProcessingConfiguration"
  8151. */
  8152. getClassName(): string;
  8153. /**
  8154. * Prepare the list of uniforms associated with the Image Processing effects.
  8155. * @param uniforms The list of uniforms used in the effect
  8156. * @param defines the list of defines currently in use
  8157. */
  8158. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8159. /**
  8160. * Prepare the list of samplers associated with the Image Processing effects.
  8161. * @param samplersList The list of uniforms used in the effect
  8162. * @param defines the list of defines currently in use
  8163. */
  8164. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8165. /**
  8166. * Prepare the list of defines associated to the shader.
  8167. * @param defines the list of defines to complete
  8168. * @param forPostProcess Define if we are currently in post process mode or not
  8169. */
  8170. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8171. /**
  8172. * Returns true if all the image processing information are ready.
  8173. * @returns True if ready, otherwise, false
  8174. */
  8175. isReady(): boolean;
  8176. /**
  8177. * Binds the image processing to the shader.
  8178. * @param effect The effect to bind to
  8179. * @param aspectRatio Define the current aspect ratio of the effect
  8180. */
  8181. bind(effect: Effect, aspectRatio?: number): void;
  8182. /**
  8183. * Clones the current image processing instance.
  8184. * @return The cloned image processing
  8185. */
  8186. clone(): ImageProcessingConfiguration;
  8187. /**
  8188. * Serializes the current image processing instance to a json representation.
  8189. * @return a JSON representation
  8190. */
  8191. serialize(): any;
  8192. /**
  8193. * Parses the image processing from a json representation.
  8194. * @param source the JSON source to parse
  8195. * @return The parsed image processing
  8196. */
  8197. static Parse(source: any): ImageProcessingConfiguration;
  8198. private static _VIGNETTEMODE_MULTIPLY;
  8199. private static _VIGNETTEMODE_OPAQUE;
  8200. /**
  8201. * Used to apply the vignette as a mix with the pixel color.
  8202. */
  8203. static readonly VIGNETTEMODE_MULTIPLY: number;
  8204. /**
  8205. * Used to apply the vignette as a replacement of the pixel color.
  8206. */
  8207. static readonly VIGNETTEMODE_OPAQUE: number;
  8208. }
  8209. }
  8210. declare module BABYLON {
  8211. /** @hidden */
  8212. export var postprocessVertexShader: {
  8213. name: string;
  8214. shader: string;
  8215. };
  8216. }
  8217. declare module BABYLON {
  8218. /** Defines supported spaces */
  8219. export enum Space {
  8220. /** Local (object) space */
  8221. LOCAL = 0,
  8222. /** World space */
  8223. WORLD = 1,
  8224. /** Bone space */
  8225. BONE = 2
  8226. }
  8227. /** Defines the 3 main axes */
  8228. export class Axis {
  8229. /** X axis */
  8230. static X: Vector3;
  8231. /** Y axis */
  8232. static Y: Vector3;
  8233. /** Z axis */
  8234. static Z: Vector3;
  8235. }
  8236. }
  8237. declare module BABYLON {
  8238. /**
  8239. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8240. * This is the base of the follow, arc rotate cameras and Free camera
  8241. * @see http://doc.babylonjs.com/features/cameras
  8242. */
  8243. export class TargetCamera extends Camera {
  8244. private static _RigCamTransformMatrix;
  8245. private static _TargetTransformMatrix;
  8246. private static _TargetFocalPoint;
  8247. /**
  8248. * Define the current direction the camera is moving to
  8249. */
  8250. cameraDirection: Vector3;
  8251. /**
  8252. * Define the current rotation the camera is rotating to
  8253. */
  8254. cameraRotation: Vector2;
  8255. /**
  8256. * When set, the up vector of the camera will be updated by the rotation of the camera
  8257. */
  8258. updateUpVectorFromRotation: boolean;
  8259. private _tmpQuaternion;
  8260. /**
  8261. * Define the current rotation of the camera
  8262. */
  8263. rotation: Vector3;
  8264. /**
  8265. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8266. */
  8267. rotationQuaternion: Quaternion;
  8268. /**
  8269. * Define the current speed of the camera
  8270. */
  8271. speed: number;
  8272. /**
  8273. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8274. * around all axis.
  8275. */
  8276. noRotationConstraint: boolean;
  8277. /**
  8278. * Define the current target of the camera as an object or a position.
  8279. */
  8280. lockedTarget: any;
  8281. /** @hidden */
  8282. _currentTarget: Vector3;
  8283. /** @hidden */
  8284. _initialFocalDistance: number;
  8285. /** @hidden */
  8286. _viewMatrix: Matrix;
  8287. /** @hidden */
  8288. _camMatrix: Matrix;
  8289. /** @hidden */
  8290. _cameraTransformMatrix: Matrix;
  8291. /** @hidden */
  8292. _cameraRotationMatrix: Matrix;
  8293. /** @hidden */
  8294. _referencePoint: Vector3;
  8295. /** @hidden */
  8296. _transformedReferencePoint: Vector3;
  8297. protected _globalCurrentTarget: Vector3;
  8298. protected _globalCurrentUpVector: Vector3;
  8299. /** @hidden */
  8300. _reset: () => void;
  8301. private _defaultUp;
  8302. /**
  8303. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8304. * This is the base of the follow, arc rotate cameras and Free camera
  8305. * @see http://doc.babylonjs.com/features/cameras
  8306. * @param name Defines the name of the camera in the scene
  8307. * @param position Defines the start position of the camera in the scene
  8308. * @param scene Defines the scene the camera belongs to
  8309. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8310. */
  8311. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8312. /**
  8313. * Gets the position in front of the camera at a given distance.
  8314. * @param distance The distance from the camera we want the position to be
  8315. * @returns the position
  8316. */
  8317. getFrontPosition(distance: number): Vector3;
  8318. /** @hidden */
  8319. _getLockedTargetPosition(): Nullable<Vector3>;
  8320. private _storedPosition;
  8321. private _storedRotation;
  8322. private _storedRotationQuaternion;
  8323. /**
  8324. * Store current camera state of the camera (fov, position, rotation, etc..)
  8325. * @returns the camera
  8326. */
  8327. storeState(): Camera;
  8328. /**
  8329. * Restored camera state. You must call storeState() first
  8330. * @returns whether it was successful or not
  8331. * @hidden
  8332. */
  8333. _restoreStateValues(): boolean;
  8334. /** @hidden */
  8335. _initCache(): void;
  8336. /** @hidden */
  8337. _updateCache(ignoreParentClass?: boolean): void;
  8338. /** @hidden */
  8339. _isSynchronizedViewMatrix(): boolean;
  8340. /** @hidden */
  8341. _computeLocalCameraSpeed(): number;
  8342. /**
  8343. * Defines the target the camera should look at.
  8344. * @param target Defines the new target as a Vector or a mesh
  8345. */
  8346. setTarget(target: Vector3): void;
  8347. /**
  8348. * Return the current target position of the camera. This value is expressed in local space.
  8349. * @returns the target position
  8350. */
  8351. getTarget(): Vector3;
  8352. /** @hidden */
  8353. _decideIfNeedsToMove(): boolean;
  8354. /** @hidden */
  8355. _updatePosition(): void;
  8356. /** @hidden */
  8357. _checkInputs(): void;
  8358. protected _updateCameraRotationMatrix(): void;
  8359. /**
  8360. * 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)
  8361. * @returns the current camera
  8362. */
  8363. private _rotateUpVectorWithCameraRotationMatrix;
  8364. private _cachedRotationZ;
  8365. private _cachedQuaternionRotationZ;
  8366. /** @hidden */
  8367. _getViewMatrix(): Matrix;
  8368. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8369. /**
  8370. * @hidden
  8371. */
  8372. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8373. /**
  8374. * @hidden
  8375. */
  8376. _updateRigCameras(): void;
  8377. private _getRigCamPositionAndTarget;
  8378. /**
  8379. * Gets the current object class name.
  8380. * @return the class name
  8381. */
  8382. getClassName(): string;
  8383. }
  8384. }
  8385. declare module BABYLON {
  8386. /**
  8387. * Gather the list of keyboard event types as constants.
  8388. */
  8389. export class KeyboardEventTypes {
  8390. /**
  8391. * The keydown event is fired when a key becomes active (pressed).
  8392. */
  8393. static readonly KEYDOWN: number;
  8394. /**
  8395. * The keyup event is fired when a key has been released.
  8396. */
  8397. static readonly KEYUP: number;
  8398. }
  8399. /**
  8400. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8401. */
  8402. export class KeyboardInfo {
  8403. /**
  8404. * Defines the type of event (KeyboardEventTypes)
  8405. */
  8406. type: number;
  8407. /**
  8408. * Defines the related dom event
  8409. */
  8410. event: KeyboardEvent;
  8411. /**
  8412. * Instantiates a new keyboard info.
  8413. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8414. * @param type Defines the type of event (KeyboardEventTypes)
  8415. * @param event Defines the related dom event
  8416. */
  8417. constructor(
  8418. /**
  8419. * Defines the type of event (KeyboardEventTypes)
  8420. */
  8421. type: number,
  8422. /**
  8423. * Defines the related dom event
  8424. */
  8425. event: KeyboardEvent);
  8426. }
  8427. /**
  8428. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8429. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8430. */
  8431. export class KeyboardInfoPre extends KeyboardInfo {
  8432. /**
  8433. * Defines the type of event (KeyboardEventTypes)
  8434. */
  8435. type: number;
  8436. /**
  8437. * Defines the related dom event
  8438. */
  8439. event: KeyboardEvent;
  8440. /**
  8441. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8442. */
  8443. skipOnPointerObservable: boolean;
  8444. /**
  8445. * Instantiates a new keyboard pre info.
  8446. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8447. * @param type Defines the type of event (KeyboardEventTypes)
  8448. * @param event Defines the related dom event
  8449. */
  8450. constructor(
  8451. /**
  8452. * Defines the type of event (KeyboardEventTypes)
  8453. */
  8454. type: number,
  8455. /**
  8456. * Defines the related dom event
  8457. */
  8458. event: KeyboardEvent);
  8459. }
  8460. }
  8461. declare module BABYLON {
  8462. /**
  8463. * Manage the keyboard inputs to control the movement of a free camera.
  8464. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8465. */
  8466. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8467. /**
  8468. * Defines the camera the input is attached to.
  8469. */
  8470. camera: FreeCamera;
  8471. /**
  8472. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8473. */
  8474. keysUp: number[];
  8475. /**
  8476. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8477. */
  8478. keysDown: number[];
  8479. /**
  8480. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8481. */
  8482. keysLeft: number[];
  8483. /**
  8484. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8485. */
  8486. keysRight: number[];
  8487. private _keys;
  8488. private _onCanvasBlurObserver;
  8489. private _onKeyboardObserver;
  8490. private _engine;
  8491. private _scene;
  8492. /**
  8493. * Attach the input controls to a specific dom element to get the input from.
  8494. * @param element Defines the element the controls should be listened from
  8495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8496. */
  8497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8498. /**
  8499. * Detach the current controls from the specified dom element.
  8500. * @param element Defines the element to stop listening the inputs from
  8501. */
  8502. detachControl(element: Nullable<HTMLElement>): void;
  8503. /**
  8504. * Update the current camera state depending on the inputs that have been used this frame.
  8505. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8506. */
  8507. checkInputs(): void;
  8508. /**
  8509. * Gets the class name of the current intput.
  8510. * @returns the class name
  8511. */
  8512. getClassName(): string;
  8513. /** @hidden */
  8514. _onLostFocus(): void;
  8515. /**
  8516. * Get the friendly name associated with the input class.
  8517. * @returns the input friendly name
  8518. */
  8519. getSimpleName(): string;
  8520. }
  8521. }
  8522. declare module BABYLON {
  8523. /**
  8524. * Interface describing all the common properties and methods a shadow light needs to implement.
  8525. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8526. * as well as binding the different shadow properties to the effects.
  8527. */
  8528. export interface IShadowLight extends Light {
  8529. /**
  8530. * The light id in the scene (used in scene.findLighById for instance)
  8531. */
  8532. id: string;
  8533. /**
  8534. * The position the shdow will be casted from.
  8535. */
  8536. position: Vector3;
  8537. /**
  8538. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8539. */
  8540. direction: Vector3;
  8541. /**
  8542. * The transformed position. Position of the light in world space taking parenting in account.
  8543. */
  8544. transformedPosition: Vector3;
  8545. /**
  8546. * The transformed direction. Direction of the light in world space taking parenting in account.
  8547. */
  8548. transformedDirection: Vector3;
  8549. /**
  8550. * The friendly name of the light in the scene.
  8551. */
  8552. name: string;
  8553. /**
  8554. * Defines the shadow projection clipping minimum z value.
  8555. */
  8556. shadowMinZ: number;
  8557. /**
  8558. * Defines the shadow projection clipping maximum z value.
  8559. */
  8560. shadowMaxZ: number;
  8561. /**
  8562. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8563. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8564. */
  8565. computeTransformedInformation(): boolean;
  8566. /**
  8567. * Gets the scene the light belongs to.
  8568. * @returns The scene
  8569. */
  8570. getScene(): Scene;
  8571. /**
  8572. * Callback defining a custom Projection Matrix Builder.
  8573. * This can be used to override the default projection matrix computation.
  8574. */
  8575. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8576. /**
  8577. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8578. * @param matrix The materix to updated with the projection information
  8579. * @param viewMatrix The transform matrix of the light
  8580. * @param renderList The list of mesh to render in the map
  8581. * @returns The current light
  8582. */
  8583. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8584. /**
  8585. * Gets the current depth scale used in ESM.
  8586. * @returns The scale
  8587. */
  8588. getDepthScale(): number;
  8589. /**
  8590. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8591. * @returns true if a cube texture needs to be use
  8592. */
  8593. needCube(): boolean;
  8594. /**
  8595. * Detects if the projection matrix requires to be recomputed this frame.
  8596. * @returns true if it requires to be recomputed otherwise, false.
  8597. */
  8598. needProjectionMatrixCompute(): boolean;
  8599. /**
  8600. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8601. */
  8602. forceProjectionMatrixCompute(): void;
  8603. /**
  8604. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8605. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8606. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8607. */
  8608. getShadowDirection(faceIndex?: number): Vector3;
  8609. /**
  8610. * Gets the minZ used for shadow according to both the scene and the light.
  8611. * @param activeCamera The camera we are returning the min for
  8612. * @returns the depth min z
  8613. */
  8614. getDepthMinZ(activeCamera: Camera): number;
  8615. /**
  8616. * Gets the maxZ used for shadow according to both the scene and the light.
  8617. * @param activeCamera The camera we are returning the max for
  8618. * @returns the depth max z
  8619. */
  8620. getDepthMaxZ(activeCamera: Camera): number;
  8621. }
  8622. /**
  8623. * Base implementation IShadowLight
  8624. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8625. */
  8626. export abstract class ShadowLight extends Light implements IShadowLight {
  8627. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8628. protected _position: Vector3;
  8629. protected _setPosition(value: Vector3): void;
  8630. /**
  8631. * Sets the position the shadow will be casted from. Also use as the light position for both
  8632. * point and spot lights.
  8633. */
  8634. /**
  8635. * Sets the position the shadow will be casted from. Also use as the light position for both
  8636. * point and spot lights.
  8637. */
  8638. position: Vector3;
  8639. protected _direction: Vector3;
  8640. protected _setDirection(value: Vector3): void;
  8641. /**
  8642. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8643. * Also use as the light direction on spot and directional lights.
  8644. */
  8645. /**
  8646. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8647. * Also use as the light direction on spot and directional lights.
  8648. */
  8649. direction: Vector3;
  8650. private _shadowMinZ;
  8651. /**
  8652. * Gets the shadow projection clipping minimum z value.
  8653. */
  8654. /**
  8655. * Sets the shadow projection clipping minimum z value.
  8656. */
  8657. shadowMinZ: number;
  8658. private _shadowMaxZ;
  8659. /**
  8660. * Sets the shadow projection clipping maximum z value.
  8661. */
  8662. /**
  8663. * Gets the shadow projection clipping maximum z value.
  8664. */
  8665. shadowMaxZ: number;
  8666. /**
  8667. * Callback defining a custom Projection Matrix Builder.
  8668. * This can be used to override the default projection matrix computation.
  8669. */
  8670. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8671. /**
  8672. * The transformed position. Position of the light in world space taking parenting in account.
  8673. */
  8674. transformedPosition: Vector3;
  8675. /**
  8676. * The transformed direction. Direction of the light in world space taking parenting in account.
  8677. */
  8678. transformedDirection: Vector3;
  8679. private _needProjectionMatrixCompute;
  8680. /**
  8681. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8682. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8683. */
  8684. computeTransformedInformation(): boolean;
  8685. /**
  8686. * Return the depth scale used for the shadow map.
  8687. * @returns the depth scale.
  8688. */
  8689. getDepthScale(): number;
  8690. /**
  8691. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8692. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8693. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8694. */
  8695. getShadowDirection(faceIndex?: number): Vector3;
  8696. /**
  8697. * Returns the ShadowLight absolute position in the World.
  8698. * @returns the position vector in world space
  8699. */
  8700. getAbsolutePosition(): Vector3;
  8701. /**
  8702. * Sets the ShadowLight direction toward the passed target.
  8703. * @param target The point to target in local space
  8704. * @returns the updated ShadowLight direction
  8705. */
  8706. setDirectionToTarget(target: Vector3): Vector3;
  8707. /**
  8708. * Returns the light rotation in euler definition.
  8709. * @returns the x y z rotation in local space.
  8710. */
  8711. getRotation(): Vector3;
  8712. /**
  8713. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8714. * @returns true if a cube texture needs to be use
  8715. */
  8716. needCube(): boolean;
  8717. /**
  8718. * Detects if the projection matrix requires to be recomputed this frame.
  8719. * @returns true if it requires to be recomputed otherwise, false.
  8720. */
  8721. needProjectionMatrixCompute(): boolean;
  8722. /**
  8723. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8724. */
  8725. forceProjectionMatrixCompute(): void;
  8726. /** @hidden */
  8727. _initCache(): void;
  8728. /** @hidden */
  8729. _isSynchronized(): boolean;
  8730. /**
  8731. * Computes the world matrix of the node
  8732. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8733. * @returns the world matrix
  8734. */
  8735. computeWorldMatrix(force?: boolean): Matrix;
  8736. /**
  8737. * Gets the minZ used for shadow according to both the scene and the light.
  8738. * @param activeCamera The camera we are returning the min for
  8739. * @returns the depth min z
  8740. */
  8741. getDepthMinZ(activeCamera: Camera): number;
  8742. /**
  8743. * Gets the maxZ used for shadow according to both the scene and the light.
  8744. * @param activeCamera The camera we are returning the max for
  8745. * @returns the depth max z
  8746. */
  8747. getDepthMaxZ(activeCamera: Camera): number;
  8748. /**
  8749. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8750. * @param matrix The materix to updated with the projection information
  8751. * @param viewMatrix The transform matrix of the light
  8752. * @param renderList The list of mesh to render in the map
  8753. * @returns The current light
  8754. */
  8755. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8756. }
  8757. }
  8758. declare module BABYLON {
  8759. /**
  8760. * "Static Class" containing the most commonly used helper while dealing with material for
  8761. * rendering purpose.
  8762. *
  8763. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8764. *
  8765. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8766. */
  8767. export class MaterialHelper {
  8768. /**
  8769. * Bind the current view position to an effect.
  8770. * @param effect The effect to be bound
  8771. * @param scene The scene the eyes position is used from
  8772. */
  8773. static BindEyePosition(effect: Effect, scene: Scene): void;
  8774. /**
  8775. * Helps preparing the defines values about the UVs in used in the effect.
  8776. * UVs are shared as much as we can accross channels in the shaders.
  8777. * @param texture The texture we are preparing the UVs for
  8778. * @param defines The defines to update
  8779. * @param key The channel key "diffuse", "specular"... used in the shader
  8780. */
  8781. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8782. /**
  8783. * Binds a texture matrix value to its corrsponding uniform
  8784. * @param texture The texture to bind the matrix for
  8785. * @param uniformBuffer The uniform buffer receivin the data
  8786. * @param key The channel key "diffuse", "specular"... used in the shader
  8787. */
  8788. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8789. /**
  8790. * Gets the current status of the fog (should it be enabled?)
  8791. * @param mesh defines the mesh to evaluate for fog support
  8792. * @param scene defines the hosting scene
  8793. * @returns true if fog must be enabled
  8794. */
  8795. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8796. /**
  8797. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8798. * @param mesh defines the current mesh
  8799. * @param scene defines the current scene
  8800. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8801. * @param pointsCloud defines if point cloud rendering has to be turned on
  8802. * @param fogEnabled defines if fog has to be turned on
  8803. * @param alphaTest defines if alpha testing has to be turned on
  8804. * @param defines defines the current list of defines
  8805. */
  8806. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8807. /**
  8808. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8809. * @param scene defines the current scene
  8810. * @param engine defines the current engine
  8811. * @param defines specifies the list of active defines
  8812. * @param useInstances defines if instances have to be turned on
  8813. * @param useClipPlane defines if clip plane have to be turned on
  8814. */
  8815. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8816. /**
  8817. * Prepares the defines for bones
  8818. * @param mesh The mesh containing the geometry data we will draw
  8819. * @param defines The defines to update
  8820. */
  8821. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8822. /**
  8823. * Prepares the defines for morph targets
  8824. * @param mesh The mesh containing the geometry data we will draw
  8825. * @param defines The defines to update
  8826. */
  8827. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8828. /**
  8829. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8830. * @param mesh The mesh containing the geometry data we will draw
  8831. * @param defines The defines to update
  8832. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8833. * @param useBones Precise whether bones should be used or not (override mesh info)
  8834. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8835. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8836. * @returns false if defines are considered not dirty and have not been checked
  8837. */
  8838. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8839. /**
  8840. * Prepares the defines related to multiview
  8841. * @param scene The scene we are intending to draw
  8842. * @param defines The defines to update
  8843. */
  8844. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8845. /**
  8846. * Prepares the defines related to the light information passed in parameter
  8847. * @param scene The scene we are intending to draw
  8848. * @param mesh The mesh the effect is compiling for
  8849. * @param light The light the effect is compiling for
  8850. * @param lightIndex The index of the light
  8851. * @param defines The defines to update
  8852. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8853. * @param state Defines the current state regarding what is needed (normals, etc...)
  8854. */
  8855. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8856. needNormals: boolean;
  8857. needRebuild: boolean;
  8858. shadowEnabled: boolean;
  8859. specularEnabled: boolean;
  8860. lightmapMode: boolean;
  8861. }): void;
  8862. /**
  8863. * Prepares the defines related to the light information passed in parameter
  8864. * @param scene The scene we are intending to draw
  8865. * @param mesh The mesh the effect is compiling for
  8866. * @param defines The defines to update
  8867. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8868. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8869. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8870. * @returns true if normals will be required for the rest of the effect
  8871. */
  8872. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8873. /**
  8874. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8875. * @param lightIndex defines the light index
  8876. * @param uniformsList The uniform list
  8877. * @param samplersList The sampler list
  8878. * @param projectedLightTexture defines if projected texture must be used
  8879. * @param uniformBuffersList defines an optional list of uniform buffers
  8880. */
  8881. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8882. /**
  8883. * Prepares the uniforms and samplers list to be used in the effect
  8884. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8885. * @param samplersList The sampler list
  8886. * @param defines The defines helping in the list generation
  8887. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8888. */
  8889. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8890. /**
  8891. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8892. * @param defines The defines to update while falling back
  8893. * @param fallbacks The authorized effect fallbacks
  8894. * @param maxSimultaneousLights The maximum number of lights allowed
  8895. * @param rank the current rank of the Effect
  8896. * @returns The newly affected rank
  8897. */
  8898. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8899. private static _TmpMorphInfluencers;
  8900. /**
  8901. * Prepares the list of attributes required for morph targets according to the effect defines.
  8902. * @param attribs The current list of supported attribs
  8903. * @param mesh The mesh to prepare the morph targets attributes for
  8904. * @param influencers The number of influencers
  8905. */
  8906. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8907. /**
  8908. * Prepares the list of attributes required for morph targets according to the effect defines.
  8909. * @param attribs The current list of supported attribs
  8910. * @param mesh The mesh to prepare the morph targets attributes for
  8911. * @param defines The current Defines of the effect
  8912. */
  8913. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8914. /**
  8915. * Prepares the list of attributes required for bones according to the effect defines.
  8916. * @param attribs The current list of supported attribs
  8917. * @param mesh The mesh to prepare the bones attributes for
  8918. * @param defines The current Defines of the effect
  8919. * @param fallbacks The current efffect fallback strategy
  8920. */
  8921. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8922. /**
  8923. * Check and prepare the list of attributes required for instances according to the effect defines.
  8924. * @param attribs The current list of supported attribs
  8925. * @param defines The current MaterialDefines of the effect
  8926. */
  8927. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8928. /**
  8929. * Add the list of attributes required for instances to the attribs array.
  8930. * @param attribs The current list of supported attribs
  8931. */
  8932. static PushAttributesForInstances(attribs: string[]): void;
  8933. /**
  8934. * Binds the light shadow information to the effect for the given mesh.
  8935. * @param light The light containing the generator
  8936. * @param scene The scene the lights belongs to
  8937. * @param mesh The mesh we are binding the information to render
  8938. * @param lightIndex The light index in the effect used to render the mesh
  8939. * @param effect The effect we are binding the data to
  8940. */
  8941. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8942. /**
  8943. * Binds the light information to the effect.
  8944. * @param light The light containing the generator
  8945. * @param effect The effect we are binding the data to
  8946. * @param lightIndex The light index in the effect used to render
  8947. */
  8948. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8949. /**
  8950. * Binds the lights information from the scene to the effect for the given mesh.
  8951. * @param light Light to bind
  8952. * @param lightIndex Light index
  8953. * @param scene The scene where the light belongs to
  8954. * @param mesh The mesh we are binding the information to render
  8955. * @param effect The effect we are binding the data to
  8956. * @param useSpecular Defines if specular is supported
  8957. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8958. */
  8959. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  8960. /**
  8961. * Binds the lights information from the scene to the effect for the given mesh.
  8962. * @param scene The scene the lights belongs to
  8963. * @param mesh The mesh we are binding the information to render
  8964. * @param effect The effect we are binding the data to
  8965. * @param defines The generated defines for the effect
  8966. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8967. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8968. */
  8969. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  8970. private static _tempFogColor;
  8971. /**
  8972. * Binds the fog information from the scene to the effect for the given mesh.
  8973. * @param scene The scene the lights belongs to
  8974. * @param mesh The mesh we are binding the information to render
  8975. * @param effect The effect we are binding the data to
  8976. * @param linearSpace Defines if the fog effect is applied in linear space
  8977. */
  8978. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8979. /**
  8980. * Binds the bones information from the mesh to the effect.
  8981. * @param mesh The mesh we are binding the information to render
  8982. * @param effect The effect we are binding the data to
  8983. */
  8984. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8985. /**
  8986. * Binds the morph targets information from the mesh to the effect.
  8987. * @param abstractMesh The mesh we are binding the information to render
  8988. * @param effect The effect we are binding the data to
  8989. */
  8990. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  8991. /**
  8992. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  8993. * @param defines The generated defines used in the effect
  8994. * @param effect The effect we are binding the data to
  8995. * @param scene The scene we are willing to render with logarithmic scale for
  8996. */
  8997. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  8998. /**
  8999. * Binds the clip plane information from the scene to the effect.
  9000. * @param scene The scene the clip plane information are extracted from
  9001. * @param effect The effect we are binding the data to
  9002. */
  9003. static BindClipPlane(effect: Effect, scene: Scene): void;
  9004. }
  9005. }
  9006. declare module BABYLON {
  9007. /** @hidden */
  9008. export var packingFunctions: {
  9009. name: string;
  9010. shader: string;
  9011. };
  9012. }
  9013. declare module BABYLON {
  9014. /** @hidden */
  9015. export var shadowMapPixelShader: {
  9016. name: string;
  9017. shader: string;
  9018. };
  9019. }
  9020. declare module BABYLON {
  9021. /** @hidden */
  9022. export var bonesDeclaration: {
  9023. name: string;
  9024. shader: string;
  9025. };
  9026. }
  9027. declare module BABYLON {
  9028. /** @hidden */
  9029. export var morphTargetsVertexGlobalDeclaration: {
  9030. name: string;
  9031. shader: string;
  9032. };
  9033. }
  9034. declare module BABYLON {
  9035. /** @hidden */
  9036. export var morphTargetsVertexDeclaration: {
  9037. name: string;
  9038. shader: string;
  9039. };
  9040. }
  9041. declare module BABYLON {
  9042. /** @hidden */
  9043. export var instancesDeclaration: {
  9044. name: string;
  9045. shader: string;
  9046. };
  9047. }
  9048. declare module BABYLON {
  9049. /** @hidden */
  9050. export var helperFunctions: {
  9051. name: string;
  9052. shader: string;
  9053. };
  9054. }
  9055. declare module BABYLON {
  9056. /** @hidden */
  9057. export var morphTargetsVertex: {
  9058. name: string;
  9059. shader: string;
  9060. };
  9061. }
  9062. declare module BABYLON {
  9063. /** @hidden */
  9064. export var instancesVertex: {
  9065. name: string;
  9066. shader: string;
  9067. };
  9068. }
  9069. declare module BABYLON {
  9070. /** @hidden */
  9071. export var bonesVertex: {
  9072. name: string;
  9073. shader: string;
  9074. };
  9075. }
  9076. declare module BABYLON {
  9077. /** @hidden */
  9078. export var shadowMapVertexShader: {
  9079. name: string;
  9080. shader: string;
  9081. };
  9082. }
  9083. declare module BABYLON {
  9084. /** @hidden */
  9085. export var depthBoxBlurPixelShader: {
  9086. name: string;
  9087. shader: string;
  9088. };
  9089. }
  9090. declare module BABYLON {
  9091. /**
  9092. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9093. */
  9094. export interface ICustomShaderOptions {
  9095. /**
  9096. * Gets or sets the custom shader name to use
  9097. */
  9098. shaderName: string;
  9099. /**
  9100. * The list of attribute names used in the shader
  9101. */
  9102. attributes?: string[];
  9103. /**
  9104. * The list of unifrom names used in the shader
  9105. */
  9106. uniforms?: string[];
  9107. /**
  9108. * The list of sampler names used in the shader
  9109. */
  9110. samplers?: string[];
  9111. /**
  9112. * The list of defines used in the shader
  9113. */
  9114. defines?: string[];
  9115. }
  9116. /**
  9117. * Interface to implement to create a shadow generator compatible with BJS.
  9118. */
  9119. export interface IShadowGenerator {
  9120. /**
  9121. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9122. * @returns The render target texture if present otherwise, null
  9123. */
  9124. getShadowMap(): Nullable<RenderTargetTexture>;
  9125. /**
  9126. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9127. * @returns The render target texture if the shadow map is present otherwise, null
  9128. */
  9129. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9130. /**
  9131. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9132. * @param subMesh The submesh we want to render in the shadow map
  9133. * @param useInstances Defines wether will draw in the map using instances
  9134. * @returns true if ready otherwise, false
  9135. */
  9136. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9137. /**
  9138. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9139. * @param defines Defines of the material we want to update
  9140. * @param lightIndex Index of the light in the enabled light list of the material
  9141. */
  9142. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9143. /**
  9144. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9145. * defined in the generator but impacting the effect).
  9146. * It implies the unifroms available on the materials are the standard BJS ones.
  9147. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9148. * @param effect The effect we are binfing the information for
  9149. */
  9150. bindShadowLight(lightIndex: string, effect: Effect): void;
  9151. /**
  9152. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9153. * (eq to shadow prjection matrix * light transform matrix)
  9154. * @returns The transform matrix used to create the shadow map
  9155. */
  9156. getTransformMatrix(): Matrix;
  9157. /**
  9158. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9159. * Cube and 2D textures for instance.
  9160. */
  9161. recreateShadowMap(): void;
  9162. /**
  9163. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9164. * @param onCompiled Callback triggered at the and of the effects compilation
  9165. * @param options Sets of optional options forcing the compilation with different modes
  9166. */
  9167. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9168. useInstances: boolean;
  9169. }>): void;
  9170. /**
  9171. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9172. * @param options Sets of optional options forcing the compilation with different modes
  9173. * @returns A promise that resolves when the compilation completes
  9174. */
  9175. forceCompilationAsync(options?: Partial<{
  9176. useInstances: boolean;
  9177. }>): Promise<void>;
  9178. /**
  9179. * Serializes the shadow generator setup to a json object.
  9180. * @returns The serialized JSON object
  9181. */
  9182. serialize(): any;
  9183. /**
  9184. * Disposes the Shadow map and related Textures and effects.
  9185. */
  9186. dispose(): void;
  9187. }
  9188. /**
  9189. * Default implementation IShadowGenerator.
  9190. * This is the main object responsible of generating shadows in the framework.
  9191. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9192. */
  9193. export class ShadowGenerator implements IShadowGenerator {
  9194. /**
  9195. * Shadow generator mode None: no filtering applied.
  9196. */
  9197. static readonly FILTER_NONE: number;
  9198. /**
  9199. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9200. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9201. */
  9202. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9203. /**
  9204. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9205. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9206. */
  9207. static readonly FILTER_POISSONSAMPLING: number;
  9208. /**
  9209. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9210. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9211. */
  9212. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9213. /**
  9214. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9215. * edge artifacts on steep falloff.
  9216. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9217. */
  9218. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9219. /**
  9220. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9221. * edge artifacts on steep falloff.
  9222. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9223. */
  9224. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9225. /**
  9226. * Shadow generator mode PCF: Percentage Closer Filtering
  9227. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9228. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9229. */
  9230. static readonly FILTER_PCF: number;
  9231. /**
  9232. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9233. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9234. * Contact Hardening
  9235. */
  9236. static readonly FILTER_PCSS: number;
  9237. /**
  9238. * Reserved for PCF and PCSS
  9239. * Highest Quality.
  9240. *
  9241. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9242. *
  9243. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9244. */
  9245. static readonly QUALITY_HIGH: number;
  9246. /**
  9247. * Reserved for PCF and PCSS
  9248. * Good tradeoff for quality/perf cross devices
  9249. *
  9250. * Execute PCF on a 3*3 kernel.
  9251. *
  9252. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9253. */
  9254. static readonly QUALITY_MEDIUM: number;
  9255. /**
  9256. * Reserved for PCF and PCSS
  9257. * The lowest quality but the fastest.
  9258. *
  9259. * Execute PCF on a 1*1 kernel.
  9260. *
  9261. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9262. */
  9263. static readonly QUALITY_LOW: number;
  9264. /** Gets or sets the custom shader name to use */
  9265. customShaderOptions: ICustomShaderOptions;
  9266. /**
  9267. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9268. */
  9269. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9270. /**
  9271. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9272. */
  9273. onAfterShadowMapRenderObservable: Observable<Effect>;
  9274. /**
  9275. * Observable triggered before a mesh is rendered in the shadow map.
  9276. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9277. */
  9278. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9279. /**
  9280. * Observable triggered after a mesh is rendered in the shadow map.
  9281. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9282. */
  9283. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9284. private _bias;
  9285. /**
  9286. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9287. */
  9288. /**
  9289. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9290. */
  9291. bias: number;
  9292. private _normalBias;
  9293. /**
  9294. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9295. */
  9296. /**
  9297. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9298. */
  9299. normalBias: number;
  9300. private _blurBoxOffset;
  9301. /**
  9302. * Gets the blur box offset: offset applied during the blur pass.
  9303. * Only useful if useKernelBlur = false
  9304. */
  9305. /**
  9306. * Sets the blur box offset: offset applied during the blur pass.
  9307. * Only useful if useKernelBlur = false
  9308. */
  9309. blurBoxOffset: number;
  9310. private _blurScale;
  9311. /**
  9312. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9313. * 2 means half of the size.
  9314. */
  9315. /**
  9316. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9317. * 2 means half of the size.
  9318. */
  9319. blurScale: number;
  9320. private _blurKernel;
  9321. /**
  9322. * Gets the blur kernel: kernel size of the blur pass.
  9323. * Only useful if useKernelBlur = true
  9324. */
  9325. /**
  9326. * Sets the blur kernel: kernel size of the blur pass.
  9327. * Only useful if useKernelBlur = true
  9328. */
  9329. blurKernel: number;
  9330. private _useKernelBlur;
  9331. /**
  9332. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9333. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9334. */
  9335. /**
  9336. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9337. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9338. */
  9339. useKernelBlur: boolean;
  9340. private _depthScale;
  9341. /**
  9342. * Gets the depth scale used in ESM mode.
  9343. */
  9344. /**
  9345. * Sets the depth scale used in ESM mode.
  9346. * This can override the scale stored on the light.
  9347. */
  9348. depthScale: number;
  9349. private _filter;
  9350. /**
  9351. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9352. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9353. */
  9354. /**
  9355. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9356. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9357. */
  9358. filter: number;
  9359. /**
  9360. * Gets if the current filter is set to Poisson Sampling.
  9361. */
  9362. /**
  9363. * Sets the current filter to Poisson Sampling.
  9364. */
  9365. usePoissonSampling: boolean;
  9366. /**
  9367. * Gets if the current filter is set to ESM.
  9368. */
  9369. /**
  9370. * Sets the current filter is to ESM.
  9371. */
  9372. useExponentialShadowMap: boolean;
  9373. /**
  9374. * Gets if the current filter is set to filtered ESM.
  9375. */
  9376. /**
  9377. * Gets if the current filter is set to filtered ESM.
  9378. */
  9379. useBlurExponentialShadowMap: boolean;
  9380. /**
  9381. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9382. * exponential to prevent steep falloff artifacts).
  9383. */
  9384. /**
  9385. * Sets the current filter to "close ESM" (using the inverse of the
  9386. * exponential to prevent steep falloff artifacts).
  9387. */
  9388. useCloseExponentialShadowMap: boolean;
  9389. /**
  9390. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9391. * exponential to prevent steep falloff artifacts).
  9392. */
  9393. /**
  9394. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9395. * exponential to prevent steep falloff artifacts).
  9396. */
  9397. useBlurCloseExponentialShadowMap: boolean;
  9398. /**
  9399. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9400. */
  9401. /**
  9402. * Sets the current filter to "PCF" (percentage closer filtering).
  9403. */
  9404. usePercentageCloserFiltering: boolean;
  9405. private _filteringQuality;
  9406. /**
  9407. * Gets the PCF or PCSS Quality.
  9408. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9409. */
  9410. /**
  9411. * Sets the PCF or PCSS Quality.
  9412. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9413. */
  9414. filteringQuality: number;
  9415. /**
  9416. * Gets if the current filter is set to "PCSS" (contact hardening).
  9417. */
  9418. /**
  9419. * Sets the current filter to "PCSS" (contact hardening).
  9420. */
  9421. useContactHardeningShadow: boolean;
  9422. private _contactHardeningLightSizeUVRatio;
  9423. /**
  9424. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9425. * Using a ratio helps keeping shape stability independently of the map size.
  9426. *
  9427. * It does not account for the light projection as it was having too much
  9428. * instability during the light setup or during light position changes.
  9429. *
  9430. * Only valid if useContactHardeningShadow is true.
  9431. */
  9432. /**
  9433. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9434. * Using a ratio helps keeping shape stability independently of the map size.
  9435. *
  9436. * It does not account for the light projection as it was having too much
  9437. * instability during the light setup or during light position changes.
  9438. *
  9439. * Only valid if useContactHardeningShadow is true.
  9440. */
  9441. contactHardeningLightSizeUVRatio: number;
  9442. private _darkness;
  9443. /** Gets or sets the actual darkness of a shadow */
  9444. darkness: number;
  9445. /**
  9446. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9447. * 0 means strongest and 1 would means no shadow.
  9448. * @returns the darkness.
  9449. */
  9450. getDarkness(): number;
  9451. /**
  9452. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9453. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9454. * @returns the shadow generator allowing fluent coding.
  9455. */
  9456. setDarkness(darkness: number): ShadowGenerator;
  9457. private _transparencyShadow;
  9458. /** Gets or sets the ability to have transparent shadow */
  9459. transparencyShadow: boolean;
  9460. /**
  9461. * Sets the ability to have transparent shadow (boolean).
  9462. * @param transparent True if transparent else False
  9463. * @returns the shadow generator allowing fluent coding
  9464. */
  9465. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9466. private _shadowMap;
  9467. private _shadowMap2;
  9468. /**
  9469. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9470. * @returns The render target texture if present otherwise, null
  9471. */
  9472. getShadowMap(): Nullable<RenderTargetTexture>;
  9473. /**
  9474. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9475. * @returns The render target texture if the shadow map is present otherwise, null
  9476. */
  9477. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9478. /**
  9479. * Gets the class name of that object
  9480. * @returns "ShadowGenerator"
  9481. */
  9482. getClassName(): string;
  9483. /**
  9484. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9485. * @param mesh Mesh to add
  9486. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9487. * @returns the Shadow Generator itself
  9488. */
  9489. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9490. /**
  9491. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9492. * @param mesh Mesh to remove
  9493. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9494. * @returns the Shadow Generator itself
  9495. */
  9496. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9497. /**
  9498. * Controls the extent to which the shadows fade out at the edge of the frustum
  9499. * Used only by directionals and spots
  9500. */
  9501. frustumEdgeFalloff: number;
  9502. private _light;
  9503. /**
  9504. * Returns the associated light object.
  9505. * @returns the light generating the shadow
  9506. */
  9507. getLight(): IShadowLight;
  9508. /**
  9509. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9510. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9511. * It might on the other hand introduce peter panning.
  9512. */
  9513. forceBackFacesOnly: boolean;
  9514. private _scene;
  9515. private _lightDirection;
  9516. private _effect;
  9517. private _viewMatrix;
  9518. private _projectionMatrix;
  9519. private _transformMatrix;
  9520. private _cachedPosition;
  9521. private _cachedDirection;
  9522. private _cachedDefines;
  9523. private _currentRenderID;
  9524. private _boxBlurPostprocess;
  9525. private _kernelBlurXPostprocess;
  9526. private _kernelBlurYPostprocess;
  9527. private _blurPostProcesses;
  9528. private _mapSize;
  9529. private _currentFaceIndex;
  9530. private _currentFaceIndexCache;
  9531. private _textureType;
  9532. private _defaultTextureMatrix;
  9533. /** @hidden */
  9534. static _SceneComponentInitialization: (scene: Scene) => void;
  9535. /**
  9536. * Creates a ShadowGenerator object.
  9537. * A ShadowGenerator is the required tool to use the shadows.
  9538. * Each light casting shadows needs to use its own ShadowGenerator.
  9539. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9540. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9541. * @param light The light object generating the shadows.
  9542. * @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.
  9543. */
  9544. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9545. private _initializeGenerator;
  9546. private _initializeShadowMap;
  9547. private _initializeBlurRTTAndPostProcesses;
  9548. private _renderForShadowMap;
  9549. private _renderSubMeshForShadowMap;
  9550. private _applyFilterValues;
  9551. /**
  9552. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9553. * @param onCompiled Callback triggered at the and of the effects compilation
  9554. * @param options Sets of optional options forcing the compilation with different modes
  9555. */
  9556. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9557. useInstances: boolean;
  9558. }>): void;
  9559. /**
  9560. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9561. * @param options Sets of optional options forcing the compilation with different modes
  9562. * @returns A promise that resolves when the compilation completes
  9563. */
  9564. forceCompilationAsync(options?: Partial<{
  9565. useInstances: boolean;
  9566. }>): Promise<void>;
  9567. /**
  9568. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9569. * @param subMesh The submesh we want to render in the shadow map
  9570. * @param useInstances Defines wether will draw in the map using instances
  9571. * @returns true if ready otherwise, false
  9572. */
  9573. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9574. /**
  9575. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9576. * @param defines Defines of the material we want to update
  9577. * @param lightIndex Index of the light in the enabled light list of the material
  9578. */
  9579. prepareDefines(defines: any, lightIndex: number): void;
  9580. /**
  9581. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9582. * defined in the generator but impacting the effect).
  9583. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9584. * @param effect The effect we are binfing the information for
  9585. */
  9586. bindShadowLight(lightIndex: string, effect: Effect): void;
  9587. /**
  9588. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9589. * (eq to shadow prjection matrix * light transform matrix)
  9590. * @returns The transform matrix used to create the shadow map
  9591. */
  9592. getTransformMatrix(): Matrix;
  9593. /**
  9594. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9595. * Cube and 2D textures for instance.
  9596. */
  9597. recreateShadowMap(): void;
  9598. private _disposeBlurPostProcesses;
  9599. private _disposeRTTandPostProcesses;
  9600. /**
  9601. * Disposes the ShadowGenerator.
  9602. * Returns nothing.
  9603. */
  9604. dispose(): void;
  9605. /**
  9606. * Serializes the shadow generator setup to a json object.
  9607. * @returns The serialized JSON object
  9608. */
  9609. serialize(): any;
  9610. /**
  9611. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9612. * @param parsedShadowGenerator The JSON object to parse
  9613. * @param scene The scene to create the shadow map for
  9614. * @returns The parsed shadow generator
  9615. */
  9616. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9617. }
  9618. }
  9619. declare module BABYLON {
  9620. /**
  9621. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9622. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9623. * 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.
  9624. */
  9625. export abstract class Light extends Node {
  9626. /**
  9627. * Falloff Default: light is falling off following the material specification:
  9628. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9629. */
  9630. static readonly FALLOFF_DEFAULT: number;
  9631. /**
  9632. * Falloff Physical: light is falling off following the inverse squared distance law.
  9633. */
  9634. static readonly FALLOFF_PHYSICAL: number;
  9635. /**
  9636. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9637. * to enhance interoperability with other engines.
  9638. */
  9639. static readonly FALLOFF_GLTF: number;
  9640. /**
  9641. * Falloff Standard: light is falling off like in the standard material
  9642. * to enhance interoperability with other materials.
  9643. */
  9644. static readonly FALLOFF_STANDARD: number;
  9645. /**
  9646. * If every light affecting the material is in this lightmapMode,
  9647. * material.lightmapTexture adds or multiplies
  9648. * (depends on material.useLightmapAsShadowmap)
  9649. * after every other light calculations.
  9650. */
  9651. static readonly LIGHTMAP_DEFAULT: number;
  9652. /**
  9653. * material.lightmapTexture as only diffuse lighting from this light
  9654. * adds only specular lighting from this light
  9655. * adds dynamic shadows
  9656. */
  9657. static readonly LIGHTMAP_SPECULAR: number;
  9658. /**
  9659. * material.lightmapTexture as only lighting
  9660. * no light calculation from this light
  9661. * only adds dynamic shadows from this light
  9662. */
  9663. static readonly LIGHTMAP_SHADOWSONLY: number;
  9664. /**
  9665. * Each light type uses the default quantity according to its type:
  9666. * point/spot lights use luminous intensity
  9667. * directional lights use illuminance
  9668. */
  9669. static readonly INTENSITYMODE_AUTOMATIC: number;
  9670. /**
  9671. * lumen (lm)
  9672. */
  9673. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9674. /**
  9675. * candela (lm/sr)
  9676. */
  9677. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9678. /**
  9679. * lux (lm/m^2)
  9680. */
  9681. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9682. /**
  9683. * nit (cd/m^2)
  9684. */
  9685. static readonly INTENSITYMODE_LUMINANCE: number;
  9686. /**
  9687. * Light type const id of the point light.
  9688. */
  9689. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9690. /**
  9691. * Light type const id of the directional light.
  9692. */
  9693. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9694. /**
  9695. * Light type const id of the spot light.
  9696. */
  9697. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9698. /**
  9699. * Light type const id of the hemispheric light.
  9700. */
  9701. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9702. /**
  9703. * Diffuse gives the basic color to an object.
  9704. */
  9705. diffuse: Color3;
  9706. /**
  9707. * Specular produces a highlight color on an object.
  9708. * Note: This is note affecting PBR materials.
  9709. */
  9710. specular: Color3;
  9711. /**
  9712. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9713. * falling off base on range or angle.
  9714. * This can be set to any values in Light.FALLOFF_x.
  9715. *
  9716. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9717. * other types of materials.
  9718. */
  9719. falloffType: number;
  9720. /**
  9721. * Strength of the light.
  9722. * Note: By default it is define in the framework own unit.
  9723. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9724. */
  9725. intensity: number;
  9726. private _range;
  9727. protected _inverseSquaredRange: number;
  9728. /**
  9729. * Defines how far from the source the light is impacting in scene units.
  9730. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9731. */
  9732. /**
  9733. * Defines how far from the source the light is impacting in scene units.
  9734. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9735. */
  9736. range: number;
  9737. /**
  9738. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9739. * of light.
  9740. */
  9741. private _photometricScale;
  9742. private _intensityMode;
  9743. /**
  9744. * Gets the photometric scale used to interpret the intensity.
  9745. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9746. */
  9747. /**
  9748. * Sets the photometric scale used to interpret the intensity.
  9749. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9750. */
  9751. intensityMode: number;
  9752. private _radius;
  9753. /**
  9754. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9755. */
  9756. /**
  9757. * sets the light radius used by PBR Materials to simulate soft area lights.
  9758. */
  9759. radius: number;
  9760. private _renderPriority;
  9761. /**
  9762. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9763. * exceeding the number allowed of the materials.
  9764. */
  9765. renderPriority: number;
  9766. private _shadowEnabled;
  9767. /**
  9768. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9769. * the current shadow generator.
  9770. */
  9771. /**
  9772. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9773. * the current shadow generator.
  9774. */
  9775. shadowEnabled: boolean;
  9776. private _includedOnlyMeshes;
  9777. /**
  9778. * Gets the only meshes impacted by this light.
  9779. */
  9780. /**
  9781. * Sets the only meshes impacted by this light.
  9782. */
  9783. includedOnlyMeshes: AbstractMesh[];
  9784. private _excludedMeshes;
  9785. /**
  9786. * Gets the meshes not impacted by this light.
  9787. */
  9788. /**
  9789. * Sets the meshes not impacted by this light.
  9790. */
  9791. excludedMeshes: AbstractMesh[];
  9792. private _excludeWithLayerMask;
  9793. /**
  9794. * Gets the layer id use to find what meshes are not impacted by the light.
  9795. * Inactive if 0
  9796. */
  9797. /**
  9798. * Sets the layer id use to find what meshes are not impacted by the light.
  9799. * Inactive if 0
  9800. */
  9801. excludeWithLayerMask: number;
  9802. private _includeOnlyWithLayerMask;
  9803. /**
  9804. * Gets the layer id use to find what meshes are impacted by the light.
  9805. * Inactive if 0
  9806. */
  9807. /**
  9808. * Sets the layer id use to find what meshes are impacted by the light.
  9809. * Inactive if 0
  9810. */
  9811. includeOnlyWithLayerMask: number;
  9812. private _lightmapMode;
  9813. /**
  9814. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9815. */
  9816. /**
  9817. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9818. */
  9819. lightmapMode: number;
  9820. /**
  9821. * Shadow generator associted to the light.
  9822. * @hidden Internal use only.
  9823. */
  9824. _shadowGenerator: Nullable<IShadowGenerator>;
  9825. /**
  9826. * @hidden Internal use only.
  9827. */
  9828. _excludedMeshesIds: string[];
  9829. /**
  9830. * @hidden Internal use only.
  9831. */
  9832. _includedOnlyMeshesIds: string[];
  9833. /**
  9834. * The current light unifom buffer.
  9835. * @hidden Internal use only.
  9836. */
  9837. _uniformBuffer: UniformBuffer;
  9838. /**
  9839. * Creates a Light object in the scene.
  9840. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9841. * @param name The firendly name of the light
  9842. * @param scene The scene the light belongs too
  9843. */
  9844. constructor(name: string, scene: Scene);
  9845. protected abstract _buildUniformLayout(): void;
  9846. /**
  9847. * Sets the passed Effect "effect" with the Light information.
  9848. * @param effect The effect to update
  9849. * @param lightIndex The index of the light in the effect to update
  9850. * @returns The light
  9851. */
  9852. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9853. /**
  9854. * Returns the string "Light".
  9855. * @returns the class name
  9856. */
  9857. getClassName(): string;
  9858. /** @hidden */
  9859. readonly _isLight: boolean;
  9860. /**
  9861. * Converts the light information to a readable string for debug purpose.
  9862. * @param fullDetails Supports for multiple levels of logging within scene loading
  9863. * @returns the human readable light info
  9864. */
  9865. toString(fullDetails?: boolean): string;
  9866. /** @hidden */
  9867. protected _syncParentEnabledState(): void;
  9868. /**
  9869. * Set the enabled state of this node.
  9870. * @param value - the new enabled state
  9871. */
  9872. setEnabled(value: boolean): void;
  9873. /**
  9874. * Returns the Light associated shadow generator if any.
  9875. * @return the associated shadow generator.
  9876. */
  9877. getShadowGenerator(): Nullable<IShadowGenerator>;
  9878. /**
  9879. * Returns a Vector3, the absolute light position in the World.
  9880. * @returns the world space position of the light
  9881. */
  9882. getAbsolutePosition(): Vector3;
  9883. /**
  9884. * Specifies if the light will affect the passed mesh.
  9885. * @param mesh The mesh to test against the light
  9886. * @return true the mesh is affected otherwise, false.
  9887. */
  9888. canAffectMesh(mesh: AbstractMesh): boolean;
  9889. /**
  9890. * Sort function to order lights for rendering.
  9891. * @param a First Light object to compare to second.
  9892. * @param b Second Light object to compare first.
  9893. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9894. */
  9895. static CompareLightsPriority(a: Light, b: Light): number;
  9896. /**
  9897. * Releases resources associated with this node.
  9898. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9899. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9900. */
  9901. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9902. /**
  9903. * Returns the light type ID (integer).
  9904. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9905. */
  9906. getTypeID(): number;
  9907. /**
  9908. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9909. * @returns the scaled intensity in intensity mode unit
  9910. */
  9911. getScaledIntensity(): number;
  9912. /**
  9913. * Returns a new Light object, named "name", from the current one.
  9914. * @param name The name of the cloned light
  9915. * @returns the new created light
  9916. */
  9917. clone(name: string): Nullable<Light>;
  9918. /**
  9919. * Serializes the current light into a Serialization object.
  9920. * @returns the serialized object.
  9921. */
  9922. serialize(): any;
  9923. /**
  9924. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9925. * This new light is named "name" and added to the passed scene.
  9926. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9927. * @param name The friendly name of the light
  9928. * @param scene The scene the new light will belong to
  9929. * @returns the constructor function
  9930. */
  9931. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9932. /**
  9933. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9934. * @param parsedLight The JSON representation of the light
  9935. * @param scene The scene to create the parsed light in
  9936. * @returns the created light after parsing
  9937. */
  9938. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9939. private _hookArrayForExcluded;
  9940. private _hookArrayForIncludedOnly;
  9941. private _resyncMeshes;
  9942. /**
  9943. * Forces the meshes to update their light related information in their rendering used effects
  9944. * @hidden Internal Use Only
  9945. */
  9946. _markMeshesAsLightDirty(): void;
  9947. /**
  9948. * Recomputes the cached photometric scale if needed.
  9949. */
  9950. private _computePhotometricScale;
  9951. /**
  9952. * Returns the Photometric Scale according to the light type and intensity mode.
  9953. */
  9954. private _getPhotometricScale;
  9955. /**
  9956. * Reorder the light in the scene according to their defined priority.
  9957. * @hidden Internal Use Only
  9958. */
  9959. _reorderLightsInScene(): void;
  9960. /**
  9961. * Prepares the list of defines specific to the light type.
  9962. * @param defines the list of defines
  9963. * @param lightIndex defines the index of the light for the effect
  9964. */
  9965. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9966. }
  9967. }
  9968. declare module BABYLON {
  9969. /**
  9970. * Interface used to define Action
  9971. */
  9972. export interface IAction {
  9973. /**
  9974. * Trigger for the action
  9975. */
  9976. trigger: number;
  9977. /** Options of the trigger */
  9978. triggerOptions: any;
  9979. /**
  9980. * Gets the trigger parameters
  9981. * @returns the trigger parameters
  9982. */
  9983. getTriggerParameter(): any;
  9984. /**
  9985. * Internal only - executes current action event
  9986. * @hidden
  9987. */
  9988. _executeCurrent(evt?: ActionEvent): void;
  9989. /**
  9990. * Serialize placeholder for child classes
  9991. * @param parent of child
  9992. * @returns the serialized object
  9993. */
  9994. serialize(parent: any): any;
  9995. /**
  9996. * Internal only
  9997. * @hidden
  9998. */
  9999. _prepare(): void;
  10000. /**
  10001. * Internal only - manager for action
  10002. * @hidden
  10003. */
  10004. _actionManager: AbstractActionManager;
  10005. /**
  10006. * Adds action to chain of actions, may be a DoNothingAction
  10007. * @param action defines the next action to execute
  10008. * @returns The action passed in
  10009. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10010. */
  10011. then(action: IAction): IAction;
  10012. }
  10013. /**
  10014. * The action to be carried out following a trigger
  10015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10016. */
  10017. export class Action implements IAction {
  10018. /** the trigger, with or without parameters, for the action */
  10019. triggerOptions: any;
  10020. /**
  10021. * Trigger for the action
  10022. */
  10023. trigger: number;
  10024. /**
  10025. * Internal only - manager for action
  10026. * @hidden
  10027. */
  10028. _actionManager: ActionManager;
  10029. private _nextActiveAction;
  10030. private _child;
  10031. private _condition?;
  10032. private _triggerParameter;
  10033. /**
  10034. * An event triggered prior to action being executed.
  10035. */
  10036. onBeforeExecuteObservable: Observable<Action>;
  10037. /**
  10038. * Creates a new Action
  10039. * @param triggerOptions the trigger, with or without parameters, for the action
  10040. * @param condition an optional determinant of action
  10041. */
  10042. constructor(
  10043. /** the trigger, with or without parameters, for the action */
  10044. triggerOptions: any, condition?: Condition);
  10045. /**
  10046. * Internal only
  10047. * @hidden
  10048. */
  10049. _prepare(): void;
  10050. /**
  10051. * Gets the trigger parameters
  10052. * @returns the trigger parameters
  10053. */
  10054. getTriggerParameter(): any;
  10055. /**
  10056. * Internal only - executes current action event
  10057. * @hidden
  10058. */
  10059. _executeCurrent(evt?: ActionEvent): void;
  10060. /**
  10061. * Execute placeholder for child classes
  10062. * @param evt optional action event
  10063. */
  10064. execute(evt?: ActionEvent): void;
  10065. /**
  10066. * Skips to next active action
  10067. */
  10068. skipToNextActiveAction(): void;
  10069. /**
  10070. * Adds action to chain of actions, may be a DoNothingAction
  10071. * @param action defines the next action to execute
  10072. * @returns The action passed in
  10073. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10074. */
  10075. then(action: Action): Action;
  10076. /**
  10077. * Internal only
  10078. * @hidden
  10079. */
  10080. _getProperty(propertyPath: string): string;
  10081. /**
  10082. * Internal only
  10083. * @hidden
  10084. */
  10085. _getEffectiveTarget(target: any, propertyPath: string): any;
  10086. /**
  10087. * Serialize placeholder for child classes
  10088. * @param parent of child
  10089. * @returns the serialized object
  10090. */
  10091. serialize(parent: any): any;
  10092. /**
  10093. * Internal only called by serialize
  10094. * @hidden
  10095. */
  10096. protected _serialize(serializedAction: any, parent?: any): any;
  10097. /**
  10098. * Internal only
  10099. * @hidden
  10100. */
  10101. static _SerializeValueAsString: (value: any) => string;
  10102. /**
  10103. * Internal only
  10104. * @hidden
  10105. */
  10106. static _GetTargetProperty: (target: Node | Scene) => {
  10107. name: string;
  10108. targetType: string;
  10109. value: string;
  10110. };
  10111. }
  10112. }
  10113. declare module BABYLON {
  10114. /**
  10115. * A Condition applied to an Action
  10116. */
  10117. export class Condition {
  10118. /**
  10119. * Internal only - manager for action
  10120. * @hidden
  10121. */
  10122. _actionManager: ActionManager;
  10123. /**
  10124. * Internal only
  10125. * @hidden
  10126. */
  10127. _evaluationId: number;
  10128. /**
  10129. * Internal only
  10130. * @hidden
  10131. */
  10132. _currentResult: boolean;
  10133. /**
  10134. * Creates a new Condition
  10135. * @param actionManager the manager of the action the condition is applied to
  10136. */
  10137. constructor(actionManager: ActionManager);
  10138. /**
  10139. * Check if the current condition is valid
  10140. * @returns a boolean
  10141. */
  10142. isValid(): boolean;
  10143. /**
  10144. * Internal only
  10145. * @hidden
  10146. */
  10147. _getProperty(propertyPath: string): string;
  10148. /**
  10149. * Internal only
  10150. * @hidden
  10151. */
  10152. _getEffectiveTarget(target: any, propertyPath: string): any;
  10153. /**
  10154. * Serialize placeholder for child classes
  10155. * @returns the serialized object
  10156. */
  10157. serialize(): any;
  10158. /**
  10159. * Internal only
  10160. * @hidden
  10161. */
  10162. protected _serialize(serializedCondition: any): any;
  10163. }
  10164. /**
  10165. * Defines specific conditional operators as extensions of Condition
  10166. */
  10167. export class ValueCondition extends Condition {
  10168. /** path to specify the property of the target the conditional operator uses */
  10169. propertyPath: string;
  10170. /** the value compared by the conditional operator against the current value of the property */
  10171. value: any;
  10172. /** the conditional operator, default ValueCondition.IsEqual */
  10173. operator: number;
  10174. /**
  10175. * Internal only
  10176. * @hidden
  10177. */
  10178. private static _IsEqual;
  10179. /**
  10180. * Internal only
  10181. * @hidden
  10182. */
  10183. private static _IsDifferent;
  10184. /**
  10185. * Internal only
  10186. * @hidden
  10187. */
  10188. private static _IsGreater;
  10189. /**
  10190. * Internal only
  10191. * @hidden
  10192. */
  10193. private static _IsLesser;
  10194. /**
  10195. * returns the number for IsEqual
  10196. */
  10197. static readonly IsEqual: number;
  10198. /**
  10199. * Returns the number for IsDifferent
  10200. */
  10201. static readonly IsDifferent: number;
  10202. /**
  10203. * Returns the number for IsGreater
  10204. */
  10205. static readonly IsGreater: number;
  10206. /**
  10207. * Returns the number for IsLesser
  10208. */
  10209. static readonly IsLesser: number;
  10210. /**
  10211. * Internal only The action manager for the condition
  10212. * @hidden
  10213. */
  10214. _actionManager: ActionManager;
  10215. /**
  10216. * Internal only
  10217. * @hidden
  10218. */
  10219. private _target;
  10220. /**
  10221. * Internal only
  10222. * @hidden
  10223. */
  10224. private _effectiveTarget;
  10225. /**
  10226. * Internal only
  10227. * @hidden
  10228. */
  10229. private _property;
  10230. /**
  10231. * Creates a new ValueCondition
  10232. * @param actionManager manager for the action the condition applies to
  10233. * @param target for the action
  10234. * @param propertyPath path to specify the property of the target the conditional operator uses
  10235. * @param value the value compared by the conditional operator against the current value of the property
  10236. * @param operator the conditional operator, default ValueCondition.IsEqual
  10237. */
  10238. constructor(actionManager: ActionManager, target: any,
  10239. /** path to specify the property of the target the conditional operator uses */
  10240. propertyPath: string,
  10241. /** the value compared by the conditional operator against the current value of the property */
  10242. value: any,
  10243. /** the conditional operator, default ValueCondition.IsEqual */
  10244. operator?: number);
  10245. /**
  10246. * Compares the given value with the property value for the specified conditional operator
  10247. * @returns the result of the comparison
  10248. */
  10249. isValid(): boolean;
  10250. /**
  10251. * Serialize the ValueCondition into a JSON compatible object
  10252. * @returns serialization object
  10253. */
  10254. serialize(): any;
  10255. /**
  10256. * Gets the name of the conditional operator for the ValueCondition
  10257. * @param operator the conditional operator
  10258. * @returns the name
  10259. */
  10260. static GetOperatorName(operator: number): string;
  10261. }
  10262. /**
  10263. * Defines a predicate condition as an extension of Condition
  10264. */
  10265. export class PredicateCondition extends Condition {
  10266. /** defines the predicate function used to validate the condition */
  10267. predicate: () => boolean;
  10268. /**
  10269. * Internal only - manager for action
  10270. * @hidden
  10271. */
  10272. _actionManager: ActionManager;
  10273. /**
  10274. * Creates a new PredicateCondition
  10275. * @param actionManager manager for the action the condition applies to
  10276. * @param predicate defines the predicate function used to validate the condition
  10277. */
  10278. constructor(actionManager: ActionManager,
  10279. /** defines the predicate function used to validate the condition */
  10280. predicate: () => boolean);
  10281. /**
  10282. * @returns the validity of the predicate condition
  10283. */
  10284. isValid(): boolean;
  10285. }
  10286. /**
  10287. * Defines a state condition as an extension of Condition
  10288. */
  10289. export class StateCondition extends Condition {
  10290. /** Value to compare with target state */
  10291. value: string;
  10292. /**
  10293. * Internal only - manager for action
  10294. * @hidden
  10295. */
  10296. _actionManager: ActionManager;
  10297. /**
  10298. * Internal only
  10299. * @hidden
  10300. */
  10301. private _target;
  10302. /**
  10303. * Creates a new StateCondition
  10304. * @param actionManager manager for the action the condition applies to
  10305. * @param target of the condition
  10306. * @param value to compare with target state
  10307. */
  10308. constructor(actionManager: ActionManager, target: any,
  10309. /** Value to compare with target state */
  10310. value: string);
  10311. /**
  10312. * Gets a boolean indicating if the current condition is met
  10313. * @returns the validity of the state
  10314. */
  10315. isValid(): boolean;
  10316. /**
  10317. * Serialize the StateCondition into a JSON compatible object
  10318. * @returns serialization object
  10319. */
  10320. serialize(): any;
  10321. }
  10322. }
  10323. declare module BABYLON {
  10324. /**
  10325. * This defines an action responsible to toggle a boolean once triggered.
  10326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10327. */
  10328. export class SwitchBooleanAction extends Action {
  10329. /**
  10330. * The path to the boolean property in the target object
  10331. */
  10332. propertyPath: string;
  10333. private _target;
  10334. private _effectiveTarget;
  10335. private _property;
  10336. /**
  10337. * Instantiate the action
  10338. * @param triggerOptions defines the trigger options
  10339. * @param target defines the object containing the boolean
  10340. * @param propertyPath defines the path to the boolean property in the target object
  10341. * @param condition defines the trigger related conditions
  10342. */
  10343. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10344. /** @hidden */
  10345. _prepare(): void;
  10346. /**
  10347. * Execute the action toggle the boolean value.
  10348. */
  10349. execute(): void;
  10350. /**
  10351. * Serializes the actions and its related information.
  10352. * @param parent defines the object to serialize in
  10353. * @returns the serialized object
  10354. */
  10355. serialize(parent: any): any;
  10356. }
  10357. /**
  10358. * This defines an action responsible to set a the state field of the target
  10359. * to a desired value once triggered.
  10360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10361. */
  10362. export class SetStateAction extends Action {
  10363. /**
  10364. * The value to store in the state field.
  10365. */
  10366. value: string;
  10367. private _target;
  10368. /**
  10369. * Instantiate the action
  10370. * @param triggerOptions defines the trigger options
  10371. * @param target defines the object containing the state property
  10372. * @param value defines the value to store in the state field
  10373. * @param condition defines the trigger related conditions
  10374. */
  10375. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10376. /**
  10377. * Execute the action and store the value on the target state property.
  10378. */
  10379. execute(): void;
  10380. /**
  10381. * Serializes the actions and its related information.
  10382. * @param parent defines the object to serialize in
  10383. * @returns the serialized object
  10384. */
  10385. serialize(parent: any): any;
  10386. }
  10387. /**
  10388. * This defines an action responsible to set a property of the target
  10389. * to a desired value once triggered.
  10390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10391. */
  10392. export class SetValueAction extends Action {
  10393. /**
  10394. * The path of the property to set in the target.
  10395. */
  10396. propertyPath: string;
  10397. /**
  10398. * The value to set in the property
  10399. */
  10400. value: any;
  10401. private _target;
  10402. private _effectiveTarget;
  10403. private _property;
  10404. /**
  10405. * Instantiate the action
  10406. * @param triggerOptions defines the trigger options
  10407. * @param target defines the object containing the property
  10408. * @param propertyPath defines the path of the property to set in the target
  10409. * @param value defines the value to set in the property
  10410. * @param condition defines the trigger related conditions
  10411. */
  10412. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10413. /** @hidden */
  10414. _prepare(): void;
  10415. /**
  10416. * Execute the action and set the targetted property to the desired value.
  10417. */
  10418. execute(): void;
  10419. /**
  10420. * Serializes the actions and its related information.
  10421. * @param parent defines the object to serialize in
  10422. * @returns the serialized object
  10423. */
  10424. serialize(parent: any): any;
  10425. }
  10426. /**
  10427. * This defines an action responsible to increment the target value
  10428. * to a desired value once triggered.
  10429. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10430. */
  10431. export class IncrementValueAction extends Action {
  10432. /**
  10433. * The path of the property to increment in the target.
  10434. */
  10435. propertyPath: string;
  10436. /**
  10437. * The value we should increment the property by.
  10438. */
  10439. value: any;
  10440. private _target;
  10441. private _effectiveTarget;
  10442. private _property;
  10443. /**
  10444. * Instantiate the action
  10445. * @param triggerOptions defines the trigger options
  10446. * @param target defines the object containing the property
  10447. * @param propertyPath defines the path of the property to increment in the target
  10448. * @param value defines the value value we should increment the property by
  10449. * @param condition defines the trigger related conditions
  10450. */
  10451. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10452. /** @hidden */
  10453. _prepare(): void;
  10454. /**
  10455. * Execute the action and increment the target of the value amount.
  10456. */
  10457. execute(): void;
  10458. /**
  10459. * Serializes the actions and its related information.
  10460. * @param parent defines the object to serialize in
  10461. * @returns the serialized object
  10462. */
  10463. serialize(parent: any): any;
  10464. }
  10465. /**
  10466. * This defines an action responsible to start an animation once triggered.
  10467. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10468. */
  10469. export class PlayAnimationAction extends Action {
  10470. /**
  10471. * Where the animation should start (animation frame)
  10472. */
  10473. from: number;
  10474. /**
  10475. * Where the animation should stop (animation frame)
  10476. */
  10477. to: number;
  10478. /**
  10479. * Define if the animation should loop or stop after the first play.
  10480. */
  10481. loop?: boolean;
  10482. private _target;
  10483. /**
  10484. * Instantiate the action
  10485. * @param triggerOptions defines the trigger options
  10486. * @param target defines the target animation or animation name
  10487. * @param from defines from where the animation should start (animation frame)
  10488. * @param end defines where the animation should stop (animation frame)
  10489. * @param loop defines if the animation should loop or stop after the first play
  10490. * @param condition defines the trigger related conditions
  10491. */
  10492. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10493. /** @hidden */
  10494. _prepare(): void;
  10495. /**
  10496. * Execute the action and play the animation.
  10497. */
  10498. execute(): void;
  10499. /**
  10500. * Serializes the actions and its related information.
  10501. * @param parent defines the object to serialize in
  10502. * @returns the serialized object
  10503. */
  10504. serialize(parent: any): any;
  10505. }
  10506. /**
  10507. * This defines an action responsible to stop an animation once triggered.
  10508. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10509. */
  10510. export class StopAnimationAction extends Action {
  10511. private _target;
  10512. /**
  10513. * Instantiate the action
  10514. * @param triggerOptions defines the trigger options
  10515. * @param target defines the target animation or animation name
  10516. * @param condition defines the trigger related conditions
  10517. */
  10518. constructor(triggerOptions: any, target: any, condition?: Condition);
  10519. /** @hidden */
  10520. _prepare(): void;
  10521. /**
  10522. * Execute the action and stop the animation.
  10523. */
  10524. execute(): void;
  10525. /**
  10526. * Serializes the actions and its related information.
  10527. * @param parent defines the object to serialize in
  10528. * @returns the serialized object
  10529. */
  10530. serialize(parent: any): any;
  10531. }
  10532. /**
  10533. * This defines an action responsible that does nothing once triggered.
  10534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10535. */
  10536. export class DoNothingAction extends Action {
  10537. /**
  10538. * Instantiate the action
  10539. * @param triggerOptions defines the trigger options
  10540. * @param condition defines the trigger related conditions
  10541. */
  10542. constructor(triggerOptions?: any, condition?: Condition);
  10543. /**
  10544. * Execute the action and do nothing.
  10545. */
  10546. execute(): void;
  10547. /**
  10548. * Serializes the actions and its related information.
  10549. * @param parent defines the object to serialize in
  10550. * @returns the serialized object
  10551. */
  10552. serialize(parent: any): any;
  10553. }
  10554. /**
  10555. * This defines an action responsible to trigger several actions once triggered.
  10556. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10557. */
  10558. export class CombineAction extends Action {
  10559. /**
  10560. * The list of aggregated animations to run.
  10561. */
  10562. children: Action[];
  10563. /**
  10564. * Instantiate the action
  10565. * @param triggerOptions defines the trigger options
  10566. * @param children defines the list of aggregated animations to run
  10567. * @param condition defines the trigger related conditions
  10568. */
  10569. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10570. /** @hidden */
  10571. _prepare(): void;
  10572. /**
  10573. * Execute the action and executes all the aggregated actions.
  10574. */
  10575. execute(evt: ActionEvent): void;
  10576. /**
  10577. * Serializes the actions and its related information.
  10578. * @param parent defines the object to serialize in
  10579. * @returns the serialized object
  10580. */
  10581. serialize(parent: any): any;
  10582. }
  10583. /**
  10584. * This defines an action responsible to run code (external event) once triggered.
  10585. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10586. */
  10587. export class ExecuteCodeAction extends Action {
  10588. /**
  10589. * The callback function to run.
  10590. */
  10591. func: (evt: ActionEvent) => void;
  10592. /**
  10593. * Instantiate the action
  10594. * @param triggerOptions defines the trigger options
  10595. * @param func defines the callback function to run
  10596. * @param condition defines the trigger related conditions
  10597. */
  10598. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10599. /**
  10600. * Execute the action and run the attached code.
  10601. */
  10602. execute(evt: ActionEvent): void;
  10603. }
  10604. /**
  10605. * This defines an action responsible to set the parent property of the target once triggered.
  10606. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10607. */
  10608. export class SetParentAction extends Action {
  10609. private _parent;
  10610. private _target;
  10611. /**
  10612. * Instantiate the action
  10613. * @param triggerOptions defines the trigger options
  10614. * @param target defines the target containing the parent property
  10615. * @param parent defines from where the animation should start (animation frame)
  10616. * @param condition defines the trigger related conditions
  10617. */
  10618. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10619. /** @hidden */
  10620. _prepare(): void;
  10621. /**
  10622. * Execute the action and set the parent property.
  10623. */
  10624. execute(): void;
  10625. /**
  10626. * Serializes the actions and its related information.
  10627. * @param parent defines the object to serialize in
  10628. * @returns the serialized object
  10629. */
  10630. serialize(parent: any): any;
  10631. }
  10632. }
  10633. declare module BABYLON {
  10634. /**
  10635. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10636. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10637. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10638. */
  10639. export class ActionManager extends AbstractActionManager {
  10640. /**
  10641. * Nothing
  10642. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10643. */
  10644. static readonly NothingTrigger: number;
  10645. /**
  10646. * On pick
  10647. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10648. */
  10649. static readonly OnPickTrigger: number;
  10650. /**
  10651. * On left pick
  10652. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10653. */
  10654. static readonly OnLeftPickTrigger: number;
  10655. /**
  10656. * On right pick
  10657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10658. */
  10659. static readonly OnRightPickTrigger: number;
  10660. /**
  10661. * On center pick
  10662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10663. */
  10664. static readonly OnCenterPickTrigger: number;
  10665. /**
  10666. * On pick down
  10667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10668. */
  10669. static readonly OnPickDownTrigger: number;
  10670. /**
  10671. * On double pick
  10672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10673. */
  10674. static readonly OnDoublePickTrigger: number;
  10675. /**
  10676. * On pick up
  10677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10678. */
  10679. static readonly OnPickUpTrigger: number;
  10680. /**
  10681. * On pick out.
  10682. * This trigger will only be raised if you also declared a OnPickDown
  10683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10684. */
  10685. static readonly OnPickOutTrigger: number;
  10686. /**
  10687. * On long press
  10688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10689. */
  10690. static readonly OnLongPressTrigger: number;
  10691. /**
  10692. * On pointer over
  10693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10694. */
  10695. static readonly OnPointerOverTrigger: number;
  10696. /**
  10697. * On pointer out
  10698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10699. */
  10700. static readonly OnPointerOutTrigger: number;
  10701. /**
  10702. * On every frame
  10703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10704. */
  10705. static readonly OnEveryFrameTrigger: number;
  10706. /**
  10707. * On intersection enter
  10708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10709. */
  10710. static readonly OnIntersectionEnterTrigger: number;
  10711. /**
  10712. * On intersection exit
  10713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10714. */
  10715. static readonly OnIntersectionExitTrigger: number;
  10716. /**
  10717. * On key down
  10718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10719. */
  10720. static readonly OnKeyDownTrigger: number;
  10721. /**
  10722. * On key up
  10723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10724. */
  10725. static readonly OnKeyUpTrigger: number;
  10726. private _scene;
  10727. /**
  10728. * Creates a new action manager
  10729. * @param scene defines the hosting scene
  10730. */
  10731. constructor(scene: Scene);
  10732. /**
  10733. * Releases all associated resources
  10734. */
  10735. dispose(): void;
  10736. /**
  10737. * Gets hosting scene
  10738. * @returns the hosting scene
  10739. */
  10740. getScene(): Scene;
  10741. /**
  10742. * Does this action manager handles actions of any of the given triggers
  10743. * @param triggers defines the triggers to be tested
  10744. * @return a boolean indicating whether one (or more) of the triggers is handled
  10745. */
  10746. hasSpecificTriggers(triggers: number[]): boolean;
  10747. /**
  10748. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10749. * speed.
  10750. * @param triggerA defines the trigger to be tested
  10751. * @param triggerB defines the trigger to be tested
  10752. * @return a boolean indicating whether one (or more) of the triggers is handled
  10753. */
  10754. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10755. /**
  10756. * Does this action manager handles actions of a given trigger
  10757. * @param trigger defines the trigger to be tested
  10758. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10759. * @return whether the trigger is handled
  10760. */
  10761. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10762. /**
  10763. * Does this action manager has pointer triggers
  10764. */
  10765. readonly hasPointerTriggers: boolean;
  10766. /**
  10767. * Does this action manager has pick triggers
  10768. */
  10769. readonly hasPickTriggers: boolean;
  10770. /**
  10771. * Registers an action to this action manager
  10772. * @param action defines the action to be registered
  10773. * @return the action amended (prepared) after registration
  10774. */
  10775. registerAction(action: IAction): Nullable<IAction>;
  10776. /**
  10777. * Unregisters an action to this action manager
  10778. * @param action defines the action to be unregistered
  10779. * @return a boolean indicating whether the action has been unregistered
  10780. */
  10781. unregisterAction(action: IAction): Boolean;
  10782. /**
  10783. * Process a specific trigger
  10784. * @param trigger defines the trigger to process
  10785. * @param evt defines the event details to be processed
  10786. */
  10787. processTrigger(trigger: number, evt?: IActionEvent): void;
  10788. /** @hidden */
  10789. _getEffectiveTarget(target: any, propertyPath: string): any;
  10790. /** @hidden */
  10791. _getProperty(propertyPath: string): string;
  10792. /**
  10793. * Serialize this manager to a JSON object
  10794. * @param name defines the property name to store this manager
  10795. * @returns a JSON representation of this manager
  10796. */
  10797. serialize(name: string): any;
  10798. /**
  10799. * Creates a new ActionManager from a JSON data
  10800. * @param parsedActions defines the JSON data to read from
  10801. * @param object defines the hosting mesh
  10802. * @param scene defines the hosting scene
  10803. */
  10804. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10805. /**
  10806. * Get a trigger name by index
  10807. * @param trigger defines the trigger index
  10808. * @returns a trigger name
  10809. */
  10810. static GetTriggerName(trigger: number): string;
  10811. }
  10812. }
  10813. declare module BABYLON {
  10814. /**
  10815. * Class representing a ray with position and direction
  10816. */
  10817. export class Ray {
  10818. /** origin point */
  10819. origin: Vector3;
  10820. /** direction */
  10821. direction: Vector3;
  10822. /** length of the ray */
  10823. length: number;
  10824. private static readonly TmpVector3;
  10825. private _tmpRay;
  10826. /**
  10827. * Creates a new ray
  10828. * @param origin origin point
  10829. * @param direction direction
  10830. * @param length length of the ray
  10831. */
  10832. constructor(
  10833. /** origin point */
  10834. origin: Vector3,
  10835. /** direction */
  10836. direction: Vector3,
  10837. /** length of the ray */
  10838. length?: number);
  10839. /**
  10840. * Checks if the ray intersects a box
  10841. * @param minimum bound of the box
  10842. * @param maximum bound of the box
  10843. * @param intersectionTreshold extra extend to be added to the box in all direction
  10844. * @returns if the box was hit
  10845. */
  10846. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10847. /**
  10848. * Checks if the ray intersects a box
  10849. * @param box the bounding box to check
  10850. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10851. * @returns if the box was hit
  10852. */
  10853. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10854. /**
  10855. * If the ray hits a sphere
  10856. * @param sphere the bounding sphere to check
  10857. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10858. * @returns true if it hits the sphere
  10859. */
  10860. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10861. /**
  10862. * If the ray hits a triange
  10863. * @param vertex0 triangle vertex
  10864. * @param vertex1 triangle vertex
  10865. * @param vertex2 triangle vertex
  10866. * @returns intersection information if hit
  10867. */
  10868. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10869. /**
  10870. * Checks if ray intersects a plane
  10871. * @param plane the plane to check
  10872. * @returns the distance away it was hit
  10873. */
  10874. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10875. /**
  10876. * Calculate the intercept of a ray on a given axis
  10877. * @param axis to check 'x' | 'y' | 'z'
  10878. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10879. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10880. */
  10881. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10882. /**
  10883. * Checks if ray intersects a mesh
  10884. * @param mesh the mesh to check
  10885. * @param fastCheck if only the bounding box should checked
  10886. * @returns picking info of the intersecton
  10887. */
  10888. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10889. /**
  10890. * Checks if ray intersects a mesh
  10891. * @param meshes the meshes to check
  10892. * @param fastCheck if only the bounding box should checked
  10893. * @param results array to store result in
  10894. * @returns Array of picking infos
  10895. */
  10896. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10897. private _comparePickingInfo;
  10898. private static smallnum;
  10899. private static rayl;
  10900. /**
  10901. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10902. * @param sega the first point of the segment to test the intersection against
  10903. * @param segb the second point of the segment to test the intersection against
  10904. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10905. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10906. */
  10907. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10908. /**
  10909. * Update the ray from viewport position
  10910. * @param x position
  10911. * @param y y position
  10912. * @param viewportWidth viewport width
  10913. * @param viewportHeight viewport height
  10914. * @param world world matrix
  10915. * @param view view matrix
  10916. * @param projection projection matrix
  10917. * @returns this ray updated
  10918. */
  10919. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10920. /**
  10921. * Creates a ray with origin and direction of 0,0,0
  10922. * @returns the new ray
  10923. */
  10924. static Zero(): Ray;
  10925. /**
  10926. * Creates a new ray from screen space and viewport
  10927. * @param x position
  10928. * @param y y position
  10929. * @param viewportWidth viewport width
  10930. * @param viewportHeight viewport height
  10931. * @param world world matrix
  10932. * @param view view matrix
  10933. * @param projection projection matrix
  10934. * @returns new ray
  10935. */
  10936. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10937. /**
  10938. * 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
  10939. * transformed to the given world matrix.
  10940. * @param origin The origin point
  10941. * @param end The end point
  10942. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10943. * @returns the new ray
  10944. */
  10945. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10946. /**
  10947. * Transforms a ray by a matrix
  10948. * @param ray ray to transform
  10949. * @param matrix matrix to apply
  10950. * @returns the resulting new ray
  10951. */
  10952. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10953. /**
  10954. * Transforms a ray by a matrix
  10955. * @param ray ray to transform
  10956. * @param matrix matrix to apply
  10957. * @param result ray to store result in
  10958. */
  10959. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10960. /**
  10961. * Unproject a ray from screen space to object space
  10962. * @param sourceX defines the screen space x coordinate to use
  10963. * @param sourceY defines the screen space y coordinate to use
  10964. * @param viewportWidth defines the current width of the viewport
  10965. * @param viewportHeight defines the current height of the viewport
  10966. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10967. * @param view defines the view matrix to use
  10968. * @param projection defines the projection matrix to use
  10969. */
  10970. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10971. }
  10972. /**
  10973. * Type used to define predicate used to select faces when a mesh intersection is detected
  10974. */
  10975. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10976. interface Scene {
  10977. /** @hidden */
  10978. _tempPickingRay: Nullable<Ray>;
  10979. /** @hidden */
  10980. _cachedRayForTransform: Ray;
  10981. /** @hidden */
  10982. _pickWithRayInverseMatrix: Matrix;
  10983. /** @hidden */
  10984. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10985. /** @hidden */
  10986. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10987. }
  10988. }
  10989. declare module BABYLON {
  10990. /**
  10991. * Groups all the scene component constants in one place to ease maintenance.
  10992. * @hidden
  10993. */
  10994. export class SceneComponentConstants {
  10995. static readonly NAME_EFFECTLAYER: string;
  10996. static readonly NAME_LAYER: string;
  10997. static readonly NAME_LENSFLARESYSTEM: string;
  10998. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10999. static readonly NAME_PARTICLESYSTEM: string;
  11000. static readonly NAME_GAMEPAD: string;
  11001. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11002. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11003. static readonly NAME_DEPTHRENDERER: string;
  11004. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11005. static readonly NAME_SPRITE: string;
  11006. static readonly NAME_OUTLINERENDERER: string;
  11007. static readonly NAME_PROCEDURALTEXTURE: string;
  11008. static readonly NAME_SHADOWGENERATOR: string;
  11009. static readonly NAME_OCTREE: string;
  11010. static readonly NAME_PHYSICSENGINE: string;
  11011. static readonly NAME_AUDIO: string;
  11012. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11013. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11014. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11015. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11016. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11017. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11018. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11019. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11020. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11021. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11022. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11023. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11024. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11025. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11026. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11027. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11028. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11029. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11030. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11031. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11032. static readonly STEP_AFTERRENDER_AUDIO: number;
  11033. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11034. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11035. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11036. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11037. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11038. static readonly STEP_POINTERMOVE_SPRITE: number;
  11039. static readonly STEP_POINTERDOWN_SPRITE: number;
  11040. static readonly STEP_POINTERUP_SPRITE: number;
  11041. }
  11042. /**
  11043. * This represents a scene component.
  11044. *
  11045. * This is used to decouple the dependency the scene is having on the different workloads like
  11046. * layers, post processes...
  11047. */
  11048. export interface ISceneComponent {
  11049. /**
  11050. * The name of the component. Each component must have a unique name.
  11051. */
  11052. name: string;
  11053. /**
  11054. * The scene the component belongs to.
  11055. */
  11056. scene: Scene;
  11057. /**
  11058. * Register the component to one instance of a scene.
  11059. */
  11060. register(): void;
  11061. /**
  11062. * Rebuilds the elements related to this component in case of
  11063. * context lost for instance.
  11064. */
  11065. rebuild(): void;
  11066. /**
  11067. * Disposes the component and the associated ressources.
  11068. */
  11069. dispose(): void;
  11070. }
  11071. /**
  11072. * This represents a SERIALIZABLE scene component.
  11073. *
  11074. * This extends Scene Component to add Serialization methods on top.
  11075. */
  11076. export interface ISceneSerializableComponent extends ISceneComponent {
  11077. /**
  11078. * Adds all the elements from the container to the scene
  11079. * @param container the container holding the elements
  11080. */
  11081. addFromContainer(container: AbstractScene): void;
  11082. /**
  11083. * Removes all the elements in the container from the scene
  11084. * @param container contains the elements to remove
  11085. * @param dispose if the removed element should be disposed (default: false)
  11086. */
  11087. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11088. /**
  11089. * Serializes the component data to the specified json object
  11090. * @param serializationObject The object to serialize to
  11091. */
  11092. serialize(serializationObject: any): void;
  11093. }
  11094. /**
  11095. * Strong typing of a Mesh related stage step action
  11096. */
  11097. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11098. /**
  11099. * Strong typing of a Evaluate Sub Mesh related stage step action
  11100. */
  11101. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11102. /**
  11103. * Strong typing of a Active Mesh related stage step action
  11104. */
  11105. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11106. /**
  11107. * Strong typing of a Camera related stage step action
  11108. */
  11109. export type CameraStageAction = (camera: Camera) => void;
  11110. /**
  11111. * Strong typing of a Camera Frame buffer related stage step action
  11112. */
  11113. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11114. /**
  11115. * Strong typing of a Render Target related stage step action
  11116. */
  11117. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11118. /**
  11119. * Strong typing of a RenderingGroup related stage step action
  11120. */
  11121. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11122. /**
  11123. * Strong typing of a Mesh Render related stage step action
  11124. */
  11125. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11126. /**
  11127. * Strong typing of a simple stage step action
  11128. */
  11129. export type SimpleStageAction = () => void;
  11130. /**
  11131. * Strong typing of a render target action.
  11132. */
  11133. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11134. /**
  11135. * Strong typing of a pointer move action.
  11136. */
  11137. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11138. /**
  11139. * Strong typing of a pointer up/down action.
  11140. */
  11141. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11142. /**
  11143. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11144. * @hidden
  11145. */
  11146. export class Stage<T extends Function> extends Array<{
  11147. index: number;
  11148. component: ISceneComponent;
  11149. action: T;
  11150. }> {
  11151. /**
  11152. * Hide ctor from the rest of the world.
  11153. * @param items The items to add.
  11154. */
  11155. private constructor();
  11156. /**
  11157. * Creates a new Stage.
  11158. * @returns A new instance of a Stage
  11159. */
  11160. static Create<T extends Function>(): Stage<T>;
  11161. /**
  11162. * Registers a step in an ordered way in the targeted stage.
  11163. * @param index Defines the position to register the step in
  11164. * @param component Defines the component attached to the step
  11165. * @param action Defines the action to launch during the step
  11166. */
  11167. registerStep(index: number, component: ISceneComponent, action: T): void;
  11168. /**
  11169. * Clears all the steps from the stage.
  11170. */
  11171. clear(): void;
  11172. }
  11173. }
  11174. declare module BABYLON {
  11175. interface Scene {
  11176. /** @hidden */
  11177. _pointerOverSprite: Nullable<Sprite>;
  11178. /** @hidden */
  11179. _pickedDownSprite: Nullable<Sprite>;
  11180. /** @hidden */
  11181. _tempSpritePickingRay: Nullable<Ray>;
  11182. /**
  11183. * All of the sprite managers added to this scene
  11184. * @see http://doc.babylonjs.com/babylon101/sprites
  11185. */
  11186. spriteManagers: Array<ISpriteManager>;
  11187. /**
  11188. * An event triggered when sprites rendering is about to start
  11189. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11190. */
  11191. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11192. /**
  11193. * An event triggered when sprites rendering is done
  11194. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11195. */
  11196. onAfterSpritesRenderingObservable: Observable<Scene>;
  11197. /** @hidden */
  11198. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11199. /** Launch a ray to try to pick a sprite in the scene
  11200. * @param x position on screen
  11201. * @param y position on screen
  11202. * @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
  11203. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11204. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11205. * @returns a PickingInfo
  11206. */
  11207. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11208. /** Use the given ray to pick a sprite in the scene
  11209. * @param ray The ray (in world space) to use to pick meshes
  11210. * @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
  11211. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11212. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11213. * @returns a PickingInfo
  11214. */
  11215. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11216. /**
  11217. * Force the sprite under the pointer
  11218. * @param sprite defines the sprite to use
  11219. */
  11220. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11221. /**
  11222. * Gets the sprite under the pointer
  11223. * @returns a Sprite or null if no sprite is under the pointer
  11224. */
  11225. getPointerOverSprite(): Nullable<Sprite>;
  11226. }
  11227. /**
  11228. * Defines the sprite scene component responsible to manage sprites
  11229. * in a given scene.
  11230. */
  11231. export class SpriteSceneComponent implements ISceneComponent {
  11232. /**
  11233. * The component name helpfull to identify the component in the list of scene components.
  11234. */
  11235. readonly name: string;
  11236. /**
  11237. * The scene the component belongs to.
  11238. */
  11239. scene: Scene;
  11240. /** @hidden */
  11241. private _spritePredicate;
  11242. /**
  11243. * Creates a new instance of the component for the given scene
  11244. * @param scene Defines the scene to register the component in
  11245. */
  11246. constructor(scene: Scene);
  11247. /**
  11248. * Registers the component in a given scene
  11249. */
  11250. register(): void;
  11251. /**
  11252. * Rebuilds the elements related to this component in case of
  11253. * context lost for instance.
  11254. */
  11255. rebuild(): void;
  11256. /**
  11257. * Disposes the component and the associated ressources.
  11258. */
  11259. dispose(): void;
  11260. private _pickSpriteButKeepRay;
  11261. private _pointerMove;
  11262. private _pointerDown;
  11263. private _pointerUp;
  11264. }
  11265. }
  11266. declare module BABYLON {
  11267. /** @hidden */
  11268. export var fogFragmentDeclaration: {
  11269. name: string;
  11270. shader: string;
  11271. };
  11272. }
  11273. declare module BABYLON {
  11274. /** @hidden */
  11275. export var fogFragment: {
  11276. name: string;
  11277. shader: string;
  11278. };
  11279. }
  11280. declare module BABYLON {
  11281. /** @hidden */
  11282. export var spritesPixelShader: {
  11283. name: string;
  11284. shader: string;
  11285. };
  11286. }
  11287. declare module BABYLON {
  11288. /** @hidden */
  11289. export var fogVertexDeclaration: {
  11290. name: string;
  11291. shader: string;
  11292. };
  11293. }
  11294. declare module BABYLON {
  11295. /** @hidden */
  11296. export var spritesVertexShader: {
  11297. name: string;
  11298. shader: string;
  11299. };
  11300. }
  11301. declare module BABYLON {
  11302. /**
  11303. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11304. */
  11305. export interface ISpriteManager extends IDisposable {
  11306. /**
  11307. * Restricts the camera to viewing objects with the same layerMask.
  11308. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11309. */
  11310. layerMask: number;
  11311. /**
  11312. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11313. */
  11314. isPickable: boolean;
  11315. /**
  11316. * Specifies the rendering group id for this mesh (0 by default)
  11317. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11318. */
  11319. renderingGroupId: number;
  11320. /**
  11321. * Defines the list of sprites managed by the manager.
  11322. */
  11323. sprites: Array<Sprite>;
  11324. /**
  11325. * Tests the intersection of a sprite with a specific ray.
  11326. * @param ray The ray we are sending to test the collision
  11327. * @param camera The camera space we are sending rays in
  11328. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11329. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11330. * @returns picking info or null.
  11331. */
  11332. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11333. /**
  11334. * Renders the list of sprites on screen.
  11335. */
  11336. render(): void;
  11337. }
  11338. /**
  11339. * Class used to manage multiple sprites on the same spritesheet
  11340. * @see http://doc.babylonjs.com/babylon101/sprites
  11341. */
  11342. export class SpriteManager implements ISpriteManager {
  11343. /** defines the manager's name */
  11344. name: string;
  11345. /** Gets the list of sprites */
  11346. sprites: Sprite[];
  11347. /** Gets or sets the rendering group id (0 by default) */
  11348. renderingGroupId: number;
  11349. /** Gets or sets camera layer mask */
  11350. layerMask: number;
  11351. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11352. fogEnabled: boolean;
  11353. /** Gets or sets a boolean indicating if the sprites are pickable */
  11354. isPickable: boolean;
  11355. /** Defines the default width of a cell in the spritesheet */
  11356. cellWidth: number;
  11357. /** Defines the default height of a cell in the spritesheet */
  11358. cellHeight: number;
  11359. /**
  11360. * An event triggered when the manager is disposed.
  11361. */
  11362. onDisposeObservable: Observable<SpriteManager>;
  11363. private _onDisposeObserver;
  11364. /**
  11365. * Callback called when the manager is disposed
  11366. */
  11367. onDispose: () => void;
  11368. private _capacity;
  11369. private _spriteTexture;
  11370. private _epsilon;
  11371. private _scene;
  11372. private _vertexData;
  11373. private _buffer;
  11374. private _vertexBuffers;
  11375. private _indexBuffer;
  11376. private _effectBase;
  11377. private _effectFog;
  11378. /**
  11379. * Gets or sets the spritesheet texture
  11380. */
  11381. texture: Texture;
  11382. /**
  11383. * Creates a new sprite manager
  11384. * @param name defines the manager's name
  11385. * @param imgUrl defines the sprite sheet url
  11386. * @param capacity defines the maximum allowed number of sprites
  11387. * @param cellSize defines the size of a sprite cell
  11388. * @param scene defines the hosting scene
  11389. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11390. * @param samplingMode defines the smapling mode to use with spritesheet
  11391. */
  11392. constructor(
  11393. /** defines the manager's name */
  11394. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11395. private _appendSpriteVertex;
  11396. /**
  11397. * Intersects the sprites with a ray
  11398. * @param ray defines the ray to intersect with
  11399. * @param camera defines the current active camera
  11400. * @param predicate defines a predicate used to select candidate sprites
  11401. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11402. * @returns null if no hit or a PickingInfo
  11403. */
  11404. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11405. /**
  11406. * Render all child sprites
  11407. */
  11408. render(): void;
  11409. /**
  11410. * Release associated resources
  11411. */
  11412. dispose(): void;
  11413. }
  11414. }
  11415. declare module BABYLON {
  11416. /**
  11417. * Class used to represent a sprite
  11418. * @see http://doc.babylonjs.com/babylon101/sprites
  11419. */
  11420. export class Sprite {
  11421. /** defines the name */
  11422. name: string;
  11423. /** Gets or sets the current world position */
  11424. position: Vector3;
  11425. /** Gets or sets the main color */
  11426. color: Color4;
  11427. /** Gets or sets the width */
  11428. width: number;
  11429. /** Gets or sets the height */
  11430. height: number;
  11431. /** Gets or sets rotation angle */
  11432. angle: number;
  11433. /** Gets or sets the cell index in the sprite sheet */
  11434. cellIndex: number;
  11435. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11436. invertU: number;
  11437. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11438. invertV: number;
  11439. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11440. disposeWhenFinishedAnimating: boolean;
  11441. /** Gets the list of attached animations */
  11442. animations: Animation[];
  11443. /** Gets or sets a boolean indicating if the sprite can be picked */
  11444. isPickable: boolean;
  11445. /**
  11446. * Gets or sets the associated action manager
  11447. */
  11448. actionManager: Nullable<ActionManager>;
  11449. private _animationStarted;
  11450. private _loopAnimation;
  11451. private _fromIndex;
  11452. private _toIndex;
  11453. private _delay;
  11454. private _direction;
  11455. private _manager;
  11456. private _time;
  11457. private _onAnimationEnd;
  11458. /**
  11459. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11460. */
  11461. isVisible: boolean;
  11462. /**
  11463. * Gets or sets the sprite size
  11464. */
  11465. size: number;
  11466. /**
  11467. * Creates a new Sprite
  11468. * @param name defines the name
  11469. * @param manager defines the manager
  11470. */
  11471. constructor(
  11472. /** defines the name */
  11473. name: string, manager: ISpriteManager);
  11474. /**
  11475. * Starts an animation
  11476. * @param from defines the initial key
  11477. * @param to defines the end key
  11478. * @param loop defines if the animation must loop
  11479. * @param delay defines the start delay (in ms)
  11480. * @param onAnimationEnd defines a callback to call when animation ends
  11481. */
  11482. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11483. /** Stops current animation (if any) */
  11484. stopAnimation(): void;
  11485. /** @hidden */
  11486. _animate(deltaTime: number): void;
  11487. /** Release associated resources */
  11488. dispose(): void;
  11489. }
  11490. }
  11491. declare module BABYLON {
  11492. /**
  11493. * Information about the result of picking within a scene
  11494. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11495. */
  11496. export class PickingInfo {
  11497. /** @hidden */
  11498. _pickingUnavailable: boolean;
  11499. /**
  11500. * If the pick collided with an object
  11501. */
  11502. hit: boolean;
  11503. /**
  11504. * Distance away where the pick collided
  11505. */
  11506. distance: number;
  11507. /**
  11508. * The location of pick collision
  11509. */
  11510. pickedPoint: Nullable<Vector3>;
  11511. /**
  11512. * The mesh corresponding the the pick collision
  11513. */
  11514. pickedMesh: Nullable<AbstractMesh>;
  11515. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11516. bu: number;
  11517. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11518. bv: number;
  11519. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11520. faceId: number;
  11521. /** Id of the the submesh that was picked */
  11522. subMeshId: number;
  11523. /** If a sprite was picked, this will be the sprite the pick collided with */
  11524. pickedSprite: Nullable<Sprite>;
  11525. /**
  11526. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11527. */
  11528. originMesh: Nullable<AbstractMesh>;
  11529. /**
  11530. * The ray that was used to perform the picking.
  11531. */
  11532. ray: Nullable<Ray>;
  11533. /**
  11534. * Gets the normal correspodning to the face the pick collided with
  11535. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11536. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11537. * @returns The normal correspodning to the face the pick collided with
  11538. */
  11539. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11540. /**
  11541. * Gets the texture coordinates of where the pick occured
  11542. * @returns the vector containing the coordnates of the texture
  11543. */
  11544. getTextureCoordinates(): Nullable<Vector2>;
  11545. }
  11546. }
  11547. declare module BABYLON {
  11548. /**
  11549. * Gather the list of pointer event types as constants.
  11550. */
  11551. export class PointerEventTypes {
  11552. /**
  11553. * 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.
  11554. */
  11555. static readonly POINTERDOWN: number;
  11556. /**
  11557. * The pointerup event is fired when a pointer is no longer active.
  11558. */
  11559. static readonly POINTERUP: number;
  11560. /**
  11561. * The pointermove event is fired when a pointer changes coordinates.
  11562. */
  11563. static readonly POINTERMOVE: number;
  11564. /**
  11565. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11566. */
  11567. static readonly POINTERWHEEL: number;
  11568. /**
  11569. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11570. */
  11571. static readonly POINTERPICK: number;
  11572. /**
  11573. * The pointertap event is fired when a the object has been touched and released without drag.
  11574. */
  11575. static readonly POINTERTAP: number;
  11576. /**
  11577. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11578. */
  11579. static readonly POINTERDOUBLETAP: number;
  11580. }
  11581. /**
  11582. * Base class of pointer info types.
  11583. */
  11584. export class PointerInfoBase {
  11585. /**
  11586. * Defines the type of event (PointerEventTypes)
  11587. */
  11588. type: number;
  11589. /**
  11590. * Defines the related dom event
  11591. */
  11592. event: PointerEvent | MouseWheelEvent;
  11593. /**
  11594. * Instantiates the base class of pointers info.
  11595. * @param type Defines the type of event (PointerEventTypes)
  11596. * @param event Defines the related dom event
  11597. */
  11598. constructor(
  11599. /**
  11600. * Defines the type of event (PointerEventTypes)
  11601. */
  11602. type: number,
  11603. /**
  11604. * Defines the related dom event
  11605. */
  11606. event: PointerEvent | MouseWheelEvent);
  11607. }
  11608. /**
  11609. * This class is used to store pointer related info for the onPrePointerObservable event.
  11610. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11611. */
  11612. export class PointerInfoPre extends PointerInfoBase {
  11613. /**
  11614. * Ray from a pointer if availible (eg. 6dof controller)
  11615. */
  11616. ray: Nullable<Ray>;
  11617. /**
  11618. * Defines the local position of the pointer on the canvas.
  11619. */
  11620. localPosition: Vector2;
  11621. /**
  11622. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11623. */
  11624. skipOnPointerObservable: boolean;
  11625. /**
  11626. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11627. * @param type Defines the type of event (PointerEventTypes)
  11628. * @param event Defines the related dom event
  11629. * @param localX Defines the local x coordinates of the pointer when the event occured
  11630. * @param localY Defines the local y coordinates of the pointer when the event occured
  11631. */
  11632. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11633. }
  11634. /**
  11635. * This type contains all the data related to a pointer event in Babylon.js.
  11636. * 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.
  11637. */
  11638. export class PointerInfo extends PointerInfoBase {
  11639. /**
  11640. * Defines the picking info associated to the info (if any)\
  11641. */
  11642. pickInfo: Nullable<PickingInfo>;
  11643. /**
  11644. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11645. * @param type Defines the type of event (PointerEventTypes)
  11646. * @param event Defines the related dom event
  11647. * @param pickInfo Defines the picking info associated to the info (if any)\
  11648. */
  11649. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11650. /**
  11651. * Defines the picking info associated to the info (if any)\
  11652. */
  11653. pickInfo: Nullable<PickingInfo>);
  11654. }
  11655. /**
  11656. * Data relating to a touch event on the screen.
  11657. */
  11658. export interface PointerTouch {
  11659. /**
  11660. * X coordinate of touch.
  11661. */
  11662. x: number;
  11663. /**
  11664. * Y coordinate of touch.
  11665. */
  11666. y: number;
  11667. /**
  11668. * Id of touch. Unique for each finger.
  11669. */
  11670. pointerId: number;
  11671. /**
  11672. * Event type passed from DOM.
  11673. */
  11674. type: any;
  11675. }
  11676. }
  11677. declare module BABYLON {
  11678. /**
  11679. * Manage the mouse inputs to control the movement of a free camera.
  11680. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11681. */
  11682. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11683. /**
  11684. * Define if touch is enabled in the mouse input
  11685. */
  11686. touchEnabled: boolean;
  11687. /**
  11688. * Defines the camera the input is attached to.
  11689. */
  11690. camera: FreeCamera;
  11691. /**
  11692. * Defines the buttons associated with the input to handle camera move.
  11693. */
  11694. buttons: number[];
  11695. /**
  11696. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11697. */
  11698. angularSensibility: number;
  11699. private _pointerInput;
  11700. private _onMouseMove;
  11701. private _observer;
  11702. private previousPosition;
  11703. /**
  11704. * Observable for when a pointer move event occurs containing the move offset
  11705. */
  11706. onPointerMovedObservable: Observable<{
  11707. offsetX: number;
  11708. offsetY: number;
  11709. }>;
  11710. /**
  11711. * @hidden
  11712. * If the camera should be rotated automatically based on pointer movement
  11713. */
  11714. _allowCameraRotation: boolean;
  11715. /**
  11716. * Manage the mouse inputs to control the movement of a free camera.
  11717. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11718. * @param touchEnabled Defines if touch is enabled or not
  11719. */
  11720. constructor(
  11721. /**
  11722. * Define if touch is enabled in the mouse input
  11723. */
  11724. touchEnabled?: boolean);
  11725. /**
  11726. * Attach the input controls to a specific dom element to get the input from.
  11727. * @param element Defines the element the controls should be listened from
  11728. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11729. */
  11730. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11731. /**
  11732. * Called on JS contextmenu event.
  11733. * Override this method to provide functionality.
  11734. */
  11735. protected onContextMenu(evt: PointerEvent): void;
  11736. /**
  11737. * Detach the current controls from the specified dom element.
  11738. * @param element Defines the element to stop listening the inputs from
  11739. */
  11740. detachControl(element: Nullable<HTMLElement>): void;
  11741. /**
  11742. * Gets the class name of the current intput.
  11743. * @returns the class name
  11744. */
  11745. getClassName(): string;
  11746. /**
  11747. * Get the friendly name associated with the input class.
  11748. * @returns the input friendly name
  11749. */
  11750. getSimpleName(): string;
  11751. }
  11752. }
  11753. declare module BABYLON {
  11754. /**
  11755. * Manage the touch inputs to control the movement of a free camera.
  11756. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11757. */
  11758. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11759. /**
  11760. * Defines the camera the input is attached to.
  11761. */
  11762. camera: FreeCamera;
  11763. /**
  11764. * Defines the touch sensibility for rotation.
  11765. * The higher the faster.
  11766. */
  11767. touchAngularSensibility: number;
  11768. /**
  11769. * Defines the touch sensibility for move.
  11770. * The higher the faster.
  11771. */
  11772. touchMoveSensibility: number;
  11773. private _offsetX;
  11774. private _offsetY;
  11775. private _pointerPressed;
  11776. private _pointerInput;
  11777. private _observer;
  11778. private _onLostFocus;
  11779. /**
  11780. * Attach the input controls to a specific dom element to get the input from.
  11781. * @param element Defines the element the controls should be listened from
  11782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11783. */
  11784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11785. /**
  11786. * Detach the current controls from the specified dom element.
  11787. * @param element Defines the element to stop listening the inputs from
  11788. */
  11789. detachControl(element: Nullable<HTMLElement>): void;
  11790. /**
  11791. * Update the current camera state depending on the inputs that have been used this frame.
  11792. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11793. */
  11794. checkInputs(): void;
  11795. /**
  11796. * Gets the class name of the current intput.
  11797. * @returns the class name
  11798. */
  11799. getClassName(): string;
  11800. /**
  11801. * Get the friendly name associated with the input class.
  11802. * @returns the input friendly name
  11803. */
  11804. getSimpleName(): string;
  11805. }
  11806. }
  11807. declare module BABYLON {
  11808. /**
  11809. * Default Inputs manager for the FreeCamera.
  11810. * It groups all the default supported inputs for ease of use.
  11811. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11812. */
  11813. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11814. /**
  11815. * @hidden
  11816. */
  11817. _mouseInput: Nullable<FreeCameraMouseInput>;
  11818. /**
  11819. * Instantiates a new FreeCameraInputsManager.
  11820. * @param camera Defines the camera the inputs belong to
  11821. */
  11822. constructor(camera: FreeCamera);
  11823. /**
  11824. * Add keyboard input support to the input manager.
  11825. * @returns the current input manager
  11826. */
  11827. addKeyboard(): FreeCameraInputsManager;
  11828. /**
  11829. * Add mouse input support to the input manager.
  11830. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11831. * @returns the current input manager
  11832. */
  11833. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11834. /**
  11835. * Removes the mouse input support from the manager
  11836. * @returns the current input manager
  11837. */
  11838. removeMouse(): FreeCameraInputsManager;
  11839. /**
  11840. * Add touch input support to the input manager.
  11841. * @returns the current input manager
  11842. */
  11843. addTouch(): FreeCameraInputsManager;
  11844. /**
  11845. * Remove all attached input methods from a camera
  11846. */
  11847. clear(): void;
  11848. }
  11849. }
  11850. declare module BABYLON {
  11851. /**
  11852. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11853. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11854. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11855. */
  11856. export class FreeCamera extends TargetCamera {
  11857. /**
  11858. * Define the collision ellipsoid of the camera.
  11859. * This is helpful to simulate a camera body like the player body around the camera
  11860. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11861. */
  11862. ellipsoid: Vector3;
  11863. /**
  11864. * Define an offset for the position of the ellipsoid around the camera.
  11865. * This can be helpful to determine the center of the body near the gravity center of the body
  11866. * instead of its head.
  11867. */
  11868. ellipsoidOffset: Vector3;
  11869. /**
  11870. * Enable or disable collisions of the camera with the rest of the scene objects.
  11871. */
  11872. checkCollisions: boolean;
  11873. /**
  11874. * Enable or disable gravity on the camera.
  11875. */
  11876. applyGravity: boolean;
  11877. /**
  11878. * Define the input manager associated to the camera.
  11879. */
  11880. inputs: FreeCameraInputsManager;
  11881. /**
  11882. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11883. * Higher values reduce sensitivity.
  11884. */
  11885. /**
  11886. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11887. * Higher values reduce sensitivity.
  11888. */
  11889. angularSensibility: number;
  11890. /**
  11891. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11892. */
  11893. keysUp: number[];
  11894. /**
  11895. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11896. */
  11897. keysDown: number[];
  11898. /**
  11899. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11900. */
  11901. keysLeft: number[];
  11902. /**
  11903. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11904. */
  11905. keysRight: number[];
  11906. /**
  11907. * Event raised when the camera collide with a mesh in the scene.
  11908. */
  11909. onCollide: (collidedMesh: AbstractMesh) => void;
  11910. private _collider;
  11911. private _needMoveForGravity;
  11912. private _oldPosition;
  11913. private _diffPosition;
  11914. private _newPosition;
  11915. /** @hidden */
  11916. _localDirection: Vector3;
  11917. /** @hidden */
  11918. _transformedDirection: Vector3;
  11919. /**
  11920. * Instantiates a Free Camera.
  11921. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11922. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11923. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11924. * @param name Define the name of the camera in the scene
  11925. * @param position Define the start position of the camera in the scene
  11926. * @param scene Define the scene the camera belongs to
  11927. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11928. */
  11929. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11930. /**
  11931. * Attached controls to the current camera.
  11932. * @param element Defines the element the controls should be listened from
  11933. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11934. */
  11935. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11936. /**
  11937. * Detach the current controls from the camera.
  11938. * The camera will stop reacting to inputs.
  11939. * @param element Defines the element to stop listening the inputs from
  11940. */
  11941. detachControl(element: HTMLElement): void;
  11942. private _collisionMask;
  11943. /**
  11944. * Define a collision mask to limit the list of object the camera can collide with
  11945. */
  11946. collisionMask: number;
  11947. /** @hidden */
  11948. _collideWithWorld(displacement: Vector3): void;
  11949. private _onCollisionPositionChange;
  11950. /** @hidden */
  11951. _checkInputs(): void;
  11952. /** @hidden */
  11953. _decideIfNeedsToMove(): boolean;
  11954. /** @hidden */
  11955. _updatePosition(): void;
  11956. /**
  11957. * Destroy the camera and release the current resources hold by it.
  11958. */
  11959. dispose(): void;
  11960. /**
  11961. * Gets the current object class name.
  11962. * @return the class name
  11963. */
  11964. getClassName(): string;
  11965. }
  11966. }
  11967. declare module BABYLON {
  11968. /**
  11969. * Represents a gamepad control stick position
  11970. */
  11971. export class StickValues {
  11972. /**
  11973. * The x component of the control stick
  11974. */
  11975. x: number;
  11976. /**
  11977. * The y component of the control stick
  11978. */
  11979. y: number;
  11980. /**
  11981. * Initializes the gamepad x and y control stick values
  11982. * @param x The x component of the gamepad control stick value
  11983. * @param y The y component of the gamepad control stick value
  11984. */
  11985. constructor(
  11986. /**
  11987. * The x component of the control stick
  11988. */
  11989. x: number,
  11990. /**
  11991. * The y component of the control stick
  11992. */
  11993. y: number);
  11994. }
  11995. /**
  11996. * An interface which manages callbacks for gamepad button changes
  11997. */
  11998. export interface GamepadButtonChanges {
  11999. /**
  12000. * Called when a gamepad has been changed
  12001. */
  12002. changed: boolean;
  12003. /**
  12004. * Called when a gamepad press event has been triggered
  12005. */
  12006. pressChanged: boolean;
  12007. /**
  12008. * Called when a touch event has been triggered
  12009. */
  12010. touchChanged: boolean;
  12011. /**
  12012. * Called when a value has changed
  12013. */
  12014. valueChanged: boolean;
  12015. }
  12016. /**
  12017. * Represents a gamepad
  12018. */
  12019. export class Gamepad {
  12020. /**
  12021. * The id of the gamepad
  12022. */
  12023. id: string;
  12024. /**
  12025. * The index of the gamepad
  12026. */
  12027. index: number;
  12028. /**
  12029. * The browser gamepad
  12030. */
  12031. browserGamepad: any;
  12032. /**
  12033. * Specifies what type of gamepad this represents
  12034. */
  12035. type: number;
  12036. private _leftStick;
  12037. private _rightStick;
  12038. /** @hidden */
  12039. _isConnected: boolean;
  12040. private _leftStickAxisX;
  12041. private _leftStickAxisY;
  12042. private _rightStickAxisX;
  12043. private _rightStickAxisY;
  12044. /**
  12045. * Triggered when the left control stick has been changed
  12046. */
  12047. private _onleftstickchanged;
  12048. /**
  12049. * Triggered when the right control stick has been changed
  12050. */
  12051. private _onrightstickchanged;
  12052. /**
  12053. * Represents a gamepad controller
  12054. */
  12055. static GAMEPAD: number;
  12056. /**
  12057. * Represents a generic controller
  12058. */
  12059. static GENERIC: number;
  12060. /**
  12061. * Represents an XBox controller
  12062. */
  12063. static XBOX: number;
  12064. /**
  12065. * Represents a pose-enabled controller
  12066. */
  12067. static POSE_ENABLED: number;
  12068. /**
  12069. * Specifies whether the left control stick should be Y-inverted
  12070. */
  12071. protected _invertLeftStickY: boolean;
  12072. /**
  12073. * Specifies if the gamepad has been connected
  12074. */
  12075. readonly isConnected: boolean;
  12076. /**
  12077. * Initializes the gamepad
  12078. * @param id The id of the gamepad
  12079. * @param index The index of the gamepad
  12080. * @param browserGamepad The browser gamepad
  12081. * @param leftStickX The x component of the left joystick
  12082. * @param leftStickY The y component of the left joystick
  12083. * @param rightStickX The x component of the right joystick
  12084. * @param rightStickY The y component of the right joystick
  12085. */
  12086. constructor(
  12087. /**
  12088. * The id of the gamepad
  12089. */
  12090. id: string,
  12091. /**
  12092. * The index of the gamepad
  12093. */
  12094. index: number,
  12095. /**
  12096. * The browser gamepad
  12097. */
  12098. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12099. /**
  12100. * Callback triggered when the left joystick has changed
  12101. * @param callback
  12102. */
  12103. onleftstickchanged(callback: (values: StickValues) => void): void;
  12104. /**
  12105. * Callback triggered when the right joystick has changed
  12106. * @param callback
  12107. */
  12108. onrightstickchanged(callback: (values: StickValues) => void): void;
  12109. /**
  12110. * Gets the left joystick
  12111. */
  12112. /**
  12113. * Sets the left joystick values
  12114. */
  12115. leftStick: StickValues;
  12116. /**
  12117. * Gets the right joystick
  12118. */
  12119. /**
  12120. * Sets the right joystick value
  12121. */
  12122. rightStick: StickValues;
  12123. /**
  12124. * Updates the gamepad joystick positions
  12125. */
  12126. update(): void;
  12127. /**
  12128. * Disposes the gamepad
  12129. */
  12130. dispose(): void;
  12131. }
  12132. /**
  12133. * Represents a generic gamepad
  12134. */
  12135. export class GenericPad extends Gamepad {
  12136. private _buttons;
  12137. private _onbuttondown;
  12138. private _onbuttonup;
  12139. /**
  12140. * Observable triggered when a button has been pressed
  12141. */
  12142. onButtonDownObservable: Observable<number>;
  12143. /**
  12144. * Observable triggered when a button has been released
  12145. */
  12146. onButtonUpObservable: Observable<number>;
  12147. /**
  12148. * Callback triggered when a button has been pressed
  12149. * @param callback Called when a button has been pressed
  12150. */
  12151. onbuttondown(callback: (buttonPressed: number) => void): void;
  12152. /**
  12153. * Callback triggered when a button has been released
  12154. * @param callback Called when a button has been released
  12155. */
  12156. onbuttonup(callback: (buttonReleased: number) => void): void;
  12157. /**
  12158. * Initializes the generic gamepad
  12159. * @param id The id of the generic gamepad
  12160. * @param index The index of the generic gamepad
  12161. * @param browserGamepad The browser gamepad
  12162. */
  12163. constructor(id: string, index: number, browserGamepad: any);
  12164. private _setButtonValue;
  12165. /**
  12166. * Updates the generic gamepad
  12167. */
  12168. update(): void;
  12169. /**
  12170. * Disposes the generic gamepad
  12171. */
  12172. dispose(): void;
  12173. }
  12174. }
  12175. declare module BABYLON {
  12176. interface Engine {
  12177. /**
  12178. * Creates a raw texture
  12179. * @param data defines the data to store in the texture
  12180. * @param width defines the width of the texture
  12181. * @param height defines the height of the texture
  12182. * @param format defines the format of the data
  12183. * @param generateMipMaps defines if the engine should generate the mip levels
  12184. * @param invertY defines if data must be stored with Y axis inverted
  12185. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12186. * @param compression defines the compression used (null by default)
  12187. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12188. * @returns the raw texture inside an InternalTexture
  12189. */
  12190. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12191. /**
  12192. * Update a raw texture
  12193. * @param texture defines the texture to update
  12194. * @param data defines the data to store in the texture
  12195. * @param format defines the format of the data
  12196. * @param invertY defines if data must be stored with Y axis inverted
  12197. */
  12198. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12199. /**
  12200. * Update a raw texture
  12201. * @param texture defines the texture to update
  12202. * @param data defines the data to store in the texture
  12203. * @param format defines the format of the data
  12204. * @param invertY defines if data must be stored with Y axis inverted
  12205. * @param compression defines the compression used (null by default)
  12206. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12207. */
  12208. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12209. /**
  12210. * Creates a new raw cube texture
  12211. * @param data defines the array of data to use to create each face
  12212. * @param size defines the size of the textures
  12213. * @param format defines the format of the data
  12214. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12215. * @param generateMipMaps defines if the engine should generate the mip levels
  12216. * @param invertY defines if data must be stored with Y axis inverted
  12217. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12218. * @param compression defines the compression used (null by default)
  12219. * @returns the cube texture as an InternalTexture
  12220. */
  12221. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12222. /**
  12223. * Update a raw cube texture
  12224. * @param texture defines the texture to udpdate
  12225. * @param data defines the data to store
  12226. * @param format defines the data format
  12227. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12228. * @param invertY defines if data must be stored with Y axis inverted
  12229. */
  12230. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12231. /**
  12232. * Update a raw cube texture
  12233. * @param texture defines the texture to udpdate
  12234. * @param data defines the data to store
  12235. * @param format defines the data format
  12236. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12237. * @param invertY defines if data must be stored with Y axis inverted
  12238. * @param compression defines the compression used (null by default)
  12239. */
  12240. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12241. /**
  12242. * Update a raw cube texture
  12243. * @param texture defines the texture to udpdate
  12244. * @param data defines the data to store
  12245. * @param format defines the data format
  12246. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12247. * @param invertY defines if data must be stored with Y axis inverted
  12248. * @param compression defines the compression used (null by default)
  12249. * @param level defines which level of the texture to update
  12250. */
  12251. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12252. /**
  12253. * Creates a new raw cube texture from a specified url
  12254. * @param url defines the url where the data is located
  12255. * @param scene defines the current scene
  12256. * @param size defines the size of the textures
  12257. * @param format defines the format of the data
  12258. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12259. * @param noMipmap defines if the engine should avoid generating the mip levels
  12260. * @param callback defines a callback used to extract texture data from loaded data
  12261. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12262. * @param onLoad defines a callback called when texture is loaded
  12263. * @param onError defines a callback called if there is an error
  12264. * @returns the cube texture as an InternalTexture
  12265. */
  12266. 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;
  12267. /**
  12268. * Creates a new raw cube texture from a specified url
  12269. * @param url defines the url where the data is located
  12270. * @param scene defines the current scene
  12271. * @param size defines the size of the textures
  12272. * @param format defines the format of the data
  12273. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12274. * @param noMipmap defines if the engine should avoid generating the mip levels
  12275. * @param callback defines a callback used to extract texture data from loaded data
  12276. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12277. * @param onLoad defines a callback called when texture is loaded
  12278. * @param onError defines a callback called if there is an error
  12279. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12280. * @param invertY defines if data must be stored with Y axis inverted
  12281. * @returns the cube texture as an InternalTexture
  12282. */
  12283. 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;
  12284. /**
  12285. * Creates a new raw 3D texture
  12286. * @param data defines the data used to create the texture
  12287. * @param width defines the width of the texture
  12288. * @param height defines the height of the texture
  12289. * @param depth defines the depth of the texture
  12290. * @param format defines the format of the texture
  12291. * @param generateMipMaps defines if the engine must generate mip levels
  12292. * @param invertY defines if data must be stored with Y axis inverted
  12293. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12294. * @param compression defines the compressed used (can be null)
  12295. * @param textureType defines the compressed used (can be null)
  12296. * @returns a new raw 3D texture (stored in an InternalTexture)
  12297. */
  12298. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12299. /**
  12300. * Update a raw 3D texture
  12301. * @param texture defines the texture to update
  12302. * @param data defines the data to store
  12303. * @param format defines the data format
  12304. * @param invertY defines if data must be stored with Y axis inverted
  12305. */
  12306. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12307. /**
  12308. * Update a raw 3D texture
  12309. * @param texture defines the texture to update
  12310. * @param data defines the data to store
  12311. * @param format defines the data format
  12312. * @param invertY defines if data must be stored with Y axis inverted
  12313. * @param compression defines the used compression (can be null)
  12314. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12315. */
  12316. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12317. }
  12318. }
  12319. declare module BABYLON {
  12320. /**
  12321. * Raw texture can help creating a texture directly from an array of data.
  12322. * This can be super useful if you either get the data from an uncompressed source or
  12323. * if you wish to create your texture pixel by pixel.
  12324. */
  12325. export class RawTexture extends Texture {
  12326. /**
  12327. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12328. */
  12329. format: number;
  12330. private _engine;
  12331. /**
  12332. * Instantiates a new RawTexture.
  12333. * Raw texture can help creating a texture directly from an array of data.
  12334. * This can be super useful if you either get the data from an uncompressed source or
  12335. * if you wish to create your texture pixel by pixel.
  12336. * @param data define the array of data to use to create the texture
  12337. * @param width define the width of the texture
  12338. * @param height define the height of the texture
  12339. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12340. * @param scene define the scene the texture belongs to
  12341. * @param generateMipMaps define whether mip maps should be generated or not
  12342. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12343. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12344. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12345. */
  12346. constructor(data: ArrayBufferView, width: number, height: number,
  12347. /**
  12348. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12349. */
  12350. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12351. /**
  12352. * Updates the texture underlying data.
  12353. * @param data Define the new data of the texture
  12354. */
  12355. update(data: ArrayBufferView): void;
  12356. /**
  12357. * Creates a luminance texture from some data.
  12358. * @param data Define the texture data
  12359. * @param width Define the width of the texture
  12360. * @param height Define the height of the texture
  12361. * @param scene Define the scene the texture belongs to
  12362. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12363. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12364. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12365. * @returns the luminance texture
  12366. */
  12367. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12368. /**
  12369. * Creates a luminance alpha texture from some data.
  12370. * @param data Define the texture data
  12371. * @param width Define the width of the texture
  12372. * @param height Define the height of the texture
  12373. * @param scene Define the scene the texture belongs to
  12374. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12375. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12376. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12377. * @returns the luminance alpha texture
  12378. */
  12379. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12380. /**
  12381. * Creates an alpha texture from some data.
  12382. * @param data Define the texture data
  12383. * @param width Define the width of the texture
  12384. * @param height Define the height of the texture
  12385. * @param scene Define the scene the texture belongs to
  12386. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12387. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12388. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12389. * @returns the alpha texture
  12390. */
  12391. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12392. /**
  12393. * Creates a RGB texture from some data.
  12394. * @param data Define the texture data
  12395. * @param width Define the width of the texture
  12396. * @param height Define the height of the texture
  12397. * @param scene Define the scene the texture belongs to
  12398. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12399. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12400. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12401. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12402. * @returns the RGB alpha texture
  12403. */
  12404. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12405. /**
  12406. * Creates a RGBA texture from some data.
  12407. * @param data Define the texture data
  12408. * @param width Define the width of the texture
  12409. * @param height Define the height of the texture
  12410. * @param scene Define the scene the texture belongs to
  12411. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12412. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12413. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12414. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12415. * @returns the RGBA texture
  12416. */
  12417. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12418. /**
  12419. * Creates a R texture from some data.
  12420. * @param data Define the texture data
  12421. * @param width Define the width of the texture
  12422. * @param height Define the height of the texture
  12423. * @param scene Define the scene the texture belongs to
  12424. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12425. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12426. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12427. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12428. * @returns the R texture
  12429. */
  12430. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12431. }
  12432. }
  12433. declare module BABYLON {
  12434. /**
  12435. * Interface for the size containing width and height
  12436. */
  12437. export interface ISize {
  12438. /**
  12439. * Width
  12440. */
  12441. width: number;
  12442. /**
  12443. * Heighht
  12444. */
  12445. height: number;
  12446. }
  12447. /**
  12448. * Size containing widht and height
  12449. */
  12450. export class Size implements ISize {
  12451. /**
  12452. * Width
  12453. */
  12454. width: number;
  12455. /**
  12456. * Height
  12457. */
  12458. height: number;
  12459. /**
  12460. * Creates a Size object from the given width and height (floats).
  12461. * @param width width of the new size
  12462. * @param height height of the new size
  12463. */
  12464. constructor(width: number, height: number);
  12465. /**
  12466. * Returns a string with the Size width and height
  12467. * @returns a string with the Size width and height
  12468. */
  12469. toString(): string;
  12470. /**
  12471. * "Size"
  12472. * @returns the string "Size"
  12473. */
  12474. getClassName(): string;
  12475. /**
  12476. * Returns the Size hash code.
  12477. * @returns a hash code for a unique width and height
  12478. */
  12479. getHashCode(): number;
  12480. /**
  12481. * Updates the current size from the given one.
  12482. * @param src the given size
  12483. */
  12484. copyFrom(src: Size): void;
  12485. /**
  12486. * Updates in place the current Size from the given floats.
  12487. * @param width width of the new size
  12488. * @param height height of the new size
  12489. * @returns the updated Size.
  12490. */
  12491. copyFromFloats(width: number, height: number): Size;
  12492. /**
  12493. * Updates in place the current Size from the given floats.
  12494. * @param width width to set
  12495. * @param height height to set
  12496. * @returns the updated Size.
  12497. */
  12498. set(width: number, height: number): Size;
  12499. /**
  12500. * Multiplies the width and height by numbers
  12501. * @param w factor to multiple the width by
  12502. * @param h factor to multiple the height by
  12503. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12504. */
  12505. multiplyByFloats(w: number, h: number): Size;
  12506. /**
  12507. * Clones the size
  12508. * @returns a new Size copied from the given one.
  12509. */
  12510. clone(): Size;
  12511. /**
  12512. * True if the current Size and the given one width and height are strictly equal.
  12513. * @param other the other size to compare against
  12514. * @returns True if the current Size and the given one width and height are strictly equal.
  12515. */
  12516. equals(other: Size): boolean;
  12517. /**
  12518. * The surface of the Size : width * height (float).
  12519. */
  12520. readonly surface: number;
  12521. /**
  12522. * Create a new size of zero
  12523. * @returns a new Size set to (0.0, 0.0)
  12524. */
  12525. static Zero(): Size;
  12526. /**
  12527. * Sums the width and height of two sizes
  12528. * @param otherSize size to add to this size
  12529. * @returns a new Size set as the addition result of the current Size and the given one.
  12530. */
  12531. add(otherSize: Size): Size;
  12532. /**
  12533. * Subtracts the width and height of two
  12534. * @param otherSize size to subtract to this size
  12535. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12536. */
  12537. subtract(otherSize: Size): Size;
  12538. /**
  12539. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12540. * @param start starting size to lerp between
  12541. * @param end end size to lerp between
  12542. * @param amount amount to lerp between the start and end values
  12543. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12544. */
  12545. static Lerp(start: Size, end: Size, amount: number): Size;
  12546. }
  12547. }
  12548. declare module BABYLON {
  12549. /**
  12550. * Defines a runtime animation
  12551. */
  12552. export class RuntimeAnimation {
  12553. private _events;
  12554. /**
  12555. * The current frame of the runtime animation
  12556. */
  12557. private _currentFrame;
  12558. /**
  12559. * The animation used by the runtime animation
  12560. */
  12561. private _animation;
  12562. /**
  12563. * The target of the runtime animation
  12564. */
  12565. private _target;
  12566. /**
  12567. * The initiating animatable
  12568. */
  12569. private _host;
  12570. /**
  12571. * The original value of the runtime animation
  12572. */
  12573. private _originalValue;
  12574. /**
  12575. * The original blend value of the runtime animation
  12576. */
  12577. private _originalBlendValue;
  12578. /**
  12579. * The offsets cache of the runtime animation
  12580. */
  12581. private _offsetsCache;
  12582. /**
  12583. * The high limits cache of the runtime animation
  12584. */
  12585. private _highLimitsCache;
  12586. /**
  12587. * Specifies if the runtime animation has been stopped
  12588. */
  12589. private _stopped;
  12590. /**
  12591. * The blending factor of the runtime animation
  12592. */
  12593. private _blendingFactor;
  12594. /**
  12595. * The BabylonJS scene
  12596. */
  12597. private _scene;
  12598. /**
  12599. * The current value of the runtime animation
  12600. */
  12601. private _currentValue;
  12602. /** @hidden */
  12603. _animationState: _IAnimationState;
  12604. /**
  12605. * The active target of the runtime animation
  12606. */
  12607. private _activeTargets;
  12608. private _currentActiveTarget;
  12609. private _directTarget;
  12610. /**
  12611. * The target path of the runtime animation
  12612. */
  12613. private _targetPath;
  12614. /**
  12615. * The weight of the runtime animation
  12616. */
  12617. private _weight;
  12618. /**
  12619. * The ratio offset of the runtime animation
  12620. */
  12621. private _ratioOffset;
  12622. /**
  12623. * The previous delay of the runtime animation
  12624. */
  12625. private _previousDelay;
  12626. /**
  12627. * The previous ratio of the runtime animation
  12628. */
  12629. private _previousRatio;
  12630. private _enableBlending;
  12631. private _keys;
  12632. private _minFrame;
  12633. private _maxFrame;
  12634. private _minValue;
  12635. private _maxValue;
  12636. private _targetIsArray;
  12637. /**
  12638. * Gets the current frame of the runtime animation
  12639. */
  12640. readonly currentFrame: number;
  12641. /**
  12642. * Gets the weight of the runtime animation
  12643. */
  12644. readonly weight: number;
  12645. /**
  12646. * Gets the current value of the runtime animation
  12647. */
  12648. readonly currentValue: any;
  12649. /**
  12650. * Gets the target path of the runtime animation
  12651. */
  12652. readonly targetPath: string;
  12653. /**
  12654. * Gets the actual target of the runtime animation
  12655. */
  12656. readonly target: any;
  12657. /** @hidden */
  12658. _onLoop: () => void;
  12659. /**
  12660. * Create a new RuntimeAnimation object
  12661. * @param target defines the target of the animation
  12662. * @param animation defines the source animation object
  12663. * @param scene defines the hosting scene
  12664. * @param host defines the initiating Animatable
  12665. */
  12666. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12667. private _preparePath;
  12668. /**
  12669. * Gets the animation from the runtime animation
  12670. */
  12671. readonly animation: Animation;
  12672. /**
  12673. * Resets the runtime animation to the beginning
  12674. * @param restoreOriginal defines whether to restore the target property to the original value
  12675. */
  12676. reset(restoreOriginal?: boolean): void;
  12677. /**
  12678. * Specifies if the runtime animation is stopped
  12679. * @returns Boolean specifying if the runtime animation is stopped
  12680. */
  12681. isStopped(): boolean;
  12682. /**
  12683. * Disposes of the runtime animation
  12684. */
  12685. dispose(): void;
  12686. /**
  12687. * Apply the interpolated value to the target
  12688. * @param currentValue defines the value computed by the animation
  12689. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12690. */
  12691. setValue(currentValue: any, weight: number): void;
  12692. private _getOriginalValues;
  12693. private _setValue;
  12694. /**
  12695. * Gets the loop pmode of the runtime animation
  12696. * @returns Loop Mode
  12697. */
  12698. private _getCorrectLoopMode;
  12699. /**
  12700. * Move the current animation to a given frame
  12701. * @param frame defines the frame to move to
  12702. */
  12703. goToFrame(frame: number): void;
  12704. /**
  12705. * @hidden Internal use only
  12706. */
  12707. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12708. /**
  12709. * Execute the current animation
  12710. * @param delay defines the delay to add to the current frame
  12711. * @param from defines the lower bound of the animation range
  12712. * @param to defines the upper bound of the animation range
  12713. * @param loop defines if the current animation must loop
  12714. * @param speedRatio defines the current speed ratio
  12715. * @param weight defines the weight of the animation (default is -1 so no weight)
  12716. * @param onLoop optional callback called when animation loops
  12717. * @returns a boolean indicating if the animation is running
  12718. */
  12719. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12720. }
  12721. }
  12722. declare module BABYLON {
  12723. /**
  12724. * Class used to store an actual running animation
  12725. */
  12726. export class Animatable {
  12727. /** defines the target object */
  12728. target: any;
  12729. /** defines the starting frame number (default is 0) */
  12730. fromFrame: number;
  12731. /** defines the ending frame number (default is 100) */
  12732. toFrame: number;
  12733. /** defines if the animation must loop (default is false) */
  12734. loopAnimation: boolean;
  12735. /** defines a callback to call when animation ends if it is not looping */
  12736. onAnimationEnd?: (() => void) | null | undefined;
  12737. /** defines a callback to call when animation loops */
  12738. onAnimationLoop?: (() => void) | null | undefined;
  12739. private _localDelayOffset;
  12740. private _pausedDelay;
  12741. private _runtimeAnimations;
  12742. private _paused;
  12743. private _scene;
  12744. private _speedRatio;
  12745. private _weight;
  12746. private _syncRoot;
  12747. /**
  12748. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12749. * This will only apply for non looping animation (default is true)
  12750. */
  12751. disposeOnEnd: boolean;
  12752. /**
  12753. * Gets a boolean indicating if the animation has started
  12754. */
  12755. animationStarted: boolean;
  12756. /**
  12757. * Observer raised when the animation ends
  12758. */
  12759. onAnimationEndObservable: Observable<Animatable>;
  12760. /**
  12761. * Observer raised when the animation loops
  12762. */
  12763. onAnimationLoopObservable: Observable<Animatable>;
  12764. /**
  12765. * Gets the root Animatable used to synchronize and normalize animations
  12766. */
  12767. readonly syncRoot: Nullable<Animatable>;
  12768. /**
  12769. * Gets the current frame of the first RuntimeAnimation
  12770. * Used to synchronize Animatables
  12771. */
  12772. readonly masterFrame: number;
  12773. /**
  12774. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12775. */
  12776. weight: number;
  12777. /**
  12778. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12779. */
  12780. speedRatio: number;
  12781. /**
  12782. * Creates a new Animatable
  12783. * @param scene defines the hosting scene
  12784. * @param target defines the target object
  12785. * @param fromFrame defines the starting frame number (default is 0)
  12786. * @param toFrame defines the ending frame number (default is 100)
  12787. * @param loopAnimation defines if the animation must loop (default is false)
  12788. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12789. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12790. * @param animations defines a group of animation to add to the new Animatable
  12791. * @param onAnimationLoop defines a callback to call when animation loops
  12792. */
  12793. constructor(scene: Scene,
  12794. /** defines the target object */
  12795. target: any,
  12796. /** defines the starting frame number (default is 0) */
  12797. fromFrame?: number,
  12798. /** defines the ending frame number (default is 100) */
  12799. toFrame?: number,
  12800. /** defines if the animation must loop (default is false) */
  12801. loopAnimation?: boolean, speedRatio?: number,
  12802. /** defines a callback to call when animation ends if it is not looping */
  12803. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12804. /** defines a callback to call when animation loops */
  12805. onAnimationLoop?: (() => void) | null | undefined);
  12806. /**
  12807. * Synchronize and normalize current Animatable with a source Animatable
  12808. * This is useful when using animation weights and when animations are not of the same length
  12809. * @param root defines the root Animatable to synchronize with
  12810. * @returns the current Animatable
  12811. */
  12812. syncWith(root: Animatable): Animatable;
  12813. /**
  12814. * Gets the list of runtime animations
  12815. * @returns an array of RuntimeAnimation
  12816. */
  12817. getAnimations(): RuntimeAnimation[];
  12818. /**
  12819. * Adds more animations to the current animatable
  12820. * @param target defines the target of the animations
  12821. * @param animations defines the new animations to add
  12822. */
  12823. appendAnimations(target: any, animations: Animation[]): void;
  12824. /**
  12825. * Gets the source animation for a specific property
  12826. * @param property defines the propertyu to look for
  12827. * @returns null or the source animation for the given property
  12828. */
  12829. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12830. /**
  12831. * Gets the runtime animation for a specific property
  12832. * @param property defines the propertyu to look for
  12833. * @returns null or the runtime animation for the given property
  12834. */
  12835. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12836. /**
  12837. * Resets the animatable to its original state
  12838. */
  12839. reset(): void;
  12840. /**
  12841. * Allows the animatable to blend with current running animations
  12842. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12843. * @param blendingSpeed defines the blending speed to use
  12844. */
  12845. enableBlending(blendingSpeed: number): void;
  12846. /**
  12847. * Disable animation blending
  12848. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12849. */
  12850. disableBlending(): void;
  12851. /**
  12852. * Jump directly to a given frame
  12853. * @param frame defines the frame to jump to
  12854. */
  12855. goToFrame(frame: number): void;
  12856. /**
  12857. * Pause the animation
  12858. */
  12859. pause(): void;
  12860. /**
  12861. * Restart the animation
  12862. */
  12863. restart(): void;
  12864. private _raiseOnAnimationEnd;
  12865. /**
  12866. * Stop and delete the current animation
  12867. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12868. * @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)
  12869. */
  12870. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12871. /**
  12872. * Wait asynchronously for the animation to end
  12873. * @returns a promise which will be fullfilled when the animation ends
  12874. */
  12875. waitAsync(): Promise<Animatable>;
  12876. /** @hidden */
  12877. _animate(delay: number): boolean;
  12878. }
  12879. interface Scene {
  12880. /** @hidden */
  12881. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12882. /** @hidden */
  12883. _processLateAnimationBindingsForMatrices(holder: {
  12884. totalWeight: number;
  12885. animations: RuntimeAnimation[];
  12886. originalValue: Matrix;
  12887. }): any;
  12888. /** @hidden */
  12889. _processLateAnimationBindingsForQuaternions(holder: {
  12890. totalWeight: number;
  12891. animations: RuntimeAnimation[];
  12892. originalValue: Quaternion;
  12893. }, refQuaternion: Quaternion): Quaternion;
  12894. /** @hidden */
  12895. _processLateAnimationBindings(): void;
  12896. /**
  12897. * Will start the animation sequence of a given target
  12898. * @param target defines the target
  12899. * @param from defines from which frame should animation start
  12900. * @param to defines until which frame should animation run.
  12901. * @param weight defines the weight to apply to the animation (1.0 by default)
  12902. * @param loop defines if the animation loops
  12903. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12904. * @param onAnimationEnd defines the function to be executed when the animation ends
  12905. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12906. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12907. * @param onAnimationLoop defines the callback to call when an animation loops
  12908. * @returns the animatable object created for this animation
  12909. */
  12910. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12911. /**
  12912. * Will start the animation sequence of a given target
  12913. * @param target defines the target
  12914. * @param from defines from which frame should animation start
  12915. * @param to defines until which frame should animation run.
  12916. * @param loop defines if the animation loops
  12917. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12918. * @param onAnimationEnd defines the function to be executed when the animation ends
  12919. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12920. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12921. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  12922. * @param onAnimationLoop defines the callback to call when an animation loops
  12923. * @returns the animatable object created for this animation
  12924. */
  12925. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12926. /**
  12927. * Will start the animation sequence of a given target and its hierarchy
  12928. * @param target defines the target
  12929. * @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.
  12930. * @param from defines from which frame should animation start
  12931. * @param to defines until which frame should animation run.
  12932. * @param loop defines if the animation loops
  12933. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12934. * @param onAnimationEnd defines the function to be executed when the animation ends
  12935. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12936. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12937. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12938. * @param onAnimationLoop defines the callback to call when an animation loops
  12939. * @returns the list of created animatables
  12940. */
  12941. 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[];
  12942. /**
  12943. * Begin a new animation on a given node
  12944. * @param target defines the target where the animation will take place
  12945. * @param animations defines the list of animations to start
  12946. * @param from defines the initial value
  12947. * @param to defines the final value
  12948. * @param loop defines if you want animation to loop (off by default)
  12949. * @param speedRatio defines the speed ratio to apply to all animations
  12950. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12951. * @param onAnimationLoop defines the callback to call when an animation loops
  12952. * @returns the list of created animatables
  12953. */
  12954. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  12955. /**
  12956. * Begin a new animation on a given node and its hierarchy
  12957. * @param target defines the root node where the animation will take place
  12958. * @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.
  12959. * @param animations defines the list of animations to start
  12960. * @param from defines the initial value
  12961. * @param to defines the final value
  12962. * @param loop defines if you want animation to loop (off by default)
  12963. * @param speedRatio defines the speed ratio to apply to all animations
  12964. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12965. * @param onAnimationLoop defines the callback to call when an animation loops
  12966. * @returns the list of animatables created for all nodes
  12967. */
  12968. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  12969. /**
  12970. * Gets the animatable associated with a specific target
  12971. * @param target defines the target of the animatable
  12972. * @returns the required animatable if found
  12973. */
  12974. getAnimatableByTarget(target: any): Nullable<Animatable>;
  12975. /**
  12976. * Gets all animatables associated with a given target
  12977. * @param target defines the target to look animatables for
  12978. * @returns an array of Animatables
  12979. */
  12980. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  12981. /**
  12982. * Stops and removes all animations that have been applied to the scene
  12983. */
  12984. stopAllAnimations(): void;
  12985. }
  12986. interface Bone {
  12987. /**
  12988. * Copy an animation range from another bone
  12989. * @param source defines the source bone
  12990. * @param rangeName defines the range name to copy
  12991. * @param frameOffset defines the frame offset
  12992. * @param rescaleAsRequired defines if rescaling must be applied if required
  12993. * @param skelDimensionsRatio defines the scaling ratio
  12994. * @returns true if operation was successful
  12995. */
  12996. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  12997. }
  12998. }
  12999. declare module BABYLON {
  13000. /**
  13001. * Class used to override all child animations of a given target
  13002. */
  13003. export class AnimationPropertiesOverride {
  13004. /**
  13005. * Gets or sets a value indicating if animation blending must be used
  13006. */
  13007. enableBlending: boolean;
  13008. /**
  13009. * Gets or sets the blending speed to use when enableBlending is true
  13010. */
  13011. blendingSpeed: number;
  13012. /**
  13013. * Gets or sets the default loop mode to use
  13014. */
  13015. loopMode: number;
  13016. }
  13017. }
  13018. declare module BABYLON {
  13019. /**
  13020. * Class used to handle skinning animations
  13021. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13022. */
  13023. export class Skeleton implements IAnimatable {
  13024. /** defines the skeleton name */
  13025. name: string;
  13026. /** defines the skeleton Id */
  13027. id: string;
  13028. /**
  13029. * Defines the list of child bones
  13030. */
  13031. bones: Bone[];
  13032. /**
  13033. * Defines an estimate of the dimension of the skeleton at rest
  13034. */
  13035. dimensionsAtRest: Vector3;
  13036. /**
  13037. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13038. */
  13039. needInitialSkinMatrix: boolean;
  13040. /**
  13041. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13042. */
  13043. overrideMesh: Nullable<AbstractMesh>;
  13044. /**
  13045. * Gets the list of animations attached to this skeleton
  13046. */
  13047. animations: Array<Animation>;
  13048. private _scene;
  13049. private _isDirty;
  13050. private _transformMatrices;
  13051. private _transformMatrixTexture;
  13052. private _meshesWithPoseMatrix;
  13053. private _animatables;
  13054. private _identity;
  13055. private _synchronizedWithMesh;
  13056. private _ranges;
  13057. private _lastAbsoluteTransformsUpdateId;
  13058. private _canUseTextureForBones;
  13059. private _uniqueId;
  13060. /** @hidden */
  13061. _numBonesWithLinkedTransformNode: number;
  13062. /** @hidden */
  13063. _hasWaitingData: Nullable<boolean>;
  13064. /**
  13065. * Specifies if the skeleton should be serialized
  13066. */
  13067. doNotSerialize: boolean;
  13068. private _useTextureToStoreBoneMatrices;
  13069. /**
  13070. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13071. * Please note that this option is not available if the hardware does not support it
  13072. */
  13073. useTextureToStoreBoneMatrices: boolean;
  13074. private _animationPropertiesOverride;
  13075. /**
  13076. * Gets or sets the animation properties override
  13077. */
  13078. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13079. /**
  13080. * List of inspectable custom properties (used by the Inspector)
  13081. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13082. */
  13083. inspectableCustomProperties: IInspectable[];
  13084. /**
  13085. * An observable triggered before computing the skeleton's matrices
  13086. */
  13087. onBeforeComputeObservable: Observable<Skeleton>;
  13088. /**
  13089. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13090. */
  13091. readonly isUsingTextureForMatrices: boolean;
  13092. /**
  13093. * Gets the unique ID of this skeleton
  13094. */
  13095. readonly uniqueId: number;
  13096. /**
  13097. * Creates a new skeleton
  13098. * @param name defines the skeleton name
  13099. * @param id defines the skeleton Id
  13100. * @param scene defines the hosting scene
  13101. */
  13102. constructor(
  13103. /** defines the skeleton name */
  13104. name: string,
  13105. /** defines the skeleton Id */
  13106. id: string, scene: Scene);
  13107. /**
  13108. * Gets the current object class name.
  13109. * @return the class name
  13110. */
  13111. getClassName(): string;
  13112. /**
  13113. * Returns an array containing the root bones
  13114. * @returns an array containing the root bones
  13115. */
  13116. getChildren(): Array<Bone>;
  13117. /**
  13118. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13119. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13120. * @returns a Float32Array containing matrices data
  13121. */
  13122. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13123. /**
  13124. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13125. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13126. * @returns a raw texture containing the data
  13127. */
  13128. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13129. /**
  13130. * Gets the current hosting scene
  13131. * @returns a scene object
  13132. */
  13133. getScene(): Scene;
  13134. /**
  13135. * Gets a string representing the current skeleton data
  13136. * @param fullDetails defines a boolean indicating if we want a verbose version
  13137. * @returns a string representing the current skeleton data
  13138. */
  13139. toString(fullDetails?: boolean): string;
  13140. /**
  13141. * Get bone's index searching by name
  13142. * @param name defines bone's name to search for
  13143. * @return the indice of the bone. Returns -1 if not found
  13144. */
  13145. getBoneIndexByName(name: string): number;
  13146. /**
  13147. * Creater a new animation range
  13148. * @param name defines the name of the range
  13149. * @param from defines the start key
  13150. * @param to defines the end key
  13151. */
  13152. createAnimationRange(name: string, from: number, to: number): void;
  13153. /**
  13154. * Delete a specific animation range
  13155. * @param name defines the name of the range
  13156. * @param deleteFrames defines if frames must be removed as well
  13157. */
  13158. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13159. /**
  13160. * Gets a specific animation range
  13161. * @param name defines the name of the range to look for
  13162. * @returns the requested animation range or null if not found
  13163. */
  13164. getAnimationRange(name: string): Nullable<AnimationRange>;
  13165. /**
  13166. * Gets the list of all animation ranges defined on this skeleton
  13167. * @returns an array
  13168. */
  13169. getAnimationRanges(): Nullable<AnimationRange>[];
  13170. /**
  13171. * Copy animation range from a source skeleton.
  13172. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13173. * @param source defines the source skeleton
  13174. * @param name defines the name of the range to copy
  13175. * @param rescaleAsRequired defines if rescaling must be applied if required
  13176. * @returns true if operation was successful
  13177. */
  13178. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13179. /**
  13180. * Forces the skeleton to go to rest pose
  13181. */
  13182. returnToRest(): void;
  13183. private _getHighestAnimationFrame;
  13184. /**
  13185. * Begin a specific animation range
  13186. * @param name defines the name of the range to start
  13187. * @param loop defines if looping must be turned on (false by default)
  13188. * @param speedRatio defines the speed ratio to apply (1 by default)
  13189. * @param onAnimationEnd defines a callback which will be called when animation will end
  13190. * @returns a new animatable
  13191. */
  13192. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13193. /** @hidden */
  13194. _markAsDirty(): void;
  13195. /** @hidden */
  13196. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13197. /** @hidden */
  13198. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13199. private _computeTransformMatrices;
  13200. /**
  13201. * Build all resources required to render a skeleton
  13202. */
  13203. prepare(): void;
  13204. /**
  13205. * Gets the list of animatables currently running for this skeleton
  13206. * @returns an array of animatables
  13207. */
  13208. getAnimatables(): IAnimatable[];
  13209. /**
  13210. * Clone the current skeleton
  13211. * @param name defines the name of the new skeleton
  13212. * @param id defines the id of the new skeleton
  13213. * @returns the new skeleton
  13214. */
  13215. clone(name: string, id: string): Skeleton;
  13216. /**
  13217. * Enable animation blending for this skeleton
  13218. * @param blendingSpeed defines the blending speed to apply
  13219. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13220. */
  13221. enableBlending(blendingSpeed?: number): void;
  13222. /**
  13223. * Releases all resources associated with the current skeleton
  13224. */
  13225. dispose(): void;
  13226. /**
  13227. * Serialize the skeleton in a JSON object
  13228. * @returns a JSON object
  13229. */
  13230. serialize(): any;
  13231. /**
  13232. * Creates a new skeleton from serialized data
  13233. * @param parsedSkeleton defines the serialized data
  13234. * @param scene defines the hosting scene
  13235. * @returns a new skeleton
  13236. */
  13237. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13238. /**
  13239. * Compute all node absolute transforms
  13240. * @param forceUpdate defines if computation must be done even if cache is up to date
  13241. */
  13242. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13243. /**
  13244. * Gets the root pose matrix
  13245. * @returns a matrix
  13246. */
  13247. getPoseMatrix(): Nullable<Matrix>;
  13248. /**
  13249. * Sorts bones per internal index
  13250. */
  13251. sortBones(): void;
  13252. private _sortBones;
  13253. }
  13254. }
  13255. declare module BABYLON {
  13256. /**
  13257. * Class used to store bone information
  13258. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13259. */
  13260. export class Bone extends Node {
  13261. /**
  13262. * defines the bone name
  13263. */
  13264. name: string;
  13265. private static _tmpVecs;
  13266. private static _tmpQuat;
  13267. private static _tmpMats;
  13268. /**
  13269. * Gets the list of child bones
  13270. */
  13271. children: Bone[];
  13272. /** Gets the animations associated with this bone */
  13273. animations: Animation[];
  13274. /**
  13275. * Gets or sets bone length
  13276. */
  13277. length: number;
  13278. /**
  13279. * @hidden Internal only
  13280. * Set this value to map this bone to a different index in the transform matrices
  13281. * Set this value to -1 to exclude the bone from the transform matrices
  13282. */
  13283. _index: Nullable<number>;
  13284. private _skeleton;
  13285. private _localMatrix;
  13286. private _restPose;
  13287. private _baseMatrix;
  13288. private _absoluteTransform;
  13289. private _invertedAbsoluteTransform;
  13290. private _parent;
  13291. private _scalingDeterminant;
  13292. private _worldTransform;
  13293. private _localScaling;
  13294. private _localRotation;
  13295. private _localPosition;
  13296. private _needToDecompose;
  13297. private _needToCompose;
  13298. /** @hidden */
  13299. _linkedTransformNode: Nullable<TransformNode>;
  13300. /** @hidden */
  13301. _waitingTransformNodeId: Nullable<string>;
  13302. /** @hidden */
  13303. /** @hidden */
  13304. _matrix: Matrix;
  13305. /**
  13306. * Create a new bone
  13307. * @param name defines the bone name
  13308. * @param skeleton defines the parent skeleton
  13309. * @param parentBone defines the parent (can be null if the bone is the root)
  13310. * @param localMatrix defines the local matrix
  13311. * @param restPose defines the rest pose matrix
  13312. * @param baseMatrix defines the base matrix
  13313. * @param index defines index of the bone in the hiearchy
  13314. */
  13315. constructor(
  13316. /**
  13317. * defines the bone name
  13318. */
  13319. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13320. /**
  13321. * Gets the current object class name.
  13322. * @return the class name
  13323. */
  13324. getClassName(): string;
  13325. /**
  13326. * Gets the parent skeleton
  13327. * @returns a skeleton
  13328. */
  13329. getSkeleton(): Skeleton;
  13330. /**
  13331. * Gets parent bone
  13332. * @returns a bone or null if the bone is the root of the bone hierarchy
  13333. */
  13334. getParent(): Nullable<Bone>;
  13335. /**
  13336. * Returns an array containing the root bones
  13337. * @returns an array containing the root bones
  13338. */
  13339. getChildren(): Array<Bone>;
  13340. /**
  13341. * Sets the parent bone
  13342. * @param parent defines the parent (can be null if the bone is the root)
  13343. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13344. */
  13345. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13346. /**
  13347. * Gets the local matrix
  13348. * @returns a matrix
  13349. */
  13350. getLocalMatrix(): Matrix;
  13351. /**
  13352. * Gets the base matrix (initial matrix which remains unchanged)
  13353. * @returns a matrix
  13354. */
  13355. getBaseMatrix(): Matrix;
  13356. /**
  13357. * Gets the rest pose matrix
  13358. * @returns a matrix
  13359. */
  13360. getRestPose(): Matrix;
  13361. /**
  13362. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13363. */
  13364. getWorldMatrix(): Matrix;
  13365. /**
  13366. * Sets the local matrix to rest pose matrix
  13367. */
  13368. returnToRest(): void;
  13369. /**
  13370. * Gets the inverse of the absolute transform matrix.
  13371. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13372. * @returns a matrix
  13373. */
  13374. getInvertedAbsoluteTransform(): Matrix;
  13375. /**
  13376. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13377. * @returns a matrix
  13378. */
  13379. getAbsoluteTransform(): Matrix;
  13380. /**
  13381. * Links with the given transform node.
  13382. * The local matrix of this bone is copied from the transform node every frame.
  13383. * @param transformNode defines the transform node to link to
  13384. */
  13385. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13386. /**
  13387. * Gets the node used to drive the bone's transformation
  13388. * @returns a transform node or null
  13389. */
  13390. getTransformNode(): Nullable<TransformNode>;
  13391. /** Gets or sets current position (in local space) */
  13392. position: Vector3;
  13393. /** Gets or sets current rotation (in local space) */
  13394. rotation: Vector3;
  13395. /** Gets or sets current rotation quaternion (in local space) */
  13396. rotationQuaternion: Quaternion;
  13397. /** Gets or sets current scaling (in local space) */
  13398. scaling: Vector3;
  13399. /**
  13400. * Gets the animation properties override
  13401. */
  13402. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13403. private _decompose;
  13404. private _compose;
  13405. /**
  13406. * Update the base and local matrices
  13407. * @param matrix defines the new base or local matrix
  13408. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13409. * @param updateLocalMatrix defines if the local matrix should be updated
  13410. */
  13411. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13412. /** @hidden */
  13413. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13414. /**
  13415. * Flag the bone as dirty (Forcing it to update everything)
  13416. */
  13417. markAsDirty(): void;
  13418. /** @hidden */
  13419. _markAsDirtyAndCompose(): void;
  13420. private _markAsDirtyAndDecompose;
  13421. /**
  13422. * Translate the bone in local or world space
  13423. * @param vec The amount to translate the bone
  13424. * @param space The space that the translation is in
  13425. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13426. */
  13427. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13428. /**
  13429. * Set the postion of the bone in local or world space
  13430. * @param position The position to set the bone
  13431. * @param space The space that the position is in
  13432. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13433. */
  13434. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13435. /**
  13436. * Set the absolute position of the bone (world space)
  13437. * @param position The position to set the bone
  13438. * @param mesh The mesh that this bone is attached to
  13439. */
  13440. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13441. /**
  13442. * Scale the bone on the x, y and z axes (in local space)
  13443. * @param x The amount to scale the bone on the x axis
  13444. * @param y The amount to scale the bone on the y axis
  13445. * @param z The amount to scale the bone on the z axis
  13446. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13447. */
  13448. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13449. /**
  13450. * Set the bone scaling in local space
  13451. * @param scale defines the scaling vector
  13452. */
  13453. setScale(scale: Vector3): void;
  13454. /**
  13455. * Gets the current scaling in local space
  13456. * @returns the current scaling vector
  13457. */
  13458. getScale(): Vector3;
  13459. /**
  13460. * Gets the current scaling in local space and stores it in a target vector
  13461. * @param result defines the target vector
  13462. */
  13463. getScaleToRef(result: Vector3): void;
  13464. /**
  13465. * Set the yaw, pitch, and roll of the bone in local or world space
  13466. * @param yaw The rotation of the bone on the y axis
  13467. * @param pitch The rotation of the bone on the x axis
  13468. * @param roll The rotation of the bone on the z axis
  13469. * @param space The space that the axes of rotation are in
  13470. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13471. */
  13472. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13473. /**
  13474. * Add a rotation to the bone on an axis in local or world space
  13475. * @param axis The axis to rotate the bone on
  13476. * @param amount The amount to rotate the bone
  13477. * @param space The space that the axis is in
  13478. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13479. */
  13480. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13481. /**
  13482. * Set the rotation of the bone to a particular axis angle in local or world space
  13483. * @param axis The axis to rotate the bone on
  13484. * @param angle The angle that the bone should be rotated to
  13485. * @param space The space that the axis is in
  13486. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13487. */
  13488. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13489. /**
  13490. * Set the euler rotation of the bone in local of world space
  13491. * @param rotation The euler rotation that the bone should be set to
  13492. * @param space The space that the rotation is in
  13493. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13494. */
  13495. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13496. /**
  13497. * Set the quaternion rotation of the bone in local of world space
  13498. * @param quat The quaternion rotation that the bone should be set to
  13499. * @param space The space that the rotation is in
  13500. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13501. */
  13502. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13503. /**
  13504. * Set the rotation matrix of the bone in local of world space
  13505. * @param rotMat The rotation matrix that the bone should be set to
  13506. * @param space The space that the rotation is in
  13507. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13508. */
  13509. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13510. private _rotateWithMatrix;
  13511. private _getNegativeRotationToRef;
  13512. /**
  13513. * Get the position of the bone in local or world space
  13514. * @param space The space that the returned position is in
  13515. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13516. * @returns The position of the bone
  13517. */
  13518. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13519. /**
  13520. * Copy the position of the bone to a vector3 in local or world space
  13521. * @param space The space that the returned position is in
  13522. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13523. * @param result The vector3 to copy the position to
  13524. */
  13525. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13526. /**
  13527. * Get the absolute position of the bone (world space)
  13528. * @param mesh The mesh that this bone is attached to
  13529. * @returns The absolute position of the bone
  13530. */
  13531. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13532. /**
  13533. * Copy the absolute position of the bone (world space) to the result param
  13534. * @param mesh The mesh that this bone is attached to
  13535. * @param result The vector3 to copy the absolute position to
  13536. */
  13537. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13538. /**
  13539. * Compute the absolute transforms of this bone and its children
  13540. */
  13541. computeAbsoluteTransforms(): void;
  13542. /**
  13543. * Get the world direction from an axis that is in the local space of the bone
  13544. * @param localAxis The local direction that is used to compute the world direction
  13545. * @param mesh The mesh that this bone is attached to
  13546. * @returns The world direction
  13547. */
  13548. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13549. /**
  13550. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13551. * @param localAxis The local direction that is used to compute the world direction
  13552. * @param mesh The mesh that this bone is attached to
  13553. * @param result The vector3 that the world direction will be copied to
  13554. */
  13555. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13556. /**
  13557. * Get the euler rotation of the bone in local or world space
  13558. * @param space The space that the rotation should be in
  13559. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13560. * @returns The euler rotation
  13561. */
  13562. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13563. /**
  13564. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13565. * @param space The space that the rotation should be in
  13566. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13567. * @param result The vector3 that the rotation should be copied to
  13568. */
  13569. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13570. /**
  13571. * Get the quaternion rotation of the bone in either local or world space
  13572. * @param space The space that the rotation should be in
  13573. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13574. * @returns The quaternion rotation
  13575. */
  13576. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13577. /**
  13578. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13579. * @param space The space that the rotation should be in
  13580. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13581. * @param result The quaternion that the rotation should be copied to
  13582. */
  13583. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13584. /**
  13585. * Get the rotation matrix of the bone in local or world space
  13586. * @param space The space that the rotation should be in
  13587. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13588. * @returns The rotation matrix
  13589. */
  13590. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13591. /**
  13592. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13593. * @param space The space that the rotation should be in
  13594. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13595. * @param result The quaternion that the rotation should be copied to
  13596. */
  13597. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13598. /**
  13599. * Get the world position of a point that is in the local space of the bone
  13600. * @param position The local position
  13601. * @param mesh The mesh that this bone is attached to
  13602. * @returns The world position
  13603. */
  13604. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13605. /**
  13606. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13607. * @param position The local position
  13608. * @param mesh The mesh that this bone is attached to
  13609. * @param result The vector3 that the world position should be copied to
  13610. */
  13611. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13612. /**
  13613. * Get the local position of a point that is in world space
  13614. * @param position The world position
  13615. * @param mesh The mesh that this bone is attached to
  13616. * @returns The local position
  13617. */
  13618. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13619. /**
  13620. * Get the local position of a point that is in world space and copy it to the result param
  13621. * @param position The world position
  13622. * @param mesh The mesh that this bone is attached to
  13623. * @param result The vector3 that the local position should be copied to
  13624. */
  13625. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13626. }
  13627. }
  13628. declare module BABYLON {
  13629. /**
  13630. * 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.
  13631. * @see https://doc.babylonjs.com/how_to/transformnode
  13632. */
  13633. export class TransformNode extends Node {
  13634. /**
  13635. * Object will not rotate to face the camera
  13636. */
  13637. static BILLBOARDMODE_NONE: number;
  13638. /**
  13639. * Object will rotate to face the camera but only on the x axis
  13640. */
  13641. static BILLBOARDMODE_X: number;
  13642. /**
  13643. * Object will rotate to face the camera but only on the y axis
  13644. */
  13645. static BILLBOARDMODE_Y: number;
  13646. /**
  13647. * Object will rotate to face the camera but only on the z axis
  13648. */
  13649. static BILLBOARDMODE_Z: number;
  13650. /**
  13651. * Object will rotate to face the camera
  13652. */
  13653. static BILLBOARDMODE_ALL: number;
  13654. private _forward;
  13655. private _forwardInverted;
  13656. private _up;
  13657. private _right;
  13658. private _rightInverted;
  13659. private _position;
  13660. private _rotation;
  13661. private _rotationQuaternion;
  13662. protected _scaling: Vector3;
  13663. protected _isDirty: boolean;
  13664. private _transformToBoneReferal;
  13665. private _isAbsoluteSynced;
  13666. private _billboardMode;
  13667. /**
  13668. * Gets or sets the billboard mode. Default is 0.
  13669. *
  13670. * | Value | Type | Description |
  13671. * | --- | --- | --- |
  13672. * | 0 | BILLBOARDMODE_NONE | |
  13673. * | 1 | BILLBOARDMODE_X | |
  13674. * | 2 | BILLBOARDMODE_Y | |
  13675. * | 4 | BILLBOARDMODE_Z | |
  13676. * | 7 | BILLBOARDMODE_ALL | |
  13677. *
  13678. */
  13679. billboardMode: number;
  13680. private _preserveParentRotationForBillboard;
  13681. /**
  13682. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13683. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13684. */
  13685. preserveParentRotationForBillboard: boolean;
  13686. /**
  13687. * 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
  13688. */
  13689. scalingDeterminant: number;
  13690. private _infiniteDistance;
  13691. /**
  13692. * Gets or sets the distance of the object to max, often used by skybox
  13693. */
  13694. infiniteDistance: boolean;
  13695. /**
  13696. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13697. * By default the system will update normals to compensate
  13698. */
  13699. ignoreNonUniformScaling: boolean;
  13700. /**
  13701. * 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
  13702. */
  13703. reIntegrateRotationIntoRotationQuaternion: boolean;
  13704. /** @hidden */
  13705. _poseMatrix: Nullable<Matrix>;
  13706. /** @hidden */
  13707. _localMatrix: Matrix;
  13708. private _usePivotMatrix;
  13709. private _absolutePosition;
  13710. private _absoluteScaling;
  13711. private _absoluteRotationQuaternion;
  13712. private _pivotMatrix;
  13713. private _pivotMatrixInverse;
  13714. protected _postMultiplyPivotMatrix: boolean;
  13715. protected _isWorldMatrixFrozen: boolean;
  13716. /** @hidden */
  13717. _indexInSceneTransformNodesArray: number;
  13718. /**
  13719. * An event triggered after the world matrix is updated
  13720. */
  13721. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13722. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13723. /**
  13724. * Gets a string identifying the name of the class
  13725. * @returns "TransformNode" string
  13726. */
  13727. getClassName(): string;
  13728. /**
  13729. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13730. */
  13731. position: Vector3;
  13732. /**
  13733. * 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)).
  13734. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13735. */
  13736. rotation: Vector3;
  13737. /**
  13738. * 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)).
  13739. */
  13740. scaling: Vector3;
  13741. /**
  13742. * 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).
  13743. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13744. */
  13745. rotationQuaternion: Nullable<Quaternion>;
  13746. /**
  13747. * The forward direction of that transform in world space.
  13748. */
  13749. readonly forward: Vector3;
  13750. /**
  13751. * The up direction of that transform in world space.
  13752. */
  13753. readonly up: Vector3;
  13754. /**
  13755. * The right direction of that transform in world space.
  13756. */
  13757. readonly right: Vector3;
  13758. /**
  13759. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13760. * @param matrix the matrix to copy the pose from
  13761. * @returns this TransformNode.
  13762. */
  13763. updatePoseMatrix(matrix: Matrix): TransformNode;
  13764. /**
  13765. * Returns the mesh Pose matrix.
  13766. * @returns the pose matrix
  13767. */
  13768. getPoseMatrix(): Matrix;
  13769. /** @hidden */
  13770. _isSynchronized(): boolean;
  13771. /** @hidden */
  13772. _initCache(): void;
  13773. /**
  13774. * Flag the transform node as dirty (Forcing it to update everything)
  13775. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13776. * @returns this transform node
  13777. */
  13778. markAsDirty(property: string): TransformNode;
  13779. /**
  13780. * Returns the current mesh absolute position.
  13781. * Returns a Vector3.
  13782. */
  13783. readonly absolutePosition: Vector3;
  13784. /**
  13785. * Returns the current mesh absolute scaling.
  13786. * Returns a Vector3.
  13787. */
  13788. readonly absoluteScaling: Vector3;
  13789. /**
  13790. * Returns the current mesh absolute rotation.
  13791. * Returns a Quaternion.
  13792. */
  13793. readonly absoluteRotationQuaternion: Quaternion;
  13794. /**
  13795. * Sets a new matrix to apply before all other transformation
  13796. * @param matrix defines the transform matrix
  13797. * @returns the current TransformNode
  13798. */
  13799. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13800. /**
  13801. * Sets a new pivot matrix to the current node
  13802. * @param matrix defines the new pivot matrix to use
  13803. * @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
  13804. * @returns the current TransformNode
  13805. */
  13806. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13807. /**
  13808. * Returns the mesh pivot matrix.
  13809. * Default : Identity.
  13810. * @returns the matrix
  13811. */
  13812. getPivotMatrix(): Matrix;
  13813. /**
  13814. * Prevents the World matrix to be computed any longer.
  13815. * @returns the TransformNode.
  13816. */
  13817. freezeWorldMatrix(): TransformNode;
  13818. /**
  13819. * Allows back the World matrix computation.
  13820. * @returns the TransformNode.
  13821. */
  13822. unfreezeWorldMatrix(): this;
  13823. /**
  13824. * True if the World matrix has been frozen.
  13825. */
  13826. readonly isWorldMatrixFrozen: boolean;
  13827. /**
  13828. * Retuns the mesh absolute position in the World.
  13829. * @returns a Vector3.
  13830. */
  13831. getAbsolutePosition(): Vector3;
  13832. /**
  13833. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13834. * @param absolutePosition the absolute position to set
  13835. * @returns the TransformNode.
  13836. */
  13837. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13838. /**
  13839. * Sets the mesh position in its local space.
  13840. * @param vector3 the position to set in localspace
  13841. * @returns the TransformNode.
  13842. */
  13843. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13844. /**
  13845. * Returns the mesh position in the local space from the current World matrix values.
  13846. * @returns a new Vector3.
  13847. */
  13848. getPositionExpressedInLocalSpace(): Vector3;
  13849. /**
  13850. * Translates the mesh along the passed Vector3 in its local space.
  13851. * @param vector3 the distance to translate in localspace
  13852. * @returns the TransformNode.
  13853. */
  13854. locallyTranslate(vector3: Vector3): TransformNode;
  13855. private static _lookAtVectorCache;
  13856. /**
  13857. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13858. * @param targetPoint the position (must be in same space as current mesh) to look at
  13859. * @param yawCor optional yaw (y-axis) correction in radians
  13860. * @param pitchCor optional pitch (x-axis) correction in radians
  13861. * @param rollCor optional roll (z-axis) correction in radians
  13862. * @param space the choosen space of the target
  13863. * @returns the TransformNode.
  13864. */
  13865. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13866. /**
  13867. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13868. * This Vector3 is expressed in the World space.
  13869. * @param localAxis axis to rotate
  13870. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13871. */
  13872. getDirection(localAxis: Vector3): Vector3;
  13873. /**
  13874. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13875. * localAxis is expressed in the mesh local space.
  13876. * result is computed in the Wordl space from the mesh World matrix.
  13877. * @param localAxis axis to rotate
  13878. * @param result the resulting transformnode
  13879. * @returns this TransformNode.
  13880. */
  13881. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13882. /**
  13883. * Sets this transform node rotation to the given local axis.
  13884. * @param localAxis the axis in local space
  13885. * @param yawCor optional yaw (y-axis) correction in radians
  13886. * @param pitchCor optional pitch (x-axis) correction in radians
  13887. * @param rollCor optional roll (z-axis) correction in radians
  13888. * @returns this TransformNode
  13889. */
  13890. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13891. /**
  13892. * Sets a new pivot point to the current node
  13893. * @param point defines the new pivot point to use
  13894. * @param space defines if the point is in world or local space (local by default)
  13895. * @returns the current TransformNode
  13896. */
  13897. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13898. /**
  13899. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13900. * @returns the pivot point
  13901. */
  13902. getPivotPoint(): Vector3;
  13903. /**
  13904. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13905. * @param result the vector3 to store the result
  13906. * @returns this TransformNode.
  13907. */
  13908. getPivotPointToRef(result: Vector3): TransformNode;
  13909. /**
  13910. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13911. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13912. */
  13913. getAbsolutePivotPoint(): Vector3;
  13914. /**
  13915. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13916. * @param result vector3 to store the result
  13917. * @returns this TransformNode.
  13918. */
  13919. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13920. /**
  13921. * Defines the passed node as the parent of the current node.
  13922. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13923. * @see https://doc.babylonjs.com/how_to/parenting
  13924. * @param node the node ot set as the parent
  13925. * @returns this TransformNode.
  13926. */
  13927. setParent(node: Nullable<Node>): TransformNode;
  13928. private _nonUniformScaling;
  13929. /**
  13930. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13931. */
  13932. readonly nonUniformScaling: boolean;
  13933. /** @hidden */
  13934. _updateNonUniformScalingState(value: boolean): boolean;
  13935. /**
  13936. * Attach the current TransformNode to another TransformNode associated with a bone
  13937. * @param bone Bone affecting the TransformNode
  13938. * @param affectedTransformNode TransformNode associated with the bone
  13939. * @returns this object
  13940. */
  13941. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13942. /**
  13943. * Detach the transform node if its associated with a bone
  13944. * @returns this object
  13945. */
  13946. detachFromBone(): TransformNode;
  13947. private static _rotationAxisCache;
  13948. /**
  13949. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13950. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13951. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13952. * The passed axis is also normalized.
  13953. * @param axis the axis to rotate around
  13954. * @param amount the amount to rotate in radians
  13955. * @param space Space to rotate in (Default: local)
  13956. * @returns the TransformNode.
  13957. */
  13958. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13959. /**
  13960. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13961. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13962. * The passed axis is also normalized. .
  13963. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13964. * @param point the point to rotate around
  13965. * @param axis the axis to rotate around
  13966. * @param amount the amount to rotate in radians
  13967. * @returns the TransformNode
  13968. */
  13969. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13970. /**
  13971. * Translates the mesh along the axis vector for the passed distance in the given space.
  13972. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13973. * @param axis the axis to translate in
  13974. * @param distance the distance to translate
  13975. * @param space Space to rotate in (Default: local)
  13976. * @returns the TransformNode.
  13977. */
  13978. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13979. /**
  13980. * Adds a rotation step to the mesh current rotation.
  13981. * x, y, z are Euler angles expressed in radians.
  13982. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13983. * This means this rotation is made in the mesh local space only.
  13984. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13985. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13986. * ```javascript
  13987. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13988. * ```
  13989. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13990. * 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.
  13991. * @param x Rotation to add
  13992. * @param y Rotation to add
  13993. * @param z Rotation to add
  13994. * @returns the TransformNode.
  13995. */
  13996. addRotation(x: number, y: number, z: number): TransformNode;
  13997. /**
  13998. * @hidden
  13999. */
  14000. protected _getEffectiveParent(): Nullable<Node>;
  14001. /**
  14002. * Computes the world matrix of the node
  14003. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14004. * @returns the world matrix
  14005. */
  14006. computeWorldMatrix(force?: boolean): Matrix;
  14007. protected _afterComputeWorldMatrix(): void;
  14008. /**
  14009. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14010. * @param func callback function to add
  14011. *
  14012. * @returns the TransformNode.
  14013. */
  14014. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14015. /**
  14016. * Removes a registered callback function.
  14017. * @param func callback function to remove
  14018. * @returns the TransformNode.
  14019. */
  14020. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14021. /**
  14022. * Gets the position of the current mesh in camera space
  14023. * @param camera defines the camera to use
  14024. * @returns a position
  14025. */
  14026. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14027. /**
  14028. * Returns the distance from the mesh to the active camera
  14029. * @param camera defines the camera to use
  14030. * @returns the distance
  14031. */
  14032. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14033. /**
  14034. * Clone the current transform node
  14035. * @param name Name of the new clone
  14036. * @param newParent New parent for the clone
  14037. * @param doNotCloneChildren Do not clone children hierarchy
  14038. * @returns the new transform node
  14039. */
  14040. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14041. /**
  14042. * Serializes the objects information.
  14043. * @param currentSerializationObject defines the object to serialize in
  14044. * @returns the serialized object
  14045. */
  14046. serialize(currentSerializationObject?: any): any;
  14047. /**
  14048. * Returns a new TransformNode object parsed from the source provided.
  14049. * @param parsedTransformNode is the source.
  14050. * @param scene the scne the object belongs to
  14051. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14052. * @returns a new TransformNode object parsed from the source provided.
  14053. */
  14054. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14055. /**
  14056. * Get all child-transformNodes of this node
  14057. * @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
  14058. * @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
  14059. * @returns an array of TransformNode
  14060. */
  14061. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14062. /**
  14063. * Releases resources associated with this transform node.
  14064. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14065. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14066. */
  14067. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14068. /**
  14069. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14070. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14071. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14072. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14073. * @returns the current mesh
  14074. */
  14075. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14076. private _syncAbsoluteScalingAndRotation;
  14077. }
  14078. }
  14079. declare module BABYLON {
  14080. /**
  14081. * Defines the types of pose enabled controllers that are supported
  14082. */
  14083. export enum PoseEnabledControllerType {
  14084. /**
  14085. * HTC Vive
  14086. */
  14087. VIVE = 0,
  14088. /**
  14089. * Oculus Rift
  14090. */
  14091. OCULUS = 1,
  14092. /**
  14093. * Windows mixed reality
  14094. */
  14095. WINDOWS = 2,
  14096. /**
  14097. * Samsung gear VR
  14098. */
  14099. GEAR_VR = 3,
  14100. /**
  14101. * Google Daydream
  14102. */
  14103. DAYDREAM = 4,
  14104. /**
  14105. * Generic
  14106. */
  14107. GENERIC = 5
  14108. }
  14109. /**
  14110. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14111. */
  14112. export interface MutableGamepadButton {
  14113. /**
  14114. * Value of the button/trigger
  14115. */
  14116. value: number;
  14117. /**
  14118. * If the button/trigger is currently touched
  14119. */
  14120. touched: boolean;
  14121. /**
  14122. * If the button/trigger is currently pressed
  14123. */
  14124. pressed: boolean;
  14125. }
  14126. /**
  14127. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14128. * @hidden
  14129. */
  14130. export interface ExtendedGamepadButton extends GamepadButton {
  14131. /**
  14132. * If the button/trigger is currently pressed
  14133. */
  14134. readonly pressed: boolean;
  14135. /**
  14136. * If the button/trigger is currently touched
  14137. */
  14138. readonly touched: boolean;
  14139. /**
  14140. * Value of the button/trigger
  14141. */
  14142. readonly value: number;
  14143. }
  14144. /** @hidden */
  14145. export interface _GamePadFactory {
  14146. /**
  14147. * Returns wether or not the current gamepad can be created for this type of controller.
  14148. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14149. * @returns true if it can be created, otherwise false
  14150. */
  14151. canCreate(gamepadInfo: any): boolean;
  14152. /**
  14153. * Creates a new instance of the Gamepad.
  14154. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14155. * @returns the new gamepad instance
  14156. */
  14157. create(gamepadInfo: any): Gamepad;
  14158. }
  14159. /**
  14160. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14161. */
  14162. export class PoseEnabledControllerHelper {
  14163. /** @hidden */
  14164. static _ControllerFactories: _GamePadFactory[];
  14165. /** @hidden */
  14166. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14167. /**
  14168. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14169. * @param vrGamepad the gamepad to initialized
  14170. * @returns a vr controller of the type the gamepad identified as
  14171. */
  14172. static InitiateController(vrGamepad: any): Gamepad;
  14173. }
  14174. /**
  14175. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14176. */
  14177. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14178. /**
  14179. * If the controller is used in a webXR session
  14180. */
  14181. isXR: boolean;
  14182. private _deviceRoomPosition;
  14183. private _deviceRoomRotationQuaternion;
  14184. /**
  14185. * The device position in babylon space
  14186. */
  14187. devicePosition: Vector3;
  14188. /**
  14189. * The device rotation in babylon space
  14190. */
  14191. deviceRotationQuaternion: Quaternion;
  14192. /**
  14193. * The scale factor of the device in babylon space
  14194. */
  14195. deviceScaleFactor: number;
  14196. /**
  14197. * (Likely devicePosition should be used instead) The device position in its room space
  14198. */
  14199. position: Vector3;
  14200. /**
  14201. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14202. */
  14203. rotationQuaternion: Quaternion;
  14204. /**
  14205. * The type of controller (Eg. Windows mixed reality)
  14206. */
  14207. controllerType: PoseEnabledControllerType;
  14208. protected _calculatedPosition: Vector3;
  14209. private _calculatedRotation;
  14210. /**
  14211. * The raw pose from the device
  14212. */
  14213. rawPose: DevicePose;
  14214. private _trackPosition;
  14215. private _maxRotationDistFromHeadset;
  14216. private _draggedRoomRotation;
  14217. /**
  14218. * @hidden
  14219. */
  14220. _disableTrackPosition(fixedPosition: Vector3): void;
  14221. /**
  14222. * Internal, the mesh attached to the controller
  14223. * @hidden
  14224. */
  14225. _mesh: Nullable<AbstractMesh>;
  14226. private _poseControlledCamera;
  14227. private _leftHandSystemQuaternion;
  14228. /**
  14229. * Internal, matrix used to convert room space to babylon space
  14230. * @hidden
  14231. */
  14232. _deviceToWorld: Matrix;
  14233. /**
  14234. * Node to be used when casting a ray from the controller
  14235. * @hidden
  14236. */
  14237. _pointingPoseNode: Nullable<TransformNode>;
  14238. /**
  14239. * Name of the child mesh that can be used to cast a ray from the controller
  14240. */
  14241. static readonly POINTING_POSE: string;
  14242. /**
  14243. * Creates a new PoseEnabledController from a gamepad
  14244. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14245. */
  14246. constructor(browserGamepad: any);
  14247. private _workingMatrix;
  14248. /**
  14249. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14250. */
  14251. update(): void;
  14252. /**
  14253. * Updates only the pose device and mesh without doing any button event checking
  14254. */
  14255. protected _updatePoseAndMesh(): void;
  14256. /**
  14257. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14258. * @param poseData raw pose fromthe device
  14259. */
  14260. updateFromDevice(poseData: DevicePose): void;
  14261. /**
  14262. * @hidden
  14263. */
  14264. _meshAttachedObservable: Observable<AbstractMesh>;
  14265. /**
  14266. * Attaches a mesh to the controller
  14267. * @param mesh the mesh to be attached
  14268. */
  14269. attachToMesh(mesh: AbstractMesh): void;
  14270. /**
  14271. * Attaches the controllers mesh to a camera
  14272. * @param camera the camera the mesh should be attached to
  14273. */
  14274. attachToPoseControlledCamera(camera: TargetCamera): void;
  14275. /**
  14276. * Disposes of the controller
  14277. */
  14278. dispose(): void;
  14279. /**
  14280. * The mesh that is attached to the controller
  14281. */
  14282. readonly mesh: Nullable<AbstractMesh>;
  14283. /**
  14284. * Gets the ray of the controller in the direction the controller is pointing
  14285. * @param length the length the resulting ray should be
  14286. * @returns a ray in the direction the controller is pointing
  14287. */
  14288. getForwardRay(length?: number): Ray;
  14289. }
  14290. }
  14291. declare module BABYLON {
  14292. /**
  14293. * Defines the WebVRController object that represents controllers tracked in 3D space
  14294. */
  14295. export abstract class WebVRController extends PoseEnabledController {
  14296. /**
  14297. * Internal, the default controller model for the controller
  14298. */
  14299. protected _defaultModel: AbstractMesh;
  14300. /**
  14301. * Fired when the trigger state has changed
  14302. */
  14303. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14304. /**
  14305. * Fired when the main button state has changed
  14306. */
  14307. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14308. /**
  14309. * Fired when the secondary button state has changed
  14310. */
  14311. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14312. /**
  14313. * Fired when the pad state has changed
  14314. */
  14315. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14316. /**
  14317. * Fired when controllers stick values have changed
  14318. */
  14319. onPadValuesChangedObservable: Observable<StickValues>;
  14320. /**
  14321. * Array of button availible on the controller
  14322. */
  14323. protected _buttons: Array<MutableGamepadButton>;
  14324. private _onButtonStateChange;
  14325. /**
  14326. * Fired when a controller button's state has changed
  14327. * @param callback the callback containing the button that was modified
  14328. */
  14329. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14330. /**
  14331. * X and Y axis corresponding to the controllers joystick
  14332. */
  14333. pad: StickValues;
  14334. /**
  14335. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14336. */
  14337. hand: string;
  14338. /**
  14339. * The default controller model for the controller
  14340. */
  14341. readonly defaultModel: AbstractMesh;
  14342. /**
  14343. * Creates a new WebVRController from a gamepad
  14344. * @param vrGamepad the gamepad that the WebVRController should be created from
  14345. */
  14346. constructor(vrGamepad: any);
  14347. /**
  14348. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14349. */
  14350. update(): void;
  14351. /**
  14352. * Function to be called when a button is modified
  14353. */
  14354. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14355. /**
  14356. * Loads a mesh and attaches it to the controller
  14357. * @param scene the scene the mesh should be added to
  14358. * @param meshLoaded callback for when the mesh has been loaded
  14359. */
  14360. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14361. private _setButtonValue;
  14362. private _changes;
  14363. private _checkChanges;
  14364. /**
  14365. * Disposes of th webVRCOntroller
  14366. */
  14367. dispose(): void;
  14368. }
  14369. }
  14370. declare module BABYLON {
  14371. /**
  14372. * The HemisphericLight simulates the ambient environment light,
  14373. * so the passed direction is the light reflection direction, not the incoming direction.
  14374. */
  14375. export class HemisphericLight extends Light {
  14376. /**
  14377. * The groundColor is the light in the opposite direction to the one specified during creation.
  14378. * 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.
  14379. */
  14380. groundColor: Color3;
  14381. /**
  14382. * The light reflection direction, not the incoming direction.
  14383. */
  14384. direction: Vector3;
  14385. /**
  14386. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14387. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14388. * The HemisphericLight can't cast shadows.
  14389. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14390. * @param name The friendly name of the light
  14391. * @param direction The direction of the light reflection
  14392. * @param scene The scene the light belongs to
  14393. */
  14394. constructor(name: string, direction: Vector3, scene: Scene);
  14395. protected _buildUniformLayout(): void;
  14396. /**
  14397. * Returns the string "HemisphericLight".
  14398. * @return The class name
  14399. */
  14400. getClassName(): string;
  14401. /**
  14402. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14403. * Returns the updated direction.
  14404. * @param target The target the direction should point to
  14405. * @return The computed direction
  14406. */
  14407. setDirectionToTarget(target: Vector3): Vector3;
  14408. /**
  14409. * Returns the shadow generator associated to the light.
  14410. * @returns Always null for hemispheric lights because it does not support shadows.
  14411. */
  14412. getShadowGenerator(): Nullable<IShadowGenerator>;
  14413. /**
  14414. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14415. * @param effect The effect to update
  14416. * @param lightIndex The index of the light in the effect to update
  14417. * @returns The hemispheric light
  14418. */
  14419. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14420. /**
  14421. * Computes the world matrix of the node
  14422. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14423. * @param useWasUpdatedFlag defines a reserved property
  14424. * @returns the world matrix
  14425. */
  14426. computeWorldMatrix(): Matrix;
  14427. /**
  14428. * Returns the integer 3.
  14429. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14430. */
  14431. getTypeID(): number;
  14432. /**
  14433. * Prepares the list of defines specific to the light type.
  14434. * @param defines the list of defines
  14435. * @param lightIndex defines the index of the light for the effect
  14436. */
  14437. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14438. }
  14439. }
  14440. declare module BABYLON {
  14441. /** @hidden */
  14442. export var vrMultiviewToSingleviewPixelShader: {
  14443. name: string;
  14444. shader: string;
  14445. };
  14446. }
  14447. declare module BABYLON {
  14448. /**
  14449. * Renders to multiple views with a single draw call
  14450. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14451. */
  14452. export class MultiviewRenderTarget extends RenderTargetTexture {
  14453. /**
  14454. * Creates a multiview render target
  14455. * @param scene scene used with the render target
  14456. * @param size the size of the render target (used for each view)
  14457. */
  14458. constructor(scene: Scene, size?: number | {
  14459. width: number;
  14460. height: number;
  14461. } | {
  14462. ratio: number;
  14463. });
  14464. /**
  14465. * @hidden
  14466. * @param faceIndex the face index, if its a cube texture
  14467. */
  14468. _bindFrameBuffer(faceIndex?: number): void;
  14469. /**
  14470. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14471. * @returns the view count
  14472. */
  14473. getViewCount(): number;
  14474. }
  14475. }
  14476. declare module BABYLON {
  14477. /**
  14478. * Reprasents a camera frustum
  14479. */
  14480. export class Frustum {
  14481. /**
  14482. * Gets the planes representing the frustum
  14483. * @param transform matrix to be applied to the returned planes
  14484. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14485. */
  14486. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14487. /**
  14488. * Gets the near frustum plane transformed by the transform matrix
  14489. * @param transform transformation matrix to be applied to the resulting frustum plane
  14490. * @param frustumPlane the resuling frustum plane
  14491. */
  14492. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14493. /**
  14494. * Gets the far frustum plane transformed by the transform matrix
  14495. * @param transform transformation matrix to be applied to the resulting frustum plane
  14496. * @param frustumPlane the resuling frustum plane
  14497. */
  14498. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14499. /**
  14500. * Gets the left frustum plane transformed by the transform matrix
  14501. * @param transform transformation matrix to be applied to the resulting frustum plane
  14502. * @param frustumPlane the resuling frustum plane
  14503. */
  14504. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14505. /**
  14506. * Gets the right frustum plane transformed by the transform matrix
  14507. * @param transform transformation matrix to be applied to the resulting frustum plane
  14508. * @param frustumPlane the resuling frustum plane
  14509. */
  14510. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14511. /**
  14512. * Gets the top frustum plane transformed by the transform matrix
  14513. * @param transform transformation matrix to be applied to the resulting frustum plane
  14514. * @param frustumPlane the resuling frustum plane
  14515. */
  14516. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14517. /**
  14518. * Gets the bottom frustum plane transformed by the transform matrix
  14519. * @param transform transformation matrix to be applied to the resulting frustum plane
  14520. * @param frustumPlane the resuling frustum plane
  14521. */
  14522. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14523. /**
  14524. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14525. * @param transform transformation matrix to be applied to the resulting frustum planes
  14526. * @param frustumPlanes the resuling frustum planes
  14527. */
  14528. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14529. }
  14530. }
  14531. declare module BABYLON {
  14532. interface Engine {
  14533. /**
  14534. * Creates a new multiview render target
  14535. * @param width defines the width of the texture
  14536. * @param height defines the height of the texture
  14537. * @returns the created multiview texture
  14538. */
  14539. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14540. /**
  14541. * Binds a multiview framebuffer to be drawn to
  14542. * @param multiviewTexture texture to bind
  14543. */
  14544. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14545. }
  14546. interface Camera {
  14547. /**
  14548. * @hidden
  14549. * 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)
  14550. */
  14551. _useMultiviewToSingleView: boolean;
  14552. /**
  14553. * @hidden
  14554. * 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)
  14555. */
  14556. _multiviewTexture: Nullable<RenderTargetTexture>;
  14557. /**
  14558. * @hidden
  14559. * ensures the multiview texture of the camera exists and has the specified width/height
  14560. * @param width height to set on the multiview texture
  14561. * @param height width to set on the multiview texture
  14562. */
  14563. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14564. }
  14565. interface Scene {
  14566. /** @hidden */
  14567. _transformMatrixR: Matrix;
  14568. /** @hidden */
  14569. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14570. /** @hidden */
  14571. _createMultiviewUbo(): void;
  14572. /** @hidden */
  14573. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14574. /** @hidden */
  14575. _renderMultiviewToSingleView(camera: Camera): void;
  14576. }
  14577. }
  14578. declare module BABYLON {
  14579. /**
  14580. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14581. * This will not be used for webXR as it supports displaying texture arrays directly
  14582. */
  14583. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14584. /**
  14585. * Initializes a VRMultiviewToSingleview
  14586. * @param name name of the post process
  14587. * @param camera camera to be applied to
  14588. * @param scaleFactor scaling factor to the size of the output texture
  14589. */
  14590. constructor(name: string, camera: Camera, scaleFactor: number);
  14591. }
  14592. }
  14593. declare module BABYLON {
  14594. interface Engine {
  14595. /** @hidden */
  14596. _vrDisplay: any;
  14597. /** @hidden */
  14598. _vrSupported: boolean;
  14599. /** @hidden */
  14600. _oldSize: Size;
  14601. /** @hidden */
  14602. _oldHardwareScaleFactor: number;
  14603. /** @hidden */
  14604. _vrExclusivePointerMode: boolean;
  14605. /** @hidden */
  14606. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14607. /** @hidden */
  14608. _onVRDisplayPointerRestricted: () => void;
  14609. /** @hidden */
  14610. _onVRDisplayPointerUnrestricted: () => void;
  14611. /** @hidden */
  14612. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14613. /** @hidden */
  14614. _onVrDisplayDisconnect: Nullable<() => void>;
  14615. /** @hidden */
  14616. _onVrDisplayPresentChange: Nullable<() => void>;
  14617. /**
  14618. * Observable signaled when VR display mode changes
  14619. */
  14620. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14621. /**
  14622. * Observable signaled when VR request present is complete
  14623. */
  14624. onVRRequestPresentComplete: Observable<boolean>;
  14625. /**
  14626. * Observable signaled when VR request present starts
  14627. */
  14628. onVRRequestPresentStart: Observable<Engine>;
  14629. /**
  14630. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14631. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14632. */
  14633. isInVRExclusivePointerMode: boolean;
  14634. /**
  14635. * Gets a boolean indicating if a webVR device was detected
  14636. * @returns true if a webVR device was detected
  14637. */
  14638. isVRDevicePresent(): boolean;
  14639. /**
  14640. * Gets the current webVR device
  14641. * @returns the current webVR device (or null)
  14642. */
  14643. getVRDevice(): any;
  14644. /**
  14645. * Initializes a webVR display and starts listening to display change events
  14646. * The onVRDisplayChangedObservable will be notified upon these changes
  14647. * @returns A promise containing a VRDisplay and if vr is supported
  14648. */
  14649. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14650. /** @hidden */
  14651. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14652. /**
  14653. * Call this function to switch to webVR mode
  14654. * Will do nothing if webVR is not supported or if there is no webVR device
  14655. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14656. */
  14657. enableVR(): void;
  14658. /** @hidden */
  14659. _onVRFullScreenTriggered(): void;
  14660. }
  14661. }
  14662. declare module BABYLON {
  14663. /**
  14664. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14665. * IMPORTANT!! The data is right-hand data.
  14666. * @export
  14667. * @interface DevicePose
  14668. */
  14669. export interface DevicePose {
  14670. /**
  14671. * The position of the device, values in array are [x,y,z].
  14672. */
  14673. readonly position: Nullable<Float32Array>;
  14674. /**
  14675. * The linearVelocity of the device, values in array are [x,y,z].
  14676. */
  14677. readonly linearVelocity: Nullable<Float32Array>;
  14678. /**
  14679. * The linearAcceleration of the device, values in array are [x,y,z].
  14680. */
  14681. readonly linearAcceleration: Nullable<Float32Array>;
  14682. /**
  14683. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14684. */
  14685. readonly orientation: Nullable<Float32Array>;
  14686. /**
  14687. * The angularVelocity of the device, values in array are [x,y,z].
  14688. */
  14689. readonly angularVelocity: Nullable<Float32Array>;
  14690. /**
  14691. * The angularAcceleration of the device, values in array are [x,y,z].
  14692. */
  14693. readonly angularAcceleration: Nullable<Float32Array>;
  14694. }
  14695. /**
  14696. * Interface representing a pose controlled object in Babylon.
  14697. * A pose controlled object has both regular pose values as well as pose values
  14698. * from an external device such as a VR head mounted display
  14699. */
  14700. export interface PoseControlled {
  14701. /**
  14702. * The position of the object in babylon space.
  14703. */
  14704. position: Vector3;
  14705. /**
  14706. * The rotation quaternion of the object in babylon space.
  14707. */
  14708. rotationQuaternion: Quaternion;
  14709. /**
  14710. * The position of the device in babylon space.
  14711. */
  14712. devicePosition?: Vector3;
  14713. /**
  14714. * The rotation quaternion of the device in babylon space.
  14715. */
  14716. deviceRotationQuaternion: Quaternion;
  14717. /**
  14718. * The raw pose coming from the device.
  14719. */
  14720. rawPose: Nullable<DevicePose>;
  14721. /**
  14722. * The scale of the device to be used when translating from device space to babylon space.
  14723. */
  14724. deviceScaleFactor: number;
  14725. /**
  14726. * Updates the poseControlled values based on the input device pose.
  14727. * @param poseData the pose data to update the object with
  14728. */
  14729. updateFromDevice(poseData: DevicePose): void;
  14730. }
  14731. /**
  14732. * Set of options to customize the webVRCamera
  14733. */
  14734. export interface WebVROptions {
  14735. /**
  14736. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14737. */
  14738. trackPosition?: boolean;
  14739. /**
  14740. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14741. */
  14742. positionScale?: number;
  14743. /**
  14744. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14745. */
  14746. displayName?: string;
  14747. /**
  14748. * Should the native controller meshes be initialized. (default: true)
  14749. */
  14750. controllerMeshes?: boolean;
  14751. /**
  14752. * Creating a default HemiLight only on controllers. (default: true)
  14753. */
  14754. defaultLightingOnControllers?: boolean;
  14755. /**
  14756. * If you don't want to use the default VR button of the helper. (default: false)
  14757. */
  14758. useCustomVRButton?: boolean;
  14759. /**
  14760. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14761. */
  14762. customVRButton?: HTMLButtonElement;
  14763. /**
  14764. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14765. */
  14766. rayLength?: number;
  14767. /**
  14768. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14769. */
  14770. defaultHeight?: number;
  14771. /**
  14772. * If multiview should be used if availible (default: false)
  14773. */
  14774. useMultiview?: boolean;
  14775. }
  14776. /**
  14777. * This represents a WebVR camera.
  14778. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14779. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14780. */
  14781. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14782. private webVROptions;
  14783. /**
  14784. * @hidden
  14785. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14786. */
  14787. _vrDevice: any;
  14788. /**
  14789. * The rawPose of the vrDevice.
  14790. */
  14791. rawPose: Nullable<DevicePose>;
  14792. private _onVREnabled;
  14793. private _specsVersion;
  14794. private _attached;
  14795. private _frameData;
  14796. protected _descendants: Array<Node>;
  14797. private _deviceRoomPosition;
  14798. /** @hidden */
  14799. _deviceRoomRotationQuaternion: Quaternion;
  14800. private _standingMatrix;
  14801. /**
  14802. * Represents device position in babylon space.
  14803. */
  14804. devicePosition: Vector3;
  14805. /**
  14806. * Represents device rotation in babylon space.
  14807. */
  14808. deviceRotationQuaternion: Quaternion;
  14809. /**
  14810. * The scale of the device to be used when translating from device space to babylon space.
  14811. */
  14812. deviceScaleFactor: number;
  14813. private _deviceToWorld;
  14814. private _worldToDevice;
  14815. /**
  14816. * References to the webVR controllers for the vrDevice.
  14817. */
  14818. controllers: Array<WebVRController>;
  14819. /**
  14820. * Emits an event when a controller is attached.
  14821. */
  14822. onControllersAttachedObservable: Observable<WebVRController[]>;
  14823. /**
  14824. * Emits an event when a controller's mesh has been loaded;
  14825. */
  14826. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14827. /**
  14828. * Emits an event when the HMD's pose has been updated.
  14829. */
  14830. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14831. private _poseSet;
  14832. /**
  14833. * If the rig cameras be used as parent instead of this camera.
  14834. */
  14835. rigParenting: boolean;
  14836. private _lightOnControllers;
  14837. private _defaultHeight?;
  14838. /**
  14839. * Instantiates a WebVRFreeCamera.
  14840. * @param name The name of the WebVRFreeCamera
  14841. * @param position The starting anchor position for the camera
  14842. * @param scene The scene the camera belongs to
  14843. * @param webVROptions a set of customizable options for the webVRCamera
  14844. */
  14845. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14846. /**
  14847. * Gets the device distance from the ground in meters.
  14848. * @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.
  14849. */
  14850. deviceDistanceToRoomGround(): number;
  14851. /**
  14852. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14853. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14854. */
  14855. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14856. /**
  14857. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14858. * @returns A promise with a boolean set to if the standing matrix is supported.
  14859. */
  14860. useStandingMatrixAsync(): Promise<boolean>;
  14861. /**
  14862. * Disposes the camera
  14863. */
  14864. dispose(): void;
  14865. /**
  14866. * Gets a vrController by name.
  14867. * @param name The name of the controller to retreive
  14868. * @returns the controller matching the name specified or null if not found
  14869. */
  14870. getControllerByName(name: string): Nullable<WebVRController>;
  14871. private _leftController;
  14872. /**
  14873. * The controller corresponding to the users left hand.
  14874. */
  14875. readonly leftController: Nullable<WebVRController>;
  14876. private _rightController;
  14877. /**
  14878. * The controller corresponding to the users right hand.
  14879. */
  14880. readonly rightController: Nullable<WebVRController>;
  14881. /**
  14882. * Casts a ray forward from the vrCamera's gaze.
  14883. * @param length Length of the ray (default: 100)
  14884. * @returns the ray corresponding to the gaze
  14885. */
  14886. getForwardRay(length?: number): Ray;
  14887. /**
  14888. * @hidden
  14889. * Updates the camera based on device's frame data
  14890. */
  14891. _checkInputs(): void;
  14892. /**
  14893. * Updates the poseControlled values based on the input device pose.
  14894. * @param poseData Pose coming from the device
  14895. */
  14896. updateFromDevice(poseData: DevicePose): void;
  14897. private _htmlElementAttached;
  14898. private _detachIfAttached;
  14899. /**
  14900. * WebVR's attach control will start broadcasting frames to the device.
  14901. * Note that in certain browsers (chrome for example) this function must be called
  14902. * within a user-interaction callback. Example:
  14903. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14904. *
  14905. * @param element html element to attach the vrDevice to
  14906. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14907. */
  14908. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14909. /**
  14910. * Detaches the camera from the html element and disables VR
  14911. *
  14912. * @param element html element to detach from
  14913. */
  14914. detachControl(element: HTMLElement): void;
  14915. /**
  14916. * @returns the name of this class
  14917. */
  14918. getClassName(): string;
  14919. /**
  14920. * Calls resetPose on the vrDisplay
  14921. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14922. */
  14923. resetToCurrentRotation(): void;
  14924. /**
  14925. * @hidden
  14926. * Updates the rig cameras (left and right eye)
  14927. */
  14928. _updateRigCameras(): void;
  14929. private _workingVector;
  14930. private _oneVector;
  14931. private _workingMatrix;
  14932. private updateCacheCalled;
  14933. private _correctPositionIfNotTrackPosition;
  14934. /**
  14935. * @hidden
  14936. * Updates the cached values of the camera
  14937. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  14938. */
  14939. _updateCache(ignoreParentClass?: boolean): void;
  14940. /**
  14941. * @hidden
  14942. * Get current device position in babylon world
  14943. */
  14944. _computeDevicePosition(): void;
  14945. /**
  14946. * Updates the current device position and rotation in the babylon world
  14947. */
  14948. update(): void;
  14949. /**
  14950. * @hidden
  14951. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  14952. * @returns an identity matrix
  14953. */
  14954. _getViewMatrix(): Matrix;
  14955. private _tmpMatrix;
  14956. /**
  14957. * This function is called by the two RIG cameras.
  14958. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  14959. * @hidden
  14960. */
  14961. _getWebVRViewMatrix(): Matrix;
  14962. /** @hidden */
  14963. _getWebVRProjectionMatrix(): Matrix;
  14964. private _onGamepadConnectedObserver;
  14965. private _onGamepadDisconnectedObserver;
  14966. private _updateCacheWhenTrackingDisabledObserver;
  14967. /**
  14968. * Initializes the controllers and their meshes
  14969. */
  14970. initControllers(): void;
  14971. }
  14972. }
  14973. declare module BABYLON {
  14974. /**
  14975. * Size options for a post process
  14976. */
  14977. export type PostProcessOptions = {
  14978. width: number;
  14979. height: number;
  14980. };
  14981. /**
  14982. * PostProcess can be used to apply a shader to a texture after it has been rendered
  14983. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14984. */
  14985. export class PostProcess {
  14986. /** Name of the PostProcess. */
  14987. name: string;
  14988. /**
  14989. * Gets or sets the unique id of the post process
  14990. */
  14991. uniqueId: number;
  14992. /**
  14993. * Width of the texture to apply the post process on
  14994. */
  14995. width: number;
  14996. /**
  14997. * Height of the texture to apply the post process on
  14998. */
  14999. height: number;
  15000. /**
  15001. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15002. * @hidden
  15003. */
  15004. _outputTexture: Nullable<InternalTexture>;
  15005. /**
  15006. * Sampling mode used by the shader
  15007. * See https://doc.babylonjs.com/classes/3.1/texture
  15008. */
  15009. renderTargetSamplingMode: number;
  15010. /**
  15011. * Clear color to use when screen clearing
  15012. */
  15013. clearColor: Color4;
  15014. /**
  15015. * If the buffer needs to be cleared before applying the post process. (default: true)
  15016. * Should be set to false if shader will overwrite all previous pixels.
  15017. */
  15018. autoClear: boolean;
  15019. /**
  15020. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15021. */
  15022. alphaMode: number;
  15023. /**
  15024. * Sets the setAlphaBlendConstants of the babylon engine
  15025. */
  15026. alphaConstants: Color4;
  15027. /**
  15028. * Animations to be used for the post processing
  15029. */
  15030. animations: Animation[];
  15031. /**
  15032. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15033. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15034. */
  15035. enablePixelPerfectMode: boolean;
  15036. /**
  15037. * Force the postprocess to be applied without taking in account viewport
  15038. */
  15039. forceFullscreenViewport: boolean;
  15040. /**
  15041. * List of inspectable custom properties (used by the Inspector)
  15042. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15043. */
  15044. inspectableCustomProperties: IInspectable[];
  15045. /**
  15046. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15047. *
  15048. * | Value | Type | Description |
  15049. * | ----- | ----------------------------------- | ----------- |
  15050. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15051. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15052. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15053. *
  15054. */
  15055. scaleMode: number;
  15056. /**
  15057. * Force textures to be a power of two (default: false)
  15058. */
  15059. alwaysForcePOT: boolean;
  15060. private _samples;
  15061. /**
  15062. * Number of sample textures (default: 1)
  15063. */
  15064. samples: number;
  15065. /**
  15066. * Modify the scale of the post process to be the same as the viewport (default: false)
  15067. */
  15068. adaptScaleToCurrentViewport: boolean;
  15069. private _camera;
  15070. private _scene;
  15071. private _engine;
  15072. private _options;
  15073. private _reusable;
  15074. private _textureType;
  15075. /**
  15076. * Smart array of input and output textures for the post process.
  15077. * @hidden
  15078. */
  15079. _textures: SmartArray<InternalTexture>;
  15080. /**
  15081. * The index in _textures that corresponds to the output texture.
  15082. * @hidden
  15083. */
  15084. _currentRenderTextureInd: number;
  15085. private _effect;
  15086. private _samplers;
  15087. private _fragmentUrl;
  15088. private _vertexUrl;
  15089. private _parameters;
  15090. private _scaleRatio;
  15091. protected _indexParameters: any;
  15092. private _shareOutputWithPostProcess;
  15093. private _texelSize;
  15094. private _forcedOutputTexture;
  15095. /**
  15096. * Returns the fragment url or shader name used in the post process.
  15097. * @returns the fragment url or name in the shader store.
  15098. */
  15099. getEffectName(): string;
  15100. /**
  15101. * An event triggered when the postprocess is activated.
  15102. */
  15103. onActivateObservable: Observable<Camera>;
  15104. private _onActivateObserver;
  15105. /**
  15106. * A function that is added to the onActivateObservable
  15107. */
  15108. onActivate: Nullable<(camera: Camera) => void>;
  15109. /**
  15110. * An event triggered when the postprocess changes its size.
  15111. */
  15112. onSizeChangedObservable: Observable<PostProcess>;
  15113. private _onSizeChangedObserver;
  15114. /**
  15115. * A function that is added to the onSizeChangedObservable
  15116. */
  15117. onSizeChanged: (postProcess: PostProcess) => void;
  15118. /**
  15119. * An event triggered when the postprocess applies its effect.
  15120. */
  15121. onApplyObservable: Observable<Effect>;
  15122. private _onApplyObserver;
  15123. /**
  15124. * A function that is added to the onApplyObservable
  15125. */
  15126. onApply: (effect: Effect) => void;
  15127. /**
  15128. * An event triggered before rendering the postprocess
  15129. */
  15130. onBeforeRenderObservable: Observable<Effect>;
  15131. private _onBeforeRenderObserver;
  15132. /**
  15133. * A function that is added to the onBeforeRenderObservable
  15134. */
  15135. onBeforeRender: (effect: Effect) => void;
  15136. /**
  15137. * An event triggered after rendering the postprocess
  15138. */
  15139. onAfterRenderObservable: Observable<Effect>;
  15140. private _onAfterRenderObserver;
  15141. /**
  15142. * A function that is added to the onAfterRenderObservable
  15143. */
  15144. onAfterRender: (efect: Effect) => void;
  15145. /**
  15146. * 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
  15147. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15148. */
  15149. inputTexture: InternalTexture;
  15150. /**
  15151. * Gets the camera which post process is applied to.
  15152. * @returns The camera the post process is applied to.
  15153. */
  15154. getCamera(): Camera;
  15155. /**
  15156. * Gets the texel size of the postprocess.
  15157. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15158. */
  15159. readonly texelSize: Vector2;
  15160. /**
  15161. * Creates a new instance PostProcess
  15162. * @param name The name of the PostProcess.
  15163. * @param fragmentUrl The url of the fragment shader to be used.
  15164. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15165. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15166. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15167. * @param camera The camera to apply the render pass to.
  15168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15169. * @param engine The engine which the post process will be applied. (default: current engine)
  15170. * @param reusable If the post process can be reused on the same frame. (default: false)
  15171. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15172. * @param textureType Type of textures used when performing the post process. (default: 0)
  15173. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15174. * @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
  15175. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15176. */
  15177. constructor(
  15178. /** Name of the PostProcess. */
  15179. 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);
  15180. /**
  15181. * Gets a string idenfifying the name of the class
  15182. * @returns "PostProcess" string
  15183. */
  15184. getClassName(): string;
  15185. /**
  15186. * Gets the engine which this post process belongs to.
  15187. * @returns The engine the post process was enabled with.
  15188. */
  15189. getEngine(): Engine;
  15190. /**
  15191. * The effect that is created when initializing the post process.
  15192. * @returns The created effect corresponding the the postprocess.
  15193. */
  15194. getEffect(): Effect;
  15195. /**
  15196. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15197. * @param postProcess The post process to share the output with.
  15198. * @returns This post process.
  15199. */
  15200. shareOutputWith(postProcess: PostProcess): PostProcess;
  15201. /**
  15202. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15203. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15204. */
  15205. useOwnOutput(): void;
  15206. /**
  15207. * Updates the effect with the current post process compile time values and recompiles the shader.
  15208. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15209. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15210. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15211. * @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
  15212. * @param onCompiled Called when the shader has been compiled.
  15213. * @param onError Called if there is an error when compiling a shader.
  15214. */
  15215. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15216. /**
  15217. * The post process is reusable if it can be used multiple times within one frame.
  15218. * @returns If the post process is reusable
  15219. */
  15220. isReusable(): boolean;
  15221. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15222. markTextureDirty(): void;
  15223. /**
  15224. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15225. * 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.
  15226. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15227. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15228. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15229. * @returns The target texture that was bound to be written to.
  15230. */
  15231. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15232. /**
  15233. * If the post process is supported.
  15234. */
  15235. readonly isSupported: boolean;
  15236. /**
  15237. * The aspect ratio of the output texture.
  15238. */
  15239. readonly aspectRatio: number;
  15240. /**
  15241. * Get a value indicating if the post-process is ready to be used
  15242. * @returns true if the post-process is ready (shader is compiled)
  15243. */
  15244. isReady(): boolean;
  15245. /**
  15246. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15247. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15248. */
  15249. apply(): Nullable<Effect>;
  15250. private _disposeTextures;
  15251. /**
  15252. * Disposes the post process.
  15253. * @param camera The camera to dispose the post process on.
  15254. */
  15255. dispose(camera?: Camera): void;
  15256. }
  15257. }
  15258. declare module BABYLON {
  15259. /** @hidden */
  15260. export var kernelBlurVaryingDeclaration: {
  15261. name: string;
  15262. shader: string;
  15263. };
  15264. }
  15265. declare module BABYLON {
  15266. /** @hidden */
  15267. export var kernelBlurFragment: {
  15268. name: string;
  15269. shader: string;
  15270. };
  15271. }
  15272. declare module BABYLON {
  15273. /** @hidden */
  15274. export var kernelBlurFragment2: {
  15275. name: string;
  15276. shader: string;
  15277. };
  15278. }
  15279. declare module BABYLON {
  15280. /** @hidden */
  15281. export var kernelBlurPixelShader: {
  15282. name: string;
  15283. shader: string;
  15284. };
  15285. }
  15286. declare module BABYLON {
  15287. /** @hidden */
  15288. export var kernelBlurVertex: {
  15289. name: string;
  15290. shader: string;
  15291. };
  15292. }
  15293. declare module BABYLON {
  15294. /** @hidden */
  15295. export var kernelBlurVertexShader: {
  15296. name: string;
  15297. shader: string;
  15298. };
  15299. }
  15300. declare module BABYLON {
  15301. /**
  15302. * The Blur Post Process which blurs an image based on a kernel and direction.
  15303. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15304. */
  15305. export class BlurPostProcess extends PostProcess {
  15306. /** The direction in which to blur the image. */
  15307. direction: Vector2;
  15308. private blockCompilation;
  15309. protected _kernel: number;
  15310. protected _idealKernel: number;
  15311. protected _packedFloat: boolean;
  15312. private _staticDefines;
  15313. /**
  15314. * Sets the length in pixels of the blur sample region
  15315. */
  15316. /**
  15317. * Gets the length in pixels of the blur sample region
  15318. */
  15319. kernel: number;
  15320. /**
  15321. * Sets wether or not the blur needs to unpack/repack floats
  15322. */
  15323. /**
  15324. * Gets wether or not the blur is unpacking/repacking floats
  15325. */
  15326. packedFloat: boolean;
  15327. /**
  15328. * Creates a new instance BlurPostProcess
  15329. * @param name The name of the effect.
  15330. * @param direction The direction in which to blur the image.
  15331. * @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.
  15332. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15333. * @param camera The camera to apply the render pass to.
  15334. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15335. * @param engine The engine which the post process will be applied. (default: current engine)
  15336. * @param reusable If the post process can be reused on the same frame. (default: false)
  15337. * @param textureType Type of textures used when performing the post process. (default: 0)
  15338. * @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)
  15339. */
  15340. constructor(name: string,
  15341. /** The direction in which to blur the image. */
  15342. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15343. /**
  15344. * Updates the effect with the current post process compile time values and recompiles the shader.
  15345. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15346. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15347. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15348. * @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
  15349. * @param onCompiled Called when the shader has been compiled.
  15350. * @param onError Called if there is an error when compiling a shader.
  15351. */
  15352. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15353. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15354. /**
  15355. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15356. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15357. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15358. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15359. * The gaps between physical kernels are compensated for in the weighting of the samples
  15360. * @param idealKernel Ideal blur kernel.
  15361. * @return Nearest best kernel.
  15362. */
  15363. protected _nearestBestKernel(idealKernel: number): number;
  15364. /**
  15365. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15366. * @param x The point on the Gaussian distribution to sample.
  15367. * @return the value of the Gaussian function at x.
  15368. */
  15369. protected _gaussianWeight(x: number): number;
  15370. /**
  15371. * Generates a string that can be used as a floating point number in GLSL.
  15372. * @param x Value to print.
  15373. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15374. * @return GLSL float string.
  15375. */
  15376. protected _glslFloat(x: number, decimalFigures?: number): string;
  15377. }
  15378. }
  15379. declare module BABYLON {
  15380. /**
  15381. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15382. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15383. * You can then easily use it as a reflectionTexture on a flat surface.
  15384. * In case the surface is not a plane, please consider relying on reflection probes.
  15385. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15386. */
  15387. export class MirrorTexture extends RenderTargetTexture {
  15388. private scene;
  15389. /**
  15390. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15391. * 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.
  15392. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15393. */
  15394. mirrorPlane: Plane;
  15395. /**
  15396. * Define the blur ratio used to blur the reflection if needed.
  15397. */
  15398. blurRatio: number;
  15399. /**
  15400. * Define the adaptive blur kernel used to blur the reflection if needed.
  15401. * This will autocompute the closest best match for the `blurKernel`
  15402. */
  15403. adaptiveBlurKernel: number;
  15404. /**
  15405. * Define the blur kernel used to blur the reflection if needed.
  15406. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15407. */
  15408. blurKernel: number;
  15409. /**
  15410. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15411. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15412. */
  15413. blurKernelX: number;
  15414. /**
  15415. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15416. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15417. */
  15418. blurKernelY: number;
  15419. private _autoComputeBlurKernel;
  15420. protected _onRatioRescale(): void;
  15421. private _updateGammaSpace;
  15422. private _imageProcessingConfigChangeObserver;
  15423. private _transformMatrix;
  15424. private _mirrorMatrix;
  15425. private _savedViewMatrix;
  15426. private _blurX;
  15427. private _blurY;
  15428. private _adaptiveBlurKernel;
  15429. private _blurKernelX;
  15430. private _blurKernelY;
  15431. private _blurRatio;
  15432. /**
  15433. * Instantiates a Mirror Texture.
  15434. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15435. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15436. * You can then easily use it as a reflectionTexture on a flat surface.
  15437. * In case the surface is not a plane, please consider relying on reflection probes.
  15438. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15439. * @param name
  15440. * @param size
  15441. * @param scene
  15442. * @param generateMipMaps
  15443. * @param type
  15444. * @param samplingMode
  15445. * @param generateDepthBuffer
  15446. */
  15447. constructor(name: string, size: number | {
  15448. width: number;
  15449. height: number;
  15450. } | {
  15451. ratio: number;
  15452. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15453. private _preparePostProcesses;
  15454. /**
  15455. * Clone the mirror texture.
  15456. * @returns the cloned texture
  15457. */
  15458. clone(): MirrorTexture;
  15459. /**
  15460. * Serialize the texture to a JSON representation you could use in Parse later on
  15461. * @returns the serialized JSON representation
  15462. */
  15463. serialize(): any;
  15464. /**
  15465. * Dispose the texture and release its associated resources.
  15466. */
  15467. dispose(): void;
  15468. }
  15469. }
  15470. declare module BABYLON {
  15471. /**
  15472. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15473. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15474. */
  15475. export class Texture extends BaseTexture {
  15476. /** @hidden */
  15477. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15478. /** @hidden */
  15479. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15480. /** @hidden */
  15481. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15482. /** nearest is mag = nearest and min = nearest and mip = linear */
  15483. static readonly NEAREST_SAMPLINGMODE: number;
  15484. /** nearest is mag = nearest and min = nearest and mip = linear */
  15485. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15486. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15487. static readonly BILINEAR_SAMPLINGMODE: number;
  15488. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15489. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15490. /** Trilinear is mag = linear and min = linear and mip = linear */
  15491. static readonly TRILINEAR_SAMPLINGMODE: number;
  15492. /** Trilinear is mag = linear and min = linear and mip = linear */
  15493. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15494. /** mag = nearest and min = nearest and mip = nearest */
  15495. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15496. /** mag = nearest and min = linear and mip = nearest */
  15497. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15498. /** mag = nearest and min = linear and mip = linear */
  15499. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15500. /** mag = nearest and min = linear and mip = none */
  15501. static readonly NEAREST_LINEAR: number;
  15502. /** mag = nearest and min = nearest and mip = none */
  15503. static readonly NEAREST_NEAREST: number;
  15504. /** mag = linear and min = nearest and mip = nearest */
  15505. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15506. /** mag = linear and min = nearest and mip = linear */
  15507. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15508. /** mag = linear and min = linear and mip = none */
  15509. static readonly LINEAR_LINEAR: number;
  15510. /** mag = linear and min = nearest and mip = none */
  15511. static readonly LINEAR_NEAREST: number;
  15512. /** Explicit coordinates mode */
  15513. static readonly EXPLICIT_MODE: number;
  15514. /** Spherical coordinates mode */
  15515. static readonly SPHERICAL_MODE: number;
  15516. /** Planar coordinates mode */
  15517. static readonly PLANAR_MODE: number;
  15518. /** Cubic coordinates mode */
  15519. static readonly CUBIC_MODE: number;
  15520. /** Projection coordinates mode */
  15521. static readonly PROJECTION_MODE: number;
  15522. /** Inverse Cubic coordinates mode */
  15523. static readonly SKYBOX_MODE: number;
  15524. /** Inverse Cubic coordinates mode */
  15525. static readonly INVCUBIC_MODE: number;
  15526. /** Equirectangular coordinates mode */
  15527. static readonly EQUIRECTANGULAR_MODE: number;
  15528. /** Equirectangular Fixed coordinates mode */
  15529. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15530. /** Equirectangular Fixed Mirrored coordinates mode */
  15531. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15532. /** Texture is not repeating outside of 0..1 UVs */
  15533. static readonly CLAMP_ADDRESSMODE: number;
  15534. /** Texture is repeating outside of 0..1 UVs */
  15535. static readonly WRAP_ADDRESSMODE: number;
  15536. /** Texture is repeating and mirrored */
  15537. static readonly MIRROR_ADDRESSMODE: number;
  15538. /**
  15539. * 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
  15540. */
  15541. static UseSerializedUrlIfAny: boolean;
  15542. /**
  15543. * Define the url of the texture.
  15544. */
  15545. url: Nullable<string>;
  15546. /**
  15547. * Define an offset on the texture to offset the u coordinates of the UVs
  15548. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15549. */
  15550. uOffset: number;
  15551. /**
  15552. * Define an offset on the texture to offset the v coordinates of the UVs
  15553. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15554. */
  15555. vOffset: number;
  15556. /**
  15557. * Define an offset on the texture to scale the u coordinates of the UVs
  15558. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15559. */
  15560. uScale: number;
  15561. /**
  15562. * Define an offset on the texture to scale the v coordinates of the UVs
  15563. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15564. */
  15565. vScale: number;
  15566. /**
  15567. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15568. * @see http://doc.babylonjs.com/how_to/more_materials
  15569. */
  15570. uAng: number;
  15571. /**
  15572. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15573. * @see http://doc.babylonjs.com/how_to/more_materials
  15574. */
  15575. vAng: number;
  15576. /**
  15577. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15578. * @see http://doc.babylonjs.com/how_to/more_materials
  15579. */
  15580. wAng: number;
  15581. /**
  15582. * Defines the center of rotation (U)
  15583. */
  15584. uRotationCenter: number;
  15585. /**
  15586. * Defines the center of rotation (V)
  15587. */
  15588. vRotationCenter: number;
  15589. /**
  15590. * Defines the center of rotation (W)
  15591. */
  15592. wRotationCenter: number;
  15593. /**
  15594. * Are mip maps generated for this texture or not.
  15595. */
  15596. readonly noMipmap: boolean;
  15597. /**
  15598. * List of inspectable custom properties (used by the Inspector)
  15599. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15600. */
  15601. inspectableCustomProperties: Nullable<IInspectable[]>;
  15602. private _noMipmap;
  15603. /** @hidden */
  15604. _invertY: boolean;
  15605. private _rowGenerationMatrix;
  15606. private _cachedTextureMatrix;
  15607. private _projectionModeMatrix;
  15608. private _t0;
  15609. private _t1;
  15610. private _t2;
  15611. private _cachedUOffset;
  15612. private _cachedVOffset;
  15613. private _cachedUScale;
  15614. private _cachedVScale;
  15615. private _cachedUAng;
  15616. private _cachedVAng;
  15617. private _cachedWAng;
  15618. private _cachedProjectionMatrixId;
  15619. private _cachedCoordinatesMode;
  15620. /** @hidden */
  15621. protected _initialSamplingMode: number;
  15622. /** @hidden */
  15623. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  15624. private _deleteBuffer;
  15625. protected _format: Nullable<number>;
  15626. private _delayedOnLoad;
  15627. private _delayedOnError;
  15628. /**
  15629. * Observable triggered once the texture has been loaded.
  15630. */
  15631. onLoadObservable: Observable<Texture>;
  15632. protected _isBlocking: boolean;
  15633. /**
  15634. * Is the texture preventing material to render while loading.
  15635. * If false, a default texture will be used instead of the loading one during the preparation step.
  15636. */
  15637. isBlocking: boolean;
  15638. /**
  15639. * Get the current sampling mode associated with the texture.
  15640. */
  15641. readonly samplingMode: number;
  15642. /**
  15643. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15644. */
  15645. readonly invertY: boolean;
  15646. /**
  15647. * Instantiates a new texture.
  15648. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15649. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15650. * @param url define the url of the picture to load as a texture
  15651. * @param scene define the scene or engine the texture will belong to
  15652. * @param noMipmap define if the texture will require mip maps or not
  15653. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15654. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15655. * @param onLoad define a callback triggered when the texture has been loaded
  15656. * @param onError define a callback triggered when an error occurred during the loading session
  15657. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15658. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15659. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15660. */
  15661. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15662. /**
  15663. * Update the url (and optional buffer) of this texture if url was null during construction.
  15664. * @param url the url of the texture
  15665. * @param buffer the buffer of the texture (defaults to null)
  15666. * @param onLoad callback called when the texture is loaded (defaults to null)
  15667. */
  15668. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15669. /**
  15670. * Finish the loading sequence of a texture flagged as delayed load.
  15671. * @hidden
  15672. */
  15673. delayLoad(): void;
  15674. private _prepareRowForTextureGeneration;
  15675. /**
  15676. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15677. * @returns the transform matrix of the texture.
  15678. */
  15679. getTextureMatrix(): Matrix;
  15680. /**
  15681. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15682. * @returns The reflection texture transform
  15683. */
  15684. getReflectionTextureMatrix(): Matrix;
  15685. /**
  15686. * Clones the texture.
  15687. * @returns the cloned texture
  15688. */
  15689. clone(): Texture;
  15690. /**
  15691. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15692. * @returns The JSON representation of the texture
  15693. */
  15694. serialize(): any;
  15695. /**
  15696. * Get the current class name of the texture useful for serialization or dynamic coding.
  15697. * @returns "Texture"
  15698. */
  15699. getClassName(): string;
  15700. /**
  15701. * Dispose the texture and release its associated resources.
  15702. */
  15703. dispose(): void;
  15704. /**
  15705. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15706. * @param parsedTexture Define the JSON representation of the texture
  15707. * @param scene Define the scene the parsed texture should be instantiated in
  15708. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15709. * @returns The parsed texture if successful
  15710. */
  15711. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15712. /**
  15713. * Creates a texture from its base 64 representation.
  15714. * @param data Define the base64 payload without the data: prefix
  15715. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15716. * @param scene Define the scene the texture should belong to
  15717. * @param noMipmap Forces the texture to not create mip map information if true
  15718. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15719. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15720. * @param onLoad define a callback triggered when the texture has been loaded
  15721. * @param onError define a callback triggered when an error occurred during the loading session
  15722. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15723. * @returns the created texture
  15724. */
  15725. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15726. /**
  15727. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15728. * @param data Define the base64 payload without the data: prefix
  15729. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15730. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15731. * @param scene Define the scene the texture should belong to
  15732. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15733. * @param noMipmap Forces the texture to not create mip map information if true
  15734. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15735. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15736. * @param onLoad define a callback triggered when the texture has been loaded
  15737. * @param onError define a callback triggered when an error occurred during the loading session
  15738. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15739. * @returns the created texture
  15740. */
  15741. 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;
  15742. }
  15743. }
  15744. declare module BABYLON {
  15745. /**
  15746. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15747. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15748. */
  15749. export class PostProcessManager {
  15750. private _scene;
  15751. private _indexBuffer;
  15752. private _vertexBuffers;
  15753. /**
  15754. * Creates a new instance PostProcess
  15755. * @param scene The scene that the post process is associated with.
  15756. */
  15757. constructor(scene: Scene);
  15758. private _prepareBuffers;
  15759. private _buildIndexBuffer;
  15760. /**
  15761. * Rebuilds the vertex buffers of the manager.
  15762. * @hidden
  15763. */
  15764. _rebuild(): void;
  15765. /**
  15766. * Prepares a frame to be run through a post process.
  15767. * @param sourceTexture The input texture to the post procesess. (default: null)
  15768. * @param postProcesses An array of post processes to be run. (default: null)
  15769. * @returns True if the post processes were able to be run.
  15770. * @hidden
  15771. */
  15772. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15773. /**
  15774. * Manually render a set of post processes to a texture.
  15775. * @param postProcesses An array of post processes to be run.
  15776. * @param targetTexture The target texture to render to.
  15777. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15778. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15779. * @param lodLevel defines which lod of the texture to render to
  15780. */
  15781. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15782. /**
  15783. * Finalize the result of the output of the postprocesses.
  15784. * @param doNotPresent If true the result will not be displayed to the screen.
  15785. * @param targetTexture The target texture to render to.
  15786. * @param faceIndex The index of the face to bind the target texture to.
  15787. * @param postProcesses The array of post processes to render.
  15788. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15789. * @hidden
  15790. */
  15791. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15792. /**
  15793. * Disposes of the post process manager.
  15794. */
  15795. dispose(): void;
  15796. }
  15797. }
  15798. declare module BABYLON {
  15799. /** Interface used by value gradients (color, factor, ...) */
  15800. export interface IValueGradient {
  15801. /**
  15802. * Gets or sets the gradient value (between 0 and 1)
  15803. */
  15804. gradient: number;
  15805. }
  15806. /** Class used to store color4 gradient */
  15807. export class ColorGradient implements IValueGradient {
  15808. /**
  15809. * Gets or sets the gradient value (between 0 and 1)
  15810. */
  15811. gradient: number;
  15812. /**
  15813. * Gets or sets first associated color
  15814. */
  15815. color1: Color4;
  15816. /**
  15817. * Gets or sets second associated color
  15818. */
  15819. color2?: Color4;
  15820. /**
  15821. * Will get a color picked randomly between color1 and color2.
  15822. * If color2 is undefined then color1 will be used
  15823. * @param result defines the target Color4 to store the result in
  15824. */
  15825. getColorToRef(result: Color4): void;
  15826. }
  15827. /** Class used to store color 3 gradient */
  15828. export class Color3Gradient implements IValueGradient {
  15829. /**
  15830. * Gets or sets the gradient value (between 0 and 1)
  15831. */
  15832. gradient: number;
  15833. /**
  15834. * Gets or sets the associated color
  15835. */
  15836. color: Color3;
  15837. }
  15838. /** Class used to store factor gradient */
  15839. export class FactorGradient implements IValueGradient {
  15840. /**
  15841. * Gets or sets the gradient value (between 0 and 1)
  15842. */
  15843. gradient: number;
  15844. /**
  15845. * Gets or sets first associated factor
  15846. */
  15847. factor1: number;
  15848. /**
  15849. * Gets or sets second associated factor
  15850. */
  15851. factor2?: number;
  15852. /**
  15853. * Will get a number picked randomly between factor1 and factor2.
  15854. * If factor2 is undefined then factor1 will be used
  15855. * @returns the picked number
  15856. */
  15857. getFactor(): number;
  15858. }
  15859. /**
  15860. * Helper used to simplify some generic gradient tasks
  15861. */
  15862. export class GradientHelper {
  15863. /**
  15864. * Gets the current gradient from an array of IValueGradient
  15865. * @param ratio defines the current ratio to get
  15866. * @param gradients defines the array of IValueGradient
  15867. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15868. */
  15869. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15870. }
  15871. }
  15872. declare module BABYLON {
  15873. interface AbstractScene {
  15874. /**
  15875. * The list of procedural textures added to the scene
  15876. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15877. */
  15878. proceduralTextures: Array<ProceduralTexture>;
  15879. }
  15880. /**
  15881. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15882. * in a given scene.
  15883. */
  15884. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15885. /**
  15886. * The component name helpfull to identify the component in the list of scene components.
  15887. */
  15888. readonly name: string;
  15889. /**
  15890. * The scene the component belongs to.
  15891. */
  15892. scene: Scene;
  15893. /**
  15894. * Creates a new instance of the component for the given scene
  15895. * @param scene Defines the scene to register the component in
  15896. */
  15897. constructor(scene: Scene);
  15898. /**
  15899. * Registers the component in a given scene
  15900. */
  15901. register(): void;
  15902. /**
  15903. * Rebuilds the elements related to this component in case of
  15904. * context lost for instance.
  15905. */
  15906. rebuild(): void;
  15907. /**
  15908. * Disposes the component and the associated ressources.
  15909. */
  15910. dispose(): void;
  15911. private _beforeClear;
  15912. }
  15913. }
  15914. declare module BABYLON {
  15915. interface Engine {
  15916. /**
  15917. * Creates a new render target cube texture
  15918. * @param size defines the size of the texture
  15919. * @param options defines the options used to create the texture
  15920. * @returns a new render target cube texture stored in an InternalTexture
  15921. */
  15922. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15923. }
  15924. }
  15925. declare module BABYLON {
  15926. /** @hidden */
  15927. export var proceduralVertexShader: {
  15928. name: string;
  15929. shader: string;
  15930. };
  15931. }
  15932. declare module BABYLON {
  15933. /**
  15934. * 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.
  15935. * This is the base class of any Procedural texture and contains most of the shareable code.
  15936. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15937. */
  15938. export class ProceduralTexture extends Texture {
  15939. isCube: boolean;
  15940. /**
  15941. * Define if the texture is enabled or not (disabled texture will not render)
  15942. */
  15943. isEnabled: boolean;
  15944. /**
  15945. * Define if the texture must be cleared before rendering (default is true)
  15946. */
  15947. autoClear: boolean;
  15948. /**
  15949. * Callback called when the texture is generated
  15950. */
  15951. onGenerated: () => void;
  15952. /**
  15953. * Event raised when the texture is generated
  15954. */
  15955. onGeneratedObservable: Observable<ProceduralTexture>;
  15956. /** @hidden */
  15957. _generateMipMaps: boolean;
  15958. /** @hidden **/
  15959. _effect: Effect;
  15960. /** @hidden */
  15961. _textures: {
  15962. [key: string]: Texture;
  15963. };
  15964. private _size;
  15965. private _currentRefreshId;
  15966. private _refreshRate;
  15967. private _vertexBuffers;
  15968. private _indexBuffer;
  15969. private _uniforms;
  15970. private _samplers;
  15971. private _fragment;
  15972. private _floats;
  15973. private _ints;
  15974. private _floatsArrays;
  15975. private _colors3;
  15976. private _colors4;
  15977. private _vectors2;
  15978. private _vectors3;
  15979. private _matrices;
  15980. private _fallbackTexture;
  15981. private _fallbackTextureUsed;
  15982. private _engine;
  15983. private _cachedDefines;
  15984. private _contentUpdateId;
  15985. private _contentData;
  15986. /**
  15987. * Instantiates a new procedural texture.
  15988. * 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.
  15989. * This is the base class of any Procedural texture and contains most of the shareable code.
  15990. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15991. * @param name Define the name of the texture
  15992. * @param size Define the size of the texture to create
  15993. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  15994. * @param scene Define the scene the texture belongs to
  15995. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  15996. * @param generateMipMaps Define if the texture should creates mip maps or not
  15997. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  15998. */
  15999. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16000. /**
  16001. * The effect that is created when initializing the post process.
  16002. * @returns The created effect corresponding the the postprocess.
  16003. */
  16004. getEffect(): Effect;
  16005. /**
  16006. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16007. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16008. */
  16009. getContent(): Nullable<ArrayBufferView>;
  16010. private _createIndexBuffer;
  16011. /** @hidden */
  16012. _rebuild(): void;
  16013. /**
  16014. * Resets the texture in order to recreate its associated resources.
  16015. * This can be called in case of context loss
  16016. */
  16017. reset(): void;
  16018. protected _getDefines(): string;
  16019. /**
  16020. * Is the texture ready to be used ? (rendered at least once)
  16021. * @returns true if ready, otherwise, false.
  16022. */
  16023. isReady(): boolean;
  16024. /**
  16025. * Resets the refresh counter of the texture and start bak from scratch.
  16026. * Could be useful to regenerate the texture if it is setup to render only once.
  16027. */
  16028. resetRefreshCounter(): void;
  16029. /**
  16030. * Set the fragment shader to use in order to render the texture.
  16031. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16032. */
  16033. setFragment(fragment: any): void;
  16034. /**
  16035. * Define the refresh rate of the texture or the rendering frequency.
  16036. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16037. */
  16038. refreshRate: number;
  16039. /** @hidden */
  16040. _shouldRender(): boolean;
  16041. /**
  16042. * Get the size the texture is rendering at.
  16043. * @returns the size (texture is always squared)
  16044. */
  16045. getRenderSize(): number;
  16046. /**
  16047. * Resize the texture to new value.
  16048. * @param size Define the new size the texture should have
  16049. * @param generateMipMaps Define whether the new texture should create mip maps
  16050. */
  16051. resize(size: number, generateMipMaps: boolean): void;
  16052. private _checkUniform;
  16053. /**
  16054. * Set a texture in the shader program used to render.
  16055. * @param name Define the name of the uniform samplers as defined in the shader
  16056. * @param texture Define the texture to bind to this sampler
  16057. * @return the texture itself allowing "fluent" like uniform updates
  16058. */
  16059. setTexture(name: string, texture: Texture): ProceduralTexture;
  16060. /**
  16061. * Set a float in the shader.
  16062. * @param name Define the name of the uniform as defined in the shader
  16063. * @param value Define the value to give to the uniform
  16064. * @return the texture itself allowing "fluent" like uniform updates
  16065. */
  16066. setFloat(name: string, value: number): ProceduralTexture;
  16067. /**
  16068. * Set a int in the shader.
  16069. * @param name Define the name of the uniform as defined in the shader
  16070. * @param value Define the value to give to the uniform
  16071. * @return the texture itself allowing "fluent" like uniform updates
  16072. */
  16073. setInt(name: string, value: number): ProceduralTexture;
  16074. /**
  16075. * Set an array of floats in the shader.
  16076. * @param name Define the name of the uniform as defined in the shader
  16077. * @param value Define the value to give to the uniform
  16078. * @return the texture itself allowing "fluent" like uniform updates
  16079. */
  16080. setFloats(name: string, value: number[]): ProceduralTexture;
  16081. /**
  16082. * Set a vec3 in the shader from a Color3.
  16083. * @param name Define the name of the uniform as defined in the shader
  16084. * @param value Define the value to give to the uniform
  16085. * @return the texture itself allowing "fluent" like uniform updates
  16086. */
  16087. setColor3(name: string, value: Color3): ProceduralTexture;
  16088. /**
  16089. * Set a vec4 in the shader from a Color4.
  16090. * @param name Define the name of the uniform as defined in the shader
  16091. * @param value Define the value to give to the uniform
  16092. * @return the texture itself allowing "fluent" like uniform updates
  16093. */
  16094. setColor4(name: string, value: Color4): ProceduralTexture;
  16095. /**
  16096. * Set a vec2 in the shader from a Vector2.
  16097. * @param name Define the name of the uniform as defined in the shader
  16098. * @param value Define the value to give to the uniform
  16099. * @return the texture itself allowing "fluent" like uniform updates
  16100. */
  16101. setVector2(name: string, value: Vector2): ProceduralTexture;
  16102. /**
  16103. * Set a vec3 in the shader from a Vector3.
  16104. * @param name Define the name of the uniform as defined in the shader
  16105. * @param value Define the value to give to the uniform
  16106. * @return the texture itself allowing "fluent" like uniform updates
  16107. */
  16108. setVector3(name: string, value: Vector3): ProceduralTexture;
  16109. /**
  16110. * Set a mat4 in the shader from a MAtrix.
  16111. * @param name Define the name of the uniform as defined in the shader
  16112. * @param value Define the value to give to the uniform
  16113. * @return the texture itself allowing "fluent" like uniform updates
  16114. */
  16115. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16116. /**
  16117. * Render the texture to its associated render target.
  16118. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16119. */
  16120. render(useCameraPostProcess?: boolean): void;
  16121. /**
  16122. * Clone the texture.
  16123. * @returns the cloned texture
  16124. */
  16125. clone(): ProceduralTexture;
  16126. /**
  16127. * Dispose the texture and release its asoociated resources.
  16128. */
  16129. dispose(): void;
  16130. }
  16131. }
  16132. declare module BABYLON {
  16133. /**
  16134. * This represents the base class for particle system in Babylon.
  16135. * 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.
  16136. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16137. * @example https://doc.babylonjs.com/babylon101/particles
  16138. */
  16139. export class BaseParticleSystem {
  16140. /**
  16141. * Source color is added to the destination color without alpha affecting the result
  16142. */
  16143. static BLENDMODE_ONEONE: number;
  16144. /**
  16145. * Blend current color and particle color using particle’s alpha
  16146. */
  16147. static BLENDMODE_STANDARD: number;
  16148. /**
  16149. * Add current color and particle color multiplied by particle’s alpha
  16150. */
  16151. static BLENDMODE_ADD: number;
  16152. /**
  16153. * Multiply current color with particle color
  16154. */
  16155. static BLENDMODE_MULTIPLY: number;
  16156. /**
  16157. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16158. */
  16159. static BLENDMODE_MULTIPLYADD: number;
  16160. /**
  16161. * List of animations used by the particle system.
  16162. */
  16163. animations: Animation[];
  16164. /**
  16165. * The id of the Particle system.
  16166. */
  16167. id: string;
  16168. /**
  16169. * The friendly name of the Particle system.
  16170. */
  16171. name: string;
  16172. /**
  16173. * The rendering group used by the Particle system to chose when to render.
  16174. */
  16175. renderingGroupId: number;
  16176. /**
  16177. * The emitter represents the Mesh or position we are attaching the particle system to.
  16178. */
  16179. emitter: Nullable<AbstractMesh | Vector3>;
  16180. /**
  16181. * The maximum number of particles to emit per frame
  16182. */
  16183. emitRate: number;
  16184. /**
  16185. * If you want to launch only a few particles at once, that can be done, as well.
  16186. */
  16187. manualEmitCount: number;
  16188. /**
  16189. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16190. */
  16191. updateSpeed: number;
  16192. /**
  16193. * The amount of time the particle system is running (depends of the overall update speed).
  16194. */
  16195. targetStopDuration: number;
  16196. /**
  16197. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16198. */
  16199. disposeOnStop: boolean;
  16200. /**
  16201. * Minimum power of emitting particles.
  16202. */
  16203. minEmitPower: number;
  16204. /**
  16205. * Maximum power of emitting particles.
  16206. */
  16207. maxEmitPower: number;
  16208. /**
  16209. * Minimum life time of emitting particles.
  16210. */
  16211. minLifeTime: number;
  16212. /**
  16213. * Maximum life time of emitting particles.
  16214. */
  16215. maxLifeTime: number;
  16216. /**
  16217. * Minimum Size of emitting particles.
  16218. */
  16219. minSize: number;
  16220. /**
  16221. * Maximum Size of emitting particles.
  16222. */
  16223. maxSize: number;
  16224. /**
  16225. * Minimum scale of emitting particles on X axis.
  16226. */
  16227. minScaleX: number;
  16228. /**
  16229. * Maximum scale of emitting particles on X axis.
  16230. */
  16231. maxScaleX: number;
  16232. /**
  16233. * Minimum scale of emitting particles on Y axis.
  16234. */
  16235. minScaleY: number;
  16236. /**
  16237. * Maximum scale of emitting particles on Y axis.
  16238. */
  16239. maxScaleY: number;
  16240. /**
  16241. * Gets or sets the minimal initial rotation in radians.
  16242. */
  16243. minInitialRotation: number;
  16244. /**
  16245. * Gets or sets the maximal initial rotation in radians.
  16246. */
  16247. maxInitialRotation: number;
  16248. /**
  16249. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16250. */
  16251. minAngularSpeed: number;
  16252. /**
  16253. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16254. */
  16255. maxAngularSpeed: number;
  16256. /**
  16257. * The texture used to render each particle. (this can be a spritesheet)
  16258. */
  16259. particleTexture: Nullable<Texture>;
  16260. /**
  16261. * The layer mask we are rendering the particles through.
  16262. */
  16263. layerMask: number;
  16264. /**
  16265. * This can help using your own shader to render the particle system.
  16266. * The according effect will be created
  16267. */
  16268. customShader: any;
  16269. /**
  16270. * By default particle system starts as soon as they are created. This prevents the
  16271. * automatic start to happen and let you decide when to start emitting particles.
  16272. */
  16273. preventAutoStart: boolean;
  16274. private _noiseTexture;
  16275. /**
  16276. * Gets or sets a texture used to add random noise to particle positions
  16277. */
  16278. noiseTexture: Nullable<ProceduralTexture>;
  16279. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16280. noiseStrength: Vector3;
  16281. /**
  16282. * Callback triggered when the particle animation is ending.
  16283. */
  16284. onAnimationEnd: Nullable<() => void>;
  16285. /**
  16286. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16287. */
  16288. blendMode: number;
  16289. /**
  16290. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16291. * to override the particles.
  16292. */
  16293. forceDepthWrite: boolean;
  16294. /** 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 */
  16295. preWarmCycles: number;
  16296. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16297. preWarmStepOffset: number;
  16298. /**
  16299. * 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)
  16300. */
  16301. spriteCellChangeSpeed: number;
  16302. /**
  16303. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16304. */
  16305. startSpriteCellID: number;
  16306. /**
  16307. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16308. */
  16309. endSpriteCellID: number;
  16310. /**
  16311. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16312. */
  16313. spriteCellWidth: number;
  16314. /**
  16315. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16316. */
  16317. spriteCellHeight: number;
  16318. /**
  16319. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16320. */
  16321. spriteRandomStartCell: boolean;
  16322. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16323. translationPivot: Vector2;
  16324. /** @hidden */
  16325. protected _isAnimationSheetEnabled: boolean;
  16326. /**
  16327. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16328. */
  16329. beginAnimationOnStart: boolean;
  16330. /**
  16331. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16332. */
  16333. beginAnimationFrom: number;
  16334. /**
  16335. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16336. */
  16337. beginAnimationTo: number;
  16338. /**
  16339. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16340. */
  16341. beginAnimationLoop: boolean;
  16342. /**
  16343. * Gets or sets a world offset applied to all particles
  16344. */
  16345. worldOffset: Vector3;
  16346. /**
  16347. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16348. */
  16349. isAnimationSheetEnabled: boolean;
  16350. /**
  16351. * Get hosting scene
  16352. * @returns the scene
  16353. */
  16354. getScene(): Scene;
  16355. /**
  16356. * You can use gravity if you want to give an orientation to your particles.
  16357. */
  16358. gravity: Vector3;
  16359. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16360. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16361. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16362. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16363. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16364. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16365. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16366. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16367. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16368. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16369. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16370. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16371. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16372. /**
  16373. * Defines the delay in milliseconds before starting the system (0 by default)
  16374. */
  16375. startDelay: number;
  16376. /**
  16377. * Gets the current list of drag gradients.
  16378. * You must use addDragGradient and removeDragGradient to udpate this list
  16379. * @returns the list of drag gradients
  16380. */
  16381. getDragGradients(): Nullable<Array<FactorGradient>>;
  16382. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16383. limitVelocityDamping: number;
  16384. /**
  16385. * Gets the current list of limit velocity gradients.
  16386. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16387. * @returns the list of limit velocity gradients
  16388. */
  16389. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16390. /**
  16391. * Gets the current list of color gradients.
  16392. * You must use addColorGradient and removeColorGradient to udpate this list
  16393. * @returns the list of color gradients
  16394. */
  16395. getColorGradients(): Nullable<Array<ColorGradient>>;
  16396. /**
  16397. * Gets the current list of size gradients.
  16398. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16399. * @returns the list of size gradients
  16400. */
  16401. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16402. /**
  16403. * Gets the current list of color remap gradients.
  16404. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16405. * @returns the list of color remap gradients
  16406. */
  16407. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16408. /**
  16409. * Gets the current list of alpha remap gradients.
  16410. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16411. * @returns the list of alpha remap gradients
  16412. */
  16413. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16414. /**
  16415. * Gets the current list of life time gradients.
  16416. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16417. * @returns the list of life time gradients
  16418. */
  16419. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16420. /**
  16421. * Gets the current list of angular speed gradients.
  16422. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16423. * @returns the list of angular speed gradients
  16424. */
  16425. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16426. /**
  16427. * Gets the current list of velocity gradients.
  16428. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16429. * @returns the list of velocity gradients
  16430. */
  16431. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16432. /**
  16433. * Gets the current list of start size gradients.
  16434. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16435. * @returns the list of start size gradients
  16436. */
  16437. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16438. /**
  16439. * Gets the current list of emit rate gradients.
  16440. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16441. * @returns the list of emit rate gradients
  16442. */
  16443. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16444. /**
  16445. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16446. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16447. */
  16448. direction1: Vector3;
  16449. /**
  16450. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16451. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16452. */
  16453. direction2: Vector3;
  16454. /**
  16455. * 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.
  16456. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16457. */
  16458. minEmitBox: Vector3;
  16459. /**
  16460. * 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.
  16461. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16462. */
  16463. maxEmitBox: Vector3;
  16464. /**
  16465. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16466. */
  16467. color1: Color4;
  16468. /**
  16469. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16470. */
  16471. color2: Color4;
  16472. /**
  16473. * Color the particle will have at the end of its lifetime
  16474. */
  16475. colorDead: Color4;
  16476. /**
  16477. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16478. */
  16479. textureMask: Color4;
  16480. /**
  16481. * The particle emitter type defines the emitter used by the particle system.
  16482. * It can be for example box, sphere, or cone...
  16483. */
  16484. particleEmitterType: IParticleEmitterType;
  16485. /** @hidden */
  16486. _isSubEmitter: boolean;
  16487. /**
  16488. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16489. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16490. */
  16491. billboardMode: number;
  16492. protected _isBillboardBased: boolean;
  16493. /**
  16494. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16495. */
  16496. isBillboardBased: boolean;
  16497. /**
  16498. * The scene the particle system belongs to.
  16499. */
  16500. protected _scene: Scene;
  16501. /**
  16502. * Local cache of defines for image processing.
  16503. */
  16504. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16505. /**
  16506. * Default configuration related to image processing available in the standard Material.
  16507. */
  16508. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16509. /**
  16510. * Gets the image processing configuration used either in this material.
  16511. */
  16512. /**
  16513. * Sets the Default image processing configuration used either in the this material.
  16514. *
  16515. * If sets to null, the scene one is in use.
  16516. */
  16517. imageProcessingConfiguration: ImageProcessingConfiguration;
  16518. /**
  16519. * Attaches a new image processing configuration to the Standard Material.
  16520. * @param configuration
  16521. */
  16522. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16523. /** @hidden */
  16524. protected _reset(): void;
  16525. /** @hidden */
  16526. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16527. /**
  16528. * Instantiates a particle system.
  16529. * 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.
  16530. * @param name The name of the particle system
  16531. */
  16532. constructor(name: string);
  16533. /**
  16534. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16535. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16536. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16537. * @returns the emitter
  16538. */
  16539. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16540. /**
  16541. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16542. * @param radius The radius of the hemisphere to emit from
  16543. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16544. * @returns the emitter
  16545. */
  16546. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16547. /**
  16548. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16549. * @param radius The radius of the sphere to emit from
  16550. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16551. * @returns the emitter
  16552. */
  16553. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16554. /**
  16555. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16556. * @param radius The radius of the sphere to emit from
  16557. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16558. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16559. * @returns the emitter
  16560. */
  16561. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16562. /**
  16563. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16564. * @param radius The radius of the emission cylinder
  16565. * @param height The height of the emission cylinder
  16566. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16567. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16568. * @returns the emitter
  16569. */
  16570. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16571. /**
  16572. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16573. * @param radius The radius of the cylinder to emit from
  16574. * @param height The height of the emission cylinder
  16575. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16576. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16577. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16578. * @returns the emitter
  16579. */
  16580. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16581. /**
  16582. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16583. * @param radius The radius of the cone to emit from
  16584. * @param angle The base angle of the cone
  16585. * @returns the emitter
  16586. */
  16587. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16588. /**
  16589. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16590. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16591. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16592. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16593. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16594. * @returns the emitter
  16595. */
  16596. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16597. }
  16598. }
  16599. declare module BABYLON {
  16600. /**
  16601. * Type of sub emitter
  16602. */
  16603. export enum SubEmitterType {
  16604. /**
  16605. * Attached to the particle over it's lifetime
  16606. */
  16607. ATTACHED = 0,
  16608. /**
  16609. * Created when the particle dies
  16610. */
  16611. END = 1
  16612. }
  16613. /**
  16614. * Sub emitter class used to emit particles from an existing particle
  16615. */
  16616. export class SubEmitter {
  16617. /**
  16618. * the particle system to be used by the sub emitter
  16619. */
  16620. particleSystem: ParticleSystem;
  16621. /**
  16622. * Type of the submitter (Default: END)
  16623. */
  16624. type: SubEmitterType;
  16625. /**
  16626. * 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)
  16627. * Note: This only is supported when using an emitter of type Mesh
  16628. */
  16629. inheritDirection: boolean;
  16630. /**
  16631. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16632. */
  16633. inheritedVelocityAmount: number;
  16634. /**
  16635. * Creates a sub emitter
  16636. * @param particleSystem the particle system to be used by the sub emitter
  16637. */
  16638. constructor(
  16639. /**
  16640. * the particle system to be used by the sub emitter
  16641. */
  16642. particleSystem: ParticleSystem);
  16643. /**
  16644. * Clones the sub emitter
  16645. * @returns the cloned sub emitter
  16646. */
  16647. clone(): SubEmitter;
  16648. /**
  16649. * Serialize current object to a JSON object
  16650. * @returns the serialized object
  16651. */
  16652. serialize(): any;
  16653. /** @hidden */
  16654. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16655. /**
  16656. * Creates a new SubEmitter from a serialized JSON version
  16657. * @param serializationObject defines the JSON object to read from
  16658. * @param scene defines the hosting scene
  16659. * @param rootUrl defines the rootUrl for data loading
  16660. * @returns a new SubEmitter
  16661. */
  16662. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16663. /** Release associated resources */
  16664. dispose(): void;
  16665. }
  16666. }
  16667. declare module BABYLON {
  16668. /** @hidden */
  16669. export var clipPlaneFragmentDeclaration: {
  16670. name: string;
  16671. shader: string;
  16672. };
  16673. }
  16674. declare module BABYLON {
  16675. /** @hidden */
  16676. export var imageProcessingDeclaration: {
  16677. name: string;
  16678. shader: string;
  16679. };
  16680. }
  16681. declare module BABYLON {
  16682. /** @hidden */
  16683. export var imageProcessingFunctions: {
  16684. name: string;
  16685. shader: string;
  16686. };
  16687. }
  16688. declare module BABYLON {
  16689. /** @hidden */
  16690. export var clipPlaneFragment: {
  16691. name: string;
  16692. shader: string;
  16693. };
  16694. }
  16695. declare module BABYLON {
  16696. /** @hidden */
  16697. export var particlesPixelShader: {
  16698. name: string;
  16699. shader: string;
  16700. };
  16701. }
  16702. declare module BABYLON {
  16703. /** @hidden */
  16704. export var clipPlaneVertexDeclaration: {
  16705. name: string;
  16706. shader: string;
  16707. };
  16708. }
  16709. declare module BABYLON {
  16710. /** @hidden */
  16711. export var clipPlaneVertex: {
  16712. name: string;
  16713. shader: string;
  16714. };
  16715. }
  16716. declare module BABYLON {
  16717. /** @hidden */
  16718. export var particlesVertexShader: {
  16719. name: string;
  16720. shader: string;
  16721. };
  16722. }
  16723. declare module BABYLON {
  16724. /**
  16725. * This represents a particle system in Babylon.
  16726. * 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.
  16727. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16728. * @example https://doc.babylonjs.com/babylon101/particles
  16729. */
  16730. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16731. /**
  16732. * Billboard mode will only apply to Y axis
  16733. */
  16734. static readonly BILLBOARDMODE_Y: number;
  16735. /**
  16736. * Billboard mode will apply to all axes
  16737. */
  16738. static readonly BILLBOARDMODE_ALL: number;
  16739. /**
  16740. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16741. */
  16742. static readonly BILLBOARDMODE_STRETCHED: number;
  16743. /**
  16744. * This function can be defined to provide custom update for active particles.
  16745. * This function will be called instead of regular update (age, position, color, etc.).
  16746. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16747. */
  16748. updateFunction: (particles: Particle[]) => void;
  16749. private _emitterWorldMatrix;
  16750. /**
  16751. * This function can be defined to specify initial direction for every new particle.
  16752. * It by default use the emitterType defined function
  16753. */
  16754. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16755. /**
  16756. * This function can be defined to specify initial position for every new particle.
  16757. * It by default use the emitterType defined function
  16758. */
  16759. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16760. /**
  16761. * @hidden
  16762. */
  16763. _inheritedVelocityOffset: Vector3;
  16764. /**
  16765. * An event triggered when the system is disposed
  16766. */
  16767. onDisposeObservable: Observable<ParticleSystem>;
  16768. private _onDisposeObserver;
  16769. /**
  16770. * Sets a callback that will be triggered when the system is disposed
  16771. */
  16772. onDispose: () => void;
  16773. private _particles;
  16774. private _epsilon;
  16775. private _capacity;
  16776. private _stockParticles;
  16777. private _newPartsExcess;
  16778. private _vertexData;
  16779. private _vertexBuffer;
  16780. private _vertexBuffers;
  16781. private _spriteBuffer;
  16782. private _indexBuffer;
  16783. private _effect;
  16784. private _customEffect;
  16785. private _cachedDefines;
  16786. private _scaledColorStep;
  16787. private _colorDiff;
  16788. private _scaledDirection;
  16789. private _scaledGravity;
  16790. private _currentRenderId;
  16791. private _alive;
  16792. private _useInstancing;
  16793. private _started;
  16794. private _stopped;
  16795. private _actualFrame;
  16796. private _scaledUpdateSpeed;
  16797. private _vertexBufferSize;
  16798. /** @hidden */
  16799. _currentEmitRateGradient: Nullable<FactorGradient>;
  16800. /** @hidden */
  16801. _currentEmitRate1: number;
  16802. /** @hidden */
  16803. _currentEmitRate2: number;
  16804. /** @hidden */
  16805. _currentStartSizeGradient: Nullable<FactorGradient>;
  16806. /** @hidden */
  16807. _currentStartSize1: number;
  16808. /** @hidden */
  16809. _currentStartSize2: number;
  16810. private readonly _rawTextureWidth;
  16811. private _rampGradientsTexture;
  16812. private _useRampGradients;
  16813. /** Gets or sets a boolean indicating that ramp gradients must be used
  16814. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16815. */
  16816. useRampGradients: boolean;
  16817. /**
  16818. * 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.
  16819. * 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: [])
  16820. */
  16821. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16822. private _subEmitters;
  16823. /**
  16824. * @hidden
  16825. * If the particle systems emitter should be disposed when the particle system is disposed
  16826. */
  16827. _disposeEmitterOnDispose: boolean;
  16828. /**
  16829. * The current active Sub-systems, this property is used by the root particle system only.
  16830. */
  16831. activeSubSystems: Array<ParticleSystem>;
  16832. private _rootParticleSystem;
  16833. /**
  16834. * Gets the current list of active particles
  16835. */
  16836. readonly particles: Particle[];
  16837. /**
  16838. * Returns the string "ParticleSystem"
  16839. * @returns a string containing the class name
  16840. */
  16841. getClassName(): string;
  16842. /**
  16843. * Instantiates a particle system.
  16844. * 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.
  16845. * @param name The name of the particle system
  16846. * @param capacity The max number of particles alive at the same time
  16847. * @param scene The scene the particle system belongs to
  16848. * @param customEffect a custom effect used to change the way particles are rendered by default
  16849. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16850. * @param epsilon Offset used to render the particles
  16851. */
  16852. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16853. private _addFactorGradient;
  16854. private _removeFactorGradient;
  16855. /**
  16856. * Adds a new life time gradient
  16857. * @param gradient defines the gradient to use (between 0 and 1)
  16858. * @param factor defines the life time factor to affect to the specified gradient
  16859. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16860. * @returns the current particle system
  16861. */
  16862. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16863. /**
  16864. * Remove a specific life time gradient
  16865. * @param gradient defines the gradient to remove
  16866. * @returns the current particle system
  16867. */
  16868. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16869. /**
  16870. * Adds a new size gradient
  16871. * @param gradient defines the gradient to use (between 0 and 1)
  16872. * @param factor defines the size factor to affect to the specified gradient
  16873. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16874. * @returns the current particle system
  16875. */
  16876. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16877. /**
  16878. * Remove a specific size gradient
  16879. * @param gradient defines the gradient to remove
  16880. * @returns the current particle system
  16881. */
  16882. removeSizeGradient(gradient: number): IParticleSystem;
  16883. /**
  16884. * Adds a new color remap gradient
  16885. * @param gradient defines the gradient to use (between 0 and 1)
  16886. * @param min defines the color remap minimal range
  16887. * @param max defines the color remap maximal range
  16888. * @returns the current particle system
  16889. */
  16890. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16891. /**
  16892. * Remove a specific color remap gradient
  16893. * @param gradient defines the gradient to remove
  16894. * @returns the current particle system
  16895. */
  16896. removeColorRemapGradient(gradient: number): IParticleSystem;
  16897. /**
  16898. * Adds a new alpha remap gradient
  16899. * @param gradient defines the gradient to use (between 0 and 1)
  16900. * @param min defines the alpha remap minimal range
  16901. * @param max defines the alpha remap maximal range
  16902. * @returns the current particle system
  16903. */
  16904. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16905. /**
  16906. * Remove a specific alpha remap gradient
  16907. * @param gradient defines the gradient to remove
  16908. * @returns the current particle system
  16909. */
  16910. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16911. /**
  16912. * Adds a new angular speed gradient
  16913. * @param gradient defines the gradient to use (between 0 and 1)
  16914. * @param factor defines the angular speed to affect to the specified gradient
  16915. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16916. * @returns the current particle system
  16917. */
  16918. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16919. /**
  16920. * Remove a specific angular speed gradient
  16921. * @param gradient defines the gradient to remove
  16922. * @returns the current particle system
  16923. */
  16924. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16925. /**
  16926. * Adds a new velocity gradient
  16927. * @param gradient defines the gradient to use (between 0 and 1)
  16928. * @param factor defines the velocity to affect to the specified gradient
  16929. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16930. * @returns the current particle system
  16931. */
  16932. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16933. /**
  16934. * Remove a specific velocity gradient
  16935. * @param gradient defines the gradient to remove
  16936. * @returns the current particle system
  16937. */
  16938. removeVelocityGradient(gradient: number): IParticleSystem;
  16939. /**
  16940. * Adds a new limit velocity gradient
  16941. * @param gradient defines the gradient to use (between 0 and 1)
  16942. * @param factor defines the limit velocity value to affect to the specified gradient
  16943. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16944. * @returns the current particle system
  16945. */
  16946. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16947. /**
  16948. * Remove a specific limit velocity gradient
  16949. * @param gradient defines the gradient to remove
  16950. * @returns the current particle system
  16951. */
  16952. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16953. /**
  16954. * Adds a new drag gradient
  16955. * @param gradient defines the gradient to use (between 0 and 1)
  16956. * @param factor defines the drag value to affect to the specified gradient
  16957. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16958. * @returns the current particle system
  16959. */
  16960. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16961. /**
  16962. * Remove a specific drag gradient
  16963. * @param gradient defines the gradient to remove
  16964. * @returns the current particle system
  16965. */
  16966. removeDragGradient(gradient: number): IParticleSystem;
  16967. /**
  16968. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16969. * @param gradient defines the gradient to use (between 0 and 1)
  16970. * @param factor defines the emit rate value to affect to the specified gradient
  16971. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16972. * @returns the current particle system
  16973. */
  16974. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16975. /**
  16976. * Remove a specific emit rate gradient
  16977. * @param gradient defines the gradient to remove
  16978. * @returns the current particle system
  16979. */
  16980. removeEmitRateGradient(gradient: number): IParticleSystem;
  16981. /**
  16982. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16983. * @param gradient defines the gradient to use (between 0 and 1)
  16984. * @param factor defines the start size value to affect to the specified gradient
  16985. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16986. * @returns the current particle system
  16987. */
  16988. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16989. /**
  16990. * Remove a specific start size gradient
  16991. * @param gradient defines the gradient to remove
  16992. * @returns the current particle system
  16993. */
  16994. removeStartSizeGradient(gradient: number): IParticleSystem;
  16995. private _createRampGradientTexture;
  16996. /**
  16997. * Gets the current list of ramp gradients.
  16998. * You must use addRampGradient and removeRampGradient to udpate this list
  16999. * @returns the list of ramp gradients
  17000. */
  17001. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17002. /**
  17003. * Adds a new ramp gradient used to remap particle colors
  17004. * @param gradient defines the gradient to use (between 0 and 1)
  17005. * @param color defines the color to affect to the specified gradient
  17006. * @returns the current particle system
  17007. */
  17008. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17009. /**
  17010. * Remove a specific ramp gradient
  17011. * @param gradient defines the gradient to remove
  17012. * @returns the current particle system
  17013. */
  17014. removeRampGradient(gradient: number): ParticleSystem;
  17015. /**
  17016. * Adds a new color gradient
  17017. * @param gradient defines the gradient to use (between 0 and 1)
  17018. * @param color1 defines the color to affect to the specified gradient
  17019. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17020. * @returns this particle system
  17021. */
  17022. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17023. /**
  17024. * Remove a specific color gradient
  17025. * @param gradient defines the gradient to remove
  17026. * @returns this particle system
  17027. */
  17028. removeColorGradient(gradient: number): IParticleSystem;
  17029. private _fetchR;
  17030. protected _reset(): void;
  17031. private _resetEffect;
  17032. private _createVertexBuffers;
  17033. private _createIndexBuffer;
  17034. /**
  17035. * Gets the maximum number of particles active at the same time.
  17036. * @returns The max number of active particles.
  17037. */
  17038. getCapacity(): number;
  17039. /**
  17040. * Gets whether there are still active particles in the system.
  17041. * @returns True if it is alive, otherwise false.
  17042. */
  17043. isAlive(): boolean;
  17044. /**
  17045. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17046. * @returns True if it has been started, otherwise false.
  17047. */
  17048. isStarted(): boolean;
  17049. private _prepareSubEmitterInternalArray;
  17050. /**
  17051. * Starts the particle system and begins to emit
  17052. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17053. */
  17054. start(delay?: number): void;
  17055. /**
  17056. * Stops the particle system.
  17057. * @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.
  17058. */
  17059. stop(stopSubEmitters?: boolean): void;
  17060. /**
  17061. * Remove all active particles
  17062. */
  17063. reset(): void;
  17064. /**
  17065. * @hidden (for internal use only)
  17066. */
  17067. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17068. /**
  17069. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17070. * Its lifetime will start back at 0.
  17071. */
  17072. recycleParticle: (particle: Particle) => void;
  17073. private _stopSubEmitters;
  17074. private _createParticle;
  17075. private _removeFromRoot;
  17076. private _emitFromParticle;
  17077. private _update;
  17078. /** @hidden */
  17079. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17080. /** @hidden */
  17081. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17082. /** @hidden */
  17083. private _getEffect;
  17084. /**
  17085. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17086. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17087. */
  17088. animate(preWarmOnly?: boolean): void;
  17089. private _appendParticleVertices;
  17090. /**
  17091. * Rebuilds the particle system.
  17092. */
  17093. rebuild(): void;
  17094. /**
  17095. * Is this system ready to be used/rendered
  17096. * @return true if the system is ready
  17097. */
  17098. isReady(): boolean;
  17099. private _render;
  17100. /**
  17101. * Renders the particle system in its current state.
  17102. * @returns the current number of particles
  17103. */
  17104. render(): number;
  17105. /**
  17106. * Disposes the particle system and free the associated resources
  17107. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17108. */
  17109. dispose(disposeTexture?: boolean): void;
  17110. /**
  17111. * Clones the particle system.
  17112. * @param name The name of the cloned object
  17113. * @param newEmitter The new emitter to use
  17114. * @returns the cloned particle system
  17115. */
  17116. clone(name: string, newEmitter: any): ParticleSystem;
  17117. /**
  17118. * Serializes the particle system to a JSON object.
  17119. * @returns the JSON object
  17120. */
  17121. serialize(): any;
  17122. /** @hidden */
  17123. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17124. /** @hidden */
  17125. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17126. /**
  17127. * Parses a JSON object to create a particle system.
  17128. * @param parsedParticleSystem The JSON object to parse
  17129. * @param scene The scene to create the particle system in
  17130. * @param rootUrl The root url to use to load external dependencies like texture
  17131. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17132. * @returns the Parsed particle system
  17133. */
  17134. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17135. }
  17136. }
  17137. declare module BABYLON {
  17138. /**
  17139. * A particle represents one of the element emitted by a particle system.
  17140. * This is mainly define by its coordinates, direction, velocity and age.
  17141. */
  17142. export class Particle {
  17143. /**
  17144. * The particle system the particle belongs to.
  17145. */
  17146. particleSystem: ParticleSystem;
  17147. private static _Count;
  17148. /**
  17149. * Unique ID of the particle
  17150. */
  17151. id: number;
  17152. /**
  17153. * The world position of the particle in the scene.
  17154. */
  17155. position: Vector3;
  17156. /**
  17157. * The world direction of the particle in the scene.
  17158. */
  17159. direction: Vector3;
  17160. /**
  17161. * The color of the particle.
  17162. */
  17163. color: Color4;
  17164. /**
  17165. * The color change of the particle per step.
  17166. */
  17167. colorStep: Color4;
  17168. /**
  17169. * Defines how long will the life of the particle be.
  17170. */
  17171. lifeTime: number;
  17172. /**
  17173. * The current age of the particle.
  17174. */
  17175. age: number;
  17176. /**
  17177. * The current size of the particle.
  17178. */
  17179. size: number;
  17180. /**
  17181. * The current scale of the particle.
  17182. */
  17183. scale: Vector2;
  17184. /**
  17185. * The current angle of the particle.
  17186. */
  17187. angle: number;
  17188. /**
  17189. * Defines how fast is the angle changing.
  17190. */
  17191. angularSpeed: number;
  17192. /**
  17193. * Defines the cell index used by the particle to be rendered from a sprite.
  17194. */
  17195. cellIndex: number;
  17196. /**
  17197. * The information required to support color remapping
  17198. */
  17199. remapData: Vector4;
  17200. /** @hidden */
  17201. _randomCellOffset?: number;
  17202. /** @hidden */
  17203. _initialDirection: Nullable<Vector3>;
  17204. /** @hidden */
  17205. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17206. /** @hidden */
  17207. _initialStartSpriteCellID: number;
  17208. /** @hidden */
  17209. _initialEndSpriteCellID: number;
  17210. /** @hidden */
  17211. _currentColorGradient: Nullable<ColorGradient>;
  17212. /** @hidden */
  17213. _currentColor1: Color4;
  17214. /** @hidden */
  17215. _currentColor2: Color4;
  17216. /** @hidden */
  17217. _currentSizeGradient: Nullable<FactorGradient>;
  17218. /** @hidden */
  17219. _currentSize1: number;
  17220. /** @hidden */
  17221. _currentSize2: number;
  17222. /** @hidden */
  17223. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17224. /** @hidden */
  17225. _currentAngularSpeed1: number;
  17226. /** @hidden */
  17227. _currentAngularSpeed2: number;
  17228. /** @hidden */
  17229. _currentVelocityGradient: Nullable<FactorGradient>;
  17230. /** @hidden */
  17231. _currentVelocity1: number;
  17232. /** @hidden */
  17233. _currentVelocity2: number;
  17234. /** @hidden */
  17235. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17236. /** @hidden */
  17237. _currentLimitVelocity1: number;
  17238. /** @hidden */
  17239. _currentLimitVelocity2: number;
  17240. /** @hidden */
  17241. _currentDragGradient: Nullable<FactorGradient>;
  17242. /** @hidden */
  17243. _currentDrag1: number;
  17244. /** @hidden */
  17245. _currentDrag2: number;
  17246. /** @hidden */
  17247. _randomNoiseCoordinates1: Vector3;
  17248. /** @hidden */
  17249. _randomNoiseCoordinates2: Vector3;
  17250. /**
  17251. * Creates a new instance Particle
  17252. * @param particleSystem the particle system the particle belongs to
  17253. */
  17254. constructor(
  17255. /**
  17256. * The particle system the particle belongs to.
  17257. */
  17258. particleSystem: ParticleSystem);
  17259. private updateCellInfoFromSystem;
  17260. /**
  17261. * Defines how the sprite cell index is updated for the particle
  17262. */
  17263. updateCellIndex(): void;
  17264. /** @hidden */
  17265. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17266. /** @hidden */
  17267. _inheritParticleInfoToSubEmitters(): void;
  17268. /** @hidden */
  17269. _reset(): void;
  17270. /**
  17271. * Copy the properties of particle to another one.
  17272. * @param other the particle to copy the information to.
  17273. */
  17274. copyTo(other: Particle): void;
  17275. }
  17276. }
  17277. declare module BABYLON {
  17278. /**
  17279. * Particle emitter represents a volume emitting particles.
  17280. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17281. */
  17282. export interface IParticleEmitterType {
  17283. /**
  17284. * Called by the particle System when the direction is computed for the created particle.
  17285. * @param worldMatrix is the world matrix of the particle system
  17286. * @param directionToUpdate is the direction vector to update with the result
  17287. * @param particle is the particle we are computed the direction for
  17288. */
  17289. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17290. /**
  17291. * Called by the particle System when the position is computed for the created particle.
  17292. * @param worldMatrix is the world matrix of the particle system
  17293. * @param positionToUpdate is the position vector to update with the result
  17294. * @param particle is the particle we are computed the position for
  17295. */
  17296. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17297. /**
  17298. * Clones the current emitter and returns a copy of it
  17299. * @returns the new emitter
  17300. */
  17301. clone(): IParticleEmitterType;
  17302. /**
  17303. * Called by the GPUParticleSystem to setup the update shader
  17304. * @param effect defines the update shader
  17305. */
  17306. applyToShader(effect: Effect): void;
  17307. /**
  17308. * Returns a string to use to update the GPU particles update shader
  17309. * @returns the effect defines string
  17310. */
  17311. getEffectDefines(): string;
  17312. /**
  17313. * Returns a string representing the class name
  17314. * @returns a string containing the class name
  17315. */
  17316. getClassName(): string;
  17317. /**
  17318. * Serializes the particle system to a JSON object.
  17319. * @returns the JSON object
  17320. */
  17321. serialize(): any;
  17322. /**
  17323. * Parse properties from a JSON object
  17324. * @param serializationObject defines the JSON object
  17325. */
  17326. parse(serializationObject: any): void;
  17327. }
  17328. }
  17329. declare module BABYLON {
  17330. /**
  17331. * Particle emitter emitting particles from the inside of a box.
  17332. * It emits the particles randomly between 2 given directions.
  17333. */
  17334. export class BoxParticleEmitter implements IParticleEmitterType {
  17335. /**
  17336. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17337. */
  17338. direction1: Vector3;
  17339. /**
  17340. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17341. */
  17342. direction2: Vector3;
  17343. /**
  17344. * 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.
  17345. */
  17346. minEmitBox: Vector3;
  17347. /**
  17348. * 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.
  17349. */
  17350. maxEmitBox: Vector3;
  17351. /**
  17352. * Creates a new instance BoxParticleEmitter
  17353. */
  17354. constructor();
  17355. /**
  17356. * Called by the particle System when the direction is computed for the created particle.
  17357. * @param worldMatrix is the world matrix of the particle system
  17358. * @param directionToUpdate is the direction vector to update with the result
  17359. * @param particle is the particle we are computed the direction for
  17360. */
  17361. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17362. /**
  17363. * Called by the particle System when the position is computed for the created particle.
  17364. * @param worldMatrix is the world matrix of the particle system
  17365. * @param positionToUpdate is the position vector to update with the result
  17366. * @param particle is the particle we are computed the position for
  17367. */
  17368. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17369. /**
  17370. * Clones the current emitter and returns a copy of it
  17371. * @returns the new emitter
  17372. */
  17373. clone(): BoxParticleEmitter;
  17374. /**
  17375. * Called by the GPUParticleSystem to setup the update shader
  17376. * @param effect defines the update shader
  17377. */
  17378. applyToShader(effect: Effect): void;
  17379. /**
  17380. * Returns a string to use to update the GPU particles update shader
  17381. * @returns a string containng the defines string
  17382. */
  17383. getEffectDefines(): string;
  17384. /**
  17385. * Returns the string "BoxParticleEmitter"
  17386. * @returns a string containing the class name
  17387. */
  17388. getClassName(): string;
  17389. /**
  17390. * Serializes the particle system to a JSON object.
  17391. * @returns the JSON object
  17392. */
  17393. serialize(): any;
  17394. /**
  17395. * Parse properties from a JSON object
  17396. * @param serializationObject defines the JSON object
  17397. */
  17398. parse(serializationObject: any): void;
  17399. }
  17400. }
  17401. declare module BABYLON {
  17402. /**
  17403. * Particle emitter emitting particles from the inside of a cone.
  17404. * It emits the particles alongside the cone volume from the base to the particle.
  17405. * The emission direction might be randomized.
  17406. */
  17407. export class ConeParticleEmitter implements IParticleEmitterType {
  17408. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17409. directionRandomizer: number;
  17410. private _radius;
  17411. private _angle;
  17412. private _height;
  17413. /**
  17414. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17415. */
  17416. radiusRange: number;
  17417. /**
  17418. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17419. */
  17420. heightRange: number;
  17421. /**
  17422. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17423. */
  17424. emitFromSpawnPointOnly: boolean;
  17425. /**
  17426. * Gets or sets the radius of the emission cone
  17427. */
  17428. radius: number;
  17429. /**
  17430. * Gets or sets the angle of the emission cone
  17431. */
  17432. angle: number;
  17433. private _buildHeight;
  17434. /**
  17435. * Creates a new instance ConeParticleEmitter
  17436. * @param radius the radius of the emission cone (1 by default)
  17437. * @param angle the cone base angle (PI by default)
  17438. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17439. */
  17440. constructor(radius?: number, angle?: number,
  17441. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17442. directionRandomizer?: number);
  17443. /**
  17444. * Called by the particle System when the direction is computed for the created particle.
  17445. * @param worldMatrix is the world matrix of the particle system
  17446. * @param directionToUpdate is the direction vector to update with the result
  17447. * @param particle is the particle we are computed the direction for
  17448. */
  17449. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17450. /**
  17451. * Called by the particle System when the position is computed for the created particle.
  17452. * @param worldMatrix is the world matrix of the particle system
  17453. * @param positionToUpdate is the position vector to update with the result
  17454. * @param particle is the particle we are computed the position for
  17455. */
  17456. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17457. /**
  17458. * Clones the current emitter and returns a copy of it
  17459. * @returns the new emitter
  17460. */
  17461. clone(): ConeParticleEmitter;
  17462. /**
  17463. * Called by the GPUParticleSystem to setup the update shader
  17464. * @param effect defines the update shader
  17465. */
  17466. applyToShader(effect: Effect): void;
  17467. /**
  17468. * Returns a string to use to update the GPU particles update shader
  17469. * @returns a string containng the defines string
  17470. */
  17471. getEffectDefines(): string;
  17472. /**
  17473. * Returns the string "ConeParticleEmitter"
  17474. * @returns a string containing the class name
  17475. */
  17476. getClassName(): string;
  17477. /**
  17478. * Serializes the particle system to a JSON object.
  17479. * @returns the JSON object
  17480. */
  17481. serialize(): any;
  17482. /**
  17483. * Parse properties from a JSON object
  17484. * @param serializationObject defines the JSON object
  17485. */
  17486. parse(serializationObject: any): void;
  17487. }
  17488. }
  17489. declare module BABYLON {
  17490. /**
  17491. * Particle emitter emitting particles from the inside of a cylinder.
  17492. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17493. */
  17494. export class CylinderParticleEmitter implements IParticleEmitterType {
  17495. /**
  17496. * The radius of the emission cylinder.
  17497. */
  17498. radius: number;
  17499. /**
  17500. * The height of the emission cylinder.
  17501. */
  17502. height: number;
  17503. /**
  17504. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17505. */
  17506. radiusRange: number;
  17507. /**
  17508. * How much to randomize the particle direction [0-1].
  17509. */
  17510. directionRandomizer: number;
  17511. /**
  17512. * Creates a new instance CylinderParticleEmitter
  17513. * @param radius the radius of the emission cylinder (1 by default)
  17514. * @param height the height of the emission cylinder (1 by default)
  17515. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17516. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17517. */
  17518. constructor(
  17519. /**
  17520. * The radius of the emission cylinder.
  17521. */
  17522. radius?: number,
  17523. /**
  17524. * The height of the emission cylinder.
  17525. */
  17526. height?: number,
  17527. /**
  17528. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17529. */
  17530. radiusRange?: number,
  17531. /**
  17532. * How much to randomize the particle direction [0-1].
  17533. */
  17534. directionRandomizer?: number);
  17535. /**
  17536. * Called by the particle System when the direction is computed for the created particle.
  17537. * @param worldMatrix is the world matrix of the particle system
  17538. * @param directionToUpdate is the direction vector to update with the result
  17539. * @param particle is the particle we are computed the direction for
  17540. */
  17541. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17542. /**
  17543. * Called by the particle System when the position is computed for the created particle.
  17544. * @param worldMatrix is the world matrix of the particle system
  17545. * @param positionToUpdate is the position vector to update with the result
  17546. * @param particle is the particle we are computed the position for
  17547. */
  17548. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17549. /**
  17550. * Clones the current emitter and returns a copy of it
  17551. * @returns the new emitter
  17552. */
  17553. clone(): CylinderParticleEmitter;
  17554. /**
  17555. * Called by the GPUParticleSystem to setup the update shader
  17556. * @param effect defines the update shader
  17557. */
  17558. applyToShader(effect: Effect): void;
  17559. /**
  17560. * Returns a string to use to update the GPU particles update shader
  17561. * @returns a string containng the defines string
  17562. */
  17563. getEffectDefines(): string;
  17564. /**
  17565. * Returns the string "CylinderParticleEmitter"
  17566. * @returns a string containing the class name
  17567. */
  17568. getClassName(): string;
  17569. /**
  17570. * Serializes the particle system to a JSON object.
  17571. * @returns the JSON object
  17572. */
  17573. serialize(): any;
  17574. /**
  17575. * Parse properties from a JSON object
  17576. * @param serializationObject defines the JSON object
  17577. */
  17578. parse(serializationObject: any): void;
  17579. }
  17580. /**
  17581. * Particle emitter emitting particles from the inside of a cylinder.
  17582. * It emits the particles randomly between two vectors.
  17583. */
  17584. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17585. /**
  17586. * The min limit of the emission direction.
  17587. */
  17588. direction1: Vector3;
  17589. /**
  17590. * The max limit of the emission direction.
  17591. */
  17592. direction2: Vector3;
  17593. /**
  17594. * Creates a new instance CylinderDirectedParticleEmitter
  17595. * @param radius the radius of the emission cylinder (1 by default)
  17596. * @param height the height of the emission cylinder (1 by default)
  17597. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17598. * @param direction1 the min limit of the emission direction (up vector by default)
  17599. * @param direction2 the max limit of the emission direction (up vector by default)
  17600. */
  17601. constructor(radius?: number, height?: number, radiusRange?: number,
  17602. /**
  17603. * The min limit of the emission direction.
  17604. */
  17605. direction1?: Vector3,
  17606. /**
  17607. * The max limit of the emission direction.
  17608. */
  17609. direction2?: Vector3);
  17610. /**
  17611. * Called by the particle System when the direction is computed for the created particle.
  17612. * @param worldMatrix is the world matrix of the particle system
  17613. * @param directionToUpdate is the direction vector to update with the result
  17614. * @param particle is the particle we are computed the direction for
  17615. */
  17616. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17617. /**
  17618. * Clones the current emitter and returns a copy of it
  17619. * @returns the new emitter
  17620. */
  17621. clone(): CylinderDirectedParticleEmitter;
  17622. /**
  17623. * Called by the GPUParticleSystem to setup the update shader
  17624. * @param effect defines the update shader
  17625. */
  17626. applyToShader(effect: Effect): void;
  17627. /**
  17628. * Returns a string to use to update the GPU particles update shader
  17629. * @returns a string containng the defines string
  17630. */
  17631. getEffectDefines(): string;
  17632. /**
  17633. * Returns the string "CylinderDirectedParticleEmitter"
  17634. * @returns a string containing the class name
  17635. */
  17636. getClassName(): string;
  17637. /**
  17638. * Serializes the particle system to a JSON object.
  17639. * @returns the JSON object
  17640. */
  17641. serialize(): any;
  17642. /**
  17643. * Parse properties from a JSON object
  17644. * @param serializationObject defines the JSON object
  17645. */
  17646. parse(serializationObject: any): void;
  17647. }
  17648. }
  17649. declare module BABYLON {
  17650. /**
  17651. * Particle emitter emitting particles from the inside of a hemisphere.
  17652. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17653. */
  17654. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17655. /**
  17656. * The radius of the emission hemisphere.
  17657. */
  17658. radius: number;
  17659. /**
  17660. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17661. */
  17662. radiusRange: number;
  17663. /**
  17664. * How much to randomize the particle direction [0-1].
  17665. */
  17666. directionRandomizer: number;
  17667. /**
  17668. * Creates a new instance HemisphericParticleEmitter
  17669. * @param radius the radius of the emission hemisphere (1 by default)
  17670. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17671. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17672. */
  17673. constructor(
  17674. /**
  17675. * The radius of the emission hemisphere.
  17676. */
  17677. radius?: number,
  17678. /**
  17679. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17680. */
  17681. radiusRange?: number,
  17682. /**
  17683. * How much to randomize the particle direction [0-1].
  17684. */
  17685. directionRandomizer?: number);
  17686. /**
  17687. * Called by the particle System when the direction is computed for the created particle.
  17688. * @param worldMatrix is the world matrix of the particle system
  17689. * @param directionToUpdate is the direction vector to update with the result
  17690. * @param particle is the particle we are computed the direction for
  17691. */
  17692. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17693. /**
  17694. * Called by the particle System when the position is computed for the created particle.
  17695. * @param worldMatrix is the world matrix of the particle system
  17696. * @param positionToUpdate is the position vector to update with the result
  17697. * @param particle is the particle we are computed the position for
  17698. */
  17699. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17700. /**
  17701. * Clones the current emitter and returns a copy of it
  17702. * @returns the new emitter
  17703. */
  17704. clone(): HemisphericParticleEmitter;
  17705. /**
  17706. * Called by the GPUParticleSystem to setup the update shader
  17707. * @param effect defines the update shader
  17708. */
  17709. applyToShader(effect: Effect): void;
  17710. /**
  17711. * Returns a string to use to update the GPU particles update shader
  17712. * @returns a string containng the defines string
  17713. */
  17714. getEffectDefines(): string;
  17715. /**
  17716. * Returns the string "HemisphericParticleEmitter"
  17717. * @returns a string containing the class name
  17718. */
  17719. getClassName(): string;
  17720. /**
  17721. * Serializes the particle system to a JSON object.
  17722. * @returns the JSON object
  17723. */
  17724. serialize(): any;
  17725. /**
  17726. * Parse properties from a JSON object
  17727. * @param serializationObject defines the JSON object
  17728. */
  17729. parse(serializationObject: any): void;
  17730. }
  17731. }
  17732. declare module BABYLON {
  17733. /**
  17734. * Particle emitter emitting particles from a point.
  17735. * It emits the particles randomly between 2 given directions.
  17736. */
  17737. export class PointParticleEmitter implements IParticleEmitterType {
  17738. /**
  17739. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17740. */
  17741. direction1: Vector3;
  17742. /**
  17743. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17744. */
  17745. direction2: Vector3;
  17746. /**
  17747. * Creates a new instance PointParticleEmitter
  17748. */
  17749. constructor();
  17750. /**
  17751. * Called by the particle System when the direction is computed for the created particle.
  17752. * @param worldMatrix is the world matrix of the particle system
  17753. * @param directionToUpdate is the direction vector to update with the result
  17754. * @param particle is the particle we are computed the direction for
  17755. */
  17756. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17757. /**
  17758. * Called by the particle System when the position is computed for the created particle.
  17759. * @param worldMatrix is the world matrix of the particle system
  17760. * @param positionToUpdate is the position vector to update with the result
  17761. * @param particle is the particle we are computed the position for
  17762. */
  17763. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17764. /**
  17765. * Clones the current emitter and returns a copy of it
  17766. * @returns the new emitter
  17767. */
  17768. clone(): PointParticleEmitter;
  17769. /**
  17770. * Called by the GPUParticleSystem to setup the update shader
  17771. * @param effect defines the update shader
  17772. */
  17773. applyToShader(effect: Effect): void;
  17774. /**
  17775. * Returns a string to use to update the GPU particles update shader
  17776. * @returns a string containng the defines string
  17777. */
  17778. getEffectDefines(): string;
  17779. /**
  17780. * Returns the string "PointParticleEmitter"
  17781. * @returns a string containing the class name
  17782. */
  17783. getClassName(): string;
  17784. /**
  17785. * Serializes the particle system to a JSON object.
  17786. * @returns the JSON object
  17787. */
  17788. serialize(): any;
  17789. /**
  17790. * Parse properties from a JSON object
  17791. * @param serializationObject defines the JSON object
  17792. */
  17793. parse(serializationObject: any): void;
  17794. }
  17795. }
  17796. declare module BABYLON {
  17797. /**
  17798. * Particle emitter emitting particles from the inside of a sphere.
  17799. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17800. */
  17801. export class SphereParticleEmitter implements IParticleEmitterType {
  17802. /**
  17803. * The radius of the emission sphere.
  17804. */
  17805. radius: number;
  17806. /**
  17807. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17808. */
  17809. radiusRange: number;
  17810. /**
  17811. * How much to randomize the particle direction [0-1].
  17812. */
  17813. directionRandomizer: number;
  17814. /**
  17815. * Creates a new instance SphereParticleEmitter
  17816. * @param radius the radius of the emission sphere (1 by default)
  17817. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17818. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17819. */
  17820. constructor(
  17821. /**
  17822. * The radius of the emission sphere.
  17823. */
  17824. radius?: number,
  17825. /**
  17826. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17827. */
  17828. radiusRange?: number,
  17829. /**
  17830. * How much to randomize the particle direction [0-1].
  17831. */
  17832. directionRandomizer?: number);
  17833. /**
  17834. * Called by the particle System when the direction is computed for the created particle.
  17835. * @param worldMatrix is the world matrix of the particle system
  17836. * @param directionToUpdate is the direction vector to update with the result
  17837. * @param particle is the particle we are computed the direction for
  17838. */
  17839. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17840. /**
  17841. * Called by the particle System when the position is computed for the created particle.
  17842. * @param worldMatrix is the world matrix of the particle system
  17843. * @param positionToUpdate is the position vector to update with the result
  17844. * @param particle is the particle we are computed the position for
  17845. */
  17846. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17847. /**
  17848. * Clones the current emitter and returns a copy of it
  17849. * @returns the new emitter
  17850. */
  17851. clone(): SphereParticleEmitter;
  17852. /**
  17853. * Called by the GPUParticleSystem to setup the update shader
  17854. * @param effect defines the update shader
  17855. */
  17856. applyToShader(effect: Effect): void;
  17857. /**
  17858. * Returns a string to use to update the GPU particles update shader
  17859. * @returns a string containng the defines string
  17860. */
  17861. getEffectDefines(): string;
  17862. /**
  17863. * Returns the string "SphereParticleEmitter"
  17864. * @returns a string containing the class name
  17865. */
  17866. getClassName(): string;
  17867. /**
  17868. * Serializes the particle system to a JSON object.
  17869. * @returns the JSON object
  17870. */
  17871. serialize(): any;
  17872. /**
  17873. * Parse properties from a JSON object
  17874. * @param serializationObject defines the JSON object
  17875. */
  17876. parse(serializationObject: any): void;
  17877. }
  17878. /**
  17879. * Particle emitter emitting particles from the inside of a sphere.
  17880. * It emits the particles randomly between two vectors.
  17881. */
  17882. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17883. /**
  17884. * The min limit of the emission direction.
  17885. */
  17886. direction1: Vector3;
  17887. /**
  17888. * The max limit of the emission direction.
  17889. */
  17890. direction2: Vector3;
  17891. /**
  17892. * Creates a new instance SphereDirectedParticleEmitter
  17893. * @param radius the radius of the emission sphere (1 by default)
  17894. * @param direction1 the min limit of the emission direction (up vector by default)
  17895. * @param direction2 the max limit of the emission direction (up vector by default)
  17896. */
  17897. constructor(radius?: number,
  17898. /**
  17899. * The min limit of the emission direction.
  17900. */
  17901. direction1?: Vector3,
  17902. /**
  17903. * The max limit of the emission direction.
  17904. */
  17905. direction2?: Vector3);
  17906. /**
  17907. * Called by the particle System when the direction is computed for the created particle.
  17908. * @param worldMatrix is the world matrix of the particle system
  17909. * @param directionToUpdate is the direction vector to update with the result
  17910. * @param particle is the particle we are computed the direction for
  17911. */
  17912. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17913. /**
  17914. * Clones the current emitter and returns a copy of it
  17915. * @returns the new emitter
  17916. */
  17917. clone(): SphereDirectedParticleEmitter;
  17918. /**
  17919. * Called by the GPUParticleSystem to setup the update shader
  17920. * @param effect defines the update shader
  17921. */
  17922. applyToShader(effect: Effect): void;
  17923. /**
  17924. * Returns a string to use to update the GPU particles update shader
  17925. * @returns a string containng the defines string
  17926. */
  17927. getEffectDefines(): string;
  17928. /**
  17929. * Returns the string "SphereDirectedParticleEmitter"
  17930. * @returns a string containing the class name
  17931. */
  17932. getClassName(): string;
  17933. /**
  17934. * Serializes the particle system to a JSON object.
  17935. * @returns the JSON object
  17936. */
  17937. serialize(): any;
  17938. /**
  17939. * Parse properties from a JSON object
  17940. * @param serializationObject defines the JSON object
  17941. */
  17942. parse(serializationObject: any): void;
  17943. }
  17944. }
  17945. declare module BABYLON {
  17946. /**
  17947. * Interface representing a particle system in Babylon.js.
  17948. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17949. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17950. */
  17951. export interface IParticleSystem {
  17952. /**
  17953. * List of animations used by the particle system.
  17954. */
  17955. animations: Animation[];
  17956. /**
  17957. * The id of the Particle system.
  17958. */
  17959. id: string;
  17960. /**
  17961. * The name of the Particle system.
  17962. */
  17963. name: string;
  17964. /**
  17965. * The emitter represents the Mesh or position we are attaching the particle system to.
  17966. */
  17967. emitter: Nullable<AbstractMesh | Vector3>;
  17968. /**
  17969. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17970. */
  17971. isBillboardBased: boolean;
  17972. /**
  17973. * The rendering group used by the Particle system to chose when to render.
  17974. */
  17975. renderingGroupId: number;
  17976. /**
  17977. * The layer mask we are rendering the particles through.
  17978. */
  17979. layerMask: number;
  17980. /**
  17981. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17982. */
  17983. updateSpeed: number;
  17984. /**
  17985. * The amount of time the particle system is running (depends of the overall update speed).
  17986. */
  17987. targetStopDuration: number;
  17988. /**
  17989. * The texture used to render each particle. (this can be a spritesheet)
  17990. */
  17991. particleTexture: Nullable<Texture>;
  17992. /**
  17993. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17994. */
  17995. blendMode: number;
  17996. /**
  17997. * Minimum life time of emitting particles.
  17998. */
  17999. minLifeTime: number;
  18000. /**
  18001. * Maximum life time of emitting particles.
  18002. */
  18003. maxLifeTime: number;
  18004. /**
  18005. * Minimum Size of emitting particles.
  18006. */
  18007. minSize: number;
  18008. /**
  18009. * Maximum Size of emitting particles.
  18010. */
  18011. maxSize: number;
  18012. /**
  18013. * Minimum scale of emitting particles on X axis.
  18014. */
  18015. minScaleX: number;
  18016. /**
  18017. * Maximum scale of emitting particles on X axis.
  18018. */
  18019. maxScaleX: number;
  18020. /**
  18021. * Minimum scale of emitting particles on Y axis.
  18022. */
  18023. minScaleY: number;
  18024. /**
  18025. * Maximum scale of emitting particles on Y axis.
  18026. */
  18027. maxScaleY: number;
  18028. /**
  18029. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18030. */
  18031. color1: Color4;
  18032. /**
  18033. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18034. */
  18035. color2: Color4;
  18036. /**
  18037. * Color the particle will have at the end of its lifetime.
  18038. */
  18039. colorDead: Color4;
  18040. /**
  18041. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18042. */
  18043. emitRate: number;
  18044. /**
  18045. * You can use gravity if you want to give an orientation to your particles.
  18046. */
  18047. gravity: Vector3;
  18048. /**
  18049. * Minimum power of emitting particles.
  18050. */
  18051. minEmitPower: number;
  18052. /**
  18053. * Maximum power of emitting particles.
  18054. */
  18055. maxEmitPower: number;
  18056. /**
  18057. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18058. */
  18059. minAngularSpeed: number;
  18060. /**
  18061. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18062. */
  18063. maxAngularSpeed: number;
  18064. /**
  18065. * Gets or sets the minimal initial rotation in radians.
  18066. */
  18067. minInitialRotation: number;
  18068. /**
  18069. * Gets or sets the maximal initial rotation in radians.
  18070. */
  18071. maxInitialRotation: number;
  18072. /**
  18073. * The particle emitter type defines the emitter used by the particle system.
  18074. * It can be for example box, sphere, or cone...
  18075. */
  18076. particleEmitterType: Nullable<IParticleEmitterType>;
  18077. /**
  18078. * Defines the delay in milliseconds before starting the system (0 by default)
  18079. */
  18080. startDelay: number;
  18081. /**
  18082. * 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
  18083. */
  18084. preWarmCycles: number;
  18085. /**
  18086. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18087. */
  18088. preWarmStepOffset: number;
  18089. /**
  18090. * 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)
  18091. */
  18092. spriteCellChangeSpeed: number;
  18093. /**
  18094. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18095. */
  18096. startSpriteCellID: number;
  18097. /**
  18098. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18099. */
  18100. endSpriteCellID: number;
  18101. /**
  18102. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18103. */
  18104. spriteCellWidth: number;
  18105. /**
  18106. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18107. */
  18108. spriteCellHeight: number;
  18109. /**
  18110. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18111. */
  18112. spriteRandomStartCell: boolean;
  18113. /**
  18114. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18115. */
  18116. isAnimationSheetEnabled: boolean;
  18117. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18118. translationPivot: Vector2;
  18119. /**
  18120. * Gets or sets a texture used to add random noise to particle positions
  18121. */
  18122. noiseTexture: Nullable<BaseTexture>;
  18123. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18124. noiseStrength: Vector3;
  18125. /**
  18126. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18127. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18128. */
  18129. billboardMode: number;
  18130. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18131. limitVelocityDamping: number;
  18132. /**
  18133. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18134. */
  18135. beginAnimationOnStart: boolean;
  18136. /**
  18137. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18138. */
  18139. beginAnimationFrom: number;
  18140. /**
  18141. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18142. */
  18143. beginAnimationTo: number;
  18144. /**
  18145. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18146. */
  18147. beginAnimationLoop: boolean;
  18148. /**
  18149. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18150. */
  18151. disposeOnStop: boolean;
  18152. /**
  18153. * Gets the maximum number of particles active at the same time.
  18154. * @returns The max number of active particles.
  18155. */
  18156. getCapacity(): number;
  18157. /**
  18158. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18159. * @returns True if it has been started, otherwise false.
  18160. */
  18161. isStarted(): boolean;
  18162. /**
  18163. * Animates the particle system for this frame.
  18164. */
  18165. animate(): void;
  18166. /**
  18167. * Renders the particle system in its current state.
  18168. * @returns the current number of particles
  18169. */
  18170. render(): number;
  18171. /**
  18172. * Dispose the particle system and frees its associated resources.
  18173. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18174. */
  18175. dispose(disposeTexture?: boolean): void;
  18176. /**
  18177. * Clones the particle system.
  18178. * @param name The name of the cloned object
  18179. * @param newEmitter The new emitter to use
  18180. * @returns the cloned particle system
  18181. */
  18182. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18183. /**
  18184. * Serializes the particle system to a JSON object.
  18185. * @returns the JSON object
  18186. */
  18187. serialize(): any;
  18188. /**
  18189. * Rebuild the particle system
  18190. */
  18191. rebuild(): void;
  18192. /**
  18193. * Starts the particle system and begins to emit
  18194. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18195. */
  18196. start(delay?: number): void;
  18197. /**
  18198. * Stops the particle system.
  18199. */
  18200. stop(): void;
  18201. /**
  18202. * Remove all active particles
  18203. */
  18204. reset(): void;
  18205. /**
  18206. * Is this system ready to be used/rendered
  18207. * @return true if the system is ready
  18208. */
  18209. isReady(): boolean;
  18210. /**
  18211. * Adds a new color gradient
  18212. * @param gradient defines the gradient to use (between 0 and 1)
  18213. * @param color1 defines the color to affect to the specified gradient
  18214. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18215. * @returns the current particle system
  18216. */
  18217. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18218. /**
  18219. * Remove a specific color gradient
  18220. * @param gradient defines the gradient to remove
  18221. * @returns the current particle system
  18222. */
  18223. removeColorGradient(gradient: number): IParticleSystem;
  18224. /**
  18225. * Adds a new size gradient
  18226. * @param gradient defines the gradient to use (between 0 and 1)
  18227. * @param factor defines the size factor to affect to the specified gradient
  18228. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18229. * @returns the current particle system
  18230. */
  18231. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18232. /**
  18233. * Remove a specific size gradient
  18234. * @param gradient defines the gradient to remove
  18235. * @returns the current particle system
  18236. */
  18237. removeSizeGradient(gradient: number): IParticleSystem;
  18238. /**
  18239. * Gets the current list of color gradients.
  18240. * You must use addColorGradient and removeColorGradient to udpate this list
  18241. * @returns the list of color gradients
  18242. */
  18243. getColorGradients(): Nullable<Array<ColorGradient>>;
  18244. /**
  18245. * Gets the current list of size gradients.
  18246. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18247. * @returns the list of size gradients
  18248. */
  18249. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18250. /**
  18251. * Gets the current list of angular speed gradients.
  18252. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18253. * @returns the list of angular speed gradients
  18254. */
  18255. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18256. /**
  18257. * Adds a new angular speed gradient
  18258. * @param gradient defines the gradient to use (between 0 and 1)
  18259. * @param factor defines the angular speed to affect to the specified gradient
  18260. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18261. * @returns the current particle system
  18262. */
  18263. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18264. /**
  18265. * Remove a specific angular speed gradient
  18266. * @param gradient defines the gradient to remove
  18267. * @returns the current particle system
  18268. */
  18269. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18270. /**
  18271. * Gets the current list of velocity gradients.
  18272. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18273. * @returns the list of velocity gradients
  18274. */
  18275. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18276. /**
  18277. * Adds a new velocity gradient
  18278. * @param gradient defines the gradient to use (between 0 and 1)
  18279. * @param factor defines the velocity to affect to the specified gradient
  18280. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18281. * @returns the current particle system
  18282. */
  18283. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18284. /**
  18285. * Remove a specific velocity gradient
  18286. * @param gradient defines the gradient to remove
  18287. * @returns the current particle system
  18288. */
  18289. removeVelocityGradient(gradient: number): IParticleSystem;
  18290. /**
  18291. * Gets the current list of limit velocity gradients.
  18292. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18293. * @returns the list of limit velocity gradients
  18294. */
  18295. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18296. /**
  18297. * Adds a new limit velocity gradient
  18298. * @param gradient defines the gradient to use (between 0 and 1)
  18299. * @param factor defines the limit velocity to affect to the specified gradient
  18300. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18301. * @returns the current particle system
  18302. */
  18303. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18304. /**
  18305. * Remove a specific limit velocity gradient
  18306. * @param gradient defines the gradient to remove
  18307. * @returns the current particle system
  18308. */
  18309. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18310. /**
  18311. * Adds a new drag gradient
  18312. * @param gradient defines the gradient to use (between 0 and 1)
  18313. * @param factor defines the drag to affect to the specified gradient
  18314. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18315. * @returns the current particle system
  18316. */
  18317. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18318. /**
  18319. * Remove a specific drag gradient
  18320. * @param gradient defines the gradient to remove
  18321. * @returns the current particle system
  18322. */
  18323. removeDragGradient(gradient: number): IParticleSystem;
  18324. /**
  18325. * Gets the current list of drag gradients.
  18326. * You must use addDragGradient and removeDragGradient to udpate this list
  18327. * @returns the list of drag gradients
  18328. */
  18329. getDragGradients(): Nullable<Array<FactorGradient>>;
  18330. /**
  18331. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18332. * @param gradient defines the gradient to use (between 0 and 1)
  18333. * @param factor defines the emit rate to affect to the specified gradient
  18334. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18335. * @returns the current particle system
  18336. */
  18337. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18338. /**
  18339. * Remove a specific emit rate gradient
  18340. * @param gradient defines the gradient to remove
  18341. * @returns the current particle system
  18342. */
  18343. removeEmitRateGradient(gradient: number): IParticleSystem;
  18344. /**
  18345. * Gets the current list of emit rate gradients.
  18346. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18347. * @returns the list of emit rate gradients
  18348. */
  18349. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18350. /**
  18351. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18352. * @param gradient defines the gradient to use (between 0 and 1)
  18353. * @param factor defines the start size to affect to the specified gradient
  18354. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18355. * @returns the current particle system
  18356. */
  18357. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18358. /**
  18359. * Remove a specific start size gradient
  18360. * @param gradient defines the gradient to remove
  18361. * @returns the current particle system
  18362. */
  18363. removeStartSizeGradient(gradient: number): IParticleSystem;
  18364. /**
  18365. * Gets the current list of start size gradients.
  18366. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18367. * @returns the list of start size gradients
  18368. */
  18369. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18370. /**
  18371. * Adds a new life time gradient
  18372. * @param gradient defines the gradient to use (between 0 and 1)
  18373. * @param factor defines the life time factor to affect to the specified gradient
  18374. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18375. * @returns the current particle system
  18376. */
  18377. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18378. /**
  18379. * Remove a specific life time gradient
  18380. * @param gradient defines the gradient to remove
  18381. * @returns the current particle system
  18382. */
  18383. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18384. /**
  18385. * Gets the current list of life time gradients.
  18386. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18387. * @returns the list of life time gradients
  18388. */
  18389. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18390. /**
  18391. * Gets the current list of color gradients.
  18392. * You must use addColorGradient and removeColorGradient to udpate this list
  18393. * @returns the list of color gradients
  18394. */
  18395. getColorGradients(): Nullable<Array<ColorGradient>>;
  18396. /**
  18397. * Adds a new ramp gradient used to remap particle colors
  18398. * @param gradient defines the gradient to use (between 0 and 1)
  18399. * @param color defines the color to affect to the specified gradient
  18400. * @returns the current particle system
  18401. */
  18402. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18403. /**
  18404. * Gets the current list of ramp gradients.
  18405. * You must use addRampGradient and removeRampGradient to udpate this list
  18406. * @returns the list of ramp gradients
  18407. */
  18408. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18409. /** Gets or sets a boolean indicating that ramp gradients must be used
  18410. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18411. */
  18412. useRampGradients: boolean;
  18413. /**
  18414. * Adds a new color remap gradient
  18415. * @param gradient defines the gradient to use (between 0 and 1)
  18416. * @param min defines the color remap minimal range
  18417. * @param max defines the color remap maximal range
  18418. * @returns the current particle system
  18419. */
  18420. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18421. /**
  18422. * Gets the current list of color remap gradients.
  18423. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18424. * @returns the list of color remap gradients
  18425. */
  18426. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18427. /**
  18428. * Adds a new alpha remap gradient
  18429. * @param gradient defines the gradient to use (between 0 and 1)
  18430. * @param min defines the alpha remap minimal range
  18431. * @param max defines the alpha remap maximal range
  18432. * @returns the current particle system
  18433. */
  18434. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18435. /**
  18436. * Gets the current list of alpha remap gradients.
  18437. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18438. * @returns the list of alpha remap gradients
  18439. */
  18440. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18441. /**
  18442. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18443. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18444. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18445. * @returns the emitter
  18446. */
  18447. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18448. /**
  18449. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18450. * @param radius The radius of the hemisphere to emit from
  18451. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18452. * @returns the emitter
  18453. */
  18454. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18455. /**
  18456. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18457. * @param radius The radius of the sphere to emit from
  18458. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18459. * @returns the emitter
  18460. */
  18461. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18462. /**
  18463. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18464. * @param radius The radius of the sphere to emit from
  18465. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18466. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18467. * @returns the emitter
  18468. */
  18469. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18470. /**
  18471. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18472. * @param radius The radius of the emission cylinder
  18473. * @param height The height of the emission cylinder
  18474. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18475. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18476. * @returns the emitter
  18477. */
  18478. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18479. /**
  18480. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18481. * @param radius The radius of the cylinder to emit from
  18482. * @param height The height of the emission cylinder
  18483. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18484. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18485. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18486. * @returns the emitter
  18487. */
  18488. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18489. /**
  18490. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18491. * @param radius The radius of the cone to emit from
  18492. * @param angle The base angle of the cone
  18493. * @returns the emitter
  18494. */
  18495. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18496. /**
  18497. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18498. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18499. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18500. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18501. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18502. * @returns the emitter
  18503. */
  18504. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18505. /**
  18506. * Get hosting scene
  18507. * @returns the scene
  18508. */
  18509. getScene(): Scene;
  18510. }
  18511. }
  18512. declare module BABYLON {
  18513. /**
  18514. * Creates an instance based on a source mesh.
  18515. */
  18516. export class InstancedMesh extends AbstractMesh {
  18517. private _sourceMesh;
  18518. private _currentLOD;
  18519. /** @hidden */
  18520. _indexInSourceMeshInstanceArray: number;
  18521. constructor(name: string, source: Mesh);
  18522. /**
  18523. * Returns the string "InstancedMesh".
  18524. */
  18525. getClassName(): string;
  18526. /** Gets the list of lights affecting that mesh */
  18527. readonly lightSources: Light[];
  18528. _resyncLightSources(): void;
  18529. _resyncLighSource(light: Light): void;
  18530. _removeLightSource(light: Light): void;
  18531. /**
  18532. * If the source mesh receives shadows
  18533. */
  18534. readonly receiveShadows: boolean;
  18535. /**
  18536. * The material of the source mesh
  18537. */
  18538. readonly material: Nullable<Material>;
  18539. /**
  18540. * Visibility of the source mesh
  18541. */
  18542. readonly visibility: number;
  18543. /**
  18544. * Skeleton of the source mesh
  18545. */
  18546. readonly skeleton: Nullable<Skeleton>;
  18547. /**
  18548. * Rendering ground id of the source mesh
  18549. */
  18550. renderingGroupId: number;
  18551. /**
  18552. * Returns the total number of vertices (integer).
  18553. */
  18554. getTotalVertices(): number;
  18555. /**
  18556. * Returns a positive integer : the total number of indices in this mesh geometry.
  18557. * @returns the numner of indices or zero if the mesh has no geometry.
  18558. */
  18559. getTotalIndices(): number;
  18560. /**
  18561. * The source mesh of the instance
  18562. */
  18563. readonly sourceMesh: Mesh;
  18564. /**
  18565. * Is this node ready to be used/rendered
  18566. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18567. * @return {boolean} is it ready
  18568. */
  18569. isReady(completeCheck?: boolean): boolean;
  18570. /**
  18571. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18572. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18573. * @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.
  18574. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18575. */
  18576. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18577. /**
  18578. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18579. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18580. * The `data` are either a numeric array either a Float32Array.
  18581. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18582. * 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).
  18583. * Note that a new underlying VertexBuffer object is created each call.
  18584. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18585. *
  18586. * Possible `kind` values :
  18587. * - VertexBuffer.PositionKind
  18588. * - VertexBuffer.UVKind
  18589. * - VertexBuffer.UV2Kind
  18590. * - VertexBuffer.UV3Kind
  18591. * - VertexBuffer.UV4Kind
  18592. * - VertexBuffer.UV5Kind
  18593. * - VertexBuffer.UV6Kind
  18594. * - VertexBuffer.ColorKind
  18595. * - VertexBuffer.MatricesIndicesKind
  18596. * - VertexBuffer.MatricesIndicesExtraKind
  18597. * - VertexBuffer.MatricesWeightsKind
  18598. * - VertexBuffer.MatricesWeightsExtraKind
  18599. *
  18600. * Returns the Mesh.
  18601. */
  18602. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  18603. /**
  18604. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18605. * If the mesh has no geometry, it is simply returned as it is.
  18606. * The `data` are either a numeric array either a Float32Array.
  18607. * No new underlying VertexBuffer object is created.
  18608. * 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.
  18609. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18610. *
  18611. * Possible `kind` values :
  18612. * - VertexBuffer.PositionKind
  18613. * - VertexBuffer.UVKind
  18614. * - VertexBuffer.UV2Kind
  18615. * - VertexBuffer.UV3Kind
  18616. * - VertexBuffer.UV4Kind
  18617. * - VertexBuffer.UV5Kind
  18618. * - VertexBuffer.UV6Kind
  18619. * - VertexBuffer.ColorKind
  18620. * - VertexBuffer.MatricesIndicesKind
  18621. * - VertexBuffer.MatricesIndicesExtraKind
  18622. * - VertexBuffer.MatricesWeightsKind
  18623. * - VertexBuffer.MatricesWeightsExtraKind
  18624. *
  18625. * Returns the Mesh.
  18626. */
  18627. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18628. /**
  18629. * Sets the mesh indices.
  18630. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18631. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18632. * This method creates a new index buffer each call.
  18633. * Returns the Mesh.
  18634. */
  18635. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18636. /**
  18637. * Boolean : True if the mesh owns the requested kind of data.
  18638. */
  18639. isVerticesDataPresent(kind: string): boolean;
  18640. /**
  18641. * Returns an array of indices (IndicesArray).
  18642. */
  18643. getIndices(): Nullable<IndicesArray>;
  18644. readonly _positions: Nullable<Vector3[]>;
  18645. /**
  18646. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18647. * This means the mesh underlying bounding box and sphere are recomputed.
  18648. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18649. * @returns the current mesh
  18650. */
  18651. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18652. /** @hidden */
  18653. _preActivate(): InstancedMesh;
  18654. /** @hidden */
  18655. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18656. /** @hidden */
  18657. _postActivate(): void;
  18658. getWorldMatrix(): Matrix;
  18659. readonly isAnInstance: boolean;
  18660. /**
  18661. * Returns the current associated LOD AbstractMesh.
  18662. */
  18663. getLOD(camera: Camera): AbstractMesh;
  18664. /** @hidden */
  18665. _syncSubMeshes(): InstancedMesh;
  18666. /** @hidden */
  18667. _generatePointsArray(): boolean;
  18668. /**
  18669. * Creates a new InstancedMesh from the current mesh.
  18670. * - name (string) : the cloned mesh name
  18671. * - newParent (optional Node) : the optional Node to parent the clone to.
  18672. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18673. *
  18674. * Returns the clone.
  18675. */
  18676. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  18677. /**
  18678. * Disposes the InstancedMesh.
  18679. * Returns nothing.
  18680. */
  18681. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18682. }
  18683. }
  18684. declare module BABYLON {
  18685. /**
  18686. * Defines the options associated with the creation of a shader material.
  18687. */
  18688. export interface IShaderMaterialOptions {
  18689. /**
  18690. * Does the material work in alpha blend mode
  18691. */
  18692. needAlphaBlending: boolean;
  18693. /**
  18694. * Does the material work in alpha test mode
  18695. */
  18696. needAlphaTesting: boolean;
  18697. /**
  18698. * The list of attribute names used in the shader
  18699. */
  18700. attributes: string[];
  18701. /**
  18702. * The list of unifrom names used in the shader
  18703. */
  18704. uniforms: string[];
  18705. /**
  18706. * The list of UBO names used in the shader
  18707. */
  18708. uniformBuffers: string[];
  18709. /**
  18710. * The list of sampler names used in the shader
  18711. */
  18712. samplers: string[];
  18713. /**
  18714. * The list of defines used in the shader
  18715. */
  18716. defines: string[];
  18717. }
  18718. /**
  18719. * 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.
  18720. *
  18721. * This returned material effects how the mesh will look based on the code in the shaders.
  18722. *
  18723. * @see http://doc.babylonjs.com/how_to/shader_material
  18724. */
  18725. export class ShaderMaterial extends Material {
  18726. private _shaderPath;
  18727. private _options;
  18728. private _textures;
  18729. private _textureArrays;
  18730. private _floats;
  18731. private _ints;
  18732. private _floatsArrays;
  18733. private _colors3;
  18734. private _colors3Arrays;
  18735. private _colors4;
  18736. private _colors4Arrays;
  18737. private _vectors2;
  18738. private _vectors3;
  18739. private _vectors4;
  18740. private _matrices;
  18741. private _matrices3x3;
  18742. private _matrices2x2;
  18743. private _vectors2Arrays;
  18744. private _vectors3Arrays;
  18745. private _vectors4Arrays;
  18746. private _cachedWorldViewMatrix;
  18747. private _cachedWorldViewProjectionMatrix;
  18748. private _renderId;
  18749. /**
  18750. * Instantiate a new shader material.
  18751. * 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.
  18752. * This returned material effects how the mesh will look based on the code in the shaders.
  18753. * @see http://doc.babylonjs.com/how_to/shader_material
  18754. * @param name Define the name of the material in the scene
  18755. * @param scene Define the scene the material belongs to
  18756. * @param shaderPath Defines the route to the shader code in one of three ways:
  18757. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18758. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18759. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18760. * @param options Define the options used to create the shader
  18761. */
  18762. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18763. /**
  18764. * Gets the options used to compile the shader.
  18765. * They can be modified to trigger a new compilation
  18766. */
  18767. readonly options: IShaderMaterialOptions;
  18768. /**
  18769. * Gets the current class name of the material e.g. "ShaderMaterial"
  18770. * Mainly use in serialization.
  18771. * @returns the class name
  18772. */
  18773. getClassName(): string;
  18774. /**
  18775. * Specifies if the material will require alpha blending
  18776. * @returns a boolean specifying if alpha blending is needed
  18777. */
  18778. needAlphaBlending(): boolean;
  18779. /**
  18780. * Specifies if this material should be rendered in alpha test mode
  18781. * @returns a boolean specifying if an alpha test is needed.
  18782. */
  18783. needAlphaTesting(): boolean;
  18784. private _checkUniform;
  18785. /**
  18786. * Set a texture in the shader.
  18787. * @param name Define the name of the uniform samplers as defined in the shader
  18788. * @param texture Define the texture to bind to this sampler
  18789. * @return the material itself allowing "fluent" like uniform updates
  18790. */
  18791. setTexture(name: string, texture: Texture): ShaderMaterial;
  18792. /**
  18793. * Set a texture array in the shader.
  18794. * @param name Define the name of the uniform sampler array as defined in the shader
  18795. * @param textures Define the list of textures to bind to this sampler
  18796. * @return the material itself allowing "fluent" like uniform updates
  18797. */
  18798. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18799. /**
  18800. * Set a float in the shader.
  18801. * @param name Define the name of the uniform as defined in the shader
  18802. * @param value Define the value to give to the uniform
  18803. * @return the material itself allowing "fluent" like uniform updates
  18804. */
  18805. setFloat(name: string, value: number): ShaderMaterial;
  18806. /**
  18807. * Set a int in the shader.
  18808. * @param name Define the name of the uniform as defined in the shader
  18809. * @param value Define the value to give to the uniform
  18810. * @return the material itself allowing "fluent" like uniform updates
  18811. */
  18812. setInt(name: string, value: number): ShaderMaterial;
  18813. /**
  18814. * Set an array of floats in the shader.
  18815. * @param name Define the name of the uniform as defined in the shader
  18816. * @param value Define the value to give to the uniform
  18817. * @return the material itself allowing "fluent" like uniform updates
  18818. */
  18819. setFloats(name: string, value: number[]): ShaderMaterial;
  18820. /**
  18821. * Set a vec3 in the shader from a Color3.
  18822. * @param name Define the name of the uniform as defined in the shader
  18823. * @param value Define the value to give to the uniform
  18824. * @return the material itself allowing "fluent" like uniform updates
  18825. */
  18826. setColor3(name: string, value: Color3): ShaderMaterial;
  18827. /**
  18828. * Set a vec3 array in the shader from a Color3 array.
  18829. * @param name Define the name of the uniform as defined in the shader
  18830. * @param value Define the value to give to the uniform
  18831. * @return the material itself allowing "fluent" like uniform updates
  18832. */
  18833. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18834. /**
  18835. * Set a vec4 in the shader from a Color4.
  18836. * @param name Define the name of the uniform as defined in the shader
  18837. * @param value Define the value to give to the uniform
  18838. * @return the material itself allowing "fluent" like uniform updates
  18839. */
  18840. setColor4(name: string, value: Color4): ShaderMaterial;
  18841. /**
  18842. * Set a vec4 array in the shader from a Color4 array.
  18843. * @param name Define the name of the uniform as defined in the shader
  18844. * @param value Define the value to give to the uniform
  18845. * @return the material itself allowing "fluent" like uniform updates
  18846. */
  18847. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18848. /**
  18849. * Set a vec2 in the shader from a Vector2.
  18850. * @param name Define the name of the uniform as defined in the shader
  18851. * @param value Define the value to give to the uniform
  18852. * @return the material itself allowing "fluent" like uniform updates
  18853. */
  18854. setVector2(name: string, value: Vector2): ShaderMaterial;
  18855. /**
  18856. * Set a vec3 in the shader from a Vector3.
  18857. * @param name Define the name of the uniform as defined in the shader
  18858. * @param value Define the value to give to the uniform
  18859. * @return the material itself allowing "fluent" like uniform updates
  18860. */
  18861. setVector3(name: string, value: Vector3): ShaderMaterial;
  18862. /**
  18863. * Set a vec4 in the shader from a Vector4.
  18864. * @param name Define the name of the uniform as defined in the shader
  18865. * @param value Define the value to give to the uniform
  18866. * @return the material itself allowing "fluent" like uniform updates
  18867. */
  18868. setVector4(name: string, value: Vector4): ShaderMaterial;
  18869. /**
  18870. * Set a mat4 in the shader from a Matrix.
  18871. * @param name Define the name of the uniform as defined in the shader
  18872. * @param value Define the value to give to the uniform
  18873. * @return the material itself allowing "fluent" like uniform updates
  18874. */
  18875. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18876. /**
  18877. * Set a mat3 in the shader from a Float32Array.
  18878. * @param name Define the name of the uniform as defined in the shader
  18879. * @param value Define the value to give to the uniform
  18880. * @return the material itself allowing "fluent" like uniform updates
  18881. */
  18882. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18883. /**
  18884. * Set a mat2 in the shader from a Float32Array.
  18885. * @param name Define the name of the uniform as defined in the shader
  18886. * @param value Define the value to give to the uniform
  18887. * @return the material itself allowing "fluent" like uniform updates
  18888. */
  18889. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18890. /**
  18891. * Set a vec2 array in the shader from a number array.
  18892. * @param name Define the name of the uniform as defined in the shader
  18893. * @param value Define the value to give to the uniform
  18894. * @return the material itself allowing "fluent" like uniform updates
  18895. */
  18896. setArray2(name: string, value: number[]): ShaderMaterial;
  18897. /**
  18898. * Set a vec3 array in the shader from a number array.
  18899. * @param name Define the name of the uniform as defined in the shader
  18900. * @param value Define the value to give to the uniform
  18901. * @return the material itself allowing "fluent" like uniform updates
  18902. */
  18903. setArray3(name: string, value: number[]): ShaderMaterial;
  18904. /**
  18905. * Set a vec4 array in the shader from a number array.
  18906. * @param name Define the name of the uniform as defined in the shader
  18907. * @param value Define the value to give to the uniform
  18908. * @return the material itself allowing "fluent" like uniform updates
  18909. */
  18910. setArray4(name: string, value: number[]): ShaderMaterial;
  18911. private _checkCache;
  18912. /**
  18913. * Specifies that the submesh is ready to be used
  18914. * @param mesh defines the mesh to check
  18915. * @param subMesh defines which submesh to check
  18916. * @param useInstances specifies that instances should be used
  18917. * @returns a boolean indicating that the submesh is ready or not
  18918. */
  18919. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18920. /**
  18921. * Checks if the material is ready to render the requested mesh
  18922. * @param mesh Define the mesh to render
  18923. * @param useInstances Define whether or not the material is used with instances
  18924. * @returns true if ready, otherwise false
  18925. */
  18926. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18927. /**
  18928. * Binds the world matrix to the material
  18929. * @param world defines the world transformation matrix
  18930. */
  18931. bindOnlyWorldMatrix(world: Matrix): void;
  18932. /**
  18933. * Binds the material to the mesh
  18934. * @param world defines the world transformation matrix
  18935. * @param mesh defines the mesh to bind the material to
  18936. */
  18937. bind(world: Matrix, mesh?: Mesh): void;
  18938. /**
  18939. * Gets the active textures from the material
  18940. * @returns an array of textures
  18941. */
  18942. getActiveTextures(): BaseTexture[];
  18943. /**
  18944. * Specifies if the material uses a texture
  18945. * @param texture defines the texture to check against the material
  18946. * @returns a boolean specifying if the material uses the texture
  18947. */
  18948. hasTexture(texture: BaseTexture): boolean;
  18949. /**
  18950. * Makes a duplicate of the material, and gives it a new name
  18951. * @param name defines the new name for the duplicated material
  18952. * @returns the cloned material
  18953. */
  18954. clone(name: string): ShaderMaterial;
  18955. /**
  18956. * Disposes the material
  18957. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18958. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18959. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18960. */
  18961. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18962. /**
  18963. * Serializes this material in a JSON representation
  18964. * @returns the serialized material object
  18965. */
  18966. serialize(): any;
  18967. /**
  18968. * Creates a shader material from parsed shader material data
  18969. * @param source defines the JSON represnetation of the material
  18970. * @param scene defines the hosting scene
  18971. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18972. * @returns a new material
  18973. */
  18974. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18975. }
  18976. }
  18977. declare module BABYLON {
  18978. /** @hidden */
  18979. export var colorPixelShader: {
  18980. name: string;
  18981. shader: string;
  18982. };
  18983. }
  18984. declare module BABYLON {
  18985. /** @hidden */
  18986. export var colorVertexShader: {
  18987. name: string;
  18988. shader: string;
  18989. };
  18990. }
  18991. declare module BABYLON {
  18992. /**
  18993. * Line mesh
  18994. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  18995. */
  18996. export class LinesMesh extends Mesh {
  18997. /**
  18998. * If vertex color should be applied to the mesh
  18999. */
  19000. readonly useVertexColor?: boolean | undefined;
  19001. /**
  19002. * If vertex alpha should be applied to the mesh
  19003. */
  19004. readonly useVertexAlpha?: boolean | undefined;
  19005. /**
  19006. * Color of the line (Default: White)
  19007. */
  19008. color: Color3;
  19009. /**
  19010. * Alpha of the line (Default: 1)
  19011. */
  19012. alpha: number;
  19013. /**
  19014. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19015. * This margin is expressed in world space coordinates, so its value may vary.
  19016. * Default value is 0.1
  19017. */
  19018. intersectionThreshold: number;
  19019. private _colorShader;
  19020. private color4;
  19021. /**
  19022. * Creates a new LinesMesh
  19023. * @param name defines the name
  19024. * @param scene defines the hosting scene
  19025. * @param parent defines the parent mesh if any
  19026. * @param source defines the optional source LinesMesh used to clone data from
  19027. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19028. * When false, achieved by calling a clone(), also passing False.
  19029. * This will make creation of children, recursive.
  19030. * @param useVertexColor defines if this LinesMesh supports vertex color
  19031. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19032. */
  19033. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  19034. /**
  19035. * If vertex color should be applied to the mesh
  19036. */
  19037. useVertexColor?: boolean | undefined,
  19038. /**
  19039. * If vertex alpha should be applied to the mesh
  19040. */
  19041. useVertexAlpha?: boolean | undefined);
  19042. private _addClipPlaneDefine;
  19043. private _removeClipPlaneDefine;
  19044. isReady(): boolean;
  19045. /**
  19046. * Returns the string "LineMesh"
  19047. */
  19048. getClassName(): string;
  19049. /**
  19050. * @hidden
  19051. */
  19052. /**
  19053. * @hidden
  19054. */
  19055. material: Material;
  19056. /**
  19057. * @hidden
  19058. */
  19059. readonly checkCollisions: boolean;
  19060. /** @hidden */
  19061. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  19062. /** @hidden */
  19063. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  19064. /**
  19065. * Disposes of the line mesh
  19066. * @param doNotRecurse If children should be disposed
  19067. */
  19068. dispose(doNotRecurse?: boolean): void;
  19069. /**
  19070. * Returns a new LineMesh object cloned from the current one.
  19071. */
  19072. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  19073. /**
  19074. * Creates a new InstancedLinesMesh object from the mesh model.
  19075. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19076. * @param name defines the name of the new instance
  19077. * @returns a new InstancedLinesMesh
  19078. */
  19079. createInstance(name: string): InstancedLinesMesh;
  19080. }
  19081. /**
  19082. * Creates an instance based on a source LinesMesh
  19083. */
  19084. export class InstancedLinesMesh extends InstancedMesh {
  19085. /**
  19086. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19087. * This margin is expressed in world space coordinates, so its value may vary.
  19088. * Initilized with the intersectionThreshold value of the source LinesMesh
  19089. */
  19090. intersectionThreshold: number;
  19091. constructor(name: string, source: LinesMesh);
  19092. /**
  19093. * Returns the string "InstancedLinesMesh".
  19094. */
  19095. getClassName(): string;
  19096. }
  19097. }
  19098. declare module BABYLON {
  19099. /** @hidden */
  19100. export var linePixelShader: {
  19101. name: string;
  19102. shader: string;
  19103. };
  19104. }
  19105. declare module BABYLON {
  19106. /** @hidden */
  19107. export var lineVertexShader: {
  19108. name: string;
  19109. shader: string;
  19110. };
  19111. }
  19112. declare module BABYLON {
  19113. interface AbstractMesh {
  19114. /**
  19115. * Gets the edgesRenderer associated with the mesh
  19116. */
  19117. edgesRenderer: Nullable<EdgesRenderer>;
  19118. }
  19119. interface LinesMesh {
  19120. /**
  19121. * Enables the edge rendering mode on the mesh.
  19122. * This mode makes the mesh edges visible
  19123. * @param epsilon defines the maximal distance between two angles to detect a face
  19124. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19125. * @returns the currentAbstractMesh
  19126. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19127. */
  19128. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19129. }
  19130. interface InstancedLinesMesh {
  19131. /**
  19132. * Enables the edge rendering mode on the mesh.
  19133. * This mode makes the mesh edges visible
  19134. * @param epsilon defines the maximal distance between two angles to detect a face
  19135. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19136. * @returns the current InstancedLinesMesh
  19137. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19138. */
  19139. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19140. }
  19141. /**
  19142. * Defines the minimum contract an Edges renderer should follow.
  19143. */
  19144. export interface IEdgesRenderer extends IDisposable {
  19145. /**
  19146. * Gets or sets a boolean indicating if the edgesRenderer is active
  19147. */
  19148. isEnabled: boolean;
  19149. /**
  19150. * Renders the edges of the attached mesh,
  19151. */
  19152. render(): void;
  19153. /**
  19154. * Checks wether or not the edges renderer is ready to render.
  19155. * @return true if ready, otherwise false.
  19156. */
  19157. isReady(): boolean;
  19158. }
  19159. /**
  19160. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19161. */
  19162. export class EdgesRenderer implements IEdgesRenderer {
  19163. /**
  19164. * Define the size of the edges with an orthographic camera
  19165. */
  19166. edgesWidthScalerForOrthographic: number;
  19167. /**
  19168. * Define the size of the edges with a perspective camera
  19169. */
  19170. edgesWidthScalerForPerspective: number;
  19171. protected _source: AbstractMesh;
  19172. protected _linesPositions: number[];
  19173. protected _linesNormals: number[];
  19174. protected _linesIndices: number[];
  19175. protected _epsilon: number;
  19176. protected _indicesCount: number;
  19177. protected _lineShader: ShaderMaterial;
  19178. protected _ib: DataBuffer;
  19179. protected _buffers: {
  19180. [key: string]: Nullable<VertexBuffer>;
  19181. };
  19182. protected _checkVerticesInsteadOfIndices: boolean;
  19183. private _meshRebuildObserver;
  19184. private _meshDisposeObserver;
  19185. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19186. isEnabled: boolean;
  19187. /**
  19188. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19189. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19190. * @param source Mesh used to create edges
  19191. * @param epsilon sum of angles in adjacency to check for edge
  19192. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19193. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19194. */
  19195. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19196. protected _prepareRessources(): void;
  19197. /** @hidden */
  19198. _rebuild(): void;
  19199. /**
  19200. * Releases the required resources for the edges renderer
  19201. */
  19202. dispose(): void;
  19203. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19204. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19205. /**
  19206. * Checks if the pair of p0 and p1 is en edge
  19207. * @param faceIndex
  19208. * @param edge
  19209. * @param faceNormals
  19210. * @param p0
  19211. * @param p1
  19212. * @private
  19213. */
  19214. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19215. /**
  19216. * push line into the position, normal and index buffer
  19217. * @protected
  19218. */
  19219. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19220. /**
  19221. * Generates lines edges from adjacencjes
  19222. * @private
  19223. */
  19224. _generateEdgesLines(): void;
  19225. /**
  19226. * Checks wether or not the edges renderer is ready to render.
  19227. * @return true if ready, otherwise false.
  19228. */
  19229. isReady(): boolean;
  19230. /**
  19231. * Renders the edges of the attached mesh,
  19232. */
  19233. render(): void;
  19234. }
  19235. /**
  19236. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19237. */
  19238. export class LineEdgesRenderer extends EdgesRenderer {
  19239. /**
  19240. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19241. * @param source LineMesh used to generate edges
  19242. * @param epsilon not important (specified angle for edge detection)
  19243. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19244. */
  19245. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19246. /**
  19247. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19248. */
  19249. _generateEdgesLines(): void;
  19250. }
  19251. }
  19252. declare module BABYLON {
  19253. /**
  19254. * This represents the object necessary to create a rendering group.
  19255. * This is exclusively used and created by the rendering manager.
  19256. * To modify the behavior, you use the available helpers in your scene or meshes.
  19257. * @hidden
  19258. */
  19259. export class RenderingGroup {
  19260. index: number;
  19261. private static _zeroVector;
  19262. private _scene;
  19263. private _opaqueSubMeshes;
  19264. private _transparentSubMeshes;
  19265. private _alphaTestSubMeshes;
  19266. private _depthOnlySubMeshes;
  19267. private _particleSystems;
  19268. private _spriteManagers;
  19269. private _opaqueSortCompareFn;
  19270. private _alphaTestSortCompareFn;
  19271. private _transparentSortCompareFn;
  19272. private _renderOpaque;
  19273. private _renderAlphaTest;
  19274. private _renderTransparent;
  19275. /** @hidden */
  19276. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19277. onBeforeTransparentRendering: () => void;
  19278. /**
  19279. * Set the opaque sort comparison function.
  19280. * If null the sub meshes will be render in the order they were created
  19281. */
  19282. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19283. /**
  19284. * Set the alpha test sort comparison function.
  19285. * If null the sub meshes will be render in the order they were created
  19286. */
  19287. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19288. /**
  19289. * Set the transparent sort comparison function.
  19290. * If null the sub meshes will be render in the order they were created
  19291. */
  19292. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19293. /**
  19294. * Creates a new rendering group.
  19295. * @param index The rendering group index
  19296. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19297. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19298. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19299. */
  19300. 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>);
  19301. /**
  19302. * Render all the sub meshes contained in the group.
  19303. * @param customRenderFunction Used to override the default render behaviour of the group.
  19304. * @returns true if rendered some submeshes.
  19305. */
  19306. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19307. /**
  19308. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19309. * @param subMeshes The submeshes to render
  19310. */
  19311. private renderOpaqueSorted;
  19312. /**
  19313. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19314. * @param subMeshes The submeshes to render
  19315. */
  19316. private renderAlphaTestSorted;
  19317. /**
  19318. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19319. * @param subMeshes The submeshes to render
  19320. */
  19321. private renderTransparentSorted;
  19322. /**
  19323. * Renders the submeshes in a specified order.
  19324. * @param subMeshes The submeshes to sort before render
  19325. * @param sortCompareFn The comparison function use to sort
  19326. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19327. * @param transparent Specifies to activate blending if true
  19328. */
  19329. private static renderSorted;
  19330. /**
  19331. * Renders the submeshes in the order they were dispatched (no sort applied).
  19332. * @param subMeshes The submeshes to render
  19333. */
  19334. private static renderUnsorted;
  19335. /**
  19336. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19337. * are rendered back to front if in the same alpha index.
  19338. *
  19339. * @param a The first submesh
  19340. * @param b The second submesh
  19341. * @returns The result of the comparison
  19342. */
  19343. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19344. /**
  19345. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19346. * are rendered back to front.
  19347. *
  19348. * @param a The first submesh
  19349. * @param b The second submesh
  19350. * @returns The result of the comparison
  19351. */
  19352. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19353. /**
  19354. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19355. * are rendered front to back (prevent overdraw).
  19356. *
  19357. * @param a The first submesh
  19358. * @param b The second submesh
  19359. * @returns The result of the comparison
  19360. */
  19361. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19362. /**
  19363. * Resets the different lists of submeshes to prepare a new frame.
  19364. */
  19365. prepare(): void;
  19366. dispose(): void;
  19367. /**
  19368. * Inserts the submesh in its correct queue depending on its material.
  19369. * @param subMesh The submesh to dispatch
  19370. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19371. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19372. */
  19373. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19374. dispatchSprites(spriteManager: ISpriteManager): void;
  19375. dispatchParticles(particleSystem: IParticleSystem): void;
  19376. private _renderParticles;
  19377. private _renderSprites;
  19378. }
  19379. }
  19380. declare module BABYLON {
  19381. /**
  19382. * Interface describing the different options available in the rendering manager
  19383. * regarding Auto Clear between groups.
  19384. */
  19385. export interface IRenderingManagerAutoClearSetup {
  19386. /**
  19387. * Defines whether or not autoclear is enable.
  19388. */
  19389. autoClear: boolean;
  19390. /**
  19391. * Defines whether or not to autoclear the depth buffer.
  19392. */
  19393. depth: boolean;
  19394. /**
  19395. * Defines whether or not to autoclear the stencil buffer.
  19396. */
  19397. stencil: boolean;
  19398. }
  19399. /**
  19400. * This class is used by the onRenderingGroupObservable
  19401. */
  19402. export class RenderingGroupInfo {
  19403. /**
  19404. * The Scene that being rendered
  19405. */
  19406. scene: Scene;
  19407. /**
  19408. * The camera currently used for the rendering pass
  19409. */
  19410. camera: Nullable<Camera>;
  19411. /**
  19412. * The ID of the renderingGroup being processed
  19413. */
  19414. renderingGroupId: number;
  19415. }
  19416. /**
  19417. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19418. * It is enable to manage the different groups as well as the different necessary sort functions.
  19419. * This should not be used directly aside of the few static configurations
  19420. */
  19421. export class RenderingManager {
  19422. /**
  19423. * The max id used for rendering groups (not included)
  19424. */
  19425. static MAX_RENDERINGGROUPS: number;
  19426. /**
  19427. * The min id used for rendering groups (included)
  19428. */
  19429. static MIN_RENDERINGGROUPS: number;
  19430. /**
  19431. * Used to globally prevent autoclearing scenes.
  19432. */
  19433. static AUTOCLEAR: boolean;
  19434. /**
  19435. * @hidden
  19436. */
  19437. _useSceneAutoClearSetup: boolean;
  19438. private _scene;
  19439. private _renderingGroups;
  19440. private _depthStencilBufferAlreadyCleaned;
  19441. private _autoClearDepthStencil;
  19442. private _customOpaqueSortCompareFn;
  19443. private _customAlphaTestSortCompareFn;
  19444. private _customTransparentSortCompareFn;
  19445. private _renderingGroupInfo;
  19446. /**
  19447. * Instantiates a new rendering group for a particular scene
  19448. * @param scene Defines the scene the groups belongs to
  19449. */
  19450. constructor(scene: Scene);
  19451. private _clearDepthStencilBuffer;
  19452. /**
  19453. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19454. * @hidden
  19455. */
  19456. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19457. /**
  19458. * Resets the different information of the group to prepare a new frame
  19459. * @hidden
  19460. */
  19461. reset(): void;
  19462. /**
  19463. * Dispose and release the group and its associated resources.
  19464. * @hidden
  19465. */
  19466. dispose(): void;
  19467. /**
  19468. * Clear the info related to rendering groups preventing retention points during dispose.
  19469. */
  19470. freeRenderingGroups(): void;
  19471. private _prepareRenderingGroup;
  19472. /**
  19473. * Add a sprite manager to the rendering manager in order to render it this frame.
  19474. * @param spriteManager Define the sprite manager to render
  19475. */
  19476. dispatchSprites(spriteManager: ISpriteManager): void;
  19477. /**
  19478. * Add a particle system to the rendering manager in order to render it this frame.
  19479. * @param particleSystem Define the particle system to render
  19480. */
  19481. dispatchParticles(particleSystem: IParticleSystem): void;
  19482. /**
  19483. * Add a submesh to the manager in order to render it this frame
  19484. * @param subMesh The submesh to dispatch
  19485. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19486. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19487. */
  19488. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19489. /**
  19490. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19491. * This allowed control for front to back rendering or reversly depending of the special needs.
  19492. *
  19493. * @param renderingGroupId The rendering group id corresponding to its index
  19494. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19495. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19496. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19497. */
  19498. 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;
  19499. /**
  19500. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19501. *
  19502. * @param renderingGroupId The rendering group id corresponding to its index
  19503. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19504. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19505. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19506. */
  19507. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19508. /**
  19509. * Gets the current auto clear configuration for one rendering group of the rendering
  19510. * manager.
  19511. * @param index the rendering group index to get the information for
  19512. * @returns The auto clear setup for the requested rendering group
  19513. */
  19514. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19515. }
  19516. }
  19517. declare module BABYLON {
  19518. /**
  19519. * This Helps creating a texture that will be created from a camera in your scene.
  19520. * It is basically a dynamic texture that could be used to create special effects for instance.
  19521. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19522. */
  19523. export class RenderTargetTexture extends Texture {
  19524. isCube: boolean;
  19525. /**
  19526. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19527. */
  19528. static readonly REFRESHRATE_RENDER_ONCE: number;
  19529. /**
  19530. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19531. */
  19532. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19533. /**
  19534. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19535. * the central point of your effect and can save a lot of performances.
  19536. */
  19537. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19538. /**
  19539. * Use this predicate to dynamically define the list of mesh you want to render.
  19540. * If set, the renderList property will be overwritten.
  19541. */
  19542. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19543. private _renderList;
  19544. /**
  19545. * Use this list to define the list of mesh you want to render.
  19546. */
  19547. renderList: Nullable<Array<AbstractMesh>>;
  19548. private _hookArray;
  19549. /**
  19550. * Define if particles should be rendered in your texture.
  19551. */
  19552. renderParticles: boolean;
  19553. /**
  19554. * Define if sprites should be rendered in your texture.
  19555. */
  19556. renderSprites: boolean;
  19557. /**
  19558. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19559. */
  19560. coordinatesMode: number;
  19561. /**
  19562. * Define the camera used to render the texture.
  19563. */
  19564. activeCamera: Nullable<Camera>;
  19565. /**
  19566. * Override the render function of the texture with your own one.
  19567. */
  19568. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19569. /**
  19570. * Define if camera post processes should be use while rendering the texture.
  19571. */
  19572. useCameraPostProcesses: boolean;
  19573. /**
  19574. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19575. */
  19576. ignoreCameraViewport: boolean;
  19577. private _postProcessManager;
  19578. private _postProcesses;
  19579. private _resizeObserver;
  19580. /**
  19581. * An event triggered when the texture is unbind.
  19582. */
  19583. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19584. /**
  19585. * An event triggered when the texture is unbind.
  19586. */
  19587. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19588. private _onAfterUnbindObserver;
  19589. /**
  19590. * Set a after unbind callback in the texture.
  19591. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19592. */
  19593. onAfterUnbind: () => void;
  19594. /**
  19595. * An event triggered before rendering the texture
  19596. */
  19597. onBeforeRenderObservable: Observable<number>;
  19598. private _onBeforeRenderObserver;
  19599. /**
  19600. * Set a before render callback in the texture.
  19601. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19602. */
  19603. onBeforeRender: (faceIndex: number) => void;
  19604. /**
  19605. * An event triggered after rendering the texture
  19606. */
  19607. onAfterRenderObservable: Observable<number>;
  19608. private _onAfterRenderObserver;
  19609. /**
  19610. * Set a after render callback in the texture.
  19611. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19612. */
  19613. onAfterRender: (faceIndex: number) => void;
  19614. /**
  19615. * An event triggered after the texture clear
  19616. */
  19617. onClearObservable: Observable<Engine>;
  19618. private _onClearObserver;
  19619. /**
  19620. * Set a clear callback in the texture.
  19621. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19622. */
  19623. onClear: (Engine: Engine) => void;
  19624. /**
  19625. * Define the clear color of the Render Target if it should be different from the scene.
  19626. */
  19627. clearColor: Color4;
  19628. protected _size: number | {
  19629. width: number;
  19630. height: number;
  19631. };
  19632. protected _initialSizeParameter: number | {
  19633. width: number;
  19634. height: number;
  19635. } | {
  19636. ratio: number;
  19637. };
  19638. protected _sizeRatio: Nullable<number>;
  19639. /** @hidden */
  19640. _generateMipMaps: boolean;
  19641. protected _renderingManager: RenderingManager;
  19642. /** @hidden */
  19643. _waitingRenderList: string[];
  19644. protected _doNotChangeAspectRatio: boolean;
  19645. protected _currentRefreshId: number;
  19646. protected _refreshRate: number;
  19647. protected _textureMatrix: Matrix;
  19648. protected _samples: number;
  19649. protected _renderTargetOptions: RenderTargetCreationOptions;
  19650. /**
  19651. * Gets render target creation options that were used.
  19652. */
  19653. readonly renderTargetOptions: RenderTargetCreationOptions;
  19654. protected _engine: Engine;
  19655. protected _onRatioRescale(): void;
  19656. /**
  19657. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19658. * It must define where the camera used to render the texture is set
  19659. */
  19660. boundingBoxPosition: Vector3;
  19661. private _boundingBoxSize;
  19662. /**
  19663. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19664. * When defined, the cubemap will switch to local mode
  19665. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19666. * @example https://www.babylonjs-playground.com/#RNASML
  19667. */
  19668. boundingBoxSize: Vector3;
  19669. /**
  19670. * In case the RTT has been created with a depth texture, get the associated
  19671. * depth texture.
  19672. * Otherwise, return null.
  19673. */
  19674. depthStencilTexture: Nullable<InternalTexture>;
  19675. /**
  19676. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19677. * or used a shadow, depth texture...
  19678. * @param name The friendly name of the texture
  19679. * @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)
  19680. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19681. * @param generateMipMaps True if mip maps need to be generated after render.
  19682. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19683. * @param type The type of the buffer in the RTT (int, half float, float...)
  19684. * @param isCube True if a cube texture needs to be created
  19685. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19686. * @param generateDepthBuffer True to generate a depth buffer
  19687. * @param generateStencilBuffer True to generate a stencil buffer
  19688. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19689. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19690. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19691. */
  19692. constructor(name: string, size: number | {
  19693. width: number;
  19694. height: number;
  19695. } | {
  19696. ratio: number;
  19697. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19698. /**
  19699. * Creates a depth stencil texture.
  19700. * This is only available in WebGL 2 or with the depth texture extension available.
  19701. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19702. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19703. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19704. */
  19705. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19706. private _processSizeParameter;
  19707. /**
  19708. * Define the number of samples to use in case of MSAA.
  19709. * It defaults to one meaning no MSAA has been enabled.
  19710. */
  19711. samples: number;
  19712. /**
  19713. * Resets the refresh counter of the texture and start bak from scratch.
  19714. * Could be useful to regenerate the texture if it is setup to render only once.
  19715. */
  19716. resetRefreshCounter(): void;
  19717. /**
  19718. * Define the refresh rate of the texture or the rendering frequency.
  19719. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19720. */
  19721. refreshRate: number;
  19722. /**
  19723. * Adds a post process to the render target rendering passes.
  19724. * @param postProcess define the post process to add
  19725. */
  19726. addPostProcess(postProcess: PostProcess): void;
  19727. /**
  19728. * Clear all the post processes attached to the render target
  19729. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19730. */
  19731. clearPostProcesses(dispose?: boolean): void;
  19732. /**
  19733. * Remove one of the post process from the list of attached post processes to the texture
  19734. * @param postProcess define the post process to remove from the list
  19735. */
  19736. removePostProcess(postProcess: PostProcess): void;
  19737. /** @hidden */
  19738. _shouldRender(): boolean;
  19739. /**
  19740. * Gets the actual render size of the texture.
  19741. * @returns the width of the render size
  19742. */
  19743. getRenderSize(): number;
  19744. /**
  19745. * Gets the actual render width of the texture.
  19746. * @returns the width of the render size
  19747. */
  19748. getRenderWidth(): number;
  19749. /**
  19750. * Gets the actual render height of the texture.
  19751. * @returns the height of the render size
  19752. */
  19753. getRenderHeight(): number;
  19754. /**
  19755. * Get if the texture can be rescaled or not.
  19756. */
  19757. readonly canRescale: boolean;
  19758. /**
  19759. * Resize the texture using a ratio.
  19760. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19761. */
  19762. scale(ratio: number): void;
  19763. /**
  19764. * Get the texture reflection matrix used to rotate/transform the reflection.
  19765. * @returns the reflection matrix
  19766. */
  19767. getReflectionTextureMatrix(): Matrix;
  19768. /**
  19769. * Resize the texture to a new desired size.
  19770. * Be carrefull as it will recreate all the data in the new texture.
  19771. * @param size Define the new size. It can be:
  19772. * - a number for squared texture,
  19773. * - an object containing { width: number, height: number }
  19774. * - or an object containing a ratio { ratio: number }
  19775. */
  19776. resize(size: number | {
  19777. width: number;
  19778. height: number;
  19779. } | {
  19780. ratio: number;
  19781. }): void;
  19782. /**
  19783. * Renders all the objects from the render list into the texture.
  19784. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19785. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19786. */
  19787. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19788. private _bestReflectionRenderTargetDimension;
  19789. /**
  19790. * @hidden
  19791. * @param faceIndex face index to bind to if this is a cubetexture
  19792. */
  19793. _bindFrameBuffer(faceIndex?: number): void;
  19794. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19795. private renderToTarget;
  19796. /**
  19797. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19798. * This allowed control for front to back rendering or reversly depending of the special needs.
  19799. *
  19800. * @param renderingGroupId The rendering group id corresponding to its index
  19801. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19802. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19803. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19804. */
  19805. 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;
  19806. /**
  19807. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19808. *
  19809. * @param renderingGroupId The rendering group id corresponding to its index
  19810. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19811. */
  19812. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19813. /**
  19814. * Clones the texture.
  19815. * @returns the cloned texture
  19816. */
  19817. clone(): RenderTargetTexture;
  19818. /**
  19819. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19820. * @returns The JSON representation of the texture
  19821. */
  19822. serialize(): any;
  19823. /**
  19824. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19825. */
  19826. disposeFramebufferObjects(): void;
  19827. /**
  19828. * Dispose the texture and release its associated resources.
  19829. */
  19830. dispose(): void;
  19831. /** @hidden */
  19832. _rebuild(): void;
  19833. /**
  19834. * Clear the info related to rendering groups preventing retention point in material dispose.
  19835. */
  19836. freeRenderingGroups(): void;
  19837. /**
  19838. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19839. * @returns the view count
  19840. */
  19841. getViewCount(): number;
  19842. }
  19843. }
  19844. declare module BABYLON {
  19845. /**
  19846. * Base class for the main features of a material in Babylon.js
  19847. */
  19848. export class Material implements IAnimatable {
  19849. /**
  19850. * Returns the triangle fill mode
  19851. */
  19852. static readonly TriangleFillMode: number;
  19853. /**
  19854. * Returns the wireframe mode
  19855. */
  19856. static readonly WireFrameFillMode: number;
  19857. /**
  19858. * Returns the point fill mode
  19859. */
  19860. static readonly PointFillMode: number;
  19861. /**
  19862. * Returns the point list draw mode
  19863. */
  19864. static readonly PointListDrawMode: number;
  19865. /**
  19866. * Returns the line list draw mode
  19867. */
  19868. static readonly LineListDrawMode: number;
  19869. /**
  19870. * Returns the line loop draw mode
  19871. */
  19872. static readonly LineLoopDrawMode: number;
  19873. /**
  19874. * Returns the line strip draw mode
  19875. */
  19876. static readonly LineStripDrawMode: number;
  19877. /**
  19878. * Returns the triangle strip draw mode
  19879. */
  19880. static readonly TriangleStripDrawMode: number;
  19881. /**
  19882. * Returns the triangle fan draw mode
  19883. */
  19884. static readonly TriangleFanDrawMode: number;
  19885. /**
  19886. * Stores the clock-wise side orientation
  19887. */
  19888. static readonly ClockWiseSideOrientation: number;
  19889. /**
  19890. * Stores the counter clock-wise side orientation
  19891. */
  19892. static readonly CounterClockWiseSideOrientation: number;
  19893. /**
  19894. * The dirty texture flag value
  19895. */
  19896. static readonly TextureDirtyFlag: number;
  19897. /**
  19898. * The dirty light flag value
  19899. */
  19900. static readonly LightDirtyFlag: number;
  19901. /**
  19902. * The dirty fresnel flag value
  19903. */
  19904. static readonly FresnelDirtyFlag: number;
  19905. /**
  19906. * The dirty attribute flag value
  19907. */
  19908. static readonly AttributesDirtyFlag: number;
  19909. /**
  19910. * The dirty misc flag value
  19911. */
  19912. static readonly MiscDirtyFlag: number;
  19913. /**
  19914. * The all dirty flag value
  19915. */
  19916. static readonly AllDirtyFlag: number;
  19917. /**
  19918. * The ID of the material
  19919. */
  19920. id: string;
  19921. /**
  19922. * Gets or sets the unique id of the material
  19923. */
  19924. uniqueId: number;
  19925. /**
  19926. * The name of the material
  19927. */
  19928. name: string;
  19929. /**
  19930. * Gets or sets user defined metadata
  19931. */
  19932. metadata: any;
  19933. /**
  19934. * For internal use only. Please do not use.
  19935. */
  19936. reservedDataStore: any;
  19937. /**
  19938. * Specifies if the ready state should be checked on each call
  19939. */
  19940. checkReadyOnEveryCall: boolean;
  19941. /**
  19942. * Specifies if the ready state should be checked once
  19943. */
  19944. checkReadyOnlyOnce: boolean;
  19945. /**
  19946. * The state of the material
  19947. */
  19948. state: string;
  19949. /**
  19950. * The alpha value of the material
  19951. */
  19952. protected _alpha: number;
  19953. /**
  19954. * List of inspectable custom properties (used by the Inspector)
  19955. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19956. */
  19957. inspectableCustomProperties: IInspectable[];
  19958. /**
  19959. * Sets the alpha value of the material
  19960. */
  19961. /**
  19962. * Gets the alpha value of the material
  19963. */
  19964. alpha: number;
  19965. /**
  19966. * Specifies if back face culling is enabled
  19967. */
  19968. protected _backFaceCulling: boolean;
  19969. /**
  19970. * Sets the back-face culling state
  19971. */
  19972. /**
  19973. * Gets the back-face culling state
  19974. */
  19975. backFaceCulling: boolean;
  19976. /**
  19977. * Stores the value for side orientation
  19978. */
  19979. sideOrientation: number;
  19980. /**
  19981. * Callback triggered when the material is compiled
  19982. */
  19983. onCompiled: Nullable<(effect: Effect) => void>;
  19984. /**
  19985. * Callback triggered when an error occurs
  19986. */
  19987. onError: Nullable<(effect: Effect, errors: string) => void>;
  19988. /**
  19989. * Callback triggered to get the render target textures
  19990. */
  19991. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  19992. /**
  19993. * Gets a boolean indicating that current material needs to register RTT
  19994. */
  19995. readonly hasRenderTargetTextures: boolean;
  19996. /**
  19997. * Specifies if the material should be serialized
  19998. */
  19999. doNotSerialize: boolean;
  20000. /**
  20001. * @hidden
  20002. */
  20003. _storeEffectOnSubMeshes: boolean;
  20004. /**
  20005. * Stores the animations for the material
  20006. */
  20007. animations: Nullable<Array<Animation>>;
  20008. /**
  20009. * An event triggered when the material is disposed
  20010. */
  20011. onDisposeObservable: Observable<Material>;
  20012. /**
  20013. * An observer which watches for dispose events
  20014. */
  20015. private _onDisposeObserver;
  20016. private _onUnBindObservable;
  20017. /**
  20018. * Called during a dispose event
  20019. */
  20020. onDispose: () => void;
  20021. private _onBindObservable;
  20022. /**
  20023. * An event triggered when the material is bound
  20024. */
  20025. readonly onBindObservable: Observable<AbstractMesh>;
  20026. /**
  20027. * An observer which watches for bind events
  20028. */
  20029. private _onBindObserver;
  20030. /**
  20031. * Called during a bind event
  20032. */
  20033. onBind: (Mesh: AbstractMesh) => void;
  20034. /**
  20035. * An event triggered when the material is unbound
  20036. */
  20037. readonly onUnBindObservable: Observable<Material>;
  20038. /**
  20039. * Stores the value of the alpha mode
  20040. */
  20041. private _alphaMode;
  20042. /**
  20043. * Sets the value of the alpha mode.
  20044. *
  20045. * | Value | Type | Description |
  20046. * | --- | --- | --- |
  20047. * | 0 | ALPHA_DISABLE | |
  20048. * | 1 | ALPHA_ADD | |
  20049. * | 2 | ALPHA_COMBINE | |
  20050. * | 3 | ALPHA_SUBTRACT | |
  20051. * | 4 | ALPHA_MULTIPLY | |
  20052. * | 5 | ALPHA_MAXIMIZED | |
  20053. * | 6 | ALPHA_ONEONE | |
  20054. * | 7 | ALPHA_PREMULTIPLIED | |
  20055. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20056. * | 9 | ALPHA_INTERPOLATE | |
  20057. * | 10 | ALPHA_SCREENMODE | |
  20058. *
  20059. */
  20060. /**
  20061. * Gets the value of the alpha mode
  20062. */
  20063. alphaMode: number;
  20064. /**
  20065. * Stores the state of the need depth pre-pass value
  20066. */
  20067. private _needDepthPrePass;
  20068. /**
  20069. * Sets the need depth pre-pass value
  20070. */
  20071. /**
  20072. * Gets the depth pre-pass value
  20073. */
  20074. needDepthPrePass: boolean;
  20075. /**
  20076. * Specifies if depth writing should be disabled
  20077. */
  20078. disableDepthWrite: boolean;
  20079. /**
  20080. * Specifies if depth writing should be forced
  20081. */
  20082. forceDepthWrite: boolean;
  20083. /**
  20084. * Specifies if there should be a separate pass for culling
  20085. */
  20086. separateCullingPass: boolean;
  20087. /**
  20088. * Stores the state specifing if fog should be enabled
  20089. */
  20090. private _fogEnabled;
  20091. /**
  20092. * Sets the state for enabling fog
  20093. */
  20094. /**
  20095. * Gets the value of the fog enabled state
  20096. */
  20097. fogEnabled: boolean;
  20098. /**
  20099. * Stores the size of points
  20100. */
  20101. pointSize: number;
  20102. /**
  20103. * Stores the z offset value
  20104. */
  20105. zOffset: number;
  20106. /**
  20107. * Gets a value specifying if wireframe mode is enabled
  20108. */
  20109. /**
  20110. * Sets the state of wireframe mode
  20111. */
  20112. wireframe: boolean;
  20113. /**
  20114. * Gets the value specifying if point clouds are enabled
  20115. */
  20116. /**
  20117. * Sets the state of point cloud mode
  20118. */
  20119. pointsCloud: boolean;
  20120. /**
  20121. * Gets the material fill mode
  20122. */
  20123. /**
  20124. * Sets the material fill mode
  20125. */
  20126. fillMode: number;
  20127. /**
  20128. * @hidden
  20129. * Stores the effects for the material
  20130. */
  20131. _effect: Nullable<Effect>;
  20132. /**
  20133. * @hidden
  20134. * Specifies if the material was previously ready
  20135. */
  20136. _wasPreviouslyReady: boolean;
  20137. /**
  20138. * Specifies if uniform buffers should be used
  20139. */
  20140. private _useUBO;
  20141. /**
  20142. * Stores a reference to the scene
  20143. */
  20144. private _scene;
  20145. /**
  20146. * Stores the fill mode state
  20147. */
  20148. private _fillMode;
  20149. /**
  20150. * Specifies if the depth write state should be cached
  20151. */
  20152. private _cachedDepthWriteState;
  20153. /**
  20154. * Stores the uniform buffer
  20155. */
  20156. protected _uniformBuffer: UniformBuffer;
  20157. /** @hidden */
  20158. _indexInSceneMaterialArray: number;
  20159. /** @hidden */
  20160. meshMap: Nullable<{
  20161. [id: string]: AbstractMesh | undefined;
  20162. }>;
  20163. /**
  20164. * Creates a material instance
  20165. * @param name defines the name of the material
  20166. * @param scene defines the scene to reference
  20167. * @param doNotAdd specifies if the material should be added to the scene
  20168. */
  20169. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20170. /**
  20171. * Returns a string representation of the current material
  20172. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20173. * @returns a string with material information
  20174. */
  20175. toString(fullDetails?: boolean): string;
  20176. /**
  20177. * Gets the class name of the material
  20178. * @returns a string with the class name of the material
  20179. */
  20180. getClassName(): string;
  20181. /**
  20182. * Specifies if updates for the material been locked
  20183. */
  20184. readonly isFrozen: boolean;
  20185. /**
  20186. * Locks updates for the material
  20187. */
  20188. freeze(): void;
  20189. /**
  20190. * Unlocks updates for the material
  20191. */
  20192. unfreeze(): void;
  20193. /**
  20194. * Specifies if the material is ready to be used
  20195. * @param mesh defines the mesh to check
  20196. * @param useInstances specifies if instances should be used
  20197. * @returns a boolean indicating if the material is ready to be used
  20198. */
  20199. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20200. /**
  20201. * Specifies that the submesh is ready to be used
  20202. * @param mesh defines the mesh to check
  20203. * @param subMesh defines which submesh to check
  20204. * @param useInstances specifies that instances should be used
  20205. * @returns a boolean indicating that the submesh is ready or not
  20206. */
  20207. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20208. /**
  20209. * Returns the material effect
  20210. * @returns the effect associated with the material
  20211. */
  20212. getEffect(): Nullable<Effect>;
  20213. /**
  20214. * Returns the current scene
  20215. * @returns a Scene
  20216. */
  20217. getScene(): Scene;
  20218. /**
  20219. * Specifies if the material will require alpha blending
  20220. * @returns a boolean specifying if alpha blending is needed
  20221. */
  20222. needAlphaBlending(): boolean;
  20223. /**
  20224. * Specifies if the mesh will require alpha blending
  20225. * @param mesh defines the mesh to check
  20226. * @returns a boolean specifying if alpha blending is needed for the mesh
  20227. */
  20228. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20229. /**
  20230. * Specifies if this material should be rendered in alpha test mode
  20231. * @returns a boolean specifying if an alpha test is needed.
  20232. */
  20233. needAlphaTesting(): boolean;
  20234. /**
  20235. * Gets the texture used for the alpha test
  20236. * @returns the texture to use for alpha testing
  20237. */
  20238. getAlphaTestTexture(): Nullable<BaseTexture>;
  20239. /**
  20240. * Marks the material to indicate that it needs to be re-calculated
  20241. */
  20242. markDirty(): void;
  20243. /** @hidden */
  20244. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20245. /**
  20246. * Binds the material to the mesh
  20247. * @param world defines the world transformation matrix
  20248. * @param mesh defines the mesh to bind the material to
  20249. */
  20250. bind(world: Matrix, mesh?: Mesh): void;
  20251. /**
  20252. * Binds the submesh to the material
  20253. * @param world defines the world transformation matrix
  20254. * @param mesh defines the mesh containing the submesh
  20255. * @param subMesh defines the submesh to bind the material to
  20256. */
  20257. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20258. /**
  20259. * Binds the world matrix to the material
  20260. * @param world defines the world transformation matrix
  20261. */
  20262. bindOnlyWorldMatrix(world: Matrix): void;
  20263. /**
  20264. * Binds the scene's uniform buffer to the effect.
  20265. * @param effect defines the effect to bind to the scene uniform buffer
  20266. * @param sceneUbo defines the uniform buffer storing scene data
  20267. */
  20268. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20269. /**
  20270. * Binds the view matrix to the effect
  20271. * @param effect defines the effect to bind the view matrix to
  20272. */
  20273. bindView(effect: Effect): void;
  20274. /**
  20275. * Binds the view projection matrix to the effect
  20276. * @param effect defines the effect to bind the view projection matrix to
  20277. */
  20278. bindViewProjection(effect: Effect): void;
  20279. /**
  20280. * Specifies if material alpha testing should be turned on for the mesh
  20281. * @param mesh defines the mesh to check
  20282. */
  20283. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20284. /**
  20285. * Processes to execute after binding the material to a mesh
  20286. * @param mesh defines the rendered mesh
  20287. */
  20288. protected _afterBind(mesh?: Mesh): void;
  20289. /**
  20290. * Unbinds the material from the mesh
  20291. */
  20292. unbind(): void;
  20293. /**
  20294. * Gets the active textures from the material
  20295. * @returns an array of textures
  20296. */
  20297. getActiveTextures(): BaseTexture[];
  20298. /**
  20299. * Specifies if the material uses a texture
  20300. * @param texture defines the texture to check against the material
  20301. * @returns a boolean specifying if the material uses the texture
  20302. */
  20303. hasTexture(texture: BaseTexture): boolean;
  20304. /**
  20305. * Makes a duplicate of the material, and gives it a new name
  20306. * @param name defines the new name for the duplicated material
  20307. * @returns the cloned material
  20308. */
  20309. clone(name: string): Nullable<Material>;
  20310. /**
  20311. * Gets the meshes bound to the material
  20312. * @returns an array of meshes bound to the material
  20313. */
  20314. getBindedMeshes(): AbstractMesh[];
  20315. /**
  20316. * Force shader compilation
  20317. * @param mesh defines the mesh associated with this material
  20318. * @param onCompiled defines a function to execute once the material is compiled
  20319. * @param options defines the options to configure the compilation
  20320. */
  20321. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20322. clipPlane: boolean;
  20323. }>): void;
  20324. /**
  20325. * Force shader compilation
  20326. * @param mesh defines the mesh that will use this material
  20327. * @param options defines additional options for compiling the shaders
  20328. * @returns a promise that resolves when the compilation completes
  20329. */
  20330. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20331. clipPlane: boolean;
  20332. }>): Promise<void>;
  20333. private static readonly _AllDirtyCallBack;
  20334. private static readonly _ImageProcessingDirtyCallBack;
  20335. private static readonly _TextureDirtyCallBack;
  20336. private static readonly _FresnelDirtyCallBack;
  20337. private static readonly _MiscDirtyCallBack;
  20338. private static readonly _LightsDirtyCallBack;
  20339. private static readonly _AttributeDirtyCallBack;
  20340. private static _FresnelAndMiscDirtyCallBack;
  20341. private static _TextureAndMiscDirtyCallBack;
  20342. private static readonly _DirtyCallbackArray;
  20343. private static readonly _RunDirtyCallBacks;
  20344. /**
  20345. * Marks a define in the material to indicate that it needs to be re-computed
  20346. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20347. */
  20348. markAsDirty(flag: number): void;
  20349. /**
  20350. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20351. * @param func defines a function which checks material defines against the submeshes
  20352. */
  20353. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20354. /**
  20355. * Indicates that we need to re-calculated for all submeshes
  20356. */
  20357. protected _markAllSubMeshesAsAllDirty(): void;
  20358. /**
  20359. * Indicates that image processing needs to be re-calculated for all submeshes
  20360. */
  20361. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20362. /**
  20363. * Indicates that textures need to be re-calculated for all submeshes
  20364. */
  20365. protected _markAllSubMeshesAsTexturesDirty(): void;
  20366. /**
  20367. * Indicates that fresnel needs to be re-calculated for all submeshes
  20368. */
  20369. protected _markAllSubMeshesAsFresnelDirty(): void;
  20370. /**
  20371. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20372. */
  20373. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20374. /**
  20375. * Indicates that lights need to be re-calculated for all submeshes
  20376. */
  20377. protected _markAllSubMeshesAsLightsDirty(): void;
  20378. /**
  20379. * Indicates that attributes need to be re-calculated for all submeshes
  20380. */
  20381. protected _markAllSubMeshesAsAttributesDirty(): void;
  20382. /**
  20383. * Indicates that misc needs to be re-calculated for all submeshes
  20384. */
  20385. protected _markAllSubMeshesAsMiscDirty(): void;
  20386. /**
  20387. * Indicates that textures and misc need to be re-calculated for all submeshes
  20388. */
  20389. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20390. /**
  20391. * Disposes the material
  20392. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20393. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20394. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20395. */
  20396. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20397. /** @hidden */
  20398. private releaseVertexArrayObject;
  20399. /**
  20400. * Serializes this material
  20401. * @returns the serialized material object
  20402. */
  20403. serialize(): any;
  20404. /**
  20405. * Creates a material from parsed material data
  20406. * @param parsedMaterial defines parsed material data
  20407. * @param scene defines the hosting scene
  20408. * @param rootUrl defines the root URL to use to load textures
  20409. * @returns a new material
  20410. */
  20411. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20412. }
  20413. }
  20414. declare module BABYLON {
  20415. /**
  20416. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20417. * separate meshes. This can be use to improve performances.
  20418. * @see http://doc.babylonjs.com/how_to/multi_materials
  20419. */
  20420. export class MultiMaterial extends Material {
  20421. private _subMaterials;
  20422. /**
  20423. * Gets or Sets the list of Materials used within the multi material.
  20424. * They need to be ordered according to the submeshes order in the associated mesh
  20425. */
  20426. subMaterials: Nullable<Material>[];
  20427. /**
  20428. * Function used to align with Node.getChildren()
  20429. * @returns the list of Materials used within the multi material
  20430. */
  20431. getChildren(): Nullable<Material>[];
  20432. /**
  20433. * Instantiates a new Multi Material
  20434. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20435. * separate meshes. This can be use to improve performances.
  20436. * @see http://doc.babylonjs.com/how_to/multi_materials
  20437. * @param name Define the name in the scene
  20438. * @param scene Define the scene the material belongs to
  20439. */
  20440. constructor(name: string, scene: Scene);
  20441. private _hookArray;
  20442. /**
  20443. * Get one of the submaterial by its index in the submaterials array
  20444. * @param index The index to look the sub material at
  20445. * @returns The Material if the index has been defined
  20446. */
  20447. getSubMaterial(index: number): Nullable<Material>;
  20448. /**
  20449. * Get the list of active textures for the whole sub materials list.
  20450. * @returns All the textures that will be used during the rendering
  20451. */
  20452. getActiveTextures(): BaseTexture[];
  20453. /**
  20454. * Gets the current class name of the material e.g. "MultiMaterial"
  20455. * Mainly use in serialization.
  20456. * @returns the class name
  20457. */
  20458. getClassName(): string;
  20459. /**
  20460. * Checks if the material is ready to render the requested sub mesh
  20461. * @param mesh Define the mesh the submesh belongs to
  20462. * @param subMesh Define the sub mesh to look readyness for
  20463. * @param useInstances Define whether or not the material is used with instances
  20464. * @returns true if ready, otherwise false
  20465. */
  20466. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20467. /**
  20468. * Clones the current material and its related sub materials
  20469. * @param name Define the name of the newly cloned material
  20470. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20471. * @returns the cloned material
  20472. */
  20473. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20474. /**
  20475. * Serializes the materials into a JSON representation.
  20476. * @returns the JSON representation
  20477. */
  20478. serialize(): any;
  20479. /**
  20480. * Dispose the material and release its associated resources
  20481. * @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)
  20482. * @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)
  20483. * @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)
  20484. */
  20485. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20486. /**
  20487. * Creates a MultiMaterial from parsed MultiMaterial data.
  20488. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20489. * @param scene defines the hosting scene
  20490. * @returns a new MultiMaterial
  20491. */
  20492. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20493. }
  20494. }
  20495. declare module BABYLON {
  20496. /**
  20497. * Base class for submeshes
  20498. */
  20499. export class BaseSubMesh {
  20500. /** @hidden */
  20501. _materialDefines: Nullable<MaterialDefines>;
  20502. /** @hidden */
  20503. _materialEffect: Nullable<Effect>;
  20504. /**
  20505. * Gets associated effect
  20506. */
  20507. readonly effect: Nullable<Effect>;
  20508. /**
  20509. * Sets associated effect (effect used to render this submesh)
  20510. * @param effect defines the effect to associate with
  20511. * @param defines defines the set of defines used to compile this effect
  20512. */
  20513. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20514. }
  20515. /**
  20516. * Defines a subdivision inside a mesh
  20517. */
  20518. export class SubMesh extends BaseSubMesh implements ICullable {
  20519. /** the material index to use */
  20520. materialIndex: number;
  20521. /** vertex index start */
  20522. verticesStart: number;
  20523. /** vertices count */
  20524. verticesCount: number;
  20525. /** index start */
  20526. indexStart: number;
  20527. /** indices count */
  20528. indexCount: number;
  20529. /** @hidden */
  20530. _linesIndexCount: number;
  20531. private _mesh;
  20532. private _renderingMesh;
  20533. private _boundingInfo;
  20534. private _linesIndexBuffer;
  20535. /** @hidden */
  20536. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20537. /** @hidden */
  20538. _trianglePlanes: Plane[];
  20539. /** @hidden */
  20540. _lastColliderTransformMatrix: Nullable<Matrix>;
  20541. /** @hidden */
  20542. _renderId: number;
  20543. /** @hidden */
  20544. _alphaIndex: number;
  20545. /** @hidden */
  20546. _distanceToCamera: number;
  20547. /** @hidden */
  20548. _id: number;
  20549. private _currentMaterial;
  20550. /**
  20551. * Add a new submesh to a mesh
  20552. * @param materialIndex defines the material index to use
  20553. * @param verticesStart defines vertex index start
  20554. * @param verticesCount defines vertices count
  20555. * @param indexStart defines index start
  20556. * @param indexCount defines indices count
  20557. * @param mesh defines the parent mesh
  20558. * @param renderingMesh defines an optional rendering mesh
  20559. * @param createBoundingBox defines if bounding box should be created for this submesh
  20560. * @returns the new submesh
  20561. */
  20562. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20563. /**
  20564. * Creates a new submesh
  20565. * @param materialIndex defines the material index to use
  20566. * @param verticesStart defines vertex index start
  20567. * @param verticesCount defines vertices count
  20568. * @param indexStart defines index start
  20569. * @param indexCount defines indices count
  20570. * @param mesh defines the parent mesh
  20571. * @param renderingMesh defines an optional rendering mesh
  20572. * @param createBoundingBox defines if bounding box should be created for this submesh
  20573. */
  20574. constructor(
  20575. /** the material index to use */
  20576. materialIndex: number,
  20577. /** vertex index start */
  20578. verticesStart: number,
  20579. /** vertices count */
  20580. verticesCount: number,
  20581. /** index start */
  20582. indexStart: number,
  20583. /** indices count */
  20584. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20585. /**
  20586. * Returns true if this submesh covers the entire parent mesh
  20587. * @ignorenaming
  20588. */
  20589. readonly IsGlobal: boolean;
  20590. /**
  20591. * Returns the submesh BoudingInfo object
  20592. * @returns current bounding info (or mesh's one if the submesh is global)
  20593. */
  20594. getBoundingInfo(): BoundingInfo;
  20595. /**
  20596. * Sets the submesh BoundingInfo
  20597. * @param boundingInfo defines the new bounding info to use
  20598. * @returns the SubMesh
  20599. */
  20600. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20601. /**
  20602. * Returns the mesh of the current submesh
  20603. * @return the parent mesh
  20604. */
  20605. getMesh(): AbstractMesh;
  20606. /**
  20607. * Returns the rendering mesh of the submesh
  20608. * @returns the rendering mesh (could be different from parent mesh)
  20609. */
  20610. getRenderingMesh(): Mesh;
  20611. /**
  20612. * Returns the submesh material
  20613. * @returns null or the current material
  20614. */
  20615. getMaterial(): Nullable<Material>;
  20616. /**
  20617. * Sets a new updated BoundingInfo object to the submesh
  20618. * @param data defines an optional position array to use to determine the bounding info
  20619. * @returns the SubMesh
  20620. */
  20621. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20622. /** @hidden */
  20623. _checkCollision(collider: Collider): boolean;
  20624. /**
  20625. * Updates the submesh BoundingInfo
  20626. * @param world defines the world matrix to use to update the bounding info
  20627. * @returns the submesh
  20628. */
  20629. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20630. /**
  20631. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20632. * @param frustumPlanes defines the frustum planes
  20633. * @returns true if the submesh is intersecting with the frustum
  20634. */
  20635. isInFrustum(frustumPlanes: Plane[]): boolean;
  20636. /**
  20637. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20638. * @param frustumPlanes defines the frustum planes
  20639. * @returns true if the submesh is inside the frustum
  20640. */
  20641. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20642. /**
  20643. * Renders the submesh
  20644. * @param enableAlphaMode defines if alpha needs to be used
  20645. * @returns the submesh
  20646. */
  20647. render(enableAlphaMode: boolean): SubMesh;
  20648. /**
  20649. * @hidden
  20650. */
  20651. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20652. /**
  20653. * Checks if the submesh intersects with a ray
  20654. * @param ray defines the ray to test
  20655. * @returns true is the passed ray intersects the submesh bounding box
  20656. */
  20657. canIntersects(ray: Ray): boolean;
  20658. /**
  20659. * Intersects current submesh with a ray
  20660. * @param ray defines the ray to test
  20661. * @param positions defines mesh's positions array
  20662. * @param indices defines mesh's indices array
  20663. * @param fastCheck defines if only bounding info should be used
  20664. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20665. * @returns intersection info or null if no intersection
  20666. */
  20667. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20668. /** @hidden */
  20669. private _intersectLines;
  20670. /** @hidden */
  20671. private _intersectUnIndexedLines;
  20672. /** @hidden */
  20673. private _intersectTriangles;
  20674. /** @hidden */
  20675. private _intersectUnIndexedTriangles;
  20676. /** @hidden */
  20677. _rebuild(): void;
  20678. /**
  20679. * Creates a new submesh from the passed mesh
  20680. * @param newMesh defines the new hosting mesh
  20681. * @param newRenderingMesh defines an optional rendering mesh
  20682. * @returns the new submesh
  20683. */
  20684. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20685. /**
  20686. * Release associated resources
  20687. */
  20688. dispose(): void;
  20689. /**
  20690. * Gets the class name
  20691. * @returns the string "SubMesh".
  20692. */
  20693. getClassName(): string;
  20694. /**
  20695. * Creates a new submesh from indices data
  20696. * @param materialIndex the index of the main mesh material
  20697. * @param startIndex the index where to start the copy in the mesh indices array
  20698. * @param indexCount the number of indices to copy then from the startIndex
  20699. * @param mesh the main mesh to create the submesh from
  20700. * @param renderingMesh the optional rendering mesh
  20701. * @returns a new submesh
  20702. */
  20703. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20704. }
  20705. }
  20706. declare module BABYLON {
  20707. /**
  20708. * Class used to represent data loading progression
  20709. */
  20710. export class SceneLoaderFlags {
  20711. private static _ForceFullSceneLoadingForIncremental;
  20712. private static _ShowLoadingScreen;
  20713. private static _CleanBoneMatrixWeights;
  20714. private static _loggingLevel;
  20715. /**
  20716. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20717. */
  20718. static ForceFullSceneLoadingForIncremental: boolean;
  20719. /**
  20720. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20721. */
  20722. static ShowLoadingScreen: boolean;
  20723. /**
  20724. * Defines the current logging level (while loading the scene)
  20725. * @ignorenaming
  20726. */
  20727. static loggingLevel: number;
  20728. /**
  20729. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20730. */
  20731. static CleanBoneMatrixWeights: boolean;
  20732. }
  20733. }
  20734. declare module BABYLON {
  20735. /**
  20736. * Class used to store geometry data (vertex buffers + index buffer)
  20737. */
  20738. export class Geometry implements IGetSetVerticesData {
  20739. /**
  20740. * Gets or sets the ID of the geometry
  20741. */
  20742. id: string;
  20743. /**
  20744. * Gets or sets the unique ID of the geometry
  20745. */
  20746. uniqueId: number;
  20747. /**
  20748. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20749. */
  20750. delayLoadState: number;
  20751. /**
  20752. * Gets the file containing the data to load when running in delay load state
  20753. */
  20754. delayLoadingFile: Nullable<string>;
  20755. /**
  20756. * Callback called when the geometry is updated
  20757. */
  20758. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20759. private _scene;
  20760. private _engine;
  20761. private _meshes;
  20762. private _totalVertices;
  20763. /** @hidden */
  20764. _indices: IndicesArray;
  20765. /** @hidden */
  20766. _vertexBuffers: {
  20767. [key: string]: VertexBuffer;
  20768. };
  20769. private _isDisposed;
  20770. private _extend;
  20771. private _boundingBias;
  20772. /** @hidden */
  20773. _delayInfo: Array<string>;
  20774. private _indexBuffer;
  20775. private _indexBufferIsUpdatable;
  20776. /** @hidden */
  20777. _boundingInfo: Nullable<BoundingInfo>;
  20778. /** @hidden */
  20779. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20780. /** @hidden */
  20781. _softwareSkinningFrameId: number;
  20782. private _vertexArrayObjects;
  20783. private _updatable;
  20784. /** @hidden */
  20785. _positions: Nullable<Vector3[]>;
  20786. /**
  20787. * 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
  20788. */
  20789. /**
  20790. * 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
  20791. */
  20792. boundingBias: Vector2;
  20793. /**
  20794. * Static function used to attach a new empty geometry to a mesh
  20795. * @param mesh defines the mesh to attach the geometry to
  20796. * @returns the new Geometry
  20797. */
  20798. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20799. /**
  20800. * Creates a new geometry
  20801. * @param id defines the unique ID
  20802. * @param scene defines the hosting scene
  20803. * @param vertexData defines the VertexData used to get geometry data
  20804. * @param updatable defines if geometry must be updatable (false by default)
  20805. * @param mesh defines the mesh that will be associated with the geometry
  20806. */
  20807. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20808. /**
  20809. * Gets the current extend of the geometry
  20810. */
  20811. readonly extend: {
  20812. minimum: Vector3;
  20813. maximum: Vector3;
  20814. };
  20815. /**
  20816. * Gets the hosting scene
  20817. * @returns the hosting Scene
  20818. */
  20819. getScene(): Scene;
  20820. /**
  20821. * Gets the hosting engine
  20822. * @returns the hosting Engine
  20823. */
  20824. getEngine(): Engine;
  20825. /**
  20826. * Defines if the geometry is ready to use
  20827. * @returns true if the geometry is ready to be used
  20828. */
  20829. isReady(): boolean;
  20830. /**
  20831. * Gets a value indicating that the geometry should not be serialized
  20832. */
  20833. readonly doNotSerialize: boolean;
  20834. /** @hidden */
  20835. _rebuild(): void;
  20836. /**
  20837. * Affects all geometry data in one call
  20838. * @param vertexData defines the geometry data
  20839. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20840. */
  20841. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20842. /**
  20843. * Set specific vertex data
  20844. * @param kind defines the data kind (Position, normal, etc...)
  20845. * @param data defines the vertex data to use
  20846. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20847. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20848. */
  20849. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20850. /**
  20851. * Removes a specific vertex data
  20852. * @param kind defines the data kind (Position, normal, etc...)
  20853. */
  20854. removeVerticesData(kind: string): void;
  20855. /**
  20856. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20857. * @param buffer defines the vertex buffer to use
  20858. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20859. */
  20860. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20861. /**
  20862. * Update a specific vertex buffer
  20863. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20864. * It will do nothing if the buffer is not updatable
  20865. * @param kind defines the data kind (Position, normal, etc...)
  20866. * @param data defines the data to use
  20867. * @param offset defines the offset in the target buffer where to store the data
  20868. * @param useBytes set to true if the offset is in bytes
  20869. */
  20870. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20871. /**
  20872. * Update a specific vertex buffer
  20873. * This function will create a new buffer if the current one is not updatable
  20874. * @param kind defines the data kind (Position, normal, etc...)
  20875. * @param data defines the data to use
  20876. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20877. */
  20878. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20879. private _updateBoundingInfo;
  20880. /** @hidden */
  20881. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20882. /**
  20883. * Gets total number of vertices
  20884. * @returns the total number of vertices
  20885. */
  20886. getTotalVertices(): number;
  20887. /**
  20888. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20889. * @param kind defines the data kind (Position, normal, etc...)
  20890. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20891. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20892. * @returns a float array containing vertex data
  20893. */
  20894. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20895. /**
  20896. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20897. * @param kind defines the data kind (Position, normal, etc...)
  20898. * @returns true if the vertex buffer with the specified kind is updatable
  20899. */
  20900. isVertexBufferUpdatable(kind: string): boolean;
  20901. /**
  20902. * Gets a specific vertex buffer
  20903. * @param kind defines the data kind (Position, normal, etc...)
  20904. * @returns a VertexBuffer
  20905. */
  20906. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20907. /**
  20908. * Returns all vertex buffers
  20909. * @return an object holding all vertex buffers indexed by kind
  20910. */
  20911. getVertexBuffers(): Nullable<{
  20912. [key: string]: VertexBuffer;
  20913. }>;
  20914. /**
  20915. * Gets a boolean indicating if specific vertex buffer is present
  20916. * @param kind defines the data kind (Position, normal, etc...)
  20917. * @returns true if data is present
  20918. */
  20919. isVerticesDataPresent(kind: string): boolean;
  20920. /**
  20921. * Gets a list of all attached data kinds (Position, normal, etc...)
  20922. * @returns a list of string containing all kinds
  20923. */
  20924. getVerticesDataKinds(): string[];
  20925. /**
  20926. * Update index buffer
  20927. * @param indices defines the indices to store in the index buffer
  20928. * @param offset defines the offset in the target buffer where to store the data
  20929. * @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)
  20930. */
  20931. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  20932. /**
  20933. * Creates a new index buffer
  20934. * @param indices defines the indices to store in the index buffer
  20935. * @param totalVertices defines the total number of vertices (could be null)
  20936. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20937. */
  20938. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20939. /**
  20940. * Return the total number of indices
  20941. * @returns the total number of indices
  20942. */
  20943. getTotalIndices(): number;
  20944. /**
  20945. * Gets the index buffer array
  20946. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20947. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20948. * @returns the index buffer array
  20949. */
  20950. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20951. /**
  20952. * Gets the index buffer
  20953. * @return the index buffer
  20954. */
  20955. getIndexBuffer(): Nullable<DataBuffer>;
  20956. /** @hidden */
  20957. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20958. /**
  20959. * Release the associated resources for a specific mesh
  20960. * @param mesh defines the source mesh
  20961. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20962. */
  20963. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20964. /**
  20965. * Apply current geometry to a given mesh
  20966. * @param mesh defines the mesh to apply geometry to
  20967. */
  20968. applyToMesh(mesh: Mesh): void;
  20969. private _updateExtend;
  20970. private _applyToMesh;
  20971. private notifyUpdate;
  20972. /**
  20973. * Load the geometry if it was flagged as delay loaded
  20974. * @param scene defines the hosting scene
  20975. * @param onLoaded defines a callback called when the geometry is loaded
  20976. */
  20977. load(scene: Scene, onLoaded?: () => void): void;
  20978. private _queueLoad;
  20979. /**
  20980. * Invert the geometry to move from a right handed system to a left handed one.
  20981. */
  20982. toLeftHanded(): void;
  20983. /** @hidden */
  20984. _resetPointsArrayCache(): void;
  20985. /** @hidden */
  20986. _generatePointsArray(): boolean;
  20987. /**
  20988. * Gets a value indicating if the geometry is disposed
  20989. * @returns true if the geometry was disposed
  20990. */
  20991. isDisposed(): boolean;
  20992. private _disposeVertexArrayObjects;
  20993. /**
  20994. * Free all associated resources
  20995. */
  20996. dispose(): void;
  20997. /**
  20998. * Clone the current geometry into a new geometry
  20999. * @param id defines the unique ID of the new geometry
  21000. * @returns a new geometry object
  21001. */
  21002. copy(id: string): Geometry;
  21003. /**
  21004. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21005. * @return a JSON representation of the current geometry data (without the vertices data)
  21006. */
  21007. serialize(): any;
  21008. private toNumberArray;
  21009. /**
  21010. * Serialize all vertices data into a JSON oject
  21011. * @returns a JSON representation of the current geometry data
  21012. */
  21013. serializeVerticeData(): any;
  21014. /**
  21015. * Extracts a clone of a mesh geometry
  21016. * @param mesh defines the source mesh
  21017. * @param id defines the unique ID of the new geometry object
  21018. * @returns the new geometry object
  21019. */
  21020. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21021. /**
  21022. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21023. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21024. * Be aware Math.random() could cause collisions, but:
  21025. * "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"
  21026. * @returns a string containing a new GUID
  21027. */
  21028. static RandomId(): string;
  21029. /** @hidden */
  21030. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21031. private static _CleanMatricesWeights;
  21032. /**
  21033. * Create a new geometry from persisted data (Using .babylon file format)
  21034. * @param parsedVertexData defines the persisted data
  21035. * @param scene defines the hosting scene
  21036. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21037. * @returns the new geometry object
  21038. */
  21039. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21040. }
  21041. }
  21042. declare module BABYLON {
  21043. /**
  21044. * Define an interface for all classes that will get and set the data on vertices
  21045. */
  21046. export interface IGetSetVerticesData {
  21047. /**
  21048. * Gets a boolean indicating if specific vertex data is present
  21049. * @param kind defines the vertex data kind to use
  21050. * @returns true is data kind is present
  21051. */
  21052. isVerticesDataPresent(kind: string): boolean;
  21053. /**
  21054. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21055. * @param kind defines the data kind (Position, normal, etc...)
  21056. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21057. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21058. * @returns a float array containing vertex data
  21059. */
  21060. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21061. /**
  21062. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21063. * @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.
  21064. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21065. * @returns the indices array or an empty array if the mesh has no geometry
  21066. */
  21067. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21068. /**
  21069. * Set specific vertex data
  21070. * @param kind defines the data kind (Position, normal, etc...)
  21071. * @param data defines the vertex data to use
  21072. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21073. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21074. */
  21075. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21076. /**
  21077. * Update a specific associated vertex buffer
  21078. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21079. * - VertexBuffer.PositionKind
  21080. * - VertexBuffer.UVKind
  21081. * - VertexBuffer.UV2Kind
  21082. * - VertexBuffer.UV3Kind
  21083. * - VertexBuffer.UV4Kind
  21084. * - VertexBuffer.UV5Kind
  21085. * - VertexBuffer.UV6Kind
  21086. * - VertexBuffer.ColorKind
  21087. * - VertexBuffer.MatricesIndicesKind
  21088. * - VertexBuffer.MatricesIndicesExtraKind
  21089. * - VertexBuffer.MatricesWeightsKind
  21090. * - VertexBuffer.MatricesWeightsExtraKind
  21091. * @param data defines the data source
  21092. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21093. * @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)
  21094. */
  21095. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21096. /**
  21097. * Creates a new index buffer
  21098. * @param indices defines the indices to store in the index buffer
  21099. * @param totalVertices defines the total number of vertices (could be null)
  21100. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21101. */
  21102. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21103. }
  21104. /**
  21105. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21106. */
  21107. export class VertexData {
  21108. /**
  21109. * Mesh side orientation : usually the external or front surface
  21110. */
  21111. static readonly FRONTSIDE: number;
  21112. /**
  21113. * Mesh side orientation : usually the internal or back surface
  21114. */
  21115. static readonly BACKSIDE: number;
  21116. /**
  21117. * Mesh side orientation : both internal and external or front and back surfaces
  21118. */
  21119. static readonly DOUBLESIDE: number;
  21120. /**
  21121. * Mesh side orientation : by default, `FRONTSIDE`
  21122. */
  21123. static readonly DEFAULTSIDE: number;
  21124. /**
  21125. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21126. */
  21127. positions: Nullable<FloatArray>;
  21128. /**
  21129. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21130. */
  21131. normals: Nullable<FloatArray>;
  21132. /**
  21133. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21134. */
  21135. tangents: Nullable<FloatArray>;
  21136. /**
  21137. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21138. */
  21139. uvs: Nullable<FloatArray>;
  21140. /**
  21141. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21142. */
  21143. uvs2: Nullable<FloatArray>;
  21144. /**
  21145. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21146. */
  21147. uvs3: Nullable<FloatArray>;
  21148. /**
  21149. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21150. */
  21151. uvs4: Nullable<FloatArray>;
  21152. /**
  21153. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21154. */
  21155. uvs5: Nullable<FloatArray>;
  21156. /**
  21157. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21158. */
  21159. uvs6: Nullable<FloatArray>;
  21160. /**
  21161. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21162. */
  21163. colors: Nullable<FloatArray>;
  21164. /**
  21165. * 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).
  21166. */
  21167. matricesIndices: Nullable<FloatArray>;
  21168. /**
  21169. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21170. */
  21171. matricesWeights: Nullable<FloatArray>;
  21172. /**
  21173. * An array extending the number of possible indices
  21174. */
  21175. matricesIndicesExtra: Nullable<FloatArray>;
  21176. /**
  21177. * An array extending the number of possible weights when the number of indices is extended
  21178. */
  21179. matricesWeightsExtra: Nullable<FloatArray>;
  21180. /**
  21181. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21182. */
  21183. indices: Nullable<IndicesArray>;
  21184. /**
  21185. * Uses the passed data array to set the set the values for the specified kind of data
  21186. * @param data a linear array of floating numbers
  21187. * @param kind the type of data that is being set, eg positions, colors etc
  21188. */
  21189. set(data: FloatArray, kind: string): void;
  21190. /**
  21191. * Associates the vertexData to the passed Mesh.
  21192. * Sets it as updatable or not (default `false`)
  21193. * @param mesh the mesh the vertexData is applied to
  21194. * @param updatable when used and having the value true allows new data to update the vertexData
  21195. * @returns the VertexData
  21196. */
  21197. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21198. /**
  21199. * Associates the vertexData to the passed Geometry.
  21200. * Sets it as updatable or not (default `false`)
  21201. * @param geometry the geometry the vertexData is applied to
  21202. * @param updatable when used and having the value true allows new data to update the vertexData
  21203. * @returns VertexData
  21204. */
  21205. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21206. /**
  21207. * Updates the associated mesh
  21208. * @param mesh the mesh to be updated
  21209. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21210. * @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
  21211. * @returns VertexData
  21212. */
  21213. updateMesh(mesh: Mesh): VertexData;
  21214. /**
  21215. * Updates the associated geometry
  21216. * @param geometry the geometry to be updated
  21217. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21218. * @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
  21219. * @returns VertexData.
  21220. */
  21221. updateGeometry(geometry: Geometry): VertexData;
  21222. private _applyTo;
  21223. private _update;
  21224. /**
  21225. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21226. * @param matrix the transforming matrix
  21227. * @returns the VertexData
  21228. */
  21229. transform(matrix: Matrix): VertexData;
  21230. /**
  21231. * Merges the passed VertexData into the current one
  21232. * @param other the VertexData to be merged into the current one
  21233. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21234. * @returns the modified VertexData
  21235. */
  21236. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21237. private _mergeElement;
  21238. private _validate;
  21239. /**
  21240. * Serializes the VertexData
  21241. * @returns a serialized object
  21242. */
  21243. serialize(): any;
  21244. /**
  21245. * Extracts the vertexData from a mesh
  21246. * @param mesh the mesh from which to extract the VertexData
  21247. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21248. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21249. * @returns the object VertexData associated to the passed mesh
  21250. */
  21251. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21252. /**
  21253. * Extracts the vertexData from the geometry
  21254. * @param geometry the geometry from which to extract the VertexData
  21255. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21256. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21257. * @returns the object VertexData associated to the passed mesh
  21258. */
  21259. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21260. private static _ExtractFrom;
  21261. /**
  21262. * Creates the VertexData for a Ribbon
  21263. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21264. * * pathArray array of paths, each of which an array of successive Vector3
  21265. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21266. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21267. * * 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
  21268. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21269. * * 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)
  21270. * * 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)
  21271. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21272. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21273. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21274. * @returns the VertexData of the ribbon
  21275. */
  21276. static CreateRibbon(options: {
  21277. pathArray: Vector3[][];
  21278. closeArray?: boolean;
  21279. closePath?: boolean;
  21280. offset?: number;
  21281. sideOrientation?: number;
  21282. frontUVs?: Vector4;
  21283. backUVs?: Vector4;
  21284. invertUV?: boolean;
  21285. uvs?: Vector2[];
  21286. colors?: Color4[];
  21287. }): VertexData;
  21288. /**
  21289. * Creates the VertexData for a box
  21290. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21291. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21292. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21293. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21294. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21295. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21296. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21297. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21298. * * 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)
  21299. * * 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)
  21300. * @returns the VertexData of the box
  21301. */
  21302. static CreateBox(options: {
  21303. size?: number;
  21304. width?: number;
  21305. height?: number;
  21306. depth?: number;
  21307. faceUV?: Vector4[];
  21308. faceColors?: Color4[];
  21309. sideOrientation?: number;
  21310. frontUVs?: Vector4;
  21311. backUVs?: Vector4;
  21312. }): VertexData;
  21313. /**
  21314. * Creates the VertexData for a tiled box
  21315. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21316. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21317. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21318. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21319. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21320. * @returns the VertexData of the box
  21321. */
  21322. static CreateTiledBox(options: {
  21323. pattern?: number;
  21324. width?: number;
  21325. height?: number;
  21326. depth?: number;
  21327. tileSize?: number;
  21328. tileWidth?: number;
  21329. tileHeight?: number;
  21330. alignHorizontal?: number;
  21331. alignVertical?: number;
  21332. faceUV?: Vector4[];
  21333. faceColors?: Color4[];
  21334. sideOrientation?: number;
  21335. }): VertexData;
  21336. /**
  21337. * Creates the VertexData for a tiled plane
  21338. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21339. * * pattern a limited pattern arrangement depending on the number
  21340. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21341. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21342. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21343. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21344. * * 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)
  21345. * * 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)
  21346. * @returns the VertexData of the tiled plane
  21347. */
  21348. static CreateTiledPlane(options: {
  21349. pattern?: number;
  21350. tileSize?: number;
  21351. tileWidth?: number;
  21352. tileHeight?: number;
  21353. size?: number;
  21354. width?: number;
  21355. height?: number;
  21356. alignHorizontal?: number;
  21357. alignVertical?: number;
  21358. sideOrientation?: number;
  21359. frontUVs?: Vector4;
  21360. backUVs?: Vector4;
  21361. }): VertexData;
  21362. /**
  21363. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21364. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21365. * * segments sets the number of horizontal strips optional, default 32
  21366. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21367. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21368. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21369. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21370. * * 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
  21371. * * 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
  21372. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21373. * * 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)
  21374. * * 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)
  21375. * @returns the VertexData of the ellipsoid
  21376. */
  21377. static CreateSphere(options: {
  21378. segments?: number;
  21379. diameter?: number;
  21380. diameterX?: number;
  21381. diameterY?: number;
  21382. diameterZ?: number;
  21383. arc?: number;
  21384. slice?: number;
  21385. sideOrientation?: number;
  21386. frontUVs?: Vector4;
  21387. backUVs?: Vector4;
  21388. }): VertexData;
  21389. /**
  21390. * Creates the VertexData for a cylinder, cone or prism
  21391. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21392. * * height sets the height (y direction) of the cylinder, optional, default 2
  21393. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21394. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21395. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21396. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21397. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21398. * * 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
  21399. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21400. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21401. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21402. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21403. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21404. * * 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)
  21405. * * 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)
  21406. * @returns the VertexData of the cylinder, cone or prism
  21407. */
  21408. static CreateCylinder(options: {
  21409. height?: number;
  21410. diameterTop?: number;
  21411. diameterBottom?: number;
  21412. diameter?: number;
  21413. tessellation?: number;
  21414. subdivisions?: number;
  21415. arc?: number;
  21416. faceColors?: Color4[];
  21417. faceUV?: Vector4[];
  21418. hasRings?: boolean;
  21419. enclose?: boolean;
  21420. sideOrientation?: number;
  21421. frontUVs?: Vector4;
  21422. backUVs?: Vector4;
  21423. }): VertexData;
  21424. /**
  21425. * Creates the VertexData for a torus
  21426. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21427. * * diameter the diameter of the torus, optional default 1
  21428. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21429. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21430. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21431. * * 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)
  21432. * * 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)
  21433. * @returns the VertexData of the torus
  21434. */
  21435. static CreateTorus(options: {
  21436. diameter?: number;
  21437. thickness?: number;
  21438. tessellation?: number;
  21439. sideOrientation?: number;
  21440. frontUVs?: Vector4;
  21441. backUVs?: Vector4;
  21442. }): VertexData;
  21443. /**
  21444. * Creates the VertexData of the LineSystem
  21445. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21446. * - lines an array of lines, each line being an array of successive Vector3
  21447. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21448. * @returns the VertexData of the LineSystem
  21449. */
  21450. static CreateLineSystem(options: {
  21451. lines: Vector3[][];
  21452. colors?: Nullable<Color4[][]>;
  21453. }): VertexData;
  21454. /**
  21455. * Create the VertexData for a DashedLines
  21456. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21457. * - points an array successive Vector3
  21458. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21459. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21460. * - dashNb the intended total number of dashes, optional, default 200
  21461. * @returns the VertexData for the DashedLines
  21462. */
  21463. static CreateDashedLines(options: {
  21464. points: Vector3[];
  21465. dashSize?: number;
  21466. gapSize?: number;
  21467. dashNb?: number;
  21468. }): VertexData;
  21469. /**
  21470. * Creates the VertexData for a Ground
  21471. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21472. * - width the width (x direction) of the ground, optional, default 1
  21473. * - height the height (z direction) of the ground, optional, default 1
  21474. * - subdivisions the number of subdivisions per side, optional, default 1
  21475. * @returns the VertexData of the Ground
  21476. */
  21477. static CreateGround(options: {
  21478. width?: number;
  21479. height?: number;
  21480. subdivisions?: number;
  21481. subdivisionsX?: number;
  21482. subdivisionsY?: number;
  21483. }): VertexData;
  21484. /**
  21485. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21486. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21487. * * xmin the ground minimum X coordinate, optional, default -1
  21488. * * zmin the ground minimum Z coordinate, optional, default -1
  21489. * * xmax the ground maximum X coordinate, optional, default 1
  21490. * * zmax the ground maximum Z coordinate, optional, default 1
  21491. * * 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}
  21492. * * 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}
  21493. * @returns the VertexData of the TiledGround
  21494. */
  21495. static CreateTiledGround(options: {
  21496. xmin: number;
  21497. zmin: number;
  21498. xmax: number;
  21499. zmax: number;
  21500. subdivisions?: {
  21501. w: number;
  21502. h: number;
  21503. };
  21504. precision?: {
  21505. w: number;
  21506. h: number;
  21507. };
  21508. }): VertexData;
  21509. /**
  21510. * Creates the VertexData of the Ground designed from a heightmap
  21511. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21512. * * width the width (x direction) of the ground
  21513. * * height the height (z direction) of the ground
  21514. * * subdivisions the number of subdivisions per side
  21515. * * minHeight the minimum altitude on the ground, optional, default 0
  21516. * * maxHeight the maximum altitude on the ground, optional default 1
  21517. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21518. * * buffer the array holding the image color data
  21519. * * bufferWidth the width of image
  21520. * * bufferHeight the height of image
  21521. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21522. * @returns the VertexData of the Ground designed from a heightmap
  21523. */
  21524. static CreateGroundFromHeightMap(options: {
  21525. width: number;
  21526. height: number;
  21527. subdivisions: number;
  21528. minHeight: number;
  21529. maxHeight: number;
  21530. colorFilter: Color3;
  21531. buffer: Uint8Array;
  21532. bufferWidth: number;
  21533. bufferHeight: number;
  21534. alphaFilter: number;
  21535. }): VertexData;
  21536. /**
  21537. * Creates the VertexData for a Plane
  21538. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21539. * * size sets the width and height of the plane to the value of size, optional default 1
  21540. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21541. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21542. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21543. * * 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)
  21544. * * 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)
  21545. * @returns the VertexData of the box
  21546. */
  21547. static CreatePlane(options: {
  21548. size?: number;
  21549. width?: number;
  21550. height?: number;
  21551. sideOrientation?: number;
  21552. frontUVs?: Vector4;
  21553. backUVs?: Vector4;
  21554. }): VertexData;
  21555. /**
  21556. * Creates the VertexData of the Disc or regular Polygon
  21557. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21558. * * radius the radius of the disc, optional default 0.5
  21559. * * tessellation the number of polygon sides, optional, default 64
  21560. * * 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
  21561. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21562. * * 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)
  21563. * * 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)
  21564. * @returns the VertexData of the box
  21565. */
  21566. static CreateDisc(options: {
  21567. radius?: number;
  21568. tessellation?: number;
  21569. arc?: number;
  21570. sideOrientation?: number;
  21571. frontUVs?: Vector4;
  21572. backUVs?: Vector4;
  21573. }): VertexData;
  21574. /**
  21575. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21576. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21577. * @param polygon a mesh built from polygonTriangulation.build()
  21578. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21579. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21580. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21581. * @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)
  21582. * @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)
  21583. * @returns the VertexData of the Polygon
  21584. */
  21585. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21586. /**
  21587. * Creates the VertexData of the IcoSphere
  21588. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21589. * * radius the radius of the IcoSphere, optional default 1
  21590. * * radiusX allows stretching in the x direction, optional, default radius
  21591. * * radiusY allows stretching in the y direction, optional, default radius
  21592. * * radiusZ allows stretching in the z direction, optional, default radius
  21593. * * flat when true creates a flat shaded mesh, optional, default true
  21594. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21595. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21596. * * 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)
  21597. * * 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)
  21598. * @returns the VertexData of the IcoSphere
  21599. */
  21600. static CreateIcoSphere(options: {
  21601. radius?: number;
  21602. radiusX?: number;
  21603. radiusY?: number;
  21604. radiusZ?: number;
  21605. flat?: boolean;
  21606. subdivisions?: number;
  21607. sideOrientation?: number;
  21608. frontUVs?: Vector4;
  21609. backUVs?: Vector4;
  21610. }): VertexData;
  21611. /**
  21612. * Creates the VertexData for a Polyhedron
  21613. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21614. * * type provided types are:
  21615. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21616. * * 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)
  21617. * * size the size of the IcoSphere, optional default 1
  21618. * * sizeX allows stretching in the x direction, optional, default size
  21619. * * sizeY allows stretching in the y direction, optional, default size
  21620. * * sizeZ allows stretching in the z direction, optional, default size
  21621. * * 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
  21622. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21623. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21624. * * flat when true creates a flat shaded mesh, optional, default true
  21625. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21626. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21627. * * 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)
  21628. * * 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)
  21629. * @returns the VertexData of the Polyhedron
  21630. */
  21631. static CreatePolyhedron(options: {
  21632. type?: number;
  21633. size?: number;
  21634. sizeX?: number;
  21635. sizeY?: number;
  21636. sizeZ?: number;
  21637. custom?: any;
  21638. faceUV?: Vector4[];
  21639. faceColors?: Color4[];
  21640. flat?: boolean;
  21641. sideOrientation?: number;
  21642. frontUVs?: Vector4;
  21643. backUVs?: Vector4;
  21644. }): VertexData;
  21645. /**
  21646. * Creates the VertexData for a TorusKnot
  21647. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21648. * * radius the radius of the torus knot, optional, default 2
  21649. * * tube the thickness of the tube, optional, default 0.5
  21650. * * radialSegments the number of sides on each tube segments, optional, default 32
  21651. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21652. * * p the number of windings around the z axis, optional, default 2
  21653. * * q the number of windings around the x axis, optional, default 3
  21654. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21655. * * 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)
  21656. * * 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)
  21657. * @returns the VertexData of the Torus Knot
  21658. */
  21659. static CreateTorusKnot(options: {
  21660. radius?: number;
  21661. tube?: number;
  21662. radialSegments?: number;
  21663. tubularSegments?: number;
  21664. p?: number;
  21665. q?: number;
  21666. sideOrientation?: number;
  21667. frontUVs?: Vector4;
  21668. backUVs?: Vector4;
  21669. }): VertexData;
  21670. /**
  21671. * Compute normals for given positions and indices
  21672. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21673. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21674. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21675. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21676. * * facetNormals : optional array of facet normals (vector3)
  21677. * * facetPositions : optional array of facet positions (vector3)
  21678. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21679. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21680. * * bInfo : optional bounding info, required for facetPartitioning computation
  21681. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21682. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21683. * * useRightHandedSystem: optional boolean to for right handed system computation
  21684. * * depthSort : optional boolean to enable the facet depth sort computation
  21685. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21686. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21687. */
  21688. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21689. facetNormals?: any;
  21690. facetPositions?: any;
  21691. facetPartitioning?: any;
  21692. ratio?: number;
  21693. bInfo?: any;
  21694. bbSize?: Vector3;
  21695. subDiv?: any;
  21696. useRightHandedSystem?: boolean;
  21697. depthSort?: boolean;
  21698. distanceTo?: Vector3;
  21699. depthSortedFacets?: any;
  21700. }): void;
  21701. /** @hidden */
  21702. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21703. /**
  21704. * Applies VertexData created from the imported parameters to the geometry
  21705. * @param parsedVertexData the parsed data from an imported file
  21706. * @param geometry the geometry to apply the VertexData to
  21707. */
  21708. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21709. }
  21710. }
  21711. declare module BABYLON {
  21712. /**
  21713. * Defines a target to use with MorphTargetManager
  21714. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21715. */
  21716. export class MorphTarget implements IAnimatable {
  21717. /** defines the name of the target */
  21718. name: string;
  21719. /**
  21720. * Gets or sets the list of animations
  21721. */
  21722. animations: Animation[];
  21723. private _scene;
  21724. private _positions;
  21725. private _normals;
  21726. private _tangents;
  21727. private _uvs;
  21728. private _influence;
  21729. /**
  21730. * Observable raised when the influence changes
  21731. */
  21732. onInfluenceChanged: Observable<boolean>;
  21733. /** @hidden */
  21734. _onDataLayoutChanged: Observable<void>;
  21735. /**
  21736. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21737. */
  21738. influence: number;
  21739. /**
  21740. * Gets or sets the id of the morph Target
  21741. */
  21742. id: string;
  21743. private _animationPropertiesOverride;
  21744. /**
  21745. * Gets or sets the animation properties override
  21746. */
  21747. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21748. /**
  21749. * Creates a new MorphTarget
  21750. * @param name defines the name of the target
  21751. * @param influence defines the influence to use
  21752. * @param scene defines the scene the morphtarget belongs to
  21753. */
  21754. constructor(
  21755. /** defines the name of the target */
  21756. name: string, influence?: number, scene?: Nullable<Scene>);
  21757. /**
  21758. * Gets a boolean defining if the target contains position data
  21759. */
  21760. readonly hasPositions: boolean;
  21761. /**
  21762. * Gets a boolean defining if the target contains normal data
  21763. */
  21764. readonly hasNormals: boolean;
  21765. /**
  21766. * Gets a boolean defining if the target contains tangent data
  21767. */
  21768. readonly hasTangents: boolean;
  21769. /**
  21770. * Gets a boolean defining if the target contains texture coordinates data
  21771. */
  21772. readonly hasUVs: boolean;
  21773. /**
  21774. * Affects position data to this target
  21775. * @param data defines the position data to use
  21776. */
  21777. setPositions(data: Nullable<FloatArray>): void;
  21778. /**
  21779. * Gets the position data stored in this target
  21780. * @returns a FloatArray containing the position data (or null if not present)
  21781. */
  21782. getPositions(): Nullable<FloatArray>;
  21783. /**
  21784. * Affects normal data to this target
  21785. * @param data defines the normal data to use
  21786. */
  21787. setNormals(data: Nullable<FloatArray>): void;
  21788. /**
  21789. * Gets the normal data stored in this target
  21790. * @returns a FloatArray containing the normal data (or null if not present)
  21791. */
  21792. getNormals(): Nullable<FloatArray>;
  21793. /**
  21794. * Affects tangent data to this target
  21795. * @param data defines the tangent data to use
  21796. */
  21797. setTangents(data: Nullable<FloatArray>): void;
  21798. /**
  21799. * Gets the tangent data stored in this target
  21800. * @returns a FloatArray containing the tangent data (or null if not present)
  21801. */
  21802. getTangents(): Nullable<FloatArray>;
  21803. /**
  21804. * Affects texture coordinates data to this target
  21805. * @param data defines the texture coordinates data to use
  21806. */
  21807. setUVs(data: Nullable<FloatArray>): void;
  21808. /**
  21809. * Gets the texture coordinates data stored in this target
  21810. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21811. */
  21812. getUVs(): Nullable<FloatArray>;
  21813. /**
  21814. * Serializes the current target into a Serialization object
  21815. * @returns the serialized object
  21816. */
  21817. serialize(): any;
  21818. /**
  21819. * Returns the string "MorphTarget"
  21820. * @returns "MorphTarget"
  21821. */
  21822. getClassName(): string;
  21823. /**
  21824. * Creates a new target from serialized data
  21825. * @param serializationObject defines the serialized data to use
  21826. * @returns a new MorphTarget
  21827. */
  21828. static Parse(serializationObject: any): MorphTarget;
  21829. /**
  21830. * Creates a MorphTarget from mesh data
  21831. * @param mesh defines the source mesh
  21832. * @param name defines the name to use for the new target
  21833. * @param influence defines the influence to attach to the target
  21834. * @returns a new MorphTarget
  21835. */
  21836. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21837. }
  21838. }
  21839. declare module BABYLON {
  21840. /**
  21841. * This class is used to deform meshes using morphing between different targets
  21842. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21843. */
  21844. export class MorphTargetManager {
  21845. private _targets;
  21846. private _targetInfluenceChangedObservers;
  21847. private _targetDataLayoutChangedObservers;
  21848. private _activeTargets;
  21849. private _scene;
  21850. private _influences;
  21851. private _supportsNormals;
  21852. private _supportsTangents;
  21853. private _supportsUVs;
  21854. private _vertexCount;
  21855. private _uniqueId;
  21856. private _tempInfluences;
  21857. /**
  21858. * Gets or sets a boolean indicating if normals must be morphed
  21859. */
  21860. enableNormalMorphing: boolean;
  21861. /**
  21862. * Gets or sets a boolean indicating if tangents must be morphed
  21863. */
  21864. enableTangentMorphing: boolean;
  21865. /**
  21866. * Gets or sets a boolean indicating if UV must be morphed
  21867. */
  21868. enableUVMorphing: boolean;
  21869. /**
  21870. * Creates a new MorphTargetManager
  21871. * @param scene defines the current scene
  21872. */
  21873. constructor(scene?: Nullable<Scene>);
  21874. /**
  21875. * Gets the unique ID of this manager
  21876. */
  21877. readonly uniqueId: number;
  21878. /**
  21879. * Gets the number of vertices handled by this manager
  21880. */
  21881. readonly vertexCount: number;
  21882. /**
  21883. * Gets a boolean indicating if this manager supports morphing of normals
  21884. */
  21885. readonly supportsNormals: boolean;
  21886. /**
  21887. * Gets a boolean indicating if this manager supports morphing of tangents
  21888. */
  21889. readonly supportsTangents: boolean;
  21890. /**
  21891. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21892. */
  21893. readonly supportsUVs: boolean;
  21894. /**
  21895. * Gets the number of targets stored in this manager
  21896. */
  21897. readonly numTargets: number;
  21898. /**
  21899. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21900. */
  21901. readonly numInfluencers: number;
  21902. /**
  21903. * Gets the list of influences (one per target)
  21904. */
  21905. readonly influences: Float32Array;
  21906. /**
  21907. * Gets the active target at specified index. An active target is a target with an influence > 0
  21908. * @param index defines the index to check
  21909. * @returns the requested target
  21910. */
  21911. getActiveTarget(index: number): MorphTarget;
  21912. /**
  21913. * Gets the target at specified index
  21914. * @param index defines the index to check
  21915. * @returns the requested target
  21916. */
  21917. getTarget(index: number): MorphTarget;
  21918. /**
  21919. * Add a new target to this manager
  21920. * @param target defines the target to add
  21921. */
  21922. addTarget(target: MorphTarget): void;
  21923. /**
  21924. * Removes a target from the manager
  21925. * @param target defines the target to remove
  21926. */
  21927. removeTarget(target: MorphTarget): void;
  21928. /**
  21929. * Serializes the current manager into a Serialization object
  21930. * @returns the serialized object
  21931. */
  21932. serialize(): any;
  21933. private _syncActiveTargets;
  21934. /**
  21935. * Syncrhonize the targets with all the meshes using this morph target manager
  21936. */
  21937. synchronize(): void;
  21938. /**
  21939. * Creates a new MorphTargetManager from serialized data
  21940. * @param serializationObject defines the serialized data
  21941. * @param scene defines the hosting scene
  21942. * @returns the new MorphTargetManager
  21943. */
  21944. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  21945. }
  21946. }
  21947. declare module BABYLON {
  21948. /**
  21949. * Class used to represent a specific level of detail of a mesh
  21950. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21951. */
  21952. export class MeshLODLevel {
  21953. /** Defines the distance where this level should star being displayed */
  21954. distance: number;
  21955. /** Defines the mesh to use to render this level */
  21956. mesh: Nullable<Mesh>;
  21957. /**
  21958. * Creates a new LOD level
  21959. * @param distance defines the distance where this level should star being displayed
  21960. * @param mesh defines the mesh to use to render this level
  21961. */
  21962. constructor(
  21963. /** Defines the distance where this level should star being displayed */
  21964. distance: number,
  21965. /** Defines the mesh to use to render this level */
  21966. mesh: Nullable<Mesh>);
  21967. }
  21968. }
  21969. declare module BABYLON {
  21970. /**
  21971. * Mesh representing the gorund
  21972. */
  21973. export class GroundMesh extends Mesh {
  21974. /** If octree should be generated */
  21975. generateOctree: boolean;
  21976. private _heightQuads;
  21977. /** @hidden */
  21978. _subdivisionsX: number;
  21979. /** @hidden */
  21980. _subdivisionsY: number;
  21981. /** @hidden */
  21982. _width: number;
  21983. /** @hidden */
  21984. _height: number;
  21985. /** @hidden */
  21986. _minX: number;
  21987. /** @hidden */
  21988. _maxX: number;
  21989. /** @hidden */
  21990. _minZ: number;
  21991. /** @hidden */
  21992. _maxZ: number;
  21993. constructor(name: string, scene: Scene);
  21994. /**
  21995. * "GroundMesh"
  21996. * @returns "GroundMesh"
  21997. */
  21998. getClassName(): string;
  21999. /**
  22000. * The minimum of x and y subdivisions
  22001. */
  22002. readonly subdivisions: number;
  22003. /**
  22004. * X subdivisions
  22005. */
  22006. readonly subdivisionsX: number;
  22007. /**
  22008. * Y subdivisions
  22009. */
  22010. readonly subdivisionsY: number;
  22011. /**
  22012. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22013. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22014. * @param chunksCount the number of subdivisions for x and y
  22015. * @param octreeBlocksSize (Default: 32)
  22016. */
  22017. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22018. /**
  22019. * Returns a height (y) value in the Worl system :
  22020. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22021. * @param x x coordinate
  22022. * @param z z coordinate
  22023. * @returns the ground y position if (x, z) are outside the ground surface.
  22024. */
  22025. getHeightAtCoordinates(x: number, z: number): number;
  22026. /**
  22027. * Returns a normalized vector (Vector3) orthogonal to the ground
  22028. * at the ground coordinates (x, z) expressed in the World system.
  22029. * @param x x coordinate
  22030. * @param z z coordinate
  22031. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22032. */
  22033. getNormalAtCoordinates(x: number, z: number): Vector3;
  22034. /**
  22035. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22036. * at the ground coordinates (x, z) expressed in the World system.
  22037. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22038. * @param x x coordinate
  22039. * @param z z coordinate
  22040. * @param ref vector to store the result
  22041. * @returns the GroundMesh.
  22042. */
  22043. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22044. /**
  22045. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22046. * if the ground has been updated.
  22047. * This can be used in the render loop.
  22048. * @returns the GroundMesh.
  22049. */
  22050. updateCoordinateHeights(): GroundMesh;
  22051. private _getFacetAt;
  22052. private _initHeightQuads;
  22053. private _computeHeightQuads;
  22054. /**
  22055. * Serializes this ground mesh
  22056. * @param serializationObject object to write serialization to
  22057. */
  22058. serialize(serializationObject: any): void;
  22059. /**
  22060. * Parses a serialized ground mesh
  22061. * @param parsedMesh the serialized mesh
  22062. * @param scene the scene to create the ground mesh in
  22063. * @returns the created ground mesh
  22064. */
  22065. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22066. }
  22067. }
  22068. declare module BABYLON {
  22069. /**
  22070. * Interface for Physics-Joint data
  22071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22072. */
  22073. export interface PhysicsJointData {
  22074. /**
  22075. * The main pivot of the joint
  22076. */
  22077. mainPivot?: Vector3;
  22078. /**
  22079. * The connected pivot of the joint
  22080. */
  22081. connectedPivot?: Vector3;
  22082. /**
  22083. * The main axis of the joint
  22084. */
  22085. mainAxis?: Vector3;
  22086. /**
  22087. * The connected axis of the joint
  22088. */
  22089. connectedAxis?: Vector3;
  22090. /**
  22091. * The collision of the joint
  22092. */
  22093. collision?: boolean;
  22094. /**
  22095. * Native Oimo/Cannon/Energy data
  22096. */
  22097. nativeParams?: any;
  22098. }
  22099. /**
  22100. * This is a holder class for the physics joint created by the physics plugin
  22101. * It holds a set of functions to control the underlying joint
  22102. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22103. */
  22104. export class PhysicsJoint {
  22105. /**
  22106. * The type of the physics joint
  22107. */
  22108. type: number;
  22109. /**
  22110. * The data for the physics joint
  22111. */
  22112. jointData: PhysicsJointData;
  22113. private _physicsJoint;
  22114. protected _physicsPlugin: IPhysicsEnginePlugin;
  22115. /**
  22116. * Initializes the physics joint
  22117. * @param type The type of the physics joint
  22118. * @param jointData The data for the physics joint
  22119. */
  22120. constructor(
  22121. /**
  22122. * The type of the physics joint
  22123. */
  22124. type: number,
  22125. /**
  22126. * The data for the physics joint
  22127. */
  22128. jointData: PhysicsJointData);
  22129. /**
  22130. * Gets the physics joint
  22131. */
  22132. /**
  22133. * Sets the physics joint
  22134. */
  22135. physicsJoint: any;
  22136. /**
  22137. * Sets the physics plugin
  22138. */
  22139. physicsPlugin: IPhysicsEnginePlugin;
  22140. /**
  22141. * Execute a function that is physics-plugin specific.
  22142. * @param {Function} func the function that will be executed.
  22143. * It accepts two parameters: the physics world and the physics joint
  22144. */
  22145. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22146. /**
  22147. * Distance-Joint type
  22148. */
  22149. static DistanceJoint: number;
  22150. /**
  22151. * Hinge-Joint type
  22152. */
  22153. static HingeJoint: number;
  22154. /**
  22155. * Ball-and-Socket joint type
  22156. */
  22157. static BallAndSocketJoint: number;
  22158. /**
  22159. * Wheel-Joint type
  22160. */
  22161. static WheelJoint: number;
  22162. /**
  22163. * Slider-Joint type
  22164. */
  22165. static SliderJoint: number;
  22166. /**
  22167. * Prismatic-Joint type
  22168. */
  22169. static PrismaticJoint: number;
  22170. /**
  22171. * Universal-Joint type
  22172. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22173. */
  22174. static UniversalJoint: number;
  22175. /**
  22176. * Hinge-Joint 2 type
  22177. */
  22178. static Hinge2Joint: number;
  22179. /**
  22180. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22181. */
  22182. static PointToPointJoint: number;
  22183. /**
  22184. * Spring-Joint type
  22185. */
  22186. static SpringJoint: number;
  22187. /**
  22188. * Lock-Joint type
  22189. */
  22190. static LockJoint: number;
  22191. }
  22192. /**
  22193. * A class representing a physics distance joint
  22194. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22195. */
  22196. export class DistanceJoint extends PhysicsJoint {
  22197. /**
  22198. *
  22199. * @param jointData The data for the Distance-Joint
  22200. */
  22201. constructor(jointData: DistanceJointData);
  22202. /**
  22203. * Update the predefined distance.
  22204. * @param maxDistance The maximum preferred distance
  22205. * @param minDistance The minimum preferred distance
  22206. */
  22207. updateDistance(maxDistance: number, minDistance?: number): void;
  22208. }
  22209. /**
  22210. * Represents a Motor-Enabled Joint
  22211. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22212. */
  22213. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22214. /**
  22215. * Initializes the Motor-Enabled Joint
  22216. * @param type The type of the joint
  22217. * @param jointData The physica joint data for the joint
  22218. */
  22219. constructor(type: number, jointData: PhysicsJointData);
  22220. /**
  22221. * Set the motor values.
  22222. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22223. * @param force the force to apply
  22224. * @param maxForce max force for this motor.
  22225. */
  22226. setMotor(force?: number, maxForce?: number): void;
  22227. /**
  22228. * Set the motor's limits.
  22229. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22230. * @param upperLimit The upper limit of the motor
  22231. * @param lowerLimit The lower limit of the motor
  22232. */
  22233. setLimit(upperLimit: number, lowerLimit?: number): void;
  22234. }
  22235. /**
  22236. * This class represents a single physics Hinge-Joint
  22237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22238. */
  22239. export class HingeJoint extends MotorEnabledJoint {
  22240. /**
  22241. * Initializes the Hinge-Joint
  22242. * @param jointData The joint data for the Hinge-Joint
  22243. */
  22244. constructor(jointData: PhysicsJointData);
  22245. /**
  22246. * Set the motor values.
  22247. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22248. * @param {number} force the force to apply
  22249. * @param {number} maxForce max force for this motor.
  22250. */
  22251. setMotor(force?: number, maxForce?: number): void;
  22252. /**
  22253. * Set the motor's limits.
  22254. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22255. * @param upperLimit The upper limit of the motor
  22256. * @param lowerLimit The lower limit of the motor
  22257. */
  22258. setLimit(upperLimit: number, lowerLimit?: number): void;
  22259. }
  22260. /**
  22261. * This class represents a dual hinge physics joint (same as wheel joint)
  22262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22263. */
  22264. export class Hinge2Joint extends MotorEnabledJoint {
  22265. /**
  22266. * Initializes the Hinge2-Joint
  22267. * @param jointData The joint data for the Hinge2-Joint
  22268. */
  22269. constructor(jointData: PhysicsJointData);
  22270. /**
  22271. * Set the motor values.
  22272. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22273. * @param {number} targetSpeed the speed the motor is to reach
  22274. * @param {number} maxForce max force for this motor.
  22275. * @param {motorIndex} the motor's index, 0 or 1.
  22276. */
  22277. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22278. /**
  22279. * Set the motor limits.
  22280. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22281. * @param {number} upperLimit the upper limit
  22282. * @param {number} lowerLimit lower limit
  22283. * @param {motorIndex} the motor's index, 0 or 1.
  22284. */
  22285. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22286. }
  22287. /**
  22288. * Interface for a motor enabled joint
  22289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22290. */
  22291. export interface IMotorEnabledJoint {
  22292. /**
  22293. * Physics joint
  22294. */
  22295. physicsJoint: any;
  22296. /**
  22297. * Sets the motor of the motor-enabled joint
  22298. * @param force The force of the motor
  22299. * @param maxForce The maximum force of the motor
  22300. * @param motorIndex The index of the motor
  22301. */
  22302. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22303. /**
  22304. * Sets the limit of the motor
  22305. * @param upperLimit The upper limit of the motor
  22306. * @param lowerLimit The lower limit of the motor
  22307. * @param motorIndex The index of the motor
  22308. */
  22309. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22310. }
  22311. /**
  22312. * Joint data for a Distance-Joint
  22313. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22314. */
  22315. export interface DistanceJointData extends PhysicsJointData {
  22316. /**
  22317. * Max distance the 2 joint objects can be apart
  22318. */
  22319. maxDistance: number;
  22320. }
  22321. /**
  22322. * Joint data from a spring joint
  22323. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22324. */
  22325. export interface SpringJointData extends PhysicsJointData {
  22326. /**
  22327. * Length of the spring
  22328. */
  22329. length: number;
  22330. /**
  22331. * Stiffness of the spring
  22332. */
  22333. stiffness: number;
  22334. /**
  22335. * Damping of the spring
  22336. */
  22337. damping: number;
  22338. /** this callback will be called when applying the force to the impostors. */
  22339. forceApplicationCallback: () => void;
  22340. }
  22341. }
  22342. declare module BABYLON {
  22343. /**
  22344. * Holds the data for the raycast result
  22345. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22346. */
  22347. export class PhysicsRaycastResult {
  22348. private _hasHit;
  22349. private _hitDistance;
  22350. private _hitNormalWorld;
  22351. private _hitPointWorld;
  22352. private _rayFromWorld;
  22353. private _rayToWorld;
  22354. /**
  22355. * Gets if there was a hit
  22356. */
  22357. readonly hasHit: boolean;
  22358. /**
  22359. * Gets the distance from the hit
  22360. */
  22361. readonly hitDistance: number;
  22362. /**
  22363. * Gets the hit normal/direction in the world
  22364. */
  22365. readonly hitNormalWorld: Vector3;
  22366. /**
  22367. * Gets the hit point in the world
  22368. */
  22369. readonly hitPointWorld: Vector3;
  22370. /**
  22371. * Gets the ray "start point" of the ray in the world
  22372. */
  22373. readonly rayFromWorld: Vector3;
  22374. /**
  22375. * Gets the ray "end point" of the ray in the world
  22376. */
  22377. readonly rayToWorld: Vector3;
  22378. /**
  22379. * Sets the hit data (normal & point in world space)
  22380. * @param hitNormalWorld defines the normal in world space
  22381. * @param hitPointWorld defines the point in world space
  22382. */
  22383. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22384. /**
  22385. * Sets the distance from the start point to the hit point
  22386. * @param distance
  22387. */
  22388. setHitDistance(distance: number): void;
  22389. /**
  22390. * Calculates the distance manually
  22391. */
  22392. calculateHitDistance(): void;
  22393. /**
  22394. * Resets all the values to default
  22395. * @param from The from point on world space
  22396. * @param to The to point on world space
  22397. */
  22398. reset(from?: Vector3, to?: Vector3): void;
  22399. }
  22400. /**
  22401. * Interface for the size containing width and height
  22402. */
  22403. interface IXYZ {
  22404. /**
  22405. * X
  22406. */
  22407. x: number;
  22408. /**
  22409. * Y
  22410. */
  22411. y: number;
  22412. /**
  22413. * Z
  22414. */
  22415. z: number;
  22416. }
  22417. }
  22418. declare module BABYLON {
  22419. /**
  22420. * Interface used to describe a physics joint
  22421. */
  22422. export interface PhysicsImpostorJoint {
  22423. /** Defines the main impostor to which the joint is linked */
  22424. mainImpostor: PhysicsImpostor;
  22425. /** Defines the impostor that is connected to the main impostor using this joint */
  22426. connectedImpostor: PhysicsImpostor;
  22427. /** Defines the joint itself */
  22428. joint: PhysicsJoint;
  22429. }
  22430. /** @hidden */
  22431. export interface IPhysicsEnginePlugin {
  22432. world: any;
  22433. name: string;
  22434. setGravity(gravity: Vector3): void;
  22435. setTimeStep(timeStep: number): void;
  22436. getTimeStep(): number;
  22437. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22438. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22439. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22440. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22441. removePhysicsBody(impostor: PhysicsImpostor): void;
  22442. generateJoint(joint: PhysicsImpostorJoint): void;
  22443. removeJoint(joint: PhysicsImpostorJoint): void;
  22444. isSupported(): boolean;
  22445. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22446. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22447. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22448. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22449. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22450. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22451. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22452. getBodyMass(impostor: PhysicsImpostor): number;
  22453. getBodyFriction(impostor: PhysicsImpostor): number;
  22454. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22455. getBodyRestitution(impostor: PhysicsImpostor): number;
  22456. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22457. getBodyPressure?(impostor: PhysicsImpostor): number;
  22458. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22459. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22460. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22461. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22462. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22463. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22464. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22465. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22466. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22467. sleepBody(impostor: PhysicsImpostor): void;
  22468. wakeUpBody(impostor: PhysicsImpostor): void;
  22469. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22470. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22471. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22472. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22473. getRadius(impostor: PhysicsImpostor): number;
  22474. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22475. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22476. dispose(): void;
  22477. }
  22478. /**
  22479. * Interface used to define a physics engine
  22480. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22481. */
  22482. export interface IPhysicsEngine {
  22483. /**
  22484. * Gets the gravity vector used by the simulation
  22485. */
  22486. gravity: Vector3;
  22487. /**
  22488. * Sets the gravity vector used by the simulation
  22489. * @param gravity defines the gravity vector to use
  22490. */
  22491. setGravity(gravity: Vector3): void;
  22492. /**
  22493. * Set the time step of the physics engine.
  22494. * Default is 1/60.
  22495. * To slow it down, enter 1/600 for example.
  22496. * To speed it up, 1/30
  22497. * @param newTimeStep the new timestep to apply to this world.
  22498. */
  22499. setTimeStep(newTimeStep: number): void;
  22500. /**
  22501. * Get the time step of the physics engine.
  22502. * @returns the current time step
  22503. */
  22504. getTimeStep(): number;
  22505. /**
  22506. * Release all resources
  22507. */
  22508. dispose(): void;
  22509. /**
  22510. * Gets the name of the current physics plugin
  22511. * @returns the name of the plugin
  22512. */
  22513. getPhysicsPluginName(): string;
  22514. /**
  22515. * Adding a new impostor for the impostor tracking.
  22516. * This will be done by the impostor itself.
  22517. * @param impostor the impostor to add
  22518. */
  22519. addImpostor(impostor: PhysicsImpostor): void;
  22520. /**
  22521. * Remove an impostor from the engine.
  22522. * This impostor and its mesh will not longer be updated by the physics engine.
  22523. * @param impostor the impostor to remove
  22524. */
  22525. removeImpostor(impostor: PhysicsImpostor): void;
  22526. /**
  22527. * Add a joint to the physics engine
  22528. * @param mainImpostor defines the main impostor to which the joint is added.
  22529. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22530. * @param joint defines the joint that will connect both impostors.
  22531. */
  22532. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22533. /**
  22534. * Removes a joint from the simulation
  22535. * @param mainImpostor defines the impostor used with the joint
  22536. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22537. * @param joint defines the joint to remove
  22538. */
  22539. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22540. /**
  22541. * Gets the current plugin used to run the simulation
  22542. * @returns current plugin
  22543. */
  22544. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22545. /**
  22546. * Gets the list of physic impostors
  22547. * @returns an array of PhysicsImpostor
  22548. */
  22549. getImpostors(): Array<PhysicsImpostor>;
  22550. /**
  22551. * Gets the impostor for a physics enabled object
  22552. * @param object defines the object impersonated by the impostor
  22553. * @returns the PhysicsImpostor or null if not found
  22554. */
  22555. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22556. /**
  22557. * Gets the impostor for a physics body object
  22558. * @param body defines physics body used by the impostor
  22559. * @returns the PhysicsImpostor or null if not found
  22560. */
  22561. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22562. /**
  22563. * Does a raycast in the physics world
  22564. * @param from when should the ray start?
  22565. * @param to when should the ray end?
  22566. * @returns PhysicsRaycastResult
  22567. */
  22568. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22569. /**
  22570. * Called by the scene. No need to call it.
  22571. * @param delta defines the timespam between frames
  22572. */
  22573. _step(delta: number): void;
  22574. }
  22575. }
  22576. declare module BABYLON {
  22577. /**
  22578. * The interface for the physics imposter parameters
  22579. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22580. */
  22581. export interface PhysicsImpostorParameters {
  22582. /**
  22583. * The mass of the physics imposter
  22584. */
  22585. mass: number;
  22586. /**
  22587. * The friction of the physics imposter
  22588. */
  22589. friction?: number;
  22590. /**
  22591. * The coefficient of restitution of the physics imposter
  22592. */
  22593. restitution?: number;
  22594. /**
  22595. * The native options of the physics imposter
  22596. */
  22597. nativeOptions?: any;
  22598. /**
  22599. * Specifies if the parent should be ignored
  22600. */
  22601. ignoreParent?: boolean;
  22602. /**
  22603. * Specifies if bi-directional transformations should be disabled
  22604. */
  22605. disableBidirectionalTransformation?: boolean;
  22606. /**
  22607. * The pressure inside the physics imposter, soft object only
  22608. */
  22609. pressure?: number;
  22610. /**
  22611. * The stiffness the physics imposter, soft object only
  22612. */
  22613. stiffness?: number;
  22614. /**
  22615. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22616. */
  22617. velocityIterations?: number;
  22618. /**
  22619. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22620. */
  22621. positionIterations?: number;
  22622. /**
  22623. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22624. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22625. * Add to fix multiple points
  22626. */
  22627. fixedPoints?: number;
  22628. /**
  22629. * The collision margin around a soft object
  22630. */
  22631. margin?: number;
  22632. /**
  22633. * The collision margin around a soft object
  22634. */
  22635. damping?: number;
  22636. /**
  22637. * The path for a rope based on an extrusion
  22638. */
  22639. path?: any;
  22640. /**
  22641. * The shape of an extrusion used for a rope based on an extrusion
  22642. */
  22643. shape?: any;
  22644. }
  22645. /**
  22646. * Interface for a physics-enabled object
  22647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22648. */
  22649. export interface IPhysicsEnabledObject {
  22650. /**
  22651. * The position of the physics-enabled object
  22652. */
  22653. position: Vector3;
  22654. /**
  22655. * The rotation of the physics-enabled object
  22656. */
  22657. rotationQuaternion: Nullable<Quaternion>;
  22658. /**
  22659. * The scale of the physics-enabled object
  22660. */
  22661. scaling: Vector3;
  22662. /**
  22663. * The rotation of the physics-enabled object
  22664. */
  22665. rotation?: Vector3;
  22666. /**
  22667. * The parent of the physics-enabled object
  22668. */
  22669. parent?: any;
  22670. /**
  22671. * The bounding info of the physics-enabled object
  22672. * @returns The bounding info of the physics-enabled object
  22673. */
  22674. getBoundingInfo(): BoundingInfo;
  22675. /**
  22676. * Computes the world matrix
  22677. * @param force Specifies if the world matrix should be computed by force
  22678. * @returns A world matrix
  22679. */
  22680. computeWorldMatrix(force: boolean): Matrix;
  22681. /**
  22682. * Gets the world matrix
  22683. * @returns A world matrix
  22684. */
  22685. getWorldMatrix?(): Matrix;
  22686. /**
  22687. * Gets the child meshes
  22688. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22689. * @returns An array of abstract meshes
  22690. */
  22691. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22692. /**
  22693. * Gets the vertex data
  22694. * @param kind The type of vertex data
  22695. * @returns A nullable array of numbers, or a float32 array
  22696. */
  22697. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22698. /**
  22699. * Gets the indices from the mesh
  22700. * @returns A nullable array of index arrays
  22701. */
  22702. getIndices?(): Nullable<IndicesArray>;
  22703. /**
  22704. * Gets the scene from the mesh
  22705. * @returns the indices array or null
  22706. */
  22707. getScene?(): Scene;
  22708. /**
  22709. * Gets the absolute position from the mesh
  22710. * @returns the absolute position
  22711. */
  22712. getAbsolutePosition(): Vector3;
  22713. /**
  22714. * Gets the absolute pivot point from the mesh
  22715. * @returns the absolute pivot point
  22716. */
  22717. getAbsolutePivotPoint(): Vector3;
  22718. /**
  22719. * Rotates the mesh
  22720. * @param axis The axis of rotation
  22721. * @param amount The amount of rotation
  22722. * @param space The space of the rotation
  22723. * @returns The rotation transform node
  22724. */
  22725. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22726. /**
  22727. * Translates the mesh
  22728. * @param axis The axis of translation
  22729. * @param distance The distance of translation
  22730. * @param space The space of the translation
  22731. * @returns The transform node
  22732. */
  22733. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22734. /**
  22735. * Sets the absolute position of the mesh
  22736. * @param absolutePosition The absolute position of the mesh
  22737. * @returns The transform node
  22738. */
  22739. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22740. /**
  22741. * Gets the class name of the mesh
  22742. * @returns The class name
  22743. */
  22744. getClassName(): string;
  22745. }
  22746. /**
  22747. * Represents a physics imposter
  22748. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22749. */
  22750. export class PhysicsImpostor {
  22751. /**
  22752. * The physics-enabled object used as the physics imposter
  22753. */
  22754. object: IPhysicsEnabledObject;
  22755. /**
  22756. * The type of the physics imposter
  22757. */
  22758. type: number;
  22759. private _options;
  22760. private _scene?;
  22761. /**
  22762. * The default object size of the imposter
  22763. */
  22764. static DEFAULT_OBJECT_SIZE: Vector3;
  22765. /**
  22766. * The identity quaternion of the imposter
  22767. */
  22768. static IDENTITY_QUATERNION: Quaternion;
  22769. /** @hidden */
  22770. _pluginData: any;
  22771. private _physicsEngine;
  22772. private _physicsBody;
  22773. private _bodyUpdateRequired;
  22774. private _onBeforePhysicsStepCallbacks;
  22775. private _onAfterPhysicsStepCallbacks;
  22776. /** @hidden */
  22777. _onPhysicsCollideCallbacks: Array<{
  22778. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22779. otherImpostors: Array<PhysicsImpostor>;
  22780. }>;
  22781. private _deltaPosition;
  22782. private _deltaRotation;
  22783. private _deltaRotationConjugated;
  22784. /** @hidden */
  22785. _isFromLine: boolean;
  22786. private _parent;
  22787. private _isDisposed;
  22788. private static _tmpVecs;
  22789. private static _tmpQuat;
  22790. /**
  22791. * Specifies if the physics imposter is disposed
  22792. */
  22793. readonly isDisposed: boolean;
  22794. /**
  22795. * Gets the mass of the physics imposter
  22796. */
  22797. mass: number;
  22798. /**
  22799. * Gets the coefficient of friction
  22800. */
  22801. /**
  22802. * Sets the coefficient of friction
  22803. */
  22804. friction: number;
  22805. /**
  22806. * Gets the coefficient of restitution
  22807. */
  22808. /**
  22809. * Sets the coefficient of restitution
  22810. */
  22811. restitution: number;
  22812. /**
  22813. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22814. */
  22815. /**
  22816. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22817. */
  22818. pressure: number;
  22819. /**
  22820. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22821. */
  22822. /**
  22823. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22824. */
  22825. stiffness: number;
  22826. /**
  22827. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22828. */
  22829. /**
  22830. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22831. */
  22832. velocityIterations: number;
  22833. /**
  22834. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22835. */
  22836. /**
  22837. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22838. */
  22839. positionIterations: number;
  22840. /**
  22841. * The unique id of the physics imposter
  22842. * set by the physics engine when adding this impostor to the array
  22843. */
  22844. uniqueId: number;
  22845. /**
  22846. * @hidden
  22847. */
  22848. soft: boolean;
  22849. /**
  22850. * @hidden
  22851. */
  22852. segments: number;
  22853. private _joints;
  22854. /**
  22855. * Initializes the physics imposter
  22856. * @param object The physics-enabled object used as the physics imposter
  22857. * @param type The type of the physics imposter
  22858. * @param _options The options for the physics imposter
  22859. * @param _scene The Babylon scene
  22860. */
  22861. constructor(
  22862. /**
  22863. * The physics-enabled object used as the physics imposter
  22864. */
  22865. object: IPhysicsEnabledObject,
  22866. /**
  22867. * The type of the physics imposter
  22868. */
  22869. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22870. /**
  22871. * This function will completly initialize this impostor.
  22872. * It will create a new body - but only if this mesh has no parent.
  22873. * If it has, this impostor will not be used other than to define the impostor
  22874. * of the child mesh.
  22875. * @hidden
  22876. */
  22877. _init(): void;
  22878. private _getPhysicsParent;
  22879. /**
  22880. * Should a new body be generated.
  22881. * @returns boolean specifying if body initialization is required
  22882. */
  22883. isBodyInitRequired(): boolean;
  22884. /**
  22885. * Sets the updated scaling
  22886. * @param updated Specifies if the scaling is updated
  22887. */
  22888. setScalingUpdated(): void;
  22889. /**
  22890. * Force a regeneration of this or the parent's impostor's body.
  22891. * Use under cautious - This will remove all joints already implemented.
  22892. */
  22893. forceUpdate(): void;
  22894. /**
  22895. * Gets the body that holds this impostor. Either its own, or its parent.
  22896. */
  22897. /**
  22898. * Set the physics body. Used mainly by the physics engine/plugin
  22899. */
  22900. physicsBody: any;
  22901. /**
  22902. * Get the parent of the physics imposter
  22903. * @returns Physics imposter or null
  22904. */
  22905. /**
  22906. * Sets the parent of the physics imposter
  22907. */
  22908. parent: Nullable<PhysicsImpostor>;
  22909. /**
  22910. * Resets the update flags
  22911. */
  22912. resetUpdateFlags(): void;
  22913. /**
  22914. * Gets the object extend size
  22915. * @returns the object extend size
  22916. */
  22917. getObjectExtendSize(): Vector3;
  22918. /**
  22919. * Gets the object center
  22920. * @returns The object center
  22921. */
  22922. getObjectCenter(): Vector3;
  22923. /**
  22924. * Get a specific parametes from the options parameter
  22925. * @param paramName The object parameter name
  22926. * @returns The object parameter
  22927. */
  22928. getParam(paramName: string): any;
  22929. /**
  22930. * Sets a specific parameter in the options given to the physics plugin
  22931. * @param paramName The parameter name
  22932. * @param value The value of the parameter
  22933. */
  22934. setParam(paramName: string, value: number): void;
  22935. /**
  22936. * Specifically change the body's mass option. Won't recreate the physics body object
  22937. * @param mass The mass of the physics imposter
  22938. */
  22939. setMass(mass: number): void;
  22940. /**
  22941. * Gets the linear velocity
  22942. * @returns linear velocity or null
  22943. */
  22944. getLinearVelocity(): Nullable<Vector3>;
  22945. /**
  22946. * Sets the linear velocity
  22947. * @param velocity linear velocity or null
  22948. */
  22949. setLinearVelocity(velocity: Nullable<Vector3>): void;
  22950. /**
  22951. * Gets the angular velocity
  22952. * @returns angular velocity or null
  22953. */
  22954. getAngularVelocity(): Nullable<Vector3>;
  22955. /**
  22956. * Sets the angular velocity
  22957. * @param velocity The velocity or null
  22958. */
  22959. setAngularVelocity(velocity: Nullable<Vector3>): void;
  22960. /**
  22961. * Execute a function with the physics plugin native code
  22962. * Provide a function the will have two variables - the world object and the physics body object
  22963. * @param func The function to execute with the physics plugin native code
  22964. */
  22965. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  22966. /**
  22967. * Register a function that will be executed before the physics world is stepping forward
  22968. * @param func The function to execute before the physics world is stepped forward
  22969. */
  22970. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22971. /**
  22972. * Unregister a function that will be executed before the physics world is stepping forward
  22973. * @param func The function to execute before the physics world is stepped forward
  22974. */
  22975. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22976. /**
  22977. * Register a function that will be executed after the physics step
  22978. * @param func The function to execute after physics step
  22979. */
  22980. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22981. /**
  22982. * Unregisters a function that will be executed after the physics step
  22983. * @param func The function to execute after physics step
  22984. */
  22985. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22986. /**
  22987. * register a function that will be executed when this impostor collides against a different body
  22988. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  22989. * @param func Callback that is executed on collision
  22990. */
  22991. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  22992. /**
  22993. * Unregisters the physics imposter on contact
  22994. * @param collideAgainst The physics object to collide against
  22995. * @param func Callback to execute on collision
  22996. */
  22997. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  22998. private _tmpQuat;
  22999. private _tmpQuat2;
  23000. /**
  23001. * Get the parent rotation
  23002. * @returns The parent rotation
  23003. */
  23004. getParentsRotation(): Quaternion;
  23005. /**
  23006. * this function is executed by the physics engine.
  23007. */
  23008. beforeStep: () => void;
  23009. /**
  23010. * this function is executed by the physics engine
  23011. */
  23012. afterStep: () => void;
  23013. /**
  23014. * Legacy collision detection event support
  23015. */
  23016. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23017. /**
  23018. * event and body object due to cannon's event-based architecture.
  23019. */
  23020. onCollide: (e: {
  23021. body: any;
  23022. }) => void;
  23023. /**
  23024. * Apply a force
  23025. * @param force The force to apply
  23026. * @param contactPoint The contact point for the force
  23027. * @returns The physics imposter
  23028. */
  23029. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23030. /**
  23031. * Apply an impulse
  23032. * @param force The impulse force
  23033. * @param contactPoint The contact point for the impulse force
  23034. * @returns The physics imposter
  23035. */
  23036. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23037. /**
  23038. * A help function to create a joint
  23039. * @param otherImpostor A physics imposter used to create a joint
  23040. * @param jointType The type of joint
  23041. * @param jointData The data for the joint
  23042. * @returns The physics imposter
  23043. */
  23044. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23045. /**
  23046. * Add a joint to this impostor with a different impostor
  23047. * @param otherImpostor A physics imposter used to add a joint
  23048. * @param joint The joint to add
  23049. * @returns The physics imposter
  23050. */
  23051. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23052. /**
  23053. * Add an anchor to a cloth impostor
  23054. * @param otherImpostor rigid impostor to anchor to
  23055. * @param width ratio across width from 0 to 1
  23056. * @param height ratio up height from 0 to 1
  23057. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23058. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23059. * @returns impostor the soft imposter
  23060. */
  23061. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23062. /**
  23063. * Add a hook to a rope impostor
  23064. * @param otherImpostor rigid impostor to anchor to
  23065. * @param length ratio across rope from 0 to 1
  23066. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23067. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23068. * @returns impostor the rope imposter
  23069. */
  23070. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23071. /**
  23072. * Will keep this body still, in a sleep mode.
  23073. * @returns the physics imposter
  23074. */
  23075. sleep(): PhysicsImpostor;
  23076. /**
  23077. * Wake the body up.
  23078. * @returns The physics imposter
  23079. */
  23080. wakeUp(): PhysicsImpostor;
  23081. /**
  23082. * Clones the physics imposter
  23083. * @param newObject The physics imposter clones to this physics-enabled object
  23084. * @returns A nullable physics imposter
  23085. */
  23086. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23087. /**
  23088. * Disposes the physics imposter
  23089. */
  23090. dispose(): void;
  23091. /**
  23092. * Sets the delta position
  23093. * @param position The delta position amount
  23094. */
  23095. setDeltaPosition(position: Vector3): void;
  23096. /**
  23097. * Sets the delta rotation
  23098. * @param rotation The delta rotation amount
  23099. */
  23100. setDeltaRotation(rotation: Quaternion): void;
  23101. /**
  23102. * Gets the box size of the physics imposter and stores the result in the input parameter
  23103. * @param result Stores the box size
  23104. * @returns The physics imposter
  23105. */
  23106. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23107. /**
  23108. * Gets the radius of the physics imposter
  23109. * @returns Radius of the physics imposter
  23110. */
  23111. getRadius(): number;
  23112. /**
  23113. * Sync a bone with this impostor
  23114. * @param bone The bone to sync to the impostor.
  23115. * @param boneMesh The mesh that the bone is influencing.
  23116. * @param jointPivot The pivot of the joint / bone in local space.
  23117. * @param distToJoint Optional distance from the impostor to the joint.
  23118. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23119. */
  23120. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23121. /**
  23122. * Sync impostor to a bone
  23123. * @param bone The bone that the impostor will be synced to.
  23124. * @param boneMesh The mesh that the bone is influencing.
  23125. * @param jointPivot The pivot of the joint / bone in local space.
  23126. * @param distToJoint Optional distance from the impostor to the joint.
  23127. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23128. * @param boneAxis Optional vector3 axis the bone is aligned with
  23129. */
  23130. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23131. /**
  23132. * No-Imposter type
  23133. */
  23134. static NoImpostor: number;
  23135. /**
  23136. * Sphere-Imposter type
  23137. */
  23138. static SphereImpostor: number;
  23139. /**
  23140. * Box-Imposter type
  23141. */
  23142. static BoxImpostor: number;
  23143. /**
  23144. * Plane-Imposter type
  23145. */
  23146. static PlaneImpostor: number;
  23147. /**
  23148. * Mesh-imposter type
  23149. */
  23150. static MeshImpostor: number;
  23151. /**
  23152. * Capsule-Impostor type (Ammo.js plugin only)
  23153. */
  23154. static CapsuleImpostor: number;
  23155. /**
  23156. * Cylinder-Imposter type
  23157. */
  23158. static CylinderImpostor: number;
  23159. /**
  23160. * Particle-Imposter type
  23161. */
  23162. static ParticleImpostor: number;
  23163. /**
  23164. * Heightmap-Imposter type
  23165. */
  23166. static HeightmapImpostor: number;
  23167. /**
  23168. * ConvexHull-Impostor type (Ammo.js plugin only)
  23169. */
  23170. static ConvexHullImpostor: number;
  23171. /**
  23172. * Rope-Imposter type
  23173. */
  23174. static RopeImpostor: number;
  23175. /**
  23176. * Cloth-Imposter type
  23177. */
  23178. static ClothImpostor: number;
  23179. /**
  23180. * Softbody-Imposter type
  23181. */
  23182. static SoftbodyImpostor: number;
  23183. }
  23184. }
  23185. declare module BABYLON {
  23186. /**
  23187. * @hidden
  23188. **/
  23189. export class _CreationDataStorage {
  23190. closePath?: boolean;
  23191. closeArray?: boolean;
  23192. idx: number[];
  23193. dashSize: number;
  23194. gapSize: number;
  23195. path3D: Path3D;
  23196. pathArray: Vector3[][];
  23197. arc: number;
  23198. radius: number;
  23199. cap: number;
  23200. tessellation: number;
  23201. }
  23202. /**
  23203. * @hidden
  23204. **/
  23205. class _InstanceDataStorage {
  23206. visibleInstances: any;
  23207. batchCache: _InstancesBatch;
  23208. instancesBufferSize: number;
  23209. instancesBuffer: Nullable<Buffer>;
  23210. instancesData: Float32Array;
  23211. overridenInstanceCount: number;
  23212. isFrozen: boolean;
  23213. previousBatch: Nullable<_InstancesBatch>;
  23214. hardwareInstancedRendering: boolean;
  23215. sideOrientation: number;
  23216. }
  23217. /**
  23218. * @hidden
  23219. **/
  23220. export class _InstancesBatch {
  23221. mustReturn: boolean;
  23222. visibleInstances: Nullable<InstancedMesh[]>[];
  23223. renderSelf: boolean[];
  23224. hardwareInstancedRendering: boolean[];
  23225. }
  23226. /**
  23227. * Class used to represent renderable models
  23228. */
  23229. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23230. /**
  23231. * Mesh side orientation : usually the external or front surface
  23232. */
  23233. static readonly FRONTSIDE: number;
  23234. /**
  23235. * Mesh side orientation : usually the internal or back surface
  23236. */
  23237. static readonly BACKSIDE: number;
  23238. /**
  23239. * Mesh side orientation : both internal and external or front and back surfaces
  23240. */
  23241. static readonly DOUBLESIDE: number;
  23242. /**
  23243. * Mesh side orientation : by default, `FRONTSIDE`
  23244. */
  23245. static readonly DEFAULTSIDE: number;
  23246. /**
  23247. * Mesh cap setting : no cap
  23248. */
  23249. static readonly NO_CAP: number;
  23250. /**
  23251. * Mesh cap setting : one cap at the beginning of the mesh
  23252. */
  23253. static readonly CAP_START: number;
  23254. /**
  23255. * Mesh cap setting : one cap at the end of the mesh
  23256. */
  23257. static readonly CAP_END: number;
  23258. /**
  23259. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23260. */
  23261. static readonly CAP_ALL: number;
  23262. /**
  23263. * Mesh pattern setting : no flip or rotate
  23264. */
  23265. static readonly NO_FLIP: number;
  23266. /**
  23267. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23268. */
  23269. static readonly FLIP_TILE: number;
  23270. /**
  23271. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23272. */
  23273. static readonly ROTATE_TILE: number;
  23274. /**
  23275. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23276. */
  23277. static readonly FLIP_ROW: number;
  23278. /**
  23279. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23280. */
  23281. static readonly ROTATE_ROW: number;
  23282. /**
  23283. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23284. */
  23285. static readonly FLIP_N_ROTATE_TILE: number;
  23286. /**
  23287. * Mesh pattern setting : rotate pattern and rotate
  23288. */
  23289. static readonly FLIP_N_ROTATE_ROW: number;
  23290. /**
  23291. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23292. */
  23293. static readonly CENTER: number;
  23294. /**
  23295. * Mesh tile positioning : part tiles on left
  23296. */
  23297. static readonly LEFT: number;
  23298. /**
  23299. * Mesh tile positioning : part tiles on right
  23300. */
  23301. static readonly RIGHT: number;
  23302. /**
  23303. * Mesh tile positioning : part tiles on top
  23304. */
  23305. static readonly TOP: number;
  23306. /**
  23307. * Mesh tile positioning : part tiles on bottom
  23308. */
  23309. static readonly BOTTOM: number;
  23310. /**
  23311. * Gets the default side orientation.
  23312. * @param orientation the orientation to value to attempt to get
  23313. * @returns the default orientation
  23314. * @hidden
  23315. */
  23316. static _GetDefaultSideOrientation(orientation?: number): number;
  23317. private _internalMeshDataInfo;
  23318. /**
  23319. * An event triggered before rendering the mesh
  23320. */
  23321. readonly onBeforeRenderObservable: Observable<Mesh>;
  23322. /**
  23323. * An event triggered before binding the mesh
  23324. */
  23325. readonly onBeforeBindObservable: Observable<Mesh>;
  23326. /**
  23327. * An event triggered after rendering the mesh
  23328. */
  23329. readonly onAfterRenderObservable: Observable<Mesh>;
  23330. /**
  23331. * An event triggered before drawing the mesh
  23332. */
  23333. readonly onBeforeDrawObservable: Observable<Mesh>;
  23334. private _onBeforeDrawObserver;
  23335. /**
  23336. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23337. */
  23338. onBeforeDraw: () => void;
  23339. /**
  23340. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23341. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23342. */
  23343. delayLoadState: number;
  23344. /**
  23345. * Gets the list of instances created from this mesh
  23346. * it is not supposed to be modified manually.
  23347. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23348. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23349. */
  23350. instances: InstancedMesh[];
  23351. /**
  23352. * Gets the file containing delay loading data for this mesh
  23353. */
  23354. delayLoadingFile: string;
  23355. /** @hidden */
  23356. _binaryInfo: any;
  23357. /**
  23358. * User defined function used to change how LOD level selection is done
  23359. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23360. */
  23361. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23362. /**
  23363. * Gets or sets the morph target manager
  23364. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23365. */
  23366. morphTargetManager: Nullable<MorphTargetManager>;
  23367. /** @hidden */
  23368. _creationDataStorage: Nullable<_CreationDataStorage>;
  23369. /** @hidden */
  23370. _geometry: Nullable<Geometry>;
  23371. /** @hidden */
  23372. _delayInfo: Array<string>;
  23373. /** @hidden */
  23374. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23375. /** @hidden */
  23376. _instanceDataStorage: _InstanceDataStorage;
  23377. private _effectiveMaterial;
  23378. /** @hidden */
  23379. _shouldGenerateFlatShading: boolean;
  23380. /** @hidden */
  23381. _originalBuilderSideOrientation: number;
  23382. /**
  23383. * Use this property to change the original side orientation defined at construction time
  23384. */
  23385. overrideMaterialSideOrientation: Nullable<number>;
  23386. /**
  23387. * Gets the source mesh (the one used to clone this one from)
  23388. */
  23389. readonly source: Nullable<Mesh>;
  23390. /**
  23391. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23392. */
  23393. isUnIndexed: boolean;
  23394. /**
  23395. * @constructor
  23396. * @param name The value used by scene.getMeshByName() to do a lookup.
  23397. * @param scene The scene to add this mesh to.
  23398. * @param parent The parent of this mesh, if it has one
  23399. * @param source An optional Mesh from which geometry is shared, cloned.
  23400. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23401. * When false, achieved by calling a clone(), also passing False.
  23402. * This will make creation of children, recursive.
  23403. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23404. */
  23405. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23406. /**
  23407. * Gets the class name
  23408. * @returns the string "Mesh".
  23409. */
  23410. getClassName(): string;
  23411. /** @hidden */
  23412. readonly _isMesh: boolean;
  23413. /**
  23414. * Returns a description of this mesh
  23415. * @param fullDetails define if full details about this mesh must be used
  23416. * @returns a descriptive string representing this mesh
  23417. */
  23418. toString(fullDetails?: boolean): string;
  23419. /** @hidden */
  23420. _unBindEffect(): void;
  23421. /**
  23422. * Gets a boolean indicating if this mesh has LOD
  23423. */
  23424. readonly hasLODLevels: boolean;
  23425. /**
  23426. * Gets the list of MeshLODLevel associated with the current mesh
  23427. * @returns an array of MeshLODLevel
  23428. */
  23429. getLODLevels(): MeshLODLevel[];
  23430. private _sortLODLevels;
  23431. /**
  23432. * Add a mesh as LOD level triggered at the given distance.
  23433. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23434. * @param distance The distance from the center of the object to show this level
  23435. * @param mesh The mesh to be added as LOD level (can be null)
  23436. * @return This mesh (for chaining)
  23437. */
  23438. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23439. /**
  23440. * Returns the LOD level mesh at the passed distance or null if not found.
  23441. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23442. * @param distance The distance from the center of the object to show this level
  23443. * @returns a Mesh or `null`
  23444. */
  23445. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23446. /**
  23447. * Remove a mesh from the LOD array
  23448. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23449. * @param mesh defines the mesh to be removed
  23450. * @return This mesh (for chaining)
  23451. */
  23452. removeLODLevel(mesh: Mesh): Mesh;
  23453. /**
  23454. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23455. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23456. * @param camera defines the camera to use to compute distance
  23457. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23458. * @return This mesh (for chaining)
  23459. */
  23460. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23461. /**
  23462. * Gets the mesh internal Geometry object
  23463. */
  23464. readonly geometry: Nullable<Geometry>;
  23465. /**
  23466. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23467. * @returns the total number of vertices
  23468. */
  23469. getTotalVertices(): number;
  23470. /**
  23471. * Returns the content of an associated vertex buffer
  23472. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23473. * - VertexBuffer.PositionKind
  23474. * - VertexBuffer.UVKind
  23475. * - VertexBuffer.UV2Kind
  23476. * - VertexBuffer.UV3Kind
  23477. * - VertexBuffer.UV4Kind
  23478. * - VertexBuffer.UV5Kind
  23479. * - VertexBuffer.UV6Kind
  23480. * - VertexBuffer.ColorKind
  23481. * - VertexBuffer.MatricesIndicesKind
  23482. * - VertexBuffer.MatricesIndicesExtraKind
  23483. * - VertexBuffer.MatricesWeightsKind
  23484. * - VertexBuffer.MatricesWeightsExtraKind
  23485. * @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
  23486. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23487. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23488. */
  23489. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23490. /**
  23491. * Returns the mesh VertexBuffer object from the requested `kind`
  23492. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23493. * - VertexBuffer.PositionKind
  23494. * - VertexBuffer.NormalKind
  23495. * - VertexBuffer.UVKind
  23496. * - VertexBuffer.UV2Kind
  23497. * - VertexBuffer.UV3Kind
  23498. * - VertexBuffer.UV4Kind
  23499. * - VertexBuffer.UV5Kind
  23500. * - VertexBuffer.UV6Kind
  23501. * - VertexBuffer.ColorKind
  23502. * - VertexBuffer.MatricesIndicesKind
  23503. * - VertexBuffer.MatricesIndicesExtraKind
  23504. * - VertexBuffer.MatricesWeightsKind
  23505. * - VertexBuffer.MatricesWeightsExtraKind
  23506. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23507. */
  23508. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23509. /**
  23510. * Tests if a specific vertex buffer is associated with this mesh
  23511. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23512. * - VertexBuffer.PositionKind
  23513. * - VertexBuffer.NormalKind
  23514. * - VertexBuffer.UVKind
  23515. * - VertexBuffer.UV2Kind
  23516. * - VertexBuffer.UV3Kind
  23517. * - VertexBuffer.UV4Kind
  23518. * - VertexBuffer.UV5Kind
  23519. * - VertexBuffer.UV6Kind
  23520. * - VertexBuffer.ColorKind
  23521. * - VertexBuffer.MatricesIndicesKind
  23522. * - VertexBuffer.MatricesIndicesExtraKind
  23523. * - VertexBuffer.MatricesWeightsKind
  23524. * - VertexBuffer.MatricesWeightsExtraKind
  23525. * @returns a boolean
  23526. */
  23527. isVerticesDataPresent(kind: string): boolean;
  23528. /**
  23529. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23530. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23531. * - VertexBuffer.PositionKind
  23532. * - VertexBuffer.UVKind
  23533. * - VertexBuffer.UV2Kind
  23534. * - VertexBuffer.UV3Kind
  23535. * - VertexBuffer.UV4Kind
  23536. * - VertexBuffer.UV5Kind
  23537. * - VertexBuffer.UV6Kind
  23538. * - VertexBuffer.ColorKind
  23539. * - VertexBuffer.MatricesIndicesKind
  23540. * - VertexBuffer.MatricesIndicesExtraKind
  23541. * - VertexBuffer.MatricesWeightsKind
  23542. * - VertexBuffer.MatricesWeightsExtraKind
  23543. * @returns a boolean
  23544. */
  23545. isVertexBufferUpdatable(kind: string): boolean;
  23546. /**
  23547. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23548. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23549. * - VertexBuffer.PositionKind
  23550. * - VertexBuffer.NormalKind
  23551. * - VertexBuffer.UVKind
  23552. * - VertexBuffer.UV2Kind
  23553. * - VertexBuffer.UV3Kind
  23554. * - VertexBuffer.UV4Kind
  23555. * - VertexBuffer.UV5Kind
  23556. * - VertexBuffer.UV6Kind
  23557. * - VertexBuffer.ColorKind
  23558. * - VertexBuffer.MatricesIndicesKind
  23559. * - VertexBuffer.MatricesIndicesExtraKind
  23560. * - VertexBuffer.MatricesWeightsKind
  23561. * - VertexBuffer.MatricesWeightsExtraKind
  23562. * @returns an array of strings
  23563. */
  23564. getVerticesDataKinds(): string[];
  23565. /**
  23566. * Returns a positive integer : the total number of indices in this mesh geometry.
  23567. * @returns the numner of indices or zero if the mesh has no geometry.
  23568. */
  23569. getTotalIndices(): number;
  23570. /**
  23571. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23572. * @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.
  23573. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23574. * @returns the indices array or an empty array if the mesh has no geometry
  23575. */
  23576. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23577. readonly isBlocked: boolean;
  23578. /**
  23579. * Determine if the current mesh is ready to be rendered
  23580. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23581. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23582. * @returns true if all associated assets are ready (material, textures, shaders)
  23583. */
  23584. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23585. /**
  23586. * 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.
  23587. */
  23588. readonly areNormalsFrozen: boolean;
  23589. /**
  23590. * 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.
  23591. * @returns the current mesh
  23592. */
  23593. freezeNormals(): Mesh;
  23594. /**
  23595. * 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
  23596. * @returns the current mesh
  23597. */
  23598. unfreezeNormals(): Mesh;
  23599. /**
  23600. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23601. */
  23602. overridenInstanceCount: number;
  23603. /** @hidden */
  23604. _preActivate(): Mesh;
  23605. /** @hidden */
  23606. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23607. /** @hidden */
  23608. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23609. /**
  23610. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23611. * This means the mesh underlying bounding box and sphere are recomputed.
  23612. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23613. * @returns the current mesh
  23614. */
  23615. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23616. /** @hidden */
  23617. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23618. /**
  23619. * This function will subdivide the mesh into multiple submeshes
  23620. * @param count defines the expected number of submeshes
  23621. */
  23622. subdivide(count: number): void;
  23623. /**
  23624. * Copy a FloatArray into a specific associated vertex buffer
  23625. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23626. * - VertexBuffer.PositionKind
  23627. * - VertexBuffer.UVKind
  23628. * - VertexBuffer.UV2Kind
  23629. * - VertexBuffer.UV3Kind
  23630. * - VertexBuffer.UV4Kind
  23631. * - VertexBuffer.UV5Kind
  23632. * - VertexBuffer.UV6Kind
  23633. * - VertexBuffer.ColorKind
  23634. * - VertexBuffer.MatricesIndicesKind
  23635. * - VertexBuffer.MatricesIndicesExtraKind
  23636. * - VertexBuffer.MatricesWeightsKind
  23637. * - VertexBuffer.MatricesWeightsExtraKind
  23638. * @param data defines the data source
  23639. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23640. * @param stride defines the data stride size (can be null)
  23641. * @returns the current mesh
  23642. */
  23643. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  23644. /**
  23645. * Flags an associated vertex buffer as updatable
  23646. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23647. * - VertexBuffer.PositionKind
  23648. * - VertexBuffer.UVKind
  23649. * - VertexBuffer.UV2Kind
  23650. * - VertexBuffer.UV3Kind
  23651. * - VertexBuffer.UV4Kind
  23652. * - VertexBuffer.UV5Kind
  23653. * - VertexBuffer.UV6Kind
  23654. * - VertexBuffer.ColorKind
  23655. * - VertexBuffer.MatricesIndicesKind
  23656. * - VertexBuffer.MatricesIndicesExtraKind
  23657. * - VertexBuffer.MatricesWeightsKind
  23658. * - VertexBuffer.MatricesWeightsExtraKind
  23659. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23660. */
  23661. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23662. /**
  23663. * Sets the mesh global Vertex Buffer
  23664. * @param buffer defines the buffer to use
  23665. * @returns the current mesh
  23666. */
  23667. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23668. /**
  23669. * Update a specific associated vertex buffer
  23670. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23671. * - VertexBuffer.PositionKind
  23672. * - VertexBuffer.UVKind
  23673. * - VertexBuffer.UV2Kind
  23674. * - VertexBuffer.UV3Kind
  23675. * - VertexBuffer.UV4Kind
  23676. * - VertexBuffer.UV5Kind
  23677. * - VertexBuffer.UV6Kind
  23678. * - VertexBuffer.ColorKind
  23679. * - VertexBuffer.MatricesIndicesKind
  23680. * - VertexBuffer.MatricesIndicesExtraKind
  23681. * - VertexBuffer.MatricesWeightsKind
  23682. * - VertexBuffer.MatricesWeightsExtraKind
  23683. * @param data defines the data source
  23684. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23685. * @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)
  23686. * @returns the current mesh
  23687. */
  23688. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  23689. /**
  23690. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23691. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23692. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23693. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23694. * @returns the current mesh
  23695. */
  23696. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23697. /**
  23698. * Creates a un-shared specific occurence of the geometry for the mesh.
  23699. * @returns the current mesh
  23700. */
  23701. makeGeometryUnique(): Mesh;
  23702. /**
  23703. * Set the index buffer of this mesh
  23704. * @param indices defines the source data
  23705. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23706. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23707. * @returns the current mesh
  23708. */
  23709. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  23710. /**
  23711. * Update the current index buffer
  23712. * @param indices defines the source data
  23713. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23714. * @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)
  23715. * @returns the current mesh
  23716. */
  23717. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  23718. /**
  23719. * Invert the geometry to move from a right handed system to a left handed one.
  23720. * @returns the current mesh
  23721. */
  23722. toLeftHanded(): Mesh;
  23723. /** @hidden */
  23724. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23725. /** @hidden */
  23726. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23727. /**
  23728. * Registers for this mesh a javascript function called just before the rendering process
  23729. * @param func defines the function to call before rendering this mesh
  23730. * @returns the current mesh
  23731. */
  23732. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23733. /**
  23734. * Disposes a previously registered javascript function called before the rendering
  23735. * @param func defines the function to remove
  23736. * @returns the current mesh
  23737. */
  23738. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23739. /**
  23740. * Registers for this mesh a javascript function called just after the rendering is complete
  23741. * @param func defines the function to call after rendering this mesh
  23742. * @returns the current mesh
  23743. */
  23744. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23745. /**
  23746. * Disposes a previously registered javascript function called after the rendering.
  23747. * @param func defines the function to remove
  23748. * @returns the current mesh
  23749. */
  23750. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23751. /** @hidden */
  23752. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23753. /** @hidden */
  23754. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23755. /** @hidden */
  23756. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23757. /** @hidden */
  23758. _rebuild(): void;
  23759. /** @hidden */
  23760. _freeze(): void;
  23761. /** @hidden */
  23762. _unFreeze(): void;
  23763. /**
  23764. * 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
  23765. * @param subMesh defines the subMesh to render
  23766. * @param enableAlphaMode defines if alpha mode can be changed
  23767. * @returns the current mesh
  23768. */
  23769. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23770. private _onBeforeDraw;
  23771. /**
  23772. * Renormalize the mesh and patch it up if there are no weights
  23773. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23774. * However in the case of zero weights then we set just a single influence to 1.
  23775. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23776. */
  23777. cleanMatrixWeights(): void;
  23778. private normalizeSkinFourWeights;
  23779. private normalizeSkinWeightsAndExtra;
  23780. /**
  23781. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23782. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23783. * the user know there was an issue with importing the mesh
  23784. * @returns a validation object with skinned, valid and report string
  23785. */
  23786. validateSkinning(): {
  23787. skinned: boolean;
  23788. valid: boolean;
  23789. report: string;
  23790. };
  23791. /** @hidden */
  23792. _checkDelayState(): Mesh;
  23793. private _queueLoad;
  23794. /**
  23795. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23796. * A mesh is in the frustum if its bounding box intersects the frustum
  23797. * @param frustumPlanes defines the frustum to test
  23798. * @returns true if the mesh is in the frustum planes
  23799. */
  23800. isInFrustum(frustumPlanes: Plane[]): boolean;
  23801. /**
  23802. * Sets the mesh material by the material or multiMaterial `id` property
  23803. * @param id is a string identifying the material or the multiMaterial
  23804. * @returns the current mesh
  23805. */
  23806. setMaterialByID(id: string): Mesh;
  23807. /**
  23808. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23809. * @returns an array of IAnimatable
  23810. */
  23811. getAnimatables(): IAnimatable[];
  23812. /**
  23813. * Modifies the mesh geometry according to the passed transformation matrix.
  23814. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23815. * The mesh normals are modified using the same transformation.
  23816. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23817. * @param transform defines the transform matrix to use
  23818. * @see http://doc.babylonjs.com/resources/baking_transformations
  23819. * @returns the current mesh
  23820. */
  23821. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23822. /**
  23823. * Modifies the mesh geometry according to its own current World Matrix.
  23824. * The mesh World Matrix is then reset.
  23825. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23826. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23827. * @see http://doc.babylonjs.com/resources/baking_transformations
  23828. * @returns the current mesh
  23829. */
  23830. bakeCurrentTransformIntoVertices(): Mesh;
  23831. /** @hidden */
  23832. readonly _positions: Nullable<Vector3[]>;
  23833. /** @hidden */
  23834. _resetPointsArrayCache(): Mesh;
  23835. /** @hidden */
  23836. _generatePointsArray(): boolean;
  23837. /**
  23838. * Returns a new Mesh object generated from the current mesh properties.
  23839. * This method must not get confused with createInstance()
  23840. * @param name is a string, the name given to the new mesh
  23841. * @param newParent can be any Node object (default `null`)
  23842. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23843. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23844. * @returns a new mesh
  23845. */
  23846. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  23847. /**
  23848. * Releases resources associated with this mesh.
  23849. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23850. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23851. */
  23852. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23853. /**
  23854. * Modifies the mesh geometry according to a displacement map.
  23855. * 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.
  23856. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23857. * @param url is a string, the URL from the image file is to be downloaded.
  23858. * @param minHeight is the lower limit of the displacement.
  23859. * @param maxHeight is the upper limit of the displacement.
  23860. * @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.
  23861. * @param uvOffset is an optional vector2 used to offset UV.
  23862. * @param uvScale is an optional vector2 used to scale UV.
  23863. * @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.
  23864. * @returns the Mesh.
  23865. */
  23866. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23867. /**
  23868. * Modifies the mesh geometry according to a displacementMap buffer.
  23869. * 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.
  23870. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23871. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23872. * @param heightMapWidth is the width of the buffer image.
  23873. * @param heightMapHeight is the height of the buffer image.
  23874. * @param minHeight is the lower limit of the displacement.
  23875. * @param maxHeight is the upper limit of the displacement.
  23876. * @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.
  23877. * @param uvOffset is an optional vector2 used to offset UV.
  23878. * @param uvScale is an optional vector2 used to scale UV.
  23879. * @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.
  23880. * @returns the Mesh.
  23881. */
  23882. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23883. /**
  23884. * Modify the mesh to get a flat shading rendering.
  23885. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23886. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23887. * @returns current mesh
  23888. */
  23889. convertToFlatShadedMesh(): Mesh;
  23890. /**
  23891. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23892. * In other words, more vertices, no more indices and a single bigger VBO.
  23893. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23894. * @returns current mesh
  23895. */
  23896. convertToUnIndexedMesh(): Mesh;
  23897. /**
  23898. * Inverses facet orientations.
  23899. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23900. * @param flipNormals will also inverts the normals
  23901. * @returns current mesh
  23902. */
  23903. flipFaces(flipNormals?: boolean): Mesh;
  23904. /**
  23905. * Increase the number of facets and hence vertices in a mesh
  23906. * Vertex normals are interpolated from existing vertex normals
  23907. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23908. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23909. */
  23910. increaseVertices(numberPerEdge: number): void;
  23911. /**
  23912. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23913. * This will undo any application of covertToFlatShadedMesh
  23914. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23915. */
  23916. forceSharedVertices(): void;
  23917. /** @hidden */
  23918. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  23919. /** @hidden */
  23920. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  23921. /**
  23922. * Creates a new InstancedMesh object from the mesh model.
  23923. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23924. * @param name defines the name of the new instance
  23925. * @returns a new InstancedMesh
  23926. */
  23927. createInstance(name: string): InstancedMesh;
  23928. /**
  23929. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  23930. * After this call, all the mesh instances have the same submeshes than the current mesh.
  23931. * @returns the current mesh
  23932. */
  23933. synchronizeInstances(): Mesh;
  23934. /**
  23935. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  23936. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  23937. * This should be used together with the simplification to avoid disappearing triangles.
  23938. * @param successCallback an optional success callback to be called after the optimization finished.
  23939. * @returns the current mesh
  23940. */
  23941. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  23942. /**
  23943. * Serialize current mesh
  23944. * @param serializationObject defines the object which will receive the serialization data
  23945. */
  23946. serialize(serializationObject: any): void;
  23947. /** @hidden */
  23948. _syncGeometryWithMorphTargetManager(): void;
  23949. /** @hidden */
  23950. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  23951. /**
  23952. * Returns a new Mesh object parsed from the source provided.
  23953. * @param parsedMesh is the source
  23954. * @param scene defines the hosting scene
  23955. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  23956. * @returns a new Mesh
  23957. */
  23958. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  23959. /**
  23960. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  23961. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23962. * @param name defines the name of the mesh to create
  23963. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  23964. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  23965. * @param closePath creates a seam between the first and the last points of each path of the path array
  23966. * @param offset is taken in account only if the `pathArray` is containing a single path
  23967. * @param scene defines the hosting scene
  23968. * @param updatable defines if the mesh must be flagged as updatable
  23969. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23970. * @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)
  23971. * @returns a new Mesh
  23972. */
  23973. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23974. /**
  23975. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  23976. * @param name defines the name of the mesh to create
  23977. * @param radius sets the radius size (float) of the polygon (default 0.5)
  23978. * @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
  23979. * @param scene defines the hosting scene
  23980. * @param updatable defines if the mesh must be flagged as updatable
  23981. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23982. * @returns a new Mesh
  23983. */
  23984. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23985. /**
  23986. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  23987. * @param name defines the name of the mesh to create
  23988. * @param size sets the size (float) of each box side (default 1)
  23989. * @param scene defines the hosting scene
  23990. * @param updatable defines if the mesh must be flagged as updatable
  23991. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23992. * @returns a new Mesh
  23993. */
  23994. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23995. /**
  23996. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  23997. * @param name defines the name of the mesh to create
  23998. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23999. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24000. * @param scene defines the hosting scene
  24001. * @param updatable defines if the mesh must be flagged as updatable
  24002. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24003. * @returns a new Mesh
  24004. */
  24005. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24006. /**
  24007. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24008. * @param name defines the name of the mesh to create
  24009. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24010. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24011. * @param scene defines the hosting scene
  24012. * @returns a new Mesh
  24013. */
  24014. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24015. /**
  24016. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24017. * @param name defines the name of the mesh to create
  24018. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24019. * @param diameterTop set the top cap diameter (floats, default 1)
  24020. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24021. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24022. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24023. * @param scene defines the hosting scene
  24024. * @param updatable defines if the mesh must be flagged as updatable
  24025. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24026. * @returns a new Mesh
  24027. */
  24028. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24029. /**
  24030. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24031. * @param name defines the name of the mesh to create
  24032. * @param diameter sets the diameter size (float) of the torus (default 1)
  24033. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24034. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24035. * @param scene defines the hosting scene
  24036. * @param updatable defines if the mesh must be flagged as updatable
  24037. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24038. * @returns a new Mesh
  24039. */
  24040. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24041. /**
  24042. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24043. * @param name defines the name of the mesh to create
  24044. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24045. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24046. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24047. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24048. * @param p the number of windings on X axis (positive integers, default 2)
  24049. * @param q the number of windings on Y axis (positive integers, default 3)
  24050. * @param scene defines the hosting scene
  24051. * @param updatable defines if the mesh must be flagged as updatable
  24052. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24053. * @returns a new Mesh
  24054. */
  24055. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24056. /**
  24057. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24058. * @param name defines the name of the mesh to create
  24059. * @param points is an array successive Vector3
  24060. * @param scene defines the hosting scene
  24061. * @param updatable defines if the mesh must be flagged as updatable
  24062. * @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).
  24063. * @returns a new Mesh
  24064. */
  24065. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24066. /**
  24067. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24068. * @param name defines the name of the mesh to create
  24069. * @param points is an array successive Vector3
  24070. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24071. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24072. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24073. * @param scene defines the hosting scene
  24074. * @param updatable defines if the mesh must be flagged as updatable
  24075. * @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)
  24076. * @returns a new Mesh
  24077. */
  24078. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24079. /**
  24080. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24081. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24082. * 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.
  24083. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24084. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24085. * Remember you can only change the shape positions, not their number when updating a polygon.
  24086. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24087. * @param name defines the name of the mesh to create
  24088. * @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
  24089. * @param scene defines the hosting scene
  24090. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24091. * @param updatable defines if the mesh must be flagged as updatable
  24092. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24093. * @param earcutInjection can be used to inject your own earcut reference
  24094. * @returns a new Mesh
  24095. */
  24096. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24097. /**
  24098. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24099. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24100. * @param name defines the name of the mesh to create
  24101. * @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
  24102. * @param depth defines the height of extrusion
  24103. * @param scene defines the hosting scene
  24104. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24105. * @param updatable defines if the mesh must be flagged as updatable
  24106. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24107. * @param earcutInjection can be used to inject your own earcut reference
  24108. * @returns a new Mesh
  24109. */
  24110. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24111. /**
  24112. * Creates an extruded shape mesh.
  24113. * 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
  24114. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24115. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24116. * @param name defines the name of the mesh to create
  24117. * @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
  24118. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24119. * @param scale is the value to scale the shape
  24120. * @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
  24121. * @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
  24122. * @param scene defines the hosting scene
  24123. * @param updatable defines if the mesh must be flagged as updatable
  24124. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24125. * @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)
  24126. * @returns a new Mesh
  24127. */
  24128. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24129. /**
  24130. * Creates an custom extruded shape mesh.
  24131. * The custom extrusion is a parametric shape.
  24132. * It has no predefined shape. Its final shape will depend on the input parameters.
  24133. * Please consider using the same method from the MeshBuilder class instead
  24134. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24135. * @param name defines the name of the mesh to create
  24136. * @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
  24137. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24138. * @param scaleFunction is a custom Javascript function called on each path point
  24139. * @param rotationFunction is a custom Javascript function called on each path point
  24140. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24141. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24142. * @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
  24143. * @param scene defines the hosting scene
  24144. * @param updatable defines if the mesh must be flagged as updatable
  24145. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24146. * @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)
  24147. * @returns a new Mesh
  24148. */
  24149. 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;
  24150. /**
  24151. * Creates lathe mesh.
  24152. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24153. * Please consider using the same method from the MeshBuilder class instead
  24154. * @param name defines the name of the mesh to create
  24155. * @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
  24156. * @param radius is the radius value of the lathe
  24157. * @param tessellation is the side number of the lathe.
  24158. * @param scene defines the hosting scene
  24159. * @param updatable defines if the mesh must be flagged as updatable
  24160. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24161. * @returns a new Mesh
  24162. */
  24163. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24164. /**
  24165. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24166. * @param name defines the name of the mesh to create
  24167. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24168. * @param scene defines the hosting scene
  24169. * @param updatable defines if the mesh must be flagged as updatable
  24170. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24171. * @returns a new Mesh
  24172. */
  24173. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24174. /**
  24175. * Creates a ground mesh.
  24176. * Please consider using the same method from the MeshBuilder class instead
  24177. * @param name defines the name of the mesh to create
  24178. * @param width set the width of the ground
  24179. * @param height set the height of the ground
  24180. * @param subdivisions sets the number of subdivisions per side
  24181. * @param scene defines the hosting scene
  24182. * @param updatable defines if the mesh must be flagged as updatable
  24183. * @returns a new Mesh
  24184. */
  24185. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24186. /**
  24187. * Creates a tiled ground mesh.
  24188. * Please consider using the same method from the MeshBuilder class instead
  24189. * @param name defines the name of the mesh to create
  24190. * @param xmin set the ground minimum X coordinate
  24191. * @param zmin set the ground minimum Y coordinate
  24192. * @param xmax set the ground maximum X coordinate
  24193. * @param zmax set the ground maximum Z coordinate
  24194. * @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
  24195. * @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
  24196. * @param scene defines the hosting scene
  24197. * @param updatable defines if the mesh must be flagged as updatable
  24198. * @returns a new Mesh
  24199. */
  24200. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24201. w: number;
  24202. h: number;
  24203. }, precision: {
  24204. w: number;
  24205. h: number;
  24206. }, scene: Scene, updatable?: boolean): Mesh;
  24207. /**
  24208. * Creates a ground mesh from a height map.
  24209. * Please consider using the same method from the MeshBuilder class instead
  24210. * @see http://doc.babylonjs.com/babylon101/height_map
  24211. * @param name defines the name of the mesh to create
  24212. * @param url sets the URL of the height map image resource
  24213. * @param width set the ground width size
  24214. * @param height set the ground height size
  24215. * @param subdivisions sets the number of subdivision per side
  24216. * @param minHeight is the minimum altitude on the ground
  24217. * @param maxHeight is the maximum altitude on the ground
  24218. * @param scene defines the hosting scene
  24219. * @param updatable defines if the mesh must be flagged as updatable
  24220. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24221. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24222. * @returns a new Mesh
  24223. */
  24224. 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;
  24225. /**
  24226. * Creates a tube mesh.
  24227. * The tube is a parametric shape.
  24228. * It has no predefined shape. Its final shape will depend on the input parameters.
  24229. * Please consider using the same method from the MeshBuilder class instead
  24230. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24231. * @param name defines the name of the mesh to create
  24232. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24233. * @param radius sets the tube radius size
  24234. * @param tessellation is the number of sides on the tubular surface
  24235. * @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
  24236. * @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
  24237. * @param scene defines the hosting scene
  24238. * @param updatable defines if the mesh must be flagged as updatable
  24239. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24240. * @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)
  24241. * @returns a new Mesh
  24242. */
  24243. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24244. (i: number, distance: number): number;
  24245. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24246. /**
  24247. * Creates a polyhedron mesh.
  24248. * Please consider using the same method from the MeshBuilder class instead.
  24249. * * 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
  24250. * * The parameter `size` (positive float, default 1) sets the polygon size
  24251. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24252. * * 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`
  24253. * * 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
  24254. * * 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)`)
  24255. * * 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
  24256. * * 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
  24257. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24258. * * 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
  24259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24260. * @param name defines the name of the mesh to create
  24261. * @param options defines the options used to create the mesh
  24262. * @param scene defines the hosting scene
  24263. * @returns a new Mesh
  24264. */
  24265. static CreatePolyhedron(name: string, options: {
  24266. type?: number;
  24267. size?: number;
  24268. sizeX?: number;
  24269. sizeY?: number;
  24270. sizeZ?: number;
  24271. custom?: any;
  24272. faceUV?: Vector4[];
  24273. faceColors?: Color4[];
  24274. updatable?: boolean;
  24275. sideOrientation?: number;
  24276. }, scene: Scene): Mesh;
  24277. /**
  24278. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24279. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24280. * * 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`)
  24281. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24282. * * 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
  24283. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24284. * * 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
  24285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24286. * @param name defines the name of the mesh
  24287. * @param options defines the options used to create the mesh
  24288. * @param scene defines the hosting scene
  24289. * @returns a new Mesh
  24290. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24291. */
  24292. static CreateIcoSphere(name: string, options: {
  24293. radius?: number;
  24294. flat?: boolean;
  24295. subdivisions?: number;
  24296. sideOrientation?: number;
  24297. updatable?: boolean;
  24298. }, scene: Scene): Mesh;
  24299. /**
  24300. * Creates a decal mesh.
  24301. * Please consider using the same method from the MeshBuilder class instead.
  24302. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24303. * @param name defines the name of the mesh
  24304. * @param sourceMesh defines the mesh receiving the decal
  24305. * @param position sets the position of the decal in world coordinates
  24306. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24307. * @param size sets the decal scaling
  24308. * @param angle sets the angle to rotate the decal
  24309. * @returns a new Mesh
  24310. */
  24311. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24312. /**
  24313. * Prepare internal position array for software CPU skinning
  24314. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24315. */
  24316. setPositionsForCPUSkinning(): Float32Array;
  24317. /**
  24318. * Prepare internal normal array for software CPU skinning
  24319. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24320. */
  24321. setNormalsForCPUSkinning(): Float32Array;
  24322. /**
  24323. * Updates the vertex buffer by applying transformation from the bones
  24324. * @param skeleton defines the skeleton to apply to current mesh
  24325. * @returns the current mesh
  24326. */
  24327. applySkeleton(skeleton: Skeleton): Mesh;
  24328. /**
  24329. * 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
  24330. * @param meshes defines the list of meshes to scan
  24331. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24332. */
  24333. static MinMax(meshes: AbstractMesh[]): {
  24334. min: Vector3;
  24335. max: Vector3;
  24336. };
  24337. /**
  24338. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24339. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24340. * @returns a vector3
  24341. */
  24342. static Center(meshesOrMinMaxVector: {
  24343. min: Vector3;
  24344. max: Vector3;
  24345. } | AbstractMesh[]): Vector3;
  24346. /**
  24347. * Merge the array of meshes into a single mesh for performance reasons.
  24348. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24349. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24350. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24351. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24352. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24353. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24354. * @returns a new mesh
  24355. */
  24356. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24357. /** @hidden */
  24358. addInstance(instance: InstancedMesh): void;
  24359. /** @hidden */
  24360. removeInstance(instance: InstancedMesh): void;
  24361. }
  24362. }
  24363. declare module BABYLON {
  24364. /**
  24365. * This is the base class of all the camera used in the application.
  24366. * @see http://doc.babylonjs.com/features/cameras
  24367. */
  24368. export class Camera extends Node {
  24369. /** @hidden */
  24370. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24371. /**
  24372. * This is the default projection mode used by the cameras.
  24373. * It helps recreating a feeling of perspective and better appreciate depth.
  24374. * This is the best way to simulate real life cameras.
  24375. */
  24376. static readonly PERSPECTIVE_CAMERA: number;
  24377. /**
  24378. * This helps creating camera with an orthographic mode.
  24379. * 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.
  24380. */
  24381. static readonly ORTHOGRAPHIC_CAMERA: number;
  24382. /**
  24383. * This is the default FOV mode for perspective cameras.
  24384. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24385. */
  24386. static readonly FOVMODE_VERTICAL_FIXED: number;
  24387. /**
  24388. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24389. */
  24390. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24391. /**
  24392. * This specifies ther is no need for a camera rig.
  24393. * Basically only one eye is rendered corresponding to the camera.
  24394. */
  24395. static readonly RIG_MODE_NONE: number;
  24396. /**
  24397. * Simulates a camera Rig with one blue eye and one red eye.
  24398. * This can be use with 3d blue and red glasses.
  24399. */
  24400. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24401. /**
  24402. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24403. */
  24404. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24405. /**
  24406. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24407. */
  24408. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24409. /**
  24410. * Defines that both eyes of the camera will be rendered over under each other.
  24411. */
  24412. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24413. /**
  24414. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24415. */
  24416. static readonly RIG_MODE_VR: number;
  24417. /**
  24418. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24419. */
  24420. static readonly RIG_MODE_WEBVR: number;
  24421. /**
  24422. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24423. */
  24424. static readonly RIG_MODE_CUSTOM: number;
  24425. /**
  24426. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24427. */
  24428. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24429. /**
  24430. * Define the input manager associated with the camera.
  24431. */
  24432. inputs: CameraInputsManager<Camera>;
  24433. /** @hidden */
  24434. _position: Vector3;
  24435. /**
  24436. * Define the current local position of the camera in the scene
  24437. */
  24438. position: Vector3;
  24439. /**
  24440. * The vector the camera should consider as up.
  24441. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24442. */
  24443. upVector: Vector3;
  24444. /**
  24445. * Define the current limit on the left side for an orthographic camera
  24446. * In scene unit
  24447. */
  24448. orthoLeft: Nullable<number>;
  24449. /**
  24450. * Define the current limit on the right side for an orthographic camera
  24451. * In scene unit
  24452. */
  24453. orthoRight: Nullable<number>;
  24454. /**
  24455. * Define the current limit on the bottom side for an orthographic camera
  24456. * In scene unit
  24457. */
  24458. orthoBottom: Nullable<number>;
  24459. /**
  24460. * Define the current limit on the top side for an orthographic camera
  24461. * In scene unit
  24462. */
  24463. orthoTop: Nullable<number>;
  24464. /**
  24465. * Field Of View is set in Radians. (default is 0.8)
  24466. */
  24467. fov: number;
  24468. /**
  24469. * Define the minimum distance the camera can see from.
  24470. * This is important to note that the depth buffer are not infinite and the closer it starts
  24471. * the more your scene might encounter depth fighting issue.
  24472. */
  24473. minZ: number;
  24474. /**
  24475. * Define the maximum distance the camera can see to.
  24476. * This is important to note that the depth buffer are not infinite and the further it end
  24477. * the more your scene might encounter depth fighting issue.
  24478. */
  24479. maxZ: number;
  24480. /**
  24481. * Define the default inertia of the camera.
  24482. * This helps giving a smooth feeling to the camera movement.
  24483. */
  24484. inertia: number;
  24485. /**
  24486. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24487. */
  24488. mode: number;
  24489. /**
  24490. * Define wether the camera is intermediate.
  24491. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24492. */
  24493. isIntermediate: boolean;
  24494. /**
  24495. * Define the viewport of the camera.
  24496. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24497. */
  24498. viewport: Viewport;
  24499. /**
  24500. * Restricts the camera to viewing objects with the same layerMask.
  24501. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24502. */
  24503. layerMask: number;
  24504. /**
  24505. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24506. */
  24507. fovMode: number;
  24508. /**
  24509. * Rig mode of the camera.
  24510. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24511. * This is normally controlled byt the camera themselves as internal use.
  24512. */
  24513. cameraRigMode: number;
  24514. /**
  24515. * Defines the distance between both "eyes" in case of a RIG
  24516. */
  24517. interaxialDistance: number;
  24518. /**
  24519. * Defines if stereoscopic rendering is done side by side or over under.
  24520. */
  24521. isStereoscopicSideBySide: boolean;
  24522. /**
  24523. * 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
  24524. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24525. * else in the scene. (Eg. security camera)
  24526. *
  24527. * 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)
  24528. */
  24529. customRenderTargets: RenderTargetTexture[];
  24530. /**
  24531. * When set, the camera will render to this render target instead of the default canvas
  24532. *
  24533. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24534. */
  24535. outputRenderTarget: Nullable<RenderTargetTexture>;
  24536. /**
  24537. * Observable triggered when the camera view matrix has changed.
  24538. */
  24539. onViewMatrixChangedObservable: Observable<Camera>;
  24540. /**
  24541. * Observable triggered when the camera Projection matrix has changed.
  24542. */
  24543. onProjectionMatrixChangedObservable: Observable<Camera>;
  24544. /**
  24545. * Observable triggered when the inputs have been processed.
  24546. */
  24547. onAfterCheckInputsObservable: Observable<Camera>;
  24548. /**
  24549. * Observable triggered when reset has been called and applied to the camera.
  24550. */
  24551. onRestoreStateObservable: Observable<Camera>;
  24552. /** @hidden */
  24553. _cameraRigParams: any;
  24554. /** @hidden */
  24555. _rigCameras: Camera[];
  24556. /** @hidden */
  24557. _rigPostProcess: Nullable<PostProcess>;
  24558. protected _webvrViewMatrix: Matrix;
  24559. /** @hidden */
  24560. _skipRendering: boolean;
  24561. /** @hidden */
  24562. _projectionMatrix: Matrix;
  24563. /** @hidden */
  24564. _postProcesses: Nullable<PostProcess>[];
  24565. /** @hidden */
  24566. _activeMeshes: SmartArray<AbstractMesh>;
  24567. protected _globalPosition: Vector3;
  24568. /** @hidden */
  24569. _computedViewMatrix: Matrix;
  24570. private _doNotComputeProjectionMatrix;
  24571. private _transformMatrix;
  24572. private _frustumPlanes;
  24573. private _refreshFrustumPlanes;
  24574. private _storedFov;
  24575. private _stateStored;
  24576. /**
  24577. * Instantiates a new camera object.
  24578. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24579. * @see http://doc.babylonjs.com/features/cameras
  24580. * @param name Defines the name of the camera in the scene
  24581. * @param position Defines the position of the camera
  24582. * @param scene Defines the scene the camera belongs too
  24583. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24584. */
  24585. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24586. /**
  24587. * Store current camera state (fov, position, etc..)
  24588. * @returns the camera
  24589. */
  24590. storeState(): Camera;
  24591. /**
  24592. * Restores the camera state values if it has been stored. You must call storeState() first
  24593. */
  24594. protected _restoreStateValues(): boolean;
  24595. /**
  24596. * Restored camera state. You must call storeState() first.
  24597. * @returns true if restored and false otherwise
  24598. */
  24599. restoreState(): boolean;
  24600. /**
  24601. * Gets the class name of the camera.
  24602. * @returns the class name
  24603. */
  24604. getClassName(): string;
  24605. /** @hidden */
  24606. readonly _isCamera: boolean;
  24607. /**
  24608. * Gets a string representation of the camera useful for debug purpose.
  24609. * @param fullDetails Defines that a more verboe level of logging is required
  24610. * @returns the string representation
  24611. */
  24612. toString(fullDetails?: boolean): string;
  24613. /**
  24614. * Gets the current world space position of the camera.
  24615. */
  24616. readonly globalPosition: Vector3;
  24617. /**
  24618. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24619. * @returns the active meshe list
  24620. */
  24621. getActiveMeshes(): SmartArray<AbstractMesh>;
  24622. /**
  24623. * Check wether a mesh is part of the current active mesh list of the camera
  24624. * @param mesh Defines the mesh to check
  24625. * @returns true if active, false otherwise
  24626. */
  24627. isActiveMesh(mesh: Mesh): boolean;
  24628. /**
  24629. * Is this camera ready to be used/rendered
  24630. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24631. * @return true if the camera is ready
  24632. */
  24633. isReady(completeCheck?: boolean): boolean;
  24634. /** @hidden */
  24635. _initCache(): void;
  24636. /** @hidden */
  24637. _updateCache(ignoreParentClass?: boolean): void;
  24638. /** @hidden */
  24639. _isSynchronized(): boolean;
  24640. /** @hidden */
  24641. _isSynchronizedViewMatrix(): boolean;
  24642. /** @hidden */
  24643. _isSynchronizedProjectionMatrix(): boolean;
  24644. /**
  24645. * Attach the input controls to a specific dom element to get the input from.
  24646. * @param element Defines the element the controls should be listened from
  24647. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24648. */
  24649. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24650. /**
  24651. * Detach the current controls from the specified dom element.
  24652. * @param element Defines the element to stop listening the inputs from
  24653. */
  24654. detachControl(element: HTMLElement): void;
  24655. /**
  24656. * Update the camera state according to the different inputs gathered during the frame.
  24657. */
  24658. update(): void;
  24659. /** @hidden */
  24660. _checkInputs(): void;
  24661. /** @hidden */
  24662. readonly rigCameras: Camera[];
  24663. /**
  24664. * Gets the post process used by the rig cameras
  24665. */
  24666. readonly rigPostProcess: Nullable<PostProcess>;
  24667. /**
  24668. * Internal, gets the first post proces.
  24669. * @returns the first post process to be run on this camera.
  24670. */
  24671. _getFirstPostProcess(): Nullable<PostProcess>;
  24672. private _cascadePostProcessesToRigCams;
  24673. /**
  24674. * Attach a post process to the camera.
  24675. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24676. * @param postProcess The post process to attach to the camera
  24677. * @param insertAt The position of the post process in case several of them are in use in the scene
  24678. * @returns the position the post process has been inserted at
  24679. */
  24680. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24681. /**
  24682. * Detach a post process to the camera.
  24683. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24684. * @param postProcess The post process to detach from the camera
  24685. */
  24686. detachPostProcess(postProcess: PostProcess): void;
  24687. /**
  24688. * Gets the current world matrix of the camera
  24689. */
  24690. getWorldMatrix(): Matrix;
  24691. /** @hidden */
  24692. _getViewMatrix(): Matrix;
  24693. /**
  24694. * Gets the current view matrix of the camera.
  24695. * @param force forces the camera to recompute the matrix without looking at the cached state
  24696. * @returns the view matrix
  24697. */
  24698. getViewMatrix(force?: boolean): Matrix;
  24699. /**
  24700. * Freeze the projection matrix.
  24701. * It will prevent the cache check of the camera projection compute and can speed up perf
  24702. * if no parameter of the camera are meant to change
  24703. * @param projection Defines manually a projection if necessary
  24704. */
  24705. freezeProjectionMatrix(projection?: Matrix): void;
  24706. /**
  24707. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24708. */
  24709. unfreezeProjectionMatrix(): void;
  24710. /**
  24711. * Gets the current projection matrix of the camera.
  24712. * @param force forces the camera to recompute the matrix without looking at the cached state
  24713. * @returns the projection matrix
  24714. */
  24715. getProjectionMatrix(force?: boolean): Matrix;
  24716. /**
  24717. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24718. * @returns a Matrix
  24719. */
  24720. getTransformationMatrix(): Matrix;
  24721. private _updateFrustumPlanes;
  24722. /**
  24723. * Checks if a cullable object (mesh...) is in the camera frustum
  24724. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24725. * @param target The object to check
  24726. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24727. * @returns true if the object is in frustum otherwise false
  24728. */
  24729. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24730. /**
  24731. * Checks if a cullable object (mesh...) is in the camera frustum
  24732. * Unlike isInFrustum this cheks the full bounding box
  24733. * @param target The object to check
  24734. * @returns true if the object is in frustum otherwise false
  24735. */
  24736. isCompletelyInFrustum(target: ICullable): boolean;
  24737. /**
  24738. * Gets a ray in the forward direction from the camera.
  24739. * @param length Defines the length of the ray to create
  24740. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24741. * @param origin Defines the start point of the ray which defaults to the camera position
  24742. * @returns the forward ray
  24743. */
  24744. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24745. /**
  24746. * Releases resources associated with this node.
  24747. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24748. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24749. */
  24750. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24751. /** @hidden */
  24752. _isLeftCamera: boolean;
  24753. /**
  24754. * Gets the left camera of a rig setup in case of Rigged Camera
  24755. */
  24756. readonly isLeftCamera: boolean;
  24757. /** @hidden */
  24758. _isRightCamera: boolean;
  24759. /**
  24760. * Gets the right camera of a rig setup in case of Rigged Camera
  24761. */
  24762. readonly isRightCamera: boolean;
  24763. /**
  24764. * Gets the left camera of a rig setup in case of Rigged Camera
  24765. */
  24766. readonly leftCamera: Nullable<FreeCamera>;
  24767. /**
  24768. * Gets the right camera of a rig setup in case of Rigged Camera
  24769. */
  24770. readonly rightCamera: Nullable<FreeCamera>;
  24771. /**
  24772. * Gets the left camera target of a rig setup in case of Rigged Camera
  24773. * @returns the target position
  24774. */
  24775. getLeftTarget(): Nullable<Vector3>;
  24776. /**
  24777. * Gets the right camera target of a rig setup in case of Rigged Camera
  24778. * @returns the target position
  24779. */
  24780. getRightTarget(): Nullable<Vector3>;
  24781. /**
  24782. * @hidden
  24783. */
  24784. setCameraRigMode(mode: number, rigParams: any): void;
  24785. /** @hidden */
  24786. static _setStereoscopicRigMode(camera: Camera): void;
  24787. /** @hidden */
  24788. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24789. /** @hidden */
  24790. static _setVRRigMode(camera: Camera, rigParams: any): void;
  24791. /** @hidden */
  24792. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24793. /** @hidden */
  24794. _getVRProjectionMatrix(): Matrix;
  24795. protected _updateCameraRotationMatrix(): void;
  24796. protected _updateWebVRCameraRotationMatrix(): void;
  24797. /**
  24798. * This function MUST be overwritten by the different WebVR cameras available.
  24799. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24800. * @hidden
  24801. */
  24802. _getWebVRProjectionMatrix(): Matrix;
  24803. /**
  24804. * This function MUST be overwritten by the different WebVR cameras available.
  24805. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24806. * @hidden
  24807. */
  24808. _getWebVRViewMatrix(): Matrix;
  24809. /** @hidden */
  24810. setCameraRigParameter(name: string, value: any): void;
  24811. /**
  24812. * needs to be overridden by children so sub has required properties to be copied
  24813. * @hidden
  24814. */
  24815. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24816. /**
  24817. * May need to be overridden by children
  24818. * @hidden
  24819. */
  24820. _updateRigCameras(): void;
  24821. /** @hidden */
  24822. _setupInputs(): void;
  24823. /**
  24824. * Serialiaze the camera setup to a json represention
  24825. * @returns the JSON representation
  24826. */
  24827. serialize(): any;
  24828. /**
  24829. * Clones the current camera.
  24830. * @param name The cloned camera name
  24831. * @returns the cloned camera
  24832. */
  24833. clone(name: string): Camera;
  24834. /**
  24835. * Gets the direction of the camera relative to a given local axis.
  24836. * @param localAxis Defines the reference axis to provide a relative direction.
  24837. * @return the direction
  24838. */
  24839. getDirection(localAxis: Vector3): Vector3;
  24840. /**
  24841. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24842. * @param localAxis Defines the reference axis to provide a relative direction.
  24843. * @param result Defines the vector to store the result in
  24844. */
  24845. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24846. /**
  24847. * Gets a camera constructor for a given camera type
  24848. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24849. * @param name The name of the camera the result will be able to instantiate
  24850. * @param scene The scene the result will construct the camera in
  24851. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24852. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24853. * @returns a factory method to construc the camera
  24854. */
  24855. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24856. /**
  24857. * Compute the world matrix of the camera.
  24858. * @returns the camera workd matrix
  24859. */
  24860. computeWorldMatrix(): Matrix;
  24861. /**
  24862. * Parse a JSON and creates the camera from the parsed information
  24863. * @param parsedCamera The JSON to parse
  24864. * @param scene The scene to instantiate the camera in
  24865. * @returns the newly constructed camera
  24866. */
  24867. static Parse(parsedCamera: any, scene: Scene): Camera;
  24868. }
  24869. }
  24870. declare module BABYLON {
  24871. /**
  24872. * Class containing static functions to help procedurally build meshes
  24873. */
  24874. export class DiscBuilder {
  24875. /**
  24876. * Creates a plane polygonal mesh. By default, this is a disc
  24877. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24878. * * 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
  24879. * * 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
  24880. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24881. * * 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
  24882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24883. * @param name defines the name of the mesh
  24884. * @param options defines the options used to create the mesh
  24885. * @param scene defines the hosting scene
  24886. * @returns the plane polygonal mesh
  24887. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24888. */
  24889. static CreateDisc(name: string, options: {
  24890. radius?: number;
  24891. tessellation?: number;
  24892. arc?: number;
  24893. updatable?: boolean;
  24894. sideOrientation?: number;
  24895. frontUVs?: Vector4;
  24896. backUVs?: Vector4;
  24897. }, scene?: Nullable<Scene>): Mesh;
  24898. }
  24899. }
  24900. declare module BABYLON {
  24901. /**
  24902. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24903. *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.
  24904. * The SPS is also a particle system. It provides some methods to manage the particles.
  24905. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24906. *
  24907. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24908. */
  24909. export class SolidParticleSystem implements IDisposable {
  24910. /**
  24911. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24912. * Example : var p = SPS.particles[i];
  24913. */
  24914. particles: SolidParticle[];
  24915. /**
  24916. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24917. */
  24918. nbParticles: number;
  24919. /**
  24920. * If the particles must ever face the camera (default false). Useful for planar particles.
  24921. */
  24922. billboard: boolean;
  24923. /**
  24924. * Recompute normals when adding a shape
  24925. */
  24926. recomputeNormals: boolean;
  24927. /**
  24928. * This a counter ofr your own usage. It's not set by any SPS functions.
  24929. */
  24930. counter: number;
  24931. /**
  24932. * The SPS name. This name is also given to the underlying mesh.
  24933. */
  24934. name: string;
  24935. /**
  24936. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24937. */
  24938. mesh: Mesh;
  24939. /**
  24940. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24941. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  24942. */
  24943. vars: any;
  24944. /**
  24945. * This array is populated when the SPS is set as 'pickable'.
  24946. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24947. * Each element of this array is an object `{idx: int, faceId: int}`.
  24948. * `idx` is the picked particle index in the `SPS.particles` array
  24949. * `faceId` is the picked face index counted within this particle.
  24950. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  24951. */
  24952. pickedParticles: {
  24953. idx: number;
  24954. faceId: number;
  24955. }[];
  24956. /**
  24957. * This array is populated when `enableDepthSort` is set to true.
  24958. * Each element of this array is an instance of the class DepthSortedParticle.
  24959. */
  24960. depthSortedParticles: DepthSortedParticle[];
  24961. /**
  24962. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24963. * @hidden
  24964. */
  24965. _bSphereOnly: boolean;
  24966. /**
  24967. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24968. * @hidden
  24969. */
  24970. _bSphereRadiusFactor: number;
  24971. private _scene;
  24972. private _positions;
  24973. private _indices;
  24974. private _normals;
  24975. private _colors;
  24976. private _uvs;
  24977. private _indices32;
  24978. private _positions32;
  24979. private _normals32;
  24980. private _fixedNormal32;
  24981. private _colors32;
  24982. private _uvs32;
  24983. private _index;
  24984. private _updatable;
  24985. private _pickable;
  24986. private _isVisibilityBoxLocked;
  24987. private _alwaysVisible;
  24988. private _depthSort;
  24989. private _shapeCounter;
  24990. private _copy;
  24991. private _color;
  24992. private _computeParticleColor;
  24993. private _computeParticleTexture;
  24994. private _computeParticleRotation;
  24995. private _computeParticleVertex;
  24996. private _computeBoundingBox;
  24997. private _depthSortParticles;
  24998. private _camera;
  24999. private _mustUnrotateFixedNormals;
  25000. private _particlesIntersect;
  25001. private _needs32Bits;
  25002. /**
  25003. * Creates a SPS (Solid Particle System) object.
  25004. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25005. * @param scene (Scene) is the scene in which the SPS is added.
  25006. * @param options defines the options of the sps e.g.
  25007. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25008. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25009. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25010. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25011. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25012. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25013. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25014. */
  25015. constructor(name: string, scene: Scene, options?: {
  25016. updatable?: boolean;
  25017. isPickable?: boolean;
  25018. enableDepthSort?: boolean;
  25019. particleIntersection?: boolean;
  25020. boundingSphereOnly?: boolean;
  25021. bSphereRadiusFactor?: number;
  25022. });
  25023. /**
  25024. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25025. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25026. * @returns the created mesh
  25027. */
  25028. buildMesh(): Mesh;
  25029. /**
  25030. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25031. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25032. * Thus the particles generated from `digest()` have their property `position` set yet.
  25033. * @param mesh ( Mesh ) is the mesh to be digested
  25034. * @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
  25035. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25036. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25037. * @returns the current SPS
  25038. */
  25039. digest(mesh: Mesh, options?: {
  25040. facetNb?: number;
  25041. number?: number;
  25042. delta?: number;
  25043. }): SolidParticleSystem;
  25044. private _unrotateFixedNormals;
  25045. private _resetCopy;
  25046. private _meshBuilder;
  25047. private _posToShape;
  25048. private _uvsToShapeUV;
  25049. private _addParticle;
  25050. /**
  25051. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25052. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25053. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25054. * @param nb (positive integer) the number of particles to be created from this model
  25055. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25056. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25057. * @returns the number of shapes in the system
  25058. */
  25059. addShape(mesh: Mesh, nb: number, options?: {
  25060. positionFunction?: any;
  25061. vertexFunction?: any;
  25062. }): number;
  25063. private _rebuildParticle;
  25064. /**
  25065. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25066. * @returns the SPS.
  25067. */
  25068. rebuildMesh(): SolidParticleSystem;
  25069. /**
  25070. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25071. * This method calls `updateParticle()` for each particle of the SPS.
  25072. * For an animated SPS, it is usually called within the render loop.
  25073. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25074. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25075. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25076. * @returns the SPS.
  25077. */
  25078. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25079. /**
  25080. * Disposes the SPS.
  25081. */
  25082. dispose(): void;
  25083. /**
  25084. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25085. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25086. * @returns the SPS.
  25087. */
  25088. refreshVisibleSize(): SolidParticleSystem;
  25089. /**
  25090. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25091. * @param size the size (float) of the visibility box
  25092. * note : this doesn't lock the SPS mesh bounding box.
  25093. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25094. */
  25095. setVisibilityBox(size: number): void;
  25096. /**
  25097. * Gets whether the SPS as always visible or not
  25098. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25099. */
  25100. /**
  25101. * Sets the SPS as always visible or not
  25102. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25103. */
  25104. isAlwaysVisible: boolean;
  25105. /**
  25106. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25107. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25108. */
  25109. /**
  25110. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25111. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25112. */
  25113. isVisibilityBoxLocked: boolean;
  25114. /**
  25115. * Tells to `setParticles()` to compute the particle rotations or not.
  25116. * Default value : true. The SPS is faster when it's set to false.
  25117. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25118. */
  25119. /**
  25120. * Gets if `setParticles()` computes the particle rotations or not.
  25121. * Default value : true. The SPS is faster when it's set to false.
  25122. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25123. */
  25124. computeParticleRotation: boolean;
  25125. /**
  25126. * Tells to `setParticles()` to compute the particle colors or not.
  25127. * Default value : true. The SPS is faster when it's set to false.
  25128. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25129. */
  25130. /**
  25131. * Gets if `setParticles()` computes the particle colors or not.
  25132. * Default value : true. The SPS is faster when it's set to false.
  25133. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25134. */
  25135. computeParticleColor: boolean;
  25136. /**
  25137. * Gets if `setParticles()` computes the particle textures or not.
  25138. * Default value : true. The SPS is faster when it's set to false.
  25139. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25140. */
  25141. computeParticleTexture: boolean;
  25142. /**
  25143. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25144. * Default value : false. The SPS is faster when it's set to false.
  25145. * Note : the particle custom vertex positions aren't stored values.
  25146. */
  25147. /**
  25148. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25149. * Default value : false. The SPS is faster when it's set to false.
  25150. * Note : the particle custom vertex positions aren't stored values.
  25151. */
  25152. computeParticleVertex: boolean;
  25153. /**
  25154. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25155. */
  25156. /**
  25157. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25158. */
  25159. computeBoundingBox: boolean;
  25160. /**
  25161. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25162. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25163. * Default : `true`
  25164. */
  25165. /**
  25166. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25167. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25168. * Default : `true`
  25169. */
  25170. depthSortParticles: boolean;
  25171. /**
  25172. * This function does nothing. It may be overwritten to set all the particle first values.
  25173. * The SPS doesn't call this function, you may have to call it by your own.
  25174. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25175. */
  25176. initParticles(): void;
  25177. /**
  25178. * This function does nothing. It may be overwritten to recycle a particle.
  25179. * The SPS doesn't call this function, you may have to call it by your own.
  25180. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25181. * @param particle The particle to recycle
  25182. * @returns the recycled particle
  25183. */
  25184. recycleParticle(particle: SolidParticle): SolidParticle;
  25185. /**
  25186. * Updates a particle : this function should be overwritten by the user.
  25187. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25188. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25189. * @example : just set a particle position or velocity and recycle conditions
  25190. * @param particle The particle to update
  25191. * @returns the updated particle
  25192. */
  25193. updateParticle(particle: SolidParticle): SolidParticle;
  25194. /**
  25195. * Updates a vertex of a particle : it can be overwritten by the user.
  25196. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25197. * @param particle the current particle
  25198. * @param vertex the current index of the current particle
  25199. * @param pt the index of the current vertex in the particle shape
  25200. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25201. * @example : just set a vertex particle position
  25202. * @returns the updated vertex
  25203. */
  25204. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25205. /**
  25206. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25207. * This does nothing and may be overwritten by the user.
  25208. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25209. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25210. * @param update the boolean update value actually passed to setParticles()
  25211. */
  25212. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25213. /**
  25214. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25215. * This will be passed three parameters.
  25216. * This does nothing and may be overwritten by the user.
  25217. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25218. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25219. * @param update the boolean update value actually passed to setParticles()
  25220. */
  25221. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25222. }
  25223. }
  25224. declare module BABYLON {
  25225. /**
  25226. * Represents one particle of a solid particle system.
  25227. */
  25228. export class SolidParticle {
  25229. /**
  25230. * particle global index
  25231. */
  25232. idx: number;
  25233. /**
  25234. * The color of the particle
  25235. */
  25236. color: Nullable<Color4>;
  25237. /**
  25238. * The world space position of the particle.
  25239. */
  25240. position: Vector3;
  25241. /**
  25242. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25243. */
  25244. rotation: Vector3;
  25245. /**
  25246. * The world space rotation quaternion of the particle.
  25247. */
  25248. rotationQuaternion: Nullable<Quaternion>;
  25249. /**
  25250. * The scaling of the particle.
  25251. */
  25252. scaling: Vector3;
  25253. /**
  25254. * The uvs of the particle.
  25255. */
  25256. uvs: Vector4;
  25257. /**
  25258. * The current speed of the particle.
  25259. */
  25260. velocity: Vector3;
  25261. /**
  25262. * The pivot point in the particle local space.
  25263. */
  25264. pivot: Vector3;
  25265. /**
  25266. * Must the particle be translated from its pivot point in its local space ?
  25267. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25268. * Default : false
  25269. */
  25270. translateFromPivot: boolean;
  25271. /**
  25272. * Is the particle active or not ?
  25273. */
  25274. alive: boolean;
  25275. /**
  25276. * Is the particle visible or not ?
  25277. */
  25278. isVisible: boolean;
  25279. /**
  25280. * Index of this particle in the global "positions" array (Internal use)
  25281. * @hidden
  25282. */
  25283. _pos: number;
  25284. /**
  25285. * @hidden Index of this particle in the global "indices" array (Internal use)
  25286. */
  25287. _ind: number;
  25288. /**
  25289. * @hidden ModelShape of this particle (Internal use)
  25290. */
  25291. _model: ModelShape;
  25292. /**
  25293. * ModelShape id of this particle
  25294. */
  25295. shapeId: number;
  25296. /**
  25297. * Index of the particle in its shape id (Internal use)
  25298. */
  25299. idxInShape: number;
  25300. /**
  25301. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25302. */
  25303. _modelBoundingInfo: BoundingInfo;
  25304. /**
  25305. * @hidden Particle BoundingInfo object (Internal use)
  25306. */
  25307. _boundingInfo: BoundingInfo;
  25308. /**
  25309. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25310. */
  25311. _sps: SolidParticleSystem;
  25312. /**
  25313. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25314. */
  25315. _stillInvisible: boolean;
  25316. /**
  25317. * @hidden Last computed particle rotation matrix
  25318. */
  25319. _rotationMatrix: number[];
  25320. /**
  25321. * Parent particle Id, if any.
  25322. * Default null.
  25323. */
  25324. parentId: Nullable<number>;
  25325. /**
  25326. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25327. * The possible values are :
  25328. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25329. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25330. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25331. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25332. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25333. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25334. * */
  25335. cullingStrategy: number;
  25336. /**
  25337. * @hidden Internal global position in the SPS.
  25338. */
  25339. _globalPosition: Vector3;
  25340. /**
  25341. * Creates a Solid Particle object.
  25342. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25343. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25344. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25345. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25346. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25347. * @param shapeId (integer) is the model shape identifier in the SPS.
  25348. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25349. * @param sps defines the sps it is associated to
  25350. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25351. */
  25352. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25353. /**
  25354. * Legacy support, changed scale to scaling
  25355. */
  25356. /**
  25357. * Legacy support, changed scale to scaling
  25358. */
  25359. scale: Vector3;
  25360. /**
  25361. * Legacy support, changed quaternion to rotationQuaternion
  25362. */
  25363. /**
  25364. * Legacy support, changed quaternion to rotationQuaternion
  25365. */
  25366. quaternion: Nullable<Quaternion>;
  25367. /**
  25368. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25369. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25370. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25371. * @returns true if it intersects
  25372. */
  25373. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25374. /**
  25375. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25376. * A particle is in the frustum if its bounding box intersects the frustum
  25377. * @param frustumPlanes defines the frustum to test
  25378. * @returns true if the particle is in the frustum planes
  25379. */
  25380. isInFrustum(frustumPlanes: Plane[]): boolean;
  25381. /**
  25382. * get the rotation matrix of the particle
  25383. * @hidden
  25384. */
  25385. getRotationMatrix(m: Matrix): void;
  25386. }
  25387. /**
  25388. * Represents the shape of the model used by one particle of a solid particle system.
  25389. * SPS internal tool, don't use it manually.
  25390. */
  25391. export class ModelShape {
  25392. /**
  25393. * The shape id
  25394. * @hidden
  25395. */
  25396. shapeID: number;
  25397. /**
  25398. * flat array of model positions (internal use)
  25399. * @hidden
  25400. */
  25401. _shape: Vector3[];
  25402. /**
  25403. * flat array of model UVs (internal use)
  25404. * @hidden
  25405. */
  25406. _shapeUV: number[];
  25407. /**
  25408. * length of the shape in the model indices array (internal use)
  25409. * @hidden
  25410. */
  25411. _indicesLength: number;
  25412. /**
  25413. * Custom position function (internal use)
  25414. * @hidden
  25415. */
  25416. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25417. /**
  25418. * Custom vertex function (internal use)
  25419. * @hidden
  25420. */
  25421. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25422. /**
  25423. * 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.
  25424. * SPS internal tool, don't use it manually.
  25425. * @hidden
  25426. */
  25427. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25428. }
  25429. /**
  25430. * Represents a Depth Sorted Particle in the solid particle system.
  25431. */
  25432. export class DepthSortedParticle {
  25433. /**
  25434. * Index of the particle in the "indices" array
  25435. */
  25436. ind: number;
  25437. /**
  25438. * Length of the particle shape in the "indices" array
  25439. */
  25440. indicesLength: number;
  25441. /**
  25442. * Squared distance from the particle to the camera
  25443. */
  25444. sqDistance: number;
  25445. }
  25446. }
  25447. declare module BABYLON {
  25448. /**
  25449. * @hidden
  25450. */
  25451. export class _MeshCollisionData {
  25452. _checkCollisions: boolean;
  25453. _collisionMask: number;
  25454. _collisionGroup: number;
  25455. _collider: Nullable<Collider>;
  25456. _oldPositionForCollisions: Vector3;
  25457. _diffPositionForCollisions: Vector3;
  25458. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25459. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25460. }
  25461. }
  25462. declare module BABYLON {
  25463. /** @hidden */
  25464. class _FacetDataStorage {
  25465. facetPositions: Vector3[];
  25466. facetNormals: Vector3[];
  25467. facetPartitioning: number[][];
  25468. facetNb: number;
  25469. partitioningSubdivisions: number;
  25470. partitioningBBoxRatio: number;
  25471. facetDataEnabled: boolean;
  25472. facetParameters: any;
  25473. bbSize: Vector3;
  25474. subDiv: {
  25475. max: number;
  25476. X: number;
  25477. Y: number;
  25478. Z: number;
  25479. };
  25480. facetDepthSort: boolean;
  25481. facetDepthSortEnabled: boolean;
  25482. depthSortedIndices: IndicesArray;
  25483. depthSortedFacets: {
  25484. ind: number;
  25485. sqDistance: number;
  25486. }[];
  25487. facetDepthSortFunction: (f1: {
  25488. ind: number;
  25489. sqDistance: number;
  25490. }, f2: {
  25491. ind: number;
  25492. sqDistance: number;
  25493. }) => number;
  25494. facetDepthSortFrom: Vector3;
  25495. facetDepthSortOrigin: Vector3;
  25496. invertedMatrix: Matrix;
  25497. }
  25498. /**
  25499. * @hidden
  25500. **/
  25501. class _InternalAbstractMeshDataInfo {
  25502. _hasVertexAlpha: boolean;
  25503. _useVertexColors: boolean;
  25504. _numBoneInfluencers: number;
  25505. _applyFog: boolean;
  25506. _receiveShadows: boolean;
  25507. _facetData: _FacetDataStorage;
  25508. _visibility: number;
  25509. _skeleton: Nullable<Skeleton>;
  25510. _layerMask: number;
  25511. _computeBonesUsingShaders: boolean;
  25512. _isActive: boolean;
  25513. _onlyForInstances: boolean;
  25514. _isActiveIntermediate: boolean;
  25515. _onlyForInstancesIntermediate: boolean;
  25516. }
  25517. /**
  25518. * Class used to store all common mesh properties
  25519. */
  25520. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25521. /** No occlusion */
  25522. static OCCLUSION_TYPE_NONE: number;
  25523. /** Occlusion set to optimisitic */
  25524. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25525. /** Occlusion set to strict */
  25526. static OCCLUSION_TYPE_STRICT: number;
  25527. /** Use an accurante occlusion algorithm */
  25528. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25529. /** Use a conservative occlusion algorithm */
  25530. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25531. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25532. * Test order :
  25533. * Is the bounding sphere outside the frustum ?
  25534. * If not, are the bounding box vertices outside the frustum ?
  25535. * It not, then the cullable object is in the frustum.
  25536. */
  25537. static readonly CULLINGSTRATEGY_STANDARD: number;
  25538. /** Culling strategy : Bounding Sphere Only.
  25539. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25540. * It's also less accurate than the standard because some not visible objects can still be selected.
  25541. * Test : is the bounding sphere outside the frustum ?
  25542. * If not, then the cullable object is in the frustum.
  25543. */
  25544. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25545. /** Culling strategy : Optimistic Inclusion.
  25546. * This in an inclusion test first, then the standard exclusion test.
  25547. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25548. * 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.
  25549. * Anyway, it's as accurate as the standard strategy.
  25550. * Test :
  25551. * Is the cullable object bounding sphere center in the frustum ?
  25552. * If not, apply the default culling strategy.
  25553. */
  25554. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25555. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25556. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25557. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25558. * 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.
  25559. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25560. * Test :
  25561. * Is the cullable object bounding sphere center in the frustum ?
  25562. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25563. */
  25564. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25565. /**
  25566. * No billboard
  25567. */
  25568. static readonly BILLBOARDMODE_NONE: number;
  25569. /** Billboard on X axis */
  25570. static readonly BILLBOARDMODE_X: number;
  25571. /** Billboard on Y axis */
  25572. static readonly BILLBOARDMODE_Y: number;
  25573. /** Billboard on Z axis */
  25574. static readonly BILLBOARDMODE_Z: number;
  25575. /** Billboard on all axes */
  25576. static readonly BILLBOARDMODE_ALL: number;
  25577. /** @hidden */
  25578. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25579. /**
  25580. * The culling strategy to use to check whether the mesh must be rendered or not.
  25581. * This value can be changed at any time and will be used on the next render mesh selection.
  25582. * The possible values are :
  25583. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25584. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25585. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25586. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25587. * Please read each static variable documentation to get details about the culling process.
  25588. * */
  25589. cullingStrategy: number;
  25590. /**
  25591. * Gets the number of facets in the mesh
  25592. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25593. */
  25594. readonly facetNb: number;
  25595. /**
  25596. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25597. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25598. */
  25599. partitioningSubdivisions: number;
  25600. /**
  25601. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25602. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25603. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25604. */
  25605. partitioningBBoxRatio: number;
  25606. /**
  25607. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25608. * Works only for updatable meshes.
  25609. * Doesn't work with multi-materials
  25610. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25611. */
  25612. mustDepthSortFacets: boolean;
  25613. /**
  25614. * The location (Vector3) where the facet depth sort must be computed from.
  25615. * By default, the active camera position.
  25616. * Used only when facet depth sort is enabled
  25617. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25618. */
  25619. facetDepthSortFrom: Vector3;
  25620. /**
  25621. * gets a boolean indicating if facetData is enabled
  25622. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25623. */
  25624. readonly isFacetDataEnabled: boolean;
  25625. /** @hidden */
  25626. _updateNonUniformScalingState(value: boolean): boolean;
  25627. /**
  25628. * An event triggered when this mesh collides with another one
  25629. */
  25630. onCollideObservable: Observable<AbstractMesh>;
  25631. /** Set a function to call when this mesh collides with another one */
  25632. onCollide: () => void;
  25633. /**
  25634. * An event triggered when the collision's position changes
  25635. */
  25636. onCollisionPositionChangeObservable: Observable<Vector3>;
  25637. /** Set a function to call when the collision's position changes */
  25638. onCollisionPositionChange: () => void;
  25639. /**
  25640. * An event triggered when material is changed
  25641. */
  25642. onMaterialChangedObservable: Observable<AbstractMesh>;
  25643. /**
  25644. * Gets or sets the orientation for POV movement & rotation
  25645. */
  25646. definedFacingForward: boolean;
  25647. /** @hidden */
  25648. _occlusionQuery: Nullable<WebGLQuery>;
  25649. /** @hidden */
  25650. _renderingGroup: Nullable<RenderingGroup>;
  25651. /**
  25652. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25653. */
  25654. /**
  25655. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25656. */
  25657. visibility: number;
  25658. /** Gets or sets the alpha index used to sort transparent meshes
  25659. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25660. */
  25661. alphaIndex: number;
  25662. /**
  25663. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25664. */
  25665. isVisible: boolean;
  25666. /**
  25667. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25668. */
  25669. isPickable: boolean;
  25670. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25671. showSubMeshesBoundingBox: boolean;
  25672. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25673. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25674. */
  25675. isBlocker: boolean;
  25676. /**
  25677. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25678. */
  25679. enablePointerMoveEvents: boolean;
  25680. /**
  25681. * Specifies the rendering group id for this mesh (0 by default)
  25682. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25683. */
  25684. renderingGroupId: number;
  25685. private _material;
  25686. /** Gets or sets current material */
  25687. material: Nullable<Material>;
  25688. /**
  25689. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25690. * @see http://doc.babylonjs.com/babylon101/shadows
  25691. */
  25692. receiveShadows: boolean;
  25693. /** Defines color to use when rendering outline */
  25694. outlineColor: Color3;
  25695. /** Define width to use when rendering outline */
  25696. outlineWidth: number;
  25697. /** Defines color to use when rendering overlay */
  25698. overlayColor: Color3;
  25699. /** Defines alpha to use when rendering overlay */
  25700. overlayAlpha: number;
  25701. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25702. hasVertexAlpha: boolean;
  25703. /** 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) */
  25704. useVertexColors: boolean;
  25705. /**
  25706. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25707. */
  25708. computeBonesUsingShaders: boolean;
  25709. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25710. numBoneInfluencers: number;
  25711. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25712. applyFog: boolean;
  25713. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25714. useOctreeForRenderingSelection: boolean;
  25715. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25716. useOctreeForPicking: boolean;
  25717. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25718. useOctreeForCollisions: boolean;
  25719. /**
  25720. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25721. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25722. */
  25723. layerMask: number;
  25724. /**
  25725. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25726. */
  25727. alwaysSelectAsActiveMesh: boolean;
  25728. /**
  25729. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25730. */
  25731. doNotSyncBoundingInfo: boolean;
  25732. /**
  25733. * Gets or sets the current action manager
  25734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25735. */
  25736. actionManager: Nullable<AbstractActionManager>;
  25737. private _meshCollisionData;
  25738. /**
  25739. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25740. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25741. */
  25742. ellipsoid: Vector3;
  25743. /**
  25744. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25745. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25746. */
  25747. ellipsoidOffset: Vector3;
  25748. /**
  25749. * Gets or sets a collision mask used to mask collisions (default is -1).
  25750. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25751. */
  25752. collisionMask: number;
  25753. /**
  25754. * Gets or sets the current collision group mask (-1 by default).
  25755. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25756. */
  25757. collisionGroup: number;
  25758. /**
  25759. * Defines edge width used when edgesRenderer is enabled
  25760. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25761. */
  25762. edgesWidth: number;
  25763. /**
  25764. * Defines edge color used when edgesRenderer is enabled
  25765. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25766. */
  25767. edgesColor: Color4;
  25768. /** @hidden */
  25769. _edgesRenderer: Nullable<IEdgesRenderer>;
  25770. /** @hidden */
  25771. _masterMesh: Nullable<AbstractMesh>;
  25772. /** @hidden */
  25773. _boundingInfo: Nullable<BoundingInfo>;
  25774. /** @hidden */
  25775. _renderId: number;
  25776. /**
  25777. * Gets or sets the list of subMeshes
  25778. * @see http://doc.babylonjs.com/how_to/multi_materials
  25779. */
  25780. subMeshes: SubMesh[];
  25781. /** @hidden */
  25782. _intersectionsInProgress: AbstractMesh[];
  25783. /** @hidden */
  25784. _unIndexed: boolean;
  25785. /** @hidden */
  25786. _lightSources: Light[];
  25787. /** Gets the list of lights affecting that mesh */
  25788. readonly lightSources: Light[];
  25789. /** @hidden */
  25790. readonly _positions: Nullable<Vector3[]>;
  25791. /** @hidden */
  25792. _waitingData: {
  25793. lods: Nullable<any>;
  25794. actions: Nullable<any>;
  25795. freezeWorldMatrix: Nullable<boolean>;
  25796. };
  25797. /** @hidden */
  25798. _bonesTransformMatrices: Nullable<Float32Array>;
  25799. /** @hidden */
  25800. _transformMatrixTexture: Nullable<RawTexture>;
  25801. /**
  25802. * Gets or sets a skeleton to apply skining transformations
  25803. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25804. */
  25805. skeleton: Nullable<Skeleton>;
  25806. /**
  25807. * An event triggered when the mesh is rebuilt.
  25808. */
  25809. onRebuildObservable: Observable<AbstractMesh>;
  25810. /**
  25811. * Creates a new AbstractMesh
  25812. * @param name defines the name of the mesh
  25813. * @param scene defines the hosting scene
  25814. */
  25815. constructor(name: string, scene?: Nullable<Scene>);
  25816. /**
  25817. * Returns the string "AbstractMesh"
  25818. * @returns "AbstractMesh"
  25819. */
  25820. getClassName(): string;
  25821. /**
  25822. * Gets a string representation of the current mesh
  25823. * @param fullDetails defines a boolean indicating if full details must be included
  25824. * @returns a string representation of the current mesh
  25825. */
  25826. toString(fullDetails?: boolean): string;
  25827. /**
  25828. * @hidden
  25829. */
  25830. protected _getEffectiveParent(): Nullable<Node>;
  25831. /** @hidden */
  25832. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25833. /** @hidden */
  25834. _rebuild(): void;
  25835. /** @hidden */
  25836. _resyncLightSources(): void;
  25837. /** @hidden */
  25838. _resyncLighSource(light: Light): void;
  25839. /** @hidden */
  25840. _unBindEffect(): void;
  25841. /** @hidden */
  25842. _removeLightSource(light: Light): void;
  25843. private _markSubMeshesAsDirty;
  25844. /** @hidden */
  25845. _markSubMeshesAsLightDirty(): void;
  25846. /** @hidden */
  25847. _markSubMeshesAsAttributesDirty(): void;
  25848. /** @hidden */
  25849. _markSubMeshesAsMiscDirty(): void;
  25850. /**
  25851. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25852. */
  25853. scaling: Vector3;
  25854. /**
  25855. * Returns true if the mesh is blocked. Implemented by child classes
  25856. */
  25857. readonly isBlocked: boolean;
  25858. /**
  25859. * Returns the mesh itself by default. Implemented by child classes
  25860. * @param camera defines the camera to use to pick the right LOD level
  25861. * @returns the currentAbstractMesh
  25862. */
  25863. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25864. /**
  25865. * Returns 0 by default. Implemented by child classes
  25866. * @returns an integer
  25867. */
  25868. getTotalVertices(): number;
  25869. /**
  25870. * Returns a positive integer : the total number of indices in this mesh geometry.
  25871. * @returns the numner of indices or zero if the mesh has no geometry.
  25872. */
  25873. getTotalIndices(): number;
  25874. /**
  25875. * Returns null by default. Implemented by child classes
  25876. * @returns null
  25877. */
  25878. getIndices(): Nullable<IndicesArray>;
  25879. /**
  25880. * Returns the array of the requested vertex data kind. Implemented by child classes
  25881. * @param kind defines the vertex data kind to use
  25882. * @returns null
  25883. */
  25884. getVerticesData(kind: string): Nullable<FloatArray>;
  25885. /**
  25886. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25887. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25888. * Note that a new underlying VertexBuffer object is created each call.
  25889. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25890. * @param kind defines vertex data kind:
  25891. * * VertexBuffer.PositionKind
  25892. * * VertexBuffer.UVKind
  25893. * * VertexBuffer.UV2Kind
  25894. * * VertexBuffer.UV3Kind
  25895. * * VertexBuffer.UV4Kind
  25896. * * VertexBuffer.UV5Kind
  25897. * * VertexBuffer.UV6Kind
  25898. * * VertexBuffer.ColorKind
  25899. * * VertexBuffer.MatricesIndicesKind
  25900. * * VertexBuffer.MatricesIndicesExtraKind
  25901. * * VertexBuffer.MatricesWeightsKind
  25902. * * VertexBuffer.MatricesWeightsExtraKind
  25903. * @param data defines the data source
  25904. * @param updatable defines if the data must be flagged as updatable (or static)
  25905. * @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
  25906. * @returns the current mesh
  25907. */
  25908. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25909. /**
  25910. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25911. * If the mesh has no geometry, it is simply returned as it is.
  25912. * @param kind defines vertex data kind:
  25913. * * VertexBuffer.PositionKind
  25914. * * VertexBuffer.UVKind
  25915. * * VertexBuffer.UV2Kind
  25916. * * VertexBuffer.UV3Kind
  25917. * * VertexBuffer.UV4Kind
  25918. * * VertexBuffer.UV5Kind
  25919. * * VertexBuffer.UV6Kind
  25920. * * VertexBuffer.ColorKind
  25921. * * VertexBuffer.MatricesIndicesKind
  25922. * * VertexBuffer.MatricesIndicesExtraKind
  25923. * * VertexBuffer.MatricesWeightsKind
  25924. * * VertexBuffer.MatricesWeightsExtraKind
  25925. * @param data defines the data source
  25926. * @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
  25927. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25928. * @returns the current mesh
  25929. */
  25930. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25931. /**
  25932. * Sets the mesh indices,
  25933. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25934. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25935. * @param totalVertices Defines the total number of vertices
  25936. * @returns the current mesh
  25937. */
  25938. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25939. /**
  25940. * Gets a boolean indicating if specific vertex data is present
  25941. * @param kind defines the vertex data kind to use
  25942. * @returns true is data kind is present
  25943. */
  25944. isVerticesDataPresent(kind: string): boolean;
  25945. /**
  25946. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25947. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25948. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25949. * @returns a BoundingInfo
  25950. */
  25951. getBoundingInfo(): BoundingInfo;
  25952. /**
  25953. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25954. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25955. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25956. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25957. * @returns the current mesh
  25958. */
  25959. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25960. /**
  25961. * Overwrite the current bounding info
  25962. * @param boundingInfo defines the new bounding info
  25963. * @returns the current mesh
  25964. */
  25965. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25966. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25967. readonly useBones: boolean;
  25968. /** @hidden */
  25969. _preActivate(): void;
  25970. /** @hidden */
  25971. _preActivateForIntermediateRendering(renderId: number): void;
  25972. /** @hidden */
  25973. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25974. /** @hidden */
  25975. _postActivate(): void;
  25976. /** @hidden */
  25977. _freeze(): void;
  25978. /** @hidden */
  25979. _unFreeze(): void;
  25980. /**
  25981. * Gets the current world matrix
  25982. * @returns a Matrix
  25983. */
  25984. getWorldMatrix(): Matrix;
  25985. /** @hidden */
  25986. _getWorldMatrixDeterminant(): number;
  25987. /**
  25988. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25989. */
  25990. readonly isAnInstance: boolean;
  25991. /**
  25992. * Perform relative position change from the point of view of behind the front of the mesh.
  25993. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25994. * Supports definition of mesh facing forward or backward
  25995. * @param amountRight defines the distance on the right axis
  25996. * @param amountUp defines the distance on the up axis
  25997. * @param amountForward defines the distance on the forward axis
  25998. * @returns the current mesh
  25999. */
  26000. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26001. /**
  26002. * Calculate relative position change from the point of view of behind the front of the mesh.
  26003. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26004. * Supports definition of mesh facing forward or backward
  26005. * @param amountRight defines the distance on the right axis
  26006. * @param amountUp defines the distance on the up axis
  26007. * @param amountForward defines the distance on the forward axis
  26008. * @returns the new displacement vector
  26009. */
  26010. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26011. /**
  26012. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26013. * Supports definition of mesh facing forward or backward
  26014. * @param flipBack defines the flip
  26015. * @param twirlClockwise defines the twirl
  26016. * @param tiltRight defines the tilt
  26017. * @returns the current mesh
  26018. */
  26019. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26020. /**
  26021. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26022. * Supports definition of mesh facing forward or backward.
  26023. * @param flipBack defines the flip
  26024. * @param twirlClockwise defines the twirl
  26025. * @param tiltRight defines the tilt
  26026. * @returns the new rotation vector
  26027. */
  26028. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26029. /**
  26030. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26031. * This means the mesh underlying bounding box and sphere are recomputed.
  26032. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26033. * @returns the current mesh
  26034. */
  26035. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26036. /** @hidden */
  26037. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26038. /** @hidden */
  26039. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26040. /** @hidden */
  26041. _updateBoundingInfo(): AbstractMesh;
  26042. /** @hidden */
  26043. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26044. /** @hidden */
  26045. protected _afterComputeWorldMatrix(): void;
  26046. /** @hidden */
  26047. readonly _effectiveMesh: AbstractMesh;
  26048. /**
  26049. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26050. * A mesh is in the frustum if its bounding box intersects the frustum
  26051. * @param frustumPlanes defines the frustum to test
  26052. * @returns true if the mesh is in the frustum planes
  26053. */
  26054. isInFrustum(frustumPlanes: Plane[]): boolean;
  26055. /**
  26056. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26057. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26058. * @param frustumPlanes defines the frustum to test
  26059. * @returns true if the mesh is completely in the frustum planes
  26060. */
  26061. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26062. /**
  26063. * True if the mesh intersects another mesh or a SolidParticle object
  26064. * @param mesh defines a target mesh or SolidParticle to test
  26065. * @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)
  26066. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26067. * @returns true if there is an intersection
  26068. */
  26069. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26070. /**
  26071. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26072. * @param point defines the point to test
  26073. * @returns true if there is an intersection
  26074. */
  26075. intersectsPoint(point: Vector3): boolean;
  26076. /**
  26077. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26078. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26079. */
  26080. checkCollisions: boolean;
  26081. /**
  26082. * Gets Collider object used to compute collisions (not physics)
  26083. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26084. */
  26085. readonly collider: Nullable<Collider>;
  26086. /**
  26087. * Move the mesh using collision engine
  26088. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26089. * @param displacement defines the requested displacement vector
  26090. * @returns the current mesh
  26091. */
  26092. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26093. private _onCollisionPositionChange;
  26094. /** @hidden */
  26095. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26096. /** @hidden */
  26097. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26098. /** @hidden */
  26099. _checkCollision(collider: Collider): AbstractMesh;
  26100. /** @hidden */
  26101. _generatePointsArray(): boolean;
  26102. /**
  26103. * Checks if the passed Ray intersects with the mesh
  26104. * @param ray defines the ray to use
  26105. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26106. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26107. * @returns the picking info
  26108. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26109. */
  26110. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26111. /**
  26112. * Clones the current mesh
  26113. * @param name defines the mesh name
  26114. * @param newParent defines the new mesh parent
  26115. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26116. * @returns the new mesh
  26117. */
  26118. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26119. /**
  26120. * Disposes all the submeshes of the current meshnp
  26121. * @returns the current mesh
  26122. */
  26123. releaseSubMeshes(): AbstractMesh;
  26124. /**
  26125. * Releases resources associated with this abstract mesh.
  26126. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26127. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26128. */
  26129. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26130. /**
  26131. * Adds the passed mesh as a child to the current mesh
  26132. * @param mesh defines the child mesh
  26133. * @returns the current mesh
  26134. */
  26135. addChild(mesh: AbstractMesh): AbstractMesh;
  26136. /**
  26137. * Removes the passed mesh from the current mesh children list
  26138. * @param mesh defines the child mesh
  26139. * @returns the current mesh
  26140. */
  26141. removeChild(mesh: AbstractMesh): AbstractMesh;
  26142. /** @hidden */
  26143. private _initFacetData;
  26144. /**
  26145. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26146. * This method can be called within the render loop.
  26147. * 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
  26148. * @returns the current mesh
  26149. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26150. */
  26151. updateFacetData(): AbstractMesh;
  26152. /**
  26153. * Returns the facetLocalNormals array.
  26154. * The normals are expressed in the mesh local spac
  26155. * @returns an array of Vector3
  26156. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26157. */
  26158. getFacetLocalNormals(): Vector3[];
  26159. /**
  26160. * Returns the facetLocalPositions array.
  26161. * The facet positions are expressed in the mesh local space
  26162. * @returns an array of Vector3
  26163. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26164. */
  26165. getFacetLocalPositions(): Vector3[];
  26166. /**
  26167. * Returns the facetLocalPartioning array
  26168. * @returns an array of array of numbers
  26169. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26170. */
  26171. getFacetLocalPartitioning(): number[][];
  26172. /**
  26173. * Returns the i-th facet position in the world system.
  26174. * This method allocates a new Vector3 per call
  26175. * @param i defines the facet index
  26176. * @returns a new Vector3
  26177. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26178. */
  26179. getFacetPosition(i: number): Vector3;
  26180. /**
  26181. * Sets the reference Vector3 with the i-th facet position in the world system
  26182. * @param i defines the facet index
  26183. * @param ref defines the target vector
  26184. * @returns the current mesh
  26185. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26186. */
  26187. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26188. /**
  26189. * Returns the i-th facet normal in the world system.
  26190. * This method allocates a new Vector3 per call
  26191. * @param i defines the facet index
  26192. * @returns a new Vector3
  26193. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26194. */
  26195. getFacetNormal(i: number): Vector3;
  26196. /**
  26197. * Sets the reference Vector3 with the i-th facet normal in the world system
  26198. * @param i defines the facet index
  26199. * @param ref defines the target vector
  26200. * @returns the current mesh
  26201. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26202. */
  26203. getFacetNormalToRef(i: number, ref: Vector3): this;
  26204. /**
  26205. * 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)
  26206. * @param x defines x coordinate
  26207. * @param y defines y coordinate
  26208. * @param z defines z coordinate
  26209. * @returns the array of facet indexes
  26210. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26211. */
  26212. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26213. /**
  26214. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26215. * @param projected sets as the (x,y,z) world projection on the facet
  26216. * @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
  26217. * @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
  26218. * @param x defines x coordinate
  26219. * @param y defines y coordinate
  26220. * @param z defines z coordinate
  26221. * @returns the face index if found (or null instead)
  26222. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26223. */
  26224. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26225. /**
  26226. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26227. * @param projected sets as the (x,y,z) local projection on the facet
  26228. * @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
  26229. * @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
  26230. * @param x defines x coordinate
  26231. * @param y defines y coordinate
  26232. * @param z defines z coordinate
  26233. * @returns the face index if found (or null instead)
  26234. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26235. */
  26236. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26237. /**
  26238. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26239. * @returns the parameters
  26240. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26241. */
  26242. getFacetDataParameters(): any;
  26243. /**
  26244. * Disables the feature FacetData and frees the related memory
  26245. * @returns the current mesh
  26246. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26247. */
  26248. disableFacetData(): AbstractMesh;
  26249. /**
  26250. * Updates the AbstractMesh indices array
  26251. * @param indices defines the data source
  26252. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26253. * @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)
  26254. * @returns the current mesh
  26255. */
  26256. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26257. /**
  26258. * Creates new normals data for the mesh
  26259. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26260. * @returns the current mesh
  26261. */
  26262. createNormals(updatable: boolean): AbstractMesh;
  26263. /**
  26264. * Align the mesh with a normal
  26265. * @param normal defines the normal to use
  26266. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26267. * @returns the current mesh
  26268. */
  26269. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26270. /** @hidden */
  26271. _checkOcclusionQuery(): boolean;
  26272. /**
  26273. * Disables the mesh edge rendering mode
  26274. * @returns the currentAbstractMesh
  26275. */
  26276. disableEdgesRendering(): AbstractMesh;
  26277. /**
  26278. * Enables the edge rendering mode on the mesh.
  26279. * This mode makes the mesh edges visible
  26280. * @param epsilon defines the maximal distance between two angles to detect a face
  26281. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26282. * @returns the currentAbstractMesh
  26283. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26284. */
  26285. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26286. }
  26287. }
  26288. declare module BABYLON {
  26289. /**
  26290. * Interface used to define ActionEvent
  26291. */
  26292. export interface IActionEvent {
  26293. /** The mesh or sprite that triggered the action */
  26294. source: any;
  26295. /** The X mouse cursor position at the time of the event */
  26296. pointerX: number;
  26297. /** The Y mouse cursor position at the time of the event */
  26298. pointerY: number;
  26299. /** The mesh that is currently pointed at (can be null) */
  26300. meshUnderPointer: Nullable<AbstractMesh>;
  26301. /** the original (browser) event that triggered the ActionEvent */
  26302. sourceEvent?: any;
  26303. /** additional data for the event */
  26304. additionalData?: any;
  26305. }
  26306. /**
  26307. * ActionEvent is the event being sent when an action is triggered.
  26308. */
  26309. export class ActionEvent implements IActionEvent {
  26310. /** The mesh or sprite that triggered the action */
  26311. source: any;
  26312. /** The X mouse cursor position at the time of the event */
  26313. pointerX: number;
  26314. /** The Y mouse cursor position at the time of the event */
  26315. pointerY: number;
  26316. /** The mesh that is currently pointed at (can be null) */
  26317. meshUnderPointer: Nullable<AbstractMesh>;
  26318. /** the original (browser) event that triggered the ActionEvent */
  26319. sourceEvent?: any;
  26320. /** additional data for the event */
  26321. additionalData?: any;
  26322. /**
  26323. * Creates a new ActionEvent
  26324. * @param source The mesh or sprite that triggered the action
  26325. * @param pointerX The X mouse cursor position at the time of the event
  26326. * @param pointerY The Y mouse cursor position at the time of the event
  26327. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26328. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26329. * @param additionalData additional data for the event
  26330. */
  26331. constructor(
  26332. /** The mesh or sprite that triggered the action */
  26333. source: any,
  26334. /** The X mouse cursor position at the time of the event */
  26335. pointerX: number,
  26336. /** The Y mouse cursor position at the time of the event */
  26337. pointerY: number,
  26338. /** The mesh that is currently pointed at (can be null) */
  26339. meshUnderPointer: Nullable<AbstractMesh>,
  26340. /** the original (browser) event that triggered the ActionEvent */
  26341. sourceEvent?: any,
  26342. /** additional data for the event */
  26343. additionalData?: any);
  26344. /**
  26345. * Helper function to auto-create an ActionEvent from a source mesh.
  26346. * @param source The source mesh that triggered the event
  26347. * @param evt The original (browser) event
  26348. * @param additionalData additional data for the event
  26349. * @returns the new ActionEvent
  26350. */
  26351. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26352. /**
  26353. * Helper function to auto-create an ActionEvent from a source sprite
  26354. * @param source The source sprite that triggered the event
  26355. * @param scene Scene associated with the sprite
  26356. * @param evt The original (browser) event
  26357. * @param additionalData additional data for the event
  26358. * @returns the new ActionEvent
  26359. */
  26360. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26361. /**
  26362. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26363. * @param scene the scene where the event occurred
  26364. * @param evt The original (browser) event
  26365. * @returns the new ActionEvent
  26366. */
  26367. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26368. /**
  26369. * Helper function to auto-create an ActionEvent from a primitive
  26370. * @param prim defines the target primitive
  26371. * @param pointerPos defines the pointer position
  26372. * @param evt The original (browser) event
  26373. * @param additionalData additional data for the event
  26374. * @returns the new ActionEvent
  26375. */
  26376. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26377. }
  26378. }
  26379. declare module BABYLON {
  26380. /**
  26381. * Abstract class used to decouple action Manager from scene and meshes.
  26382. * Do not instantiate.
  26383. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26384. */
  26385. export abstract class AbstractActionManager implements IDisposable {
  26386. /** Gets the list of active triggers */
  26387. static Triggers: {
  26388. [key: string]: number;
  26389. };
  26390. /** Gets the cursor to use when hovering items */
  26391. hoverCursor: string;
  26392. /** Gets the list of actions */
  26393. actions: IAction[];
  26394. /**
  26395. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26396. */
  26397. isRecursive: boolean;
  26398. /**
  26399. * Releases all associated resources
  26400. */
  26401. abstract dispose(): void;
  26402. /**
  26403. * Does this action manager has pointer triggers
  26404. */
  26405. abstract readonly hasPointerTriggers: boolean;
  26406. /**
  26407. * Does this action manager has pick triggers
  26408. */
  26409. abstract readonly hasPickTriggers: boolean;
  26410. /**
  26411. * Process a specific trigger
  26412. * @param trigger defines the trigger to process
  26413. * @param evt defines the event details to be processed
  26414. */
  26415. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26416. /**
  26417. * Does this action manager handles actions of any of the given triggers
  26418. * @param triggers defines the triggers to be tested
  26419. * @return a boolean indicating whether one (or more) of the triggers is handled
  26420. */
  26421. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26422. /**
  26423. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26424. * speed.
  26425. * @param triggerA defines the trigger to be tested
  26426. * @param triggerB defines the trigger to be tested
  26427. * @return a boolean indicating whether one (or more) of the triggers is handled
  26428. */
  26429. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26430. /**
  26431. * Does this action manager handles actions of a given trigger
  26432. * @param trigger defines the trigger to be tested
  26433. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26434. * @return whether the trigger is handled
  26435. */
  26436. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26437. /**
  26438. * Serialize this manager to a JSON object
  26439. * @param name defines the property name to store this manager
  26440. * @returns a JSON representation of this manager
  26441. */
  26442. abstract serialize(name: string): any;
  26443. /**
  26444. * Registers an action to this action manager
  26445. * @param action defines the action to be registered
  26446. * @return the action amended (prepared) after registration
  26447. */
  26448. abstract registerAction(action: IAction): Nullable<IAction>;
  26449. /**
  26450. * Unregisters an action to this action manager
  26451. * @param action defines the action to be unregistered
  26452. * @return a boolean indicating whether the action has been unregistered
  26453. */
  26454. abstract unregisterAction(action: IAction): Boolean;
  26455. /**
  26456. * Does exist one action manager with at least one trigger
  26457. **/
  26458. static readonly HasTriggers: boolean;
  26459. /**
  26460. * Does exist one action manager with at least one pick trigger
  26461. **/
  26462. static readonly HasPickTriggers: boolean;
  26463. /**
  26464. * Does exist one action manager that handles actions of a given trigger
  26465. * @param trigger defines the trigger to be tested
  26466. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26467. **/
  26468. static HasSpecificTrigger(trigger: number): boolean;
  26469. }
  26470. }
  26471. declare module BABYLON {
  26472. /**
  26473. * Defines how a node can be built from a string name.
  26474. */
  26475. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26476. /**
  26477. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26478. */
  26479. export class Node implements IBehaviorAware<Node> {
  26480. /** @hidden */
  26481. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26482. private static _NodeConstructors;
  26483. /**
  26484. * Add a new node constructor
  26485. * @param type defines the type name of the node to construct
  26486. * @param constructorFunc defines the constructor function
  26487. */
  26488. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26489. /**
  26490. * Returns a node constructor based on type name
  26491. * @param type defines the type name
  26492. * @param name defines the new node name
  26493. * @param scene defines the hosting scene
  26494. * @param options defines optional options to transmit to constructors
  26495. * @returns the new constructor or null
  26496. */
  26497. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26498. /**
  26499. * Gets or sets the name of the node
  26500. */
  26501. name: string;
  26502. /**
  26503. * Gets or sets the id of the node
  26504. */
  26505. id: string;
  26506. /**
  26507. * Gets or sets the unique id of the node
  26508. */
  26509. uniqueId: number;
  26510. /**
  26511. * Gets or sets a string used to store user defined state for the node
  26512. */
  26513. state: string;
  26514. /**
  26515. * Gets or sets an object used to store user defined information for the node
  26516. */
  26517. metadata: any;
  26518. /**
  26519. * For internal use only. Please do not use.
  26520. */
  26521. reservedDataStore: any;
  26522. /**
  26523. * List of inspectable custom properties (used by the Inspector)
  26524. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26525. */
  26526. inspectableCustomProperties: IInspectable[];
  26527. /**
  26528. * Gets or sets a boolean used to define if the node must be serialized
  26529. */
  26530. doNotSerialize: boolean;
  26531. /** @hidden */
  26532. _isDisposed: boolean;
  26533. /**
  26534. * Gets a list of Animations associated with the node
  26535. */
  26536. animations: Animation[];
  26537. protected _ranges: {
  26538. [name: string]: Nullable<AnimationRange>;
  26539. };
  26540. /**
  26541. * Callback raised when the node is ready to be used
  26542. */
  26543. onReady: Nullable<(node: Node) => void>;
  26544. private _isEnabled;
  26545. private _isParentEnabled;
  26546. private _isReady;
  26547. /** @hidden */
  26548. _currentRenderId: number;
  26549. private _parentUpdateId;
  26550. /** @hidden */
  26551. _childUpdateId: number;
  26552. /** @hidden */
  26553. _waitingParentId: Nullable<string>;
  26554. /** @hidden */
  26555. _scene: Scene;
  26556. /** @hidden */
  26557. _cache: any;
  26558. private _parentNode;
  26559. private _children;
  26560. /** @hidden */
  26561. _worldMatrix: Matrix;
  26562. /** @hidden */
  26563. _worldMatrixDeterminant: number;
  26564. /** @hidden */
  26565. _worldMatrixDeterminantIsDirty: boolean;
  26566. /** @hidden */
  26567. private _sceneRootNodesIndex;
  26568. /**
  26569. * Gets a boolean indicating if the node has been disposed
  26570. * @returns true if the node was disposed
  26571. */
  26572. isDisposed(): boolean;
  26573. /**
  26574. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26575. * @see https://doc.babylonjs.com/how_to/parenting
  26576. */
  26577. parent: Nullable<Node>;
  26578. private addToSceneRootNodes;
  26579. private removeFromSceneRootNodes;
  26580. private _animationPropertiesOverride;
  26581. /**
  26582. * Gets or sets the animation properties override
  26583. */
  26584. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26585. /**
  26586. * Gets a string idenfifying the name of the class
  26587. * @returns "Node" string
  26588. */
  26589. getClassName(): string;
  26590. /** @hidden */
  26591. readonly _isNode: boolean;
  26592. /**
  26593. * An event triggered when the mesh is disposed
  26594. */
  26595. onDisposeObservable: Observable<Node>;
  26596. private _onDisposeObserver;
  26597. /**
  26598. * Sets a callback that will be raised when the node will be disposed
  26599. */
  26600. onDispose: () => void;
  26601. /**
  26602. * Creates a new Node
  26603. * @param name the name and id to be given to this node
  26604. * @param scene the scene this node will be added to
  26605. * @param addToRootNodes the node will be added to scene.rootNodes
  26606. */
  26607. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26608. /**
  26609. * Gets the scene of the node
  26610. * @returns a scene
  26611. */
  26612. getScene(): Scene;
  26613. /**
  26614. * Gets the engine of the node
  26615. * @returns a Engine
  26616. */
  26617. getEngine(): Engine;
  26618. private _behaviors;
  26619. /**
  26620. * Attach a behavior to the node
  26621. * @see http://doc.babylonjs.com/features/behaviour
  26622. * @param behavior defines the behavior to attach
  26623. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26624. * @returns the current Node
  26625. */
  26626. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26627. /**
  26628. * Remove an attached behavior
  26629. * @see http://doc.babylonjs.com/features/behaviour
  26630. * @param behavior defines the behavior to attach
  26631. * @returns the current Node
  26632. */
  26633. removeBehavior(behavior: Behavior<Node>): Node;
  26634. /**
  26635. * Gets the list of attached behaviors
  26636. * @see http://doc.babylonjs.com/features/behaviour
  26637. */
  26638. readonly behaviors: Behavior<Node>[];
  26639. /**
  26640. * Gets an attached behavior by name
  26641. * @param name defines the name of the behavior to look for
  26642. * @see http://doc.babylonjs.com/features/behaviour
  26643. * @returns null if behavior was not found else the requested behavior
  26644. */
  26645. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26646. /**
  26647. * Returns the latest update of the World matrix
  26648. * @returns a Matrix
  26649. */
  26650. getWorldMatrix(): Matrix;
  26651. /** @hidden */
  26652. _getWorldMatrixDeterminant(): number;
  26653. /**
  26654. * Returns directly the latest state of the mesh World matrix.
  26655. * A Matrix is returned.
  26656. */
  26657. readonly worldMatrixFromCache: Matrix;
  26658. /** @hidden */
  26659. _initCache(): void;
  26660. /** @hidden */
  26661. updateCache(force?: boolean): void;
  26662. /** @hidden */
  26663. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26664. /** @hidden */
  26665. _updateCache(ignoreParentClass?: boolean): void;
  26666. /** @hidden */
  26667. _isSynchronized(): boolean;
  26668. /** @hidden */
  26669. _markSyncedWithParent(): void;
  26670. /** @hidden */
  26671. isSynchronizedWithParent(): boolean;
  26672. /** @hidden */
  26673. isSynchronized(): boolean;
  26674. /**
  26675. * Is this node ready to be used/rendered
  26676. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26677. * @return true if the node is ready
  26678. */
  26679. isReady(completeCheck?: boolean): boolean;
  26680. /**
  26681. * Is this node enabled?
  26682. * 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
  26683. * @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
  26684. * @return whether this node (and its parent) is enabled
  26685. */
  26686. isEnabled(checkAncestors?: boolean): boolean;
  26687. /** @hidden */
  26688. protected _syncParentEnabledState(): void;
  26689. /**
  26690. * Set the enabled state of this node
  26691. * @param value defines the new enabled state
  26692. */
  26693. setEnabled(value: boolean): void;
  26694. /**
  26695. * Is this node a descendant of the given node?
  26696. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26697. * @param ancestor defines the parent node to inspect
  26698. * @returns a boolean indicating if this node is a descendant of the given node
  26699. */
  26700. isDescendantOf(ancestor: Node): boolean;
  26701. /** @hidden */
  26702. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26703. /**
  26704. * Will return all nodes that have this node as ascendant
  26705. * @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
  26706. * @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
  26707. * @return all children nodes of all types
  26708. */
  26709. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26710. /**
  26711. * Get all child-meshes of this node
  26712. * @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)
  26713. * @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
  26714. * @returns an array of AbstractMesh
  26715. */
  26716. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26717. /**
  26718. * Get all direct children of this node
  26719. * @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
  26720. * @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)
  26721. * @returns an array of Node
  26722. */
  26723. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26724. /** @hidden */
  26725. _setReady(state: boolean): void;
  26726. /**
  26727. * Get an animation by name
  26728. * @param name defines the name of the animation to look for
  26729. * @returns null if not found else the requested animation
  26730. */
  26731. getAnimationByName(name: string): Nullable<Animation>;
  26732. /**
  26733. * Creates an animation range for this node
  26734. * @param name defines the name of the range
  26735. * @param from defines the starting key
  26736. * @param to defines the end key
  26737. */
  26738. createAnimationRange(name: string, from: number, to: number): void;
  26739. /**
  26740. * Delete a specific animation range
  26741. * @param name defines the name of the range to delete
  26742. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26743. */
  26744. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26745. /**
  26746. * Get an animation range by name
  26747. * @param name defines the name of the animation range to look for
  26748. * @returns null if not found else the requested animation range
  26749. */
  26750. getAnimationRange(name: string): Nullable<AnimationRange>;
  26751. /**
  26752. * Gets the list of all animation ranges defined on this node
  26753. * @returns an array
  26754. */
  26755. getAnimationRanges(): Nullable<AnimationRange>[];
  26756. /**
  26757. * Will start the animation sequence
  26758. * @param name defines the range frames for animation sequence
  26759. * @param loop defines if the animation should loop (false by default)
  26760. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26761. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26762. * @returns the object created for this animation. If range does not exist, it will return null
  26763. */
  26764. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26765. /**
  26766. * Serialize animation ranges into a JSON compatible object
  26767. * @returns serialization object
  26768. */
  26769. serializeAnimationRanges(): any;
  26770. /**
  26771. * Computes the world matrix of the node
  26772. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26773. * @returns the world matrix
  26774. */
  26775. computeWorldMatrix(force?: boolean): Matrix;
  26776. /**
  26777. * Releases resources associated with this node.
  26778. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26779. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26780. */
  26781. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26782. /**
  26783. * Parse animation range data from a serialization object and store them into a given node
  26784. * @param node defines where to store the animation ranges
  26785. * @param parsedNode defines the serialization object to read data from
  26786. * @param scene defines the hosting scene
  26787. */
  26788. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26789. /**
  26790. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26791. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26792. * @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
  26793. * @returns the new bounding vectors
  26794. */
  26795. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26796. min: Vector3;
  26797. max: Vector3;
  26798. };
  26799. }
  26800. }
  26801. declare module BABYLON {
  26802. /**
  26803. * @hidden
  26804. */
  26805. export class _IAnimationState {
  26806. key: number;
  26807. repeatCount: number;
  26808. workValue?: any;
  26809. loopMode?: number;
  26810. offsetValue?: any;
  26811. highLimitValue?: any;
  26812. }
  26813. /**
  26814. * Class used to store any kind of animation
  26815. */
  26816. export class Animation {
  26817. /**Name of the animation */
  26818. name: string;
  26819. /**Property to animate */
  26820. targetProperty: string;
  26821. /**The frames per second of the animation */
  26822. framePerSecond: number;
  26823. /**The data type of the animation */
  26824. dataType: number;
  26825. /**The loop mode of the animation */
  26826. loopMode?: number | undefined;
  26827. /**Specifies if blending should be enabled */
  26828. enableBlending?: boolean | undefined;
  26829. /**
  26830. * Use matrix interpolation instead of using direct key value when animating matrices
  26831. */
  26832. static AllowMatricesInterpolation: boolean;
  26833. /**
  26834. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26835. */
  26836. static AllowMatrixDecomposeForInterpolation: boolean;
  26837. /**
  26838. * Stores the key frames of the animation
  26839. */
  26840. private _keys;
  26841. /**
  26842. * Stores the easing function of the animation
  26843. */
  26844. private _easingFunction;
  26845. /**
  26846. * @hidden Internal use only
  26847. */
  26848. _runtimeAnimations: RuntimeAnimation[];
  26849. /**
  26850. * The set of event that will be linked to this animation
  26851. */
  26852. private _events;
  26853. /**
  26854. * Stores an array of target property paths
  26855. */
  26856. targetPropertyPath: string[];
  26857. /**
  26858. * Stores the blending speed of the animation
  26859. */
  26860. blendingSpeed: number;
  26861. /**
  26862. * Stores the animation ranges for the animation
  26863. */
  26864. private _ranges;
  26865. /**
  26866. * @hidden Internal use
  26867. */
  26868. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26869. /**
  26870. * Sets up an animation
  26871. * @param property The property to animate
  26872. * @param animationType The animation type to apply
  26873. * @param framePerSecond The frames per second of the animation
  26874. * @param easingFunction The easing function used in the animation
  26875. * @returns The created animation
  26876. */
  26877. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26878. /**
  26879. * Create and start an animation on a node
  26880. * @param name defines the name of the global animation that will be run on all nodes
  26881. * @param node defines the root node where the animation will take place
  26882. * @param targetProperty defines property to animate
  26883. * @param framePerSecond defines the number of frame per second yo use
  26884. * @param totalFrame defines the number of frames in total
  26885. * @param from defines the initial value
  26886. * @param to defines the final value
  26887. * @param loopMode defines which loop mode you want to use (off by default)
  26888. * @param easingFunction defines the easing function to use (linear by default)
  26889. * @param onAnimationEnd defines the callback to call when animation end
  26890. * @returns the animatable created for this animation
  26891. */
  26892. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26893. /**
  26894. * Create and start an animation on a node and its descendants
  26895. * @param name defines the name of the global animation that will be run on all nodes
  26896. * @param node defines the root node where the animation will take place
  26897. * @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
  26898. * @param targetProperty defines property to animate
  26899. * @param framePerSecond defines the number of frame per second to use
  26900. * @param totalFrame defines the number of frames in total
  26901. * @param from defines the initial value
  26902. * @param to defines the final value
  26903. * @param loopMode defines which loop mode you want to use (off by default)
  26904. * @param easingFunction defines the easing function to use (linear by default)
  26905. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26906. * @returns the list of animatables created for all nodes
  26907. * @example https://www.babylonjs-playground.com/#MH0VLI
  26908. */
  26909. 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[]>;
  26910. /**
  26911. * Creates a new animation, merges it with the existing animations and starts it
  26912. * @param name Name of the animation
  26913. * @param node Node which contains the scene that begins the animations
  26914. * @param targetProperty Specifies which property to animate
  26915. * @param framePerSecond The frames per second of the animation
  26916. * @param totalFrame The total number of frames
  26917. * @param from The frame at the beginning of the animation
  26918. * @param to The frame at the end of the animation
  26919. * @param loopMode Specifies the loop mode of the animation
  26920. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26921. * @param onAnimationEnd Callback to run once the animation is complete
  26922. * @returns Nullable animation
  26923. */
  26924. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26925. /**
  26926. * Transition property of an host to the target Value
  26927. * @param property The property to transition
  26928. * @param targetValue The target Value of the property
  26929. * @param host The object where the property to animate belongs
  26930. * @param scene Scene used to run the animation
  26931. * @param frameRate Framerate (in frame/s) to use
  26932. * @param transition The transition type we want to use
  26933. * @param duration The duration of the animation, in milliseconds
  26934. * @param onAnimationEnd Callback trigger at the end of the animation
  26935. * @returns Nullable animation
  26936. */
  26937. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26938. /**
  26939. * Return the array of runtime animations currently using this animation
  26940. */
  26941. readonly runtimeAnimations: RuntimeAnimation[];
  26942. /**
  26943. * Specifies if any of the runtime animations are currently running
  26944. */
  26945. readonly hasRunningRuntimeAnimations: boolean;
  26946. /**
  26947. * Initializes the animation
  26948. * @param name Name of the animation
  26949. * @param targetProperty Property to animate
  26950. * @param framePerSecond The frames per second of the animation
  26951. * @param dataType The data type of the animation
  26952. * @param loopMode The loop mode of the animation
  26953. * @param enableBlending Specifies if blending should be enabled
  26954. */
  26955. constructor(
  26956. /**Name of the animation */
  26957. name: string,
  26958. /**Property to animate */
  26959. targetProperty: string,
  26960. /**The frames per second of the animation */
  26961. framePerSecond: number,
  26962. /**The data type of the animation */
  26963. dataType: number,
  26964. /**The loop mode of the animation */
  26965. loopMode?: number | undefined,
  26966. /**Specifies if blending should be enabled */
  26967. enableBlending?: boolean | undefined);
  26968. /**
  26969. * Converts the animation to a string
  26970. * @param fullDetails support for multiple levels of logging within scene loading
  26971. * @returns String form of the animation
  26972. */
  26973. toString(fullDetails?: boolean): string;
  26974. /**
  26975. * Add an event to this animation
  26976. * @param event Event to add
  26977. */
  26978. addEvent(event: AnimationEvent): void;
  26979. /**
  26980. * Remove all events found at the given frame
  26981. * @param frame The frame to remove events from
  26982. */
  26983. removeEvents(frame: number): void;
  26984. /**
  26985. * Retrieves all the events from the animation
  26986. * @returns Events from the animation
  26987. */
  26988. getEvents(): AnimationEvent[];
  26989. /**
  26990. * Creates an animation range
  26991. * @param name Name of the animation range
  26992. * @param from Starting frame of the animation range
  26993. * @param to Ending frame of the animation
  26994. */
  26995. createRange(name: string, from: number, to: number): void;
  26996. /**
  26997. * Deletes an animation range by name
  26998. * @param name Name of the animation range to delete
  26999. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27000. */
  27001. deleteRange(name: string, deleteFrames?: boolean): void;
  27002. /**
  27003. * Gets the animation range by name, or null if not defined
  27004. * @param name Name of the animation range
  27005. * @returns Nullable animation range
  27006. */
  27007. getRange(name: string): Nullable<AnimationRange>;
  27008. /**
  27009. * Gets the key frames from the animation
  27010. * @returns The key frames of the animation
  27011. */
  27012. getKeys(): Array<IAnimationKey>;
  27013. /**
  27014. * Gets the highest frame rate of the animation
  27015. * @returns Highest frame rate of the animation
  27016. */
  27017. getHighestFrame(): number;
  27018. /**
  27019. * Gets the easing function of the animation
  27020. * @returns Easing function of the animation
  27021. */
  27022. getEasingFunction(): IEasingFunction;
  27023. /**
  27024. * Sets the easing function of the animation
  27025. * @param easingFunction A custom mathematical formula for animation
  27026. */
  27027. setEasingFunction(easingFunction: EasingFunction): void;
  27028. /**
  27029. * Interpolates a scalar linearly
  27030. * @param startValue Start value of the animation curve
  27031. * @param endValue End value of the animation curve
  27032. * @param gradient Scalar amount to interpolate
  27033. * @returns Interpolated scalar value
  27034. */
  27035. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27036. /**
  27037. * Interpolates a scalar cubically
  27038. * @param startValue Start value of the animation curve
  27039. * @param outTangent End tangent of the animation
  27040. * @param endValue End value of the animation curve
  27041. * @param inTangent Start tangent of the animation curve
  27042. * @param gradient Scalar amount to interpolate
  27043. * @returns Interpolated scalar value
  27044. */
  27045. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27046. /**
  27047. * Interpolates a quaternion using a spherical linear interpolation
  27048. * @param startValue Start value of the animation curve
  27049. * @param endValue End value of the animation curve
  27050. * @param gradient Scalar amount to interpolate
  27051. * @returns Interpolated quaternion value
  27052. */
  27053. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27054. /**
  27055. * Interpolates a quaternion cubically
  27056. * @param startValue Start value of the animation curve
  27057. * @param outTangent End tangent of the animation curve
  27058. * @param endValue End value of the animation curve
  27059. * @param inTangent Start tangent of the animation curve
  27060. * @param gradient Scalar amount to interpolate
  27061. * @returns Interpolated quaternion value
  27062. */
  27063. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27064. /**
  27065. * Interpolates a Vector3 linearl
  27066. * @param startValue Start value of the animation curve
  27067. * @param endValue End value of the animation curve
  27068. * @param gradient Scalar amount to interpolate
  27069. * @returns Interpolated scalar value
  27070. */
  27071. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27072. /**
  27073. * Interpolates a Vector3 cubically
  27074. * @param startValue Start value of the animation curve
  27075. * @param outTangent End tangent of the animation
  27076. * @param endValue End value of the animation curve
  27077. * @param inTangent Start tangent of the animation curve
  27078. * @param gradient Scalar amount to interpolate
  27079. * @returns InterpolatedVector3 value
  27080. */
  27081. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27082. /**
  27083. * Interpolates a Vector2 linearly
  27084. * @param startValue Start value of the animation curve
  27085. * @param endValue End value of the animation curve
  27086. * @param gradient Scalar amount to interpolate
  27087. * @returns Interpolated Vector2 value
  27088. */
  27089. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27090. /**
  27091. * Interpolates a Vector2 cubically
  27092. * @param startValue Start value of the animation curve
  27093. * @param outTangent End tangent of the animation
  27094. * @param endValue End value of the animation curve
  27095. * @param inTangent Start tangent of the animation curve
  27096. * @param gradient Scalar amount to interpolate
  27097. * @returns Interpolated Vector2 value
  27098. */
  27099. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27100. /**
  27101. * Interpolates a size linearly
  27102. * @param startValue Start value of the animation curve
  27103. * @param endValue End value of the animation curve
  27104. * @param gradient Scalar amount to interpolate
  27105. * @returns Interpolated Size value
  27106. */
  27107. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27108. /**
  27109. * Interpolates a Color3 linearly
  27110. * @param startValue Start value of the animation curve
  27111. * @param endValue End value of the animation curve
  27112. * @param gradient Scalar amount to interpolate
  27113. * @returns Interpolated Color3 value
  27114. */
  27115. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27116. /**
  27117. * @hidden Internal use only
  27118. */
  27119. _getKeyValue(value: any): any;
  27120. /**
  27121. * @hidden Internal use only
  27122. */
  27123. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27124. /**
  27125. * Defines the function to use to interpolate matrices
  27126. * @param startValue defines the start matrix
  27127. * @param endValue defines the end matrix
  27128. * @param gradient defines the gradient between both matrices
  27129. * @param result defines an optional target matrix where to store the interpolation
  27130. * @returns the interpolated matrix
  27131. */
  27132. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27133. /**
  27134. * Makes a copy of the animation
  27135. * @returns Cloned animation
  27136. */
  27137. clone(): Animation;
  27138. /**
  27139. * Sets the key frames of the animation
  27140. * @param values The animation key frames to set
  27141. */
  27142. setKeys(values: Array<IAnimationKey>): void;
  27143. /**
  27144. * Serializes the animation to an object
  27145. * @returns Serialized object
  27146. */
  27147. serialize(): any;
  27148. /**
  27149. * Float animation type
  27150. */
  27151. private static _ANIMATIONTYPE_FLOAT;
  27152. /**
  27153. * Vector3 animation type
  27154. */
  27155. private static _ANIMATIONTYPE_VECTOR3;
  27156. /**
  27157. * Quaternion animation type
  27158. */
  27159. private static _ANIMATIONTYPE_QUATERNION;
  27160. /**
  27161. * Matrix animation type
  27162. */
  27163. private static _ANIMATIONTYPE_MATRIX;
  27164. /**
  27165. * Color3 animation type
  27166. */
  27167. private static _ANIMATIONTYPE_COLOR3;
  27168. /**
  27169. * Vector2 animation type
  27170. */
  27171. private static _ANIMATIONTYPE_VECTOR2;
  27172. /**
  27173. * Size animation type
  27174. */
  27175. private static _ANIMATIONTYPE_SIZE;
  27176. /**
  27177. * Relative Loop Mode
  27178. */
  27179. private static _ANIMATIONLOOPMODE_RELATIVE;
  27180. /**
  27181. * Cycle Loop Mode
  27182. */
  27183. private static _ANIMATIONLOOPMODE_CYCLE;
  27184. /**
  27185. * Constant Loop Mode
  27186. */
  27187. private static _ANIMATIONLOOPMODE_CONSTANT;
  27188. /**
  27189. * Get the float animation type
  27190. */
  27191. static readonly ANIMATIONTYPE_FLOAT: number;
  27192. /**
  27193. * Get the Vector3 animation type
  27194. */
  27195. static readonly ANIMATIONTYPE_VECTOR3: number;
  27196. /**
  27197. * Get the Vector2 animation type
  27198. */
  27199. static readonly ANIMATIONTYPE_VECTOR2: number;
  27200. /**
  27201. * Get the Size animation type
  27202. */
  27203. static readonly ANIMATIONTYPE_SIZE: number;
  27204. /**
  27205. * Get the Quaternion animation type
  27206. */
  27207. static readonly ANIMATIONTYPE_QUATERNION: number;
  27208. /**
  27209. * Get the Matrix animation type
  27210. */
  27211. static readonly ANIMATIONTYPE_MATRIX: number;
  27212. /**
  27213. * Get the Color3 animation type
  27214. */
  27215. static readonly ANIMATIONTYPE_COLOR3: number;
  27216. /**
  27217. * Get the Relative Loop Mode
  27218. */
  27219. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27220. /**
  27221. * Get the Cycle Loop Mode
  27222. */
  27223. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27224. /**
  27225. * Get the Constant Loop Mode
  27226. */
  27227. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27228. /** @hidden */
  27229. static _UniversalLerp(left: any, right: any, amount: number): any;
  27230. /**
  27231. * Parses an animation object and creates an animation
  27232. * @param parsedAnimation Parsed animation object
  27233. * @returns Animation object
  27234. */
  27235. static Parse(parsedAnimation: any): Animation;
  27236. /**
  27237. * Appends the serialized animations from the source animations
  27238. * @param source Source containing the animations
  27239. * @param destination Target to store the animations
  27240. */
  27241. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27242. }
  27243. }
  27244. declare module BABYLON {
  27245. /**
  27246. * Interface containing an array of animations
  27247. */
  27248. export interface IAnimatable {
  27249. /**
  27250. * Array of animations
  27251. */
  27252. animations: Nullable<Array<Animation>>;
  27253. }
  27254. }
  27255. declare module BABYLON {
  27256. /**
  27257. * This represents all the required information to add a fresnel effect on a material:
  27258. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27259. */
  27260. export class FresnelParameters {
  27261. private _isEnabled;
  27262. /**
  27263. * Define if the fresnel effect is enable or not.
  27264. */
  27265. isEnabled: boolean;
  27266. /**
  27267. * Define the color used on edges (grazing angle)
  27268. */
  27269. leftColor: Color3;
  27270. /**
  27271. * Define the color used on center
  27272. */
  27273. rightColor: Color3;
  27274. /**
  27275. * Define bias applied to computed fresnel term
  27276. */
  27277. bias: number;
  27278. /**
  27279. * Defined the power exponent applied to fresnel term
  27280. */
  27281. power: number;
  27282. /**
  27283. * Clones the current fresnel and its valuues
  27284. * @returns a clone fresnel configuration
  27285. */
  27286. clone(): FresnelParameters;
  27287. /**
  27288. * Serializes the current fresnel parameters to a JSON representation.
  27289. * @return the JSON serialization
  27290. */
  27291. serialize(): any;
  27292. /**
  27293. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27294. * @param parsedFresnelParameters Define the JSON representation
  27295. * @returns the parsed parameters
  27296. */
  27297. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27298. }
  27299. }
  27300. declare module BABYLON {
  27301. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27302. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27303. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27304. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27305. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27306. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27307. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27308. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27309. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27310. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27311. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27312. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27313. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27314. /**
  27315. * Decorator used to define property that can be serialized as reference to a camera
  27316. * @param sourceName defines the name of the property to decorate
  27317. */
  27318. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27319. /**
  27320. * Class used to help serialization objects
  27321. */
  27322. export class SerializationHelper {
  27323. /** @hidden */
  27324. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27325. /** @hidden */
  27326. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27327. /** @hidden */
  27328. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27329. /** @hidden */
  27330. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27331. /**
  27332. * Appends the serialized animations from the source animations
  27333. * @param source Source containing the animations
  27334. * @param destination Target to store the animations
  27335. */
  27336. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27337. /**
  27338. * Static function used to serialized a specific entity
  27339. * @param entity defines the entity to serialize
  27340. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27341. * @returns a JSON compatible object representing the serialization of the entity
  27342. */
  27343. static Serialize<T>(entity: T, serializationObject?: any): any;
  27344. /**
  27345. * Creates a new entity from a serialization data object
  27346. * @param creationFunction defines a function used to instanciated the new entity
  27347. * @param source defines the source serialization data
  27348. * @param scene defines the hosting scene
  27349. * @param rootUrl defines the root url for resources
  27350. * @returns a new entity
  27351. */
  27352. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27353. /**
  27354. * Clones an object
  27355. * @param creationFunction defines the function used to instanciate the new object
  27356. * @param source defines the source object
  27357. * @returns the cloned object
  27358. */
  27359. static Clone<T>(creationFunction: () => T, source: T): T;
  27360. /**
  27361. * Instanciates a new object based on a source one (some data will be shared between both object)
  27362. * @param creationFunction defines the function used to instanciate the new object
  27363. * @param source defines the source object
  27364. * @returns the new object
  27365. */
  27366. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27367. }
  27368. }
  27369. declare module BABYLON {
  27370. /**
  27371. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27372. */
  27373. export interface CubeMapInfo {
  27374. /**
  27375. * The pixel array for the front face.
  27376. * This is stored in format, left to right, up to down format.
  27377. */
  27378. front: Nullable<ArrayBufferView>;
  27379. /**
  27380. * The pixel array for the back face.
  27381. * This is stored in format, left to right, up to down format.
  27382. */
  27383. back: Nullable<ArrayBufferView>;
  27384. /**
  27385. * The pixel array for the left face.
  27386. * This is stored in format, left to right, up to down format.
  27387. */
  27388. left: Nullable<ArrayBufferView>;
  27389. /**
  27390. * The pixel array for the right face.
  27391. * This is stored in format, left to right, up to down format.
  27392. */
  27393. right: Nullable<ArrayBufferView>;
  27394. /**
  27395. * The pixel array for the up face.
  27396. * This is stored in format, left to right, up to down format.
  27397. */
  27398. up: Nullable<ArrayBufferView>;
  27399. /**
  27400. * The pixel array for the down face.
  27401. * This is stored in format, left to right, up to down format.
  27402. */
  27403. down: Nullable<ArrayBufferView>;
  27404. /**
  27405. * The size of the cubemap stored.
  27406. *
  27407. * Each faces will be size * size pixels.
  27408. */
  27409. size: number;
  27410. /**
  27411. * The format of the texture.
  27412. *
  27413. * RGBA, RGB.
  27414. */
  27415. format: number;
  27416. /**
  27417. * The type of the texture data.
  27418. *
  27419. * UNSIGNED_INT, FLOAT.
  27420. */
  27421. type: number;
  27422. /**
  27423. * Specifies whether the texture is in gamma space.
  27424. */
  27425. gammaSpace: boolean;
  27426. }
  27427. /**
  27428. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27429. */
  27430. export class PanoramaToCubeMapTools {
  27431. private static FACE_FRONT;
  27432. private static FACE_BACK;
  27433. private static FACE_RIGHT;
  27434. private static FACE_LEFT;
  27435. private static FACE_DOWN;
  27436. private static FACE_UP;
  27437. /**
  27438. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27439. *
  27440. * @param float32Array The source data.
  27441. * @param inputWidth The width of the input panorama.
  27442. * @param inputHeight The height of the input panorama.
  27443. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27444. * @return The cubemap data
  27445. */
  27446. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27447. private static CreateCubemapTexture;
  27448. private static CalcProjectionSpherical;
  27449. }
  27450. }
  27451. declare module BABYLON {
  27452. /**
  27453. * Helper class dealing with the extraction of spherical polynomial dataArray
  27454. * from a cube map.
  27455. */
  27456. export class CubeMapToSphericalPolynomialTools {
  27457. private static FileFaces;
  27458. /**
  27459. * Converts a texture to the according Spherical Polynomial data.
  27460. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27461. *
  27462. * @param texture The texture to extract the information from.
  27463. * @return The Spherical Polynomial data.
  27464. */
  27465. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27466. /**
  27467. * Converts a cubemap to the according Spherical Polynomial data.
  27468. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27469. *
  27470. * @param cubeInfo The Cube map to extract the information from.
  27471. * @return The Spherical Polynomial data.
  27472. */
  27473. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27474. }
  27475. }
  27476. declare module BABYLON {
  27477. /**
  27478. * Class used to manipulate GUIDs
  27479. */
  27480. export class GUID {
  27481. /**
  27482. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27483. * Be aware Math.random() could cause collisions, but:
  27484. * "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"
  27485. * @returns a pseudo random id
  27486. */
  27487. static RandomId(): string;
  27488. }
  27489. }
  27490. declare module BABYLON {
  27491. /**
  27492. * Base class of all the textures in babylon.
  27493. * It groups all the common properties the materials, post process, lights... might need
  27494. * in order to make a correct use of the texture.
  27495. */
  27496. export class BaseTexture implements IAnimatable {
  27497. /**
  27498. * Default anisotropic filtering level for the application.
  27499. * It is set to 4 as a good tradeoff between perf and quality.
  27500. */
  27501. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27502. /**
  27503. * Gets or sets the unique id of the texture
  27504. */
  27505. uniqueId: number;
  27506. /**
  27507. * Define the name of the texture.
  27508. */
  27509. name: string;
  27510. /**
  27511. * Gets or sets an object used to store user defined information.
  27512. */
  27513. metadata: any;
  27514. /**
  27515. * For internal use only. Please do not use.
  27516. */
  27517. reservedDataStore: any;
  27518. private _hasAlpha;
  27519. /**
  27520. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27521. */
  27522. hasAlpha: boolean;
  27523. /**
  27524. * Defines if the alpha value should be determined via the rgb values.
  27525. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27526. */
  27527. getAlphaFromRGB: boolean;
  27528. /**
  27529. * Intensity or strength of the texture.
  27530. * It is commonly used by materials to fine tune the intensity of the texture
  27531. */
  27532. level: number;
  27533. /**
  27534. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27535. * This is part of the texture as textures usually maps to one uv set.
  27536. */
  27537. coordinatesIndex: number;
  27538. private _coordinatesMode;
  27539. /**
  27540. * How a texture is mapped.
  27541. *
  27542. * | Value | Type | Description |
  27543. * | ----- | ----------------------------------- | ----------- |
  27544. * | 0 | EXPLICIT_MODE | |
  27545. * | 1 | SPHERICAL_MODE | |
  27546. * | 2 | PLANAR_MODE | |
  27547. * | 3 | CUBIC_MODE | |
  27548. * | 4 | PROJECTION_MODE | |
  27549. * | 5 | SKYBOX_MODE | |
  27550. * | 6 | INVCUBIC_MODE | |
  27551. * | 7 | EQUIRECTANGULAR_MODE | |
  27552. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27553. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27554. */
  27555. coordinatesMode: number;
  27556. /**
  27557. * | Value | Type | Description |
  27558. * | ----- | ------------------ | ----------- |
  27559. * | 0 | CLAMP_ADDRESSMODE | |
  27560. * | 1 | WRAP_ADDRESSMODE | |
  27561. * | 2 | MIRROR_ADDRESSMODE | |
  27562. */
  27563. wrapU: number;
  27564. /**
  27565. * | Value | Type | Description |
  27566. * | ----- | ------------------ | ----------- |
  27567. * | 0 | CLAMP_ADDRESSMODE | |
  27568. * | 1 | WRAP_ADDRESSMODE | |
  27569. * | 2 | MIRROR_ADDRESSMODE | |
  27570. */
  27571. wrapV: number;
  27572. /**
  27573. * | Value | Type | Description |
  27574. * | ----- | ------------------ | ----------- |
  27575. * | 0 | CLAMP_ADDRESSMODE | |
  27576. * | 1 | WRAP_ADDRESSMODE | |
  27577. * | 2 | MIRROR_ADDRESSMODE | |
  27578. */
  27579. wrapR: number;
  27580. /**
  27581. * With compliant hardware and browser (supporting anisotropic filtering)
  27582. * this defines the level of anisotropic filtering in the texture.
  27583. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27584. */
  27585. anisotropicFilteringLevel: number;
  27586. /**
  27587. * Define if the texture is a cube texture or if false a 2d texture.
  27588. */
  27589. isCube: boolean;
  27590. /**
  27591. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27592. */
  27593. is3D: boolean;
  27594. /**
  27595. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27596. * HDR texture are usually stored in linear space.
  27597. * This only impacts the PBR and Background materials
  27598. */
  27599. gammaSpace: boolean;
  27600. /**
  27601. * Gets whether or not the texture contains RGBD data.
  27602. */
  27603. readonly isRGBD: boolean;
  27604. /**
  27605. * Is Z inverted in the texture (useful in a cube texture).
  27606. */
  27607. invertZ: boolean;
  27608. /**
  27609. * Are mip maps generated for this texture or not.
  27610. */
  27611. readonly noMipmap: boolean;
  27612. /**
  27613. * @hidden
  27614. */
  27615. lodLevelInAlpha: boolean;
  27616. /**
  27617. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27618. */
  27619. lodGenerationOffset: number;
  27620. /**
  27621. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27622. */
  27623. lodGenerationScale: number;
  27624. /**
  27625. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27626. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27627. * average roughness values.
  27628. */
  27629. linearSpecularLOD: boolean;
  27630. /**
  27631. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27632. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27633. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27634. */
  27635. irradianceTexture: Nullable<BaseTexture>;
  27636. /**
  27637. * Define if the texture is a render target.
  27638. */
  27639. isRenderTarget: boolean;
  27640. /**
  27641. * Define the unique id of the texture in the scene.
  27642. */
  27643. readonly uid: string;
  27644. /**
  27645. * Return a string representation of the texture.
  27646. * @returns the texture as a string
  27647. */
  27648. toString(): string;
  27649. /**
  27650. * Get the class name of the texture.
  27651. * @returns "BaseTexture"
  27652. */
  27653. getClassName(): string;
  27654. /**
  27655. * Define the list of animation attached to the texture.
  27656. */
  27657. animations: Animation[];
  27658. /**
  27659. * An event triggered when the texture is disposed.
  27660. */
  27661. onDisposeObservable: Observable<BaseTexture>;
  27662. private _onDisposeObserver;
  27663. /**
  27664. * Callback triggered when the texture has been disposed.
  27665. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27666. */
  27667. onDispose: () => void;
  27668. /**
  27669. * Define the current state of the loading sequence when in delayed load mode.
  27670. */
  27671. delayLoadState: number;
  27672. private _scene;
  27673. /** @hidden */
  27674. _texture: Nullable<InternalTexture>;
  27675. private _uid;
  27676. /**
  27677. * Define if the texture is preventinga material to render or not.
  27678. * If not and the texture is not ready, the engine will use a default black texture instead.
  27679. */
  27680. readonly isBlocking: boolean;
  27681. /**
  27682. * Instantiates a new BaseTexture.
  27683. * Base class of all the textures in babylon.
  27684. * It groups all the common properties the materials, post process, lights... might need
  27685. * in order to make a correct use of the texture.
  27686. * @param scene Define the scene the texture blongs to
  27687. */
  27688. constructor(scene: Nullable<Scene>);
  27689. /**
  27690. * Get the scene the texture belongs to.
  27691. * @returns the scene or null if undefined
  27692. */
  27693. getScene(): Nullable<Scene>;
  27694. /**
  27695. * Get the texture transform matrix used to offset tile the texture for istance.
  27696. * @returns the transformation matrix
  27697. */
  27698. getTextureMatrix(): Matrix;
  27699. /**
  27700. * Get the texture reflection matrix used to rotate/transform the reflection.
  27701. * @returns the reflection matrix
  27702. */
  27703. getReflectionTextureMatrix(): Matrix;
  27704. /**
  27705. * Get the underlying lower level texture from Babylon.
  27706. * @returns the insternal texture
  27707. */
  27708. getInternalTexture(): Nullable<InternalTexture>;
  27709. /**
  27710. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27711. * @returns true if ready or not blocking
  27712. */
  27713. isReadyOrNotBlocking(): boolean;
  27714. /**
  27715. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27716. * @returns true if fully ready
  27717. */
  27718. isReady(): boolean;
  27719. private _cachedSize;
  27720. /**
  27721. * Get the size of the texture.
  27722. * @returns the texture size.
  27723. */
  27724. getSize(): ISize;
  27725. /**
  27726. * Get the base size of the texture.
  27727. * It can be different from the size if the texture has been resized for POT for instance
  27728. * @returns the base size
  27729. */
  27730. getBaseSize(): ISize;
  27731. /**
  27732. * Update the sampling mode of the texture.
  27733. * Default is Trilinear mode.
  27734. *
  27735. * | Value | Type | Description |
  27736. * | ----- | ------------------ | ----------- |
  27737. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27738. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27739. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27740. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27741. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27742. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27743. * | 7 | NEAREST_LINEAR | |
  27744. * | 8 | NEAREST_NEAREST | |
  27745. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27746. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27747. * | 11 | LINEAR_LINEAR | |
  27748. * | 12 | LINEAR_NEAREST | |
  27749. *
  27750. * > _mag_: magnification filter (close to the viewer)
  27751. * > _min_: minification filter (far from the viewer)
  27752. * > _mip_: filter used between mip map levels
  27753. *@param samplingMode Define the new sampling mode of the texture
  27754. */
  27755. updateSamplingMode(samplingMode: number): void;
  27756. /**
  27757. * Scales the texture if is `canRescale()`
  27758. * @param ratio the resize factor we want to use to rescale
  27759. */
  27760. scale(ratio: number): void;
  27761. /**
  27762. * Get if the texture can rescale.
  27763. */
  27764. readonly canRescale: boolean;
  27765. /** @hidden */
  27766. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27767. /** @hidden */
  27768. _rebuild(): void;
  27769. /**
  27770. * Triggers the load sequence in delayed load mode.
  27771. */
  27772. delayLoad(): void;
  27773. /**
  27774. * Clones the texture.
  27775. * @returns the cloned texture
  27776. */
  27777. clone(): Nullable<BaseTexture>;
  27778. /**
  27779. * Get the texture underlying type (INT, FLOAT...)
  27780. */
  27781. readonly textureType: number;
  27782. /**
  27783. * Get the texture underlying format (RGB, RGBA...)
  27784. */
  27785. readonly textureFormat: number;
  27786. /**
  27787. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27788. * This will returns an RGBA array buffer containing either in values (0-255) or
  27789. * float values (0-1) depending of the underlying buffer type.
  27790. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27791. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27792. * @param buffer defines a user defined buffer to fill with data (can be null)
  27793. * @returns The Array buffer containing the pixels data.
  27794. */
  27795. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27796. /**
  27797. * Release and destroy the underlying lower level texture aka internalTexture.
  27798. */
  27799. releaseInternalTexture(): void;
  27800. /**
  27801. * Get the polynomial representation of the texture data.
  27802. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27803. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27804. */
  27805. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27806. /** @hidden */
  27807. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27808. /** @hidden */
  27809. readonly _lodTextureMid: Nullable<BaseTexture>;
  27810. /** @hidden */
  27811. readonly _lodTextureLow: Nullable<BaseTexture>;
  27812. /**
  27813. * Dispose the texture and release its associated resources.
  27814. */
  27815. dispose(): void;
  27816. /**
  27817. * Serialize the texture into a JSON representation that can be parsed later on.
  27818. * @returns the JSON representation of the texture
  27819. */
  27820. serialize(): any;
  27821. /**
  27822. * Helper function to be called back once a list of texture contains only ready textures.
  27823. * @param textures Define the list of textures to wait for
  27824. * @param callback Define the callback triggered once the entire list will be ready
  27825. */
  27826. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27827. }
  27828. }
  27829. declare module BABYLON {
  27830. /**
  27831. * Class used to store data associated with WebGL texture data for the engine
  27832. * This class should not be used directly
  27833. */
  27834. export class InternalTexture {
  27835. /** @hidden */
  27836. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  27837. /**
  27838. * The source of the texture data is unknown
  27839. */
  27840. static DATASOURCE_UNKNOWN: number;
  27841. /**
  27842. * Texture data comes from an URL
  27843. */
  27844. static DATASOURCE_URL: number;
  27845. /**
  27846. * Texture data is only used for temporary storage
  27847. */
  27848. static DATASOURCE_TEMP: number;
  27849. /**
  27850. * Texture data comes from raw data (ArrayBuffer)
  27851. */
  27852. static DATASOURCE_RAW: number;
  27853. /**
  27854. * Texture content is dynamic (video or dynamic texture)
  27855. */
  27856. static DATASOURCE_DYNAMIC: number;
  27857. /**
  27858. * Texture content is generated by rendering to it
  27859. */
  27860. static DATASOURCE_RENDERTARGET: number;
  27861. /**
  27862. * Texture content is part of a multi render target process
  27863. */
  27864. static DATASOURCE_MULTIRENDERTARGET: number;
  27865. /**
  27866. * Texture data comes from a cube data file
  27867. */
  27868. static DATASOURCE_CUBE: number;
  27869. /**
  27870. * Texture data comes from a raw cube data
  27871. */
  27872. static DATASOURCE_CUBERAW: number;
  27873. /**
  27874. * Texture data come from a prefiltered cube data file
  27875. */
  27876. static DATASOURCE_CUBEPREFILTERED: number;
  27877. /**
  27878. * Texture content is raw 3D data
  27879. */
  27880. static DATASOURCE_RAW3D: number;
  27881. /**
  27882. * Texture content is a depth texture
  27883. */
  27884. static DATASOURCE_DEPTHTEXTURE: number;
  27885. /**
  27886. * Texture data comes from a raw cube data encoded with RGBD
  27887. */
  27888. static DATASOURCE_CUBERAW_RGBD: number;
  27889. /**
  27890. * Defines if the texture is ready
  27891. */
  27892. isReady: boolean;
  27893. /**
  27894. * Defines if the texture is a cube texture
  27895. */
  27896. isCube: boolean;
  27897. /**
  27898. * Defines if the texture contains 3D data
  27899. */
  27900. is3D: boolean;
  27901. /**
  27902. * Defines if the texture contains multiview data
  27903. */
  27904. isMultiview: boolean;
  27905. /**
  27906. * Gets the URL used to load this texture
  27907. */
  27908. url: string;
  27909. /**
  27910. * Gets the sampling mode of the texture
  27911. */
  27912. samplingMode: number;
  27913. /**
  27914. * Gets a boolean indicating if the texture needs mipmaps generation
  27915. */
  27916. generateMipMaps: boolean;
  27917. /**
  27918. * Gets the number of samples used by the texture (WebGL2+ only)
  27919. */
  27920. samples: number;
  27921. /**
  27922. * Gets the type of the texture (int, float...)
  27923. */
  27924. type: number;
  27925. /**
  27926. * Gets the format of the texture (RGB, RGBA...)
  27927. */
  27928. format: number;
  27929. /**
  27930. * Observable called when the texture is loaded
  27931. */
  27932. onLoadedObservable: Observable<InternalTexture>;
  27933. /**
  27934. * Gets the width of the texture
  27935. */
  27936. width: number;
  27937. /**
  27938. * Gets the height of the texture
  27939. */
  27940. height: number;
  27941. /**
  27942. * Gets the depth of the texture
  27943. */
  27944. depth: number;
  27945. /**
  27946. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  27947. */
  27948. baseWidth: number;
  27949. /**
  27950. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  27951. */
  27952. baseHeight: number;
  27953. /**
  27954. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  27955. */
  27956. baseDepth: number;
  27957. /**
  27958. * Gets a boolean indicating if the texture is inverted on Y axis
  27959. */
  27960. invertY: boolean;
  27961. /** @hidden */
  27962. _invertVScale: boolean;
  27963. /** @hidden */
  27964. _associatedChannel: number;
  27965. /** @hidden */
  27966. _dataSource: number;
  27967. /** @hidden */
  27968. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  27969. /** @hidden */
  27970. _bufferView: Nullable<ArrayBufferView>;
  27971. /** @hidden */
  27972. _bufferViewArray: Nullable<ArrayBufferView[]>;
  27973. /** @hidden */
  27974. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  27975. /** @hidden */
  27976. _size: number;
  27977. /** @hidden */
  27978. _extension: string;
  27979. /** @hidden */
  27980. _files: Nullable<string[]>;
  27981. /** @hidden */
  27982. _workingCanvas: Nullable<HTMLCanvasElement>;
  27983. /** @hidden */
  27984. _workingContext: Nullable<CanvasRenderingContext2D>;
  27985. /** @hidden */
  27986. _framebuffer: Nullable<WebGLFramebuffer>;
  27987. /** @hidden */
  27988. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  27989. /** @hidden */
  27990. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  27991. /** @hidden */
  27992. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  27993. /** @hidden */
  27994. _attachments: Nullable<number[]>;
  27995. /** @hidden */
  27996. _cachedCoordinatesMode: Nullable<number>;
  27997. /** @hidden */
  27998. _cachedWrapU: Nullable<number>;
  27999. /** @hidden */
  28000. _cachedWrapV: Nullable<number>;
  28001. /** @hidden */
  28002. _cachedWrapR: Nullable<number>;
  28003. /** @hidden */
  28004. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28005. /** @hidden */
  28006. _isDisabled: boolean;
  28007. /** @hidden */
  28008. _compression: Nullable<string>;
  28009. /** @hidden */
  28010. _generateStencilBuffer: boolean;
  28011. /** @hidden */
  28012. _generateDepthBuffer: boolean;
  28013. /** @hidden */
  28014. _comparisonFunction: number;
  28015. /** @hidden */
  28016. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28017. /** @hidden */
  28018. _lodGenerationScale: number;
  28019. /** @hidden */
  28020. _lodGenerationOffset: number;
  28021. /** @hidden */
  28022. _colorTextureArray: Nullable<WebGLTexture>;
  28023. /** @hidden */
  28024. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28025. /** @hidden */
  28026. _lodTextureHigh: Nullable<BaseTexture>;
  28027. /** @hidden */
  28028. _lodTextureMid: Nullable<BaseTexture>;
  28029. /** @hidden */
  28030. _lodTextureLow: Nullable<BaseTexture>;
  28031. /** @hidden */
  28032. _isRGBD: boolean;
  28033. /** @hidden */
  28034. _linearSpecularLOD: boolean;
  28035. /** @hidden */
  28036. _irradianceTexture: Nullable<BaseTexture>;
  28037. /** @hidden */
  28038. _webGLTexture: Nullable<WebGLTexture>;
  28039. /** @hidden */
  28040. _references: number;
  28041. private _engine;
  28042. /**
  28043. * Gets the Engine the texture belongs to.
  28044. * @returns The babylon engine
  28045. */
  28046. getEngine(): Engine;
  28047. /**
  28048. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28049. */
  28050. readonly dataSource: number;
  28051. /**
  28052. * Creates a new InternalTexture
  28053. * @param engine defines the engine to use
  28054. * @param dataSource defines the type of data that will be used
  28055. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28056. */
  28057. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28058. /**
  28059. * Increments the number of references (ie. the number of Texture that point to it)
  28060. */
  28061. incrementReferences(): void;
  28062. /**
  28063. * Change the size of the texture (not the size of the content)
  28064. * @param width defines the new width
  28065. * @param height defines the new height
  28066. * @param depth defines the new depth (1 by default)
  28067. */
  28068. updateSize(width: int, height: int, depth?: int): void;
  28069. /** @hidden */
  28070. _rebuild(): void;
  28071. /** @hidden */
  28072. _swapAndDie(target: InternalTexture): void;
  28073. /**
  28074. * Dispose the current allocated resources
  28075. */
  28076. dispose(): void;
  28077. }
  28078. }
  28079. declare module BABYLON {
  28080. /**
  28081. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28082. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28083. */
  28084. export class EffectFallbacks {
  28085. private _defines;
  28086. private _currentRank;
  28087. private _maxRank;
  28088. private _mesh;
  28089. /**
  28090. * Removes the fallback from the bound mesh.
  28091. */
  28092. unBindMesh(): void;
  28093. /**
  28094. * Adds a fallback on the specified property.
  28095. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28096. * @param define The name of the define in the shader
  28097. */
  28098. addFallback(rank: number, define: string): void;
  28099. /**
  28100. * Sets the mesh to use CPU skinning when needing to fallback.
  28101. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28102. * @param mesh The mesh to use the fallbacks.
  28103. */
  28104. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28105. /**
  28106. * Checks to see if more fallbacks are still availible.
  28107. */
  28108. readonly isMoreFallbacks: boolean;
  28109. /**
  28110. * Removes the defines that should be removed when falling back.
  28111. * @param currentDefines defines the current define statements for the shader.
  28112. * @param effect defines the current effect we try to compile
  28113. * @returns The resulting defines with defines of the current rank removed.
  28114. */
  28115. reduce(currentDefines: string, effect: Effect): string;
  28116. }
  28117. /**
  28118. * Options to be used when creating an effect.
  28119. */
  28120. export class EffectCreationOptions {
  28121. /**
  28122. * Atrributes that will be used in the shader.
  28123. */
  28124. attributes: string[];
  28125. /**
  28126. * Uniform varible names that will be set in the shader.
  28127. */
  28128. uniformsNames: string[];
  28129. /**
  28130. * Uniform buffer varible names that will be set in the shader.
  28131. */
  28132. uniformBuffersNames: string[];
  28133. /**
  28134. * Sampler texture variable names that will be set in the shader.
  28135. */
  28136. samplers: string[];
  28137. /**
  28138. * Define statements that will be set in the shader.
  28139. */
  28140. defines: any;
  28141. /**
  28142. * Possible fallbacks for this effect to improve performance when needed.
  28143. */
  28144. fallbacks: Nullable<EffectFallbacks>;
  28145. /**
  28146. * Callback that will be called when the shader is compiled.
  28147. */
  28148. onCompiled: Nullable<(effect: Effect) => void>;
  28149. /**
  28150. * Callback that will be called if an error occurs during shader compilation.
  28151. */
  28152. onError: Nullable<(effect: Effect, errors: string) => void>;
  28153. /**
  28154. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28155. */
  28156. indexParameters: any;
  28157. /**
  28158. * Max number of lights that can be used in the shader.
  28159. */
  28160. maxSimultaneousLights: number;
  28161. /**
  28162. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28163. */
  28164. transformFeedbackVaryings: Nullable<string[]>;
  28165. }
  28166. /**
  28167. * Effect containing vertex and fragment shader that can be executed on an object.
  28168. */
  28169. export class Effect implements IDisposable {
  28170. /**
  28171. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28172. */
  28173. static ShadersRepository: string;
  28174. /**
  28175. * Name of the effect.
  28176. */
  28177. name: any;
  28178. /**
  28179. * String container all the define statements that should be set on the shader.
  28180. */
  28181. defines: string;
  28182. /**
  28183. * Callback that will be called when the shader is compiled.
  28184. */
  28185. onCompiled: Nullable<(effect: Effect) => void>;
  28186. /**
  28187. * Callback that will be called if an error occurs during shader compilation.
  28188. */
  28189. onError: Nullable<(effect: Effect, errors: string) => void>;
  28190. /**
  28191. * Callback that will be called when effect is bound.
  28192. */
  28193. onBind: Nullable<(effect: Effect) => void>;
  28194. /**
  28195. * Unique ID of the effect.
  28196. */
  28197. uniqueId: number;
  28198. /**
  28199. * Observable that will be called when the shader is compiled.
  28200. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28201. */
  28202. onCompileObservable: Observable<Effect>;
  28203. /**
  28204. * Observable that will be called if an error occurs during shader compilation.
  28205. */
  28206. onErrorObservable: Observable<Effect>;
  28207. /** @hidden */
  28208. _onBindObservable: Nullable<Observable<Effect>>;
  28209. /**
  28210. * Observable that will be called when effect is bound.
  28211. */
  28212. readonly onBindObservable: Observable<Effect>;
  28213. /** @hidden */
  28214. _bonesComputationForcedToCPU: boolean;
  28215. private static _uniqueIdSeed;
  28216. private _engine;
  28217. private _uniformBuffersNames;
  28218. private _uniformsNames;
  28219. private _samplerList;
  28220. private _samplers;
  28221. private _isReady;
  28222. private _compilationError;
  28223. private _attributesNames;
  28224. private _attributes;
  28225. private _uniforms;
  28226. /**
  28227. * Key for the effect.
  28228. * @hidden
  28229. */
  28230. _key: string;
  28231. private _indexParameters;
  28232. private _fallbacks;
  28233. private _vertexSourceCode;
  28234. private _fragmentSourceCode;
  28235. private _vertexSourceCodeOverride;
  28236. private _fragmentSourceCodeOverride;
  28237. private _transformFeedbackVaryings;
  28238. /**
  28239. * Compiled shader to webGL program.
  28240. * @hidden
  28241. */
  28242. _pipelineContext: Nullable<IPipelineContext>;
  28243. private _valueCache;
  28244. private static _baseCache;
  28245. /**
  28246. * Instantiates an effect.
  28247. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28248. * @param baseName Name of the effect.
  28249. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28250. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28251. * @param samplers List of sampler variables that will be passed to the shader.
  28252. * @param engine Engine to be used to render the effect
  28253. * @param defines Define statements to be added to the shader.
  28254. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28255. * @param onCompiled Callback that will be called when the shader is compiled.
  28256. * @param onError Callback that will be called if an error occurs during shader compilation.
  28257. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28258. */
  28259. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28260. private _useFinalCode;
  28261. /**
  28262. * Unique key for this effect
  28263. */
  28264. readonly key: string;
  28265. /**
  28266. * If the effect has been compiled and prepared.
  28267. * @returns if the effect is compiled and prepared.
  28268. */
  28269. isReady(): boolean;
  28270. /**
  28271. * The engine the effect was initialized with.
  28272. * @returns the engine.
  28273. */
  28274. getEngine(): Engine;
  28275. /**
  28276. * The pipeline context for this effect
  28277. * @returns the associated pipeline context
  28278. */
  28279. getPipelineContext(): Nullable<IPipelineContext>;
  28280. /**
  28281. * The set of names of attribute variables for the shader.
  28282. * @returns An array of attribute names.
  28283. */
  28284. getAttributesNames(): string[];
  28285. /**
  28286. * Returns the attribute at the given index.
  28287. * @param index The index of the attribute.
  28288. * @returns The location of the attribute.
  28289. */
  28290. getAttributeLocation(index: number): number;
  28291. /**
  28292. * Returns the attribute based on the name of the variable.
  28293. * @param name of the attribute to look up.
  28294. * @returns the attribute location.
  28295. */
  28296. getAttributeLocationByName(name: string): number;
  28297. /**
  28298. * The number of attributes.
  28299. * @returns the numnber of attributes.
  28300. */
  28301. getAttributesCount(): number;
  28302. /**
  28303. * Gets the index of a uniform variable.
  28304. * @param uniformName of the uniform to look up.
  28305. * @returns the index.
  28306. */
  28307. getUniformIndex(uniformName: string): number;
  28308. /**
  28309. * Returns the attribute based on the name of the variable.
  28310. * @param uniformName of the uniform to look up.
  28311. * @returns the location of the uniform.
  28312. */
  28313. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28314. /**
  28315. * Returns an array of sampler variable names
  28316. * @returns The array of sampler variable neames.
  28317. */
  28318. getSamplers(): string[];
  28319. /**
  28320. * The error from the last compilation.
  28321. * @returns the error string.
  28322. */
  28323. getCompilationError(): string;
  28324. /**
  28325. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28326. * @param func The callback to be used.
  28327. */
  28328. executeWhenCompiled(func: (effect: Effect) => void): void;
  28329. private _checkIsReady;
  28330. /** @hidden */
  28331. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28332. /** @hidden */
  28333. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28334. /** @hidden */
  28335. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28336. /**
  28337. * Recompiles the webGL program
  28338. * @param vertexSourceCode The source code for the vertex shader.
  28339. * @param fragmentSourceCode The source code for the fragment shader.
  28340. * @param onCompiled Callback called when completed.
  28341. * @param onError Callback called on error.
  28342. * @hidden
  28343. */
  28344. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28345. /**
  28346. * Prepares the effect
  28347. * @hidden
  28348. */
  28349. _prepareEffect(): void;
  28350. /**
  28351. * Checks if the effect is supported. (Must be called after compilation)
  28352. */
  28353. readonly isSupported: boolean;
  28354. /**
  28355. * Binds a texture to the engine to be used as output of the shader.
  28356. * @param channel Name of the output variable.
  28357. * @param texture Texture to bind.
  28358. * @hidden
  28359. */
  28360. _bindTexture(channel: string, texture: InternalTexture): void;
  28361. /**
  28362. * Sets a texture on the engine to be used in the shader.
  28363. * @param channel Name of the sampler variable.
  28364. * @param texture Texture to set.
  28365. */
  28366. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28367. /**
  28368. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28369. * @param channel Name of the sampler variable.
  28370. * @param texture Texture to set.
  28371. */
  28372. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28373. /**
  28374. * Sets an array of textures on the engine to be used in the shader.
  28375. * @param channel Name of the variable.
  28376. * @param textures Textures to set.
  28377. */
  28378. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28379. /**
  28380. * 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)
  28381. * @param channel Name of the sampler variable.
  28382. * @param postProcess Post process to get the input texture from.
  28383. */
  28384. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28385. /**
  28386. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28387. * 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)
  28388. * @param channel Name of the sampler variable.
  28389. * @param postProcess Post process to get the output texture from.
  28390. */
  28391. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28392. /** @hidden */
  28393. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28394. /** @hidden */
  28395. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28396. /** @hidden */
  28397. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28398. /** @hidden */
  28399. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28400. /**
  28401. * Binds a buffer to a uniform.
  28402. * @param buffer Buffer to bind.
  28403. * @param name Name of the uniform variable to bind to.
  28404. */
  28405. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28406. /**
  28407. * Binds block to a uniform.
  28408. * @param blockName Name of the block to bind.
  28409. * @param index Index to bind.
  28410. */
  28411. bindUniformBlock(blockName: string, index: number): void;
  28412. /**
  28413. * Sets an interger value on a uniform variable.
  28414. * @param uniformName Name of the variable.
  28415. * @param value Value to be set.
  28416. * @returns this effect.
  28417. */
  28418. setInt(uniformName: string, value: number): Effect;
  28419. /**
  28420. * Sets an int array on a uniform variable.
  28421. * @param uniformName Name of the variable.
  28422. * @param array array to be set.
  28423. * @returns this effect.
  28424. */
  28425. setIntArray(uniformName: string, array: Int32Array): Effect;
  28426. /**
  28427. * 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)
  28428. * @param uniformName Name of the variable.
  28429. * @param array array to be set.
  28430. * @returns this effect.
  28431. */
  28432. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28433. /**
  28434. * 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)
  28435. * @param uniformName Name of the variable.
  28436. * @param array array to be set.
  28437. * @returns this effect.
  28438. */
  28439. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28440. /**
  28441. * 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)
  28442. * @param uniformName Name of the variable.
  28443. * @param array array to be set.
  28444. * @returns this effect.
  28445. */
  28446. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28447. /**
  28448. * Sets an float array on a uniform variable.
  28449. * @param uniformName Name of the variable.
  28450. * @param array array to be set.
  28451. * @returns this effect.
  28452. */
  28453. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28454. /**
  28455. * 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)
  28456. * @param uniformName Name of the variable.
  28457. * @param array array to be set.
  28458. * @returns this effect.
  28459. */
  28460. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28461. /**
  28462. * 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)
  28463. * @param uniformName Name of the variable.
  28464. * @param array array to be set.
  28465. * @returns this effect.
  28466. */
  28467. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28468. /**
  28469. * 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)
  28470. * @param uniformName Name of the variable.
  28471. * @param array array to be set.
  28472. * @returns this effect.
  28473. */
  28474. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28475. /**
  28476. * Sets an array on a uniform variable.
  28477. * @param uniformName Name of the variable.
  28478. * @param array array to be set.
  28479. * @returns this effect.
  28480. */
  28481. setArray(uniformName: string, array: number[]): Effect;
  28482. /**
  28483. * 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)
  28484. * @param uniformName Name of the variable.
  28485. * @param array array to be set.
  28486. * @returns this effect.
  28487. */
  28488. setArray2(uniformName: string, array: number[]): Effect;
  28489. /**
  28490. * 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)
  28491. * @param uniformName Name of the variable.
  28492. * @param array array to be set.
  28493. * @returns this effect.
  28494. */
  28495. setArray3(uniformName: string, array: number[]): Effect;
  28496. /**
  28497. * 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)
  28498. * @param uniformName Name of the variable.
  28499. * @param array array to be set.
  28500. * @returns this effect.
  28501. */
  28502. setArray4(uniformName: string, array: number[]): Effect;
  28503. /**
  28504. * Sets matrices on a uniform variable.
  28505. * @param uniformName Name of the variable.
  28506. * @param matrices matrices to be set.
  28507. * @returns this effect.
  28508. */
  28509. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28510. /**
  28511. * Sets matrix on a uniform variable.
  28512. * @param uniformName Name of the variable.
  28513. * @param matrix matrix to be set.
  28514. * @returns this effect.
  28515. */
  28516. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28517. /**
  28518. * 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)
  28519. * @param uniformName Name of the variable.
  28520. * @param matrix matrix to be set.
  28521. * @returns this effect.
  28522. */
  28523. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28524. /**
  28525. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28526. * @param uniformName Name of the variable.
  28527. * @param matrix matrix to be set.
  28528. * @returns this effect.
  28529. */
  28530. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28531. /**
  28532. * Sets a float on a uniform variable.
  28533. * @param uniformName Name of the variable.
  28534. * @param value value to be set.
  28535. * @returns this effect.
  28536. */
  28537. setFloat(uniformName: string, value: number): Effect;
  28538. /**
  28539. * Sets a boolean on a uniform variable.
  28540. * @param uniformName Name of the variable.
  28541. * @param bool value to be set.
  28542. * @returns this effect.
  28543. */
  28544. setBool(uniformName: string, bool: boolean): Effect;
  28545. /**
  28546. * Sets a Vector2 on a uniform variable.
  28547. * @param uniformName Name of the variable.
  28548. * @param vector2 vector2 to be set.
  28549. * @returns this effect.
  28550. */
  28551. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28552. /**
  28553. * Sets a float2 on a uniform variable.
  28554. * @param uniformName Name of the variable.
  28555. * @param x First float in float2.
  28556. * @param y Second float in float2.
  28557. * @returns this effect.
  28558. */
  28559. setFloat2(uniformName: string, x: number, y: number): Effect;
  28560. /**
  28561. * Sets a Vector3 on a uniform variable.
  28562. * @param uniformName Name of the variable.
  28563. * @param vector3 Value to be set.
  28564. * @returns this effect.
  28565. */
  28566. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28567. /**
  28568. * Sets a float3 on a uniform variable.
  28569. * @param uniformName Name of the variable.
  28570. * @param x First float in float3.
  28571. * @param y Second float in float3.
  28572. * @param z Third float in float3.
  28573. * @returns this effect.
  28574. */
  28575. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28576. /**
  28577. * Sets a Vector4 on a uniform variable.
  28578. * @param uniformName Name of the variable.
  28579. * @param vector4 Value to be set.
  28580. * @returns this effect.
  28581. */
  28582. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28583. /**
  28584. * Sets a float4 on a uniform variable.
  28585. * @param uniformName Name of the variable.
  28586. * @param x First float in float4.
  28587. * @param y Second float in float4.
  28588. * @param z Third float in float4.
  28589. * @param w Fourth float in float4.
  28590. * @returns this effect.
  28591. */
  28592. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28593. /**
  28594. * Sets a Color3 on a uniform variable.
  28595. * @param uniformName Name of the variable.
  28596. * @param color3 Value to be set.
  28597. * @returns this effect.
  28598. */
  28599. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28600. /**
  28601. * Sets a Color4 on a uniform variable.
  28602. * @param uniformName Name of the variable.
  28603. * @param color3 Value to be set.
  28604. * @param alpha Alpha value to be set.
  28605. * @returns this effect.
  28606. */
  28607. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28608. /**
  28609. * Sets a Color4 on a uniform variable
  28610. * @param uniformName defines the name of the variable
  28611. * @param color4 defines the value to be set
  28612. * @returns this effect.
  28613. */
  28614. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28615. /** Release all associated resources */
  28616. dispose(): void;
  28617. /**
  28618. * This function will add a new shader to the shader store
  28619. * @param name the name of the shader
  28620. * @param pixelShader optional pixel shader content
  28621. * @param vertexShader optional vertex shader content
  28622. */
  28623. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28624. /**
  28625. * Store of each shader (The can be looked up using effect.key)
  28626. */
  28627. static ShadersStore: {
  28628. [key: string]: string;
  28629. };
  28630. /**
  28631. * Store of each included file for a shader (The can be looked up using effect.key)
  28632. */
  28633. static IncludesShadersStore: {
  28634. [key: string]: string;
  28635. };
  28636. /**
  28637. * Resets the cache of effects.
  28638. */
  28639. static ResetCache(): void;
  28640. }
  28641. }
  28642. declare module BABYLON {
  28643. /**
  28644. * Uniform buffer objects.
  28645. *
  28646. * Handles blocks of uniform on the GPU.
  28647. *
  28648. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28649. *
  28650. * For more information, please refer to :
  28651. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28652. */
  28653. export class UniformBuffer {
  28654. private _engine;
  28655. private _buffer;
  28656. private _data;
  28657. private _bufferData;
  28658. private _dynamic?;
  28659. private _uniformLocations;
  28660. private _uniformSizes;
  28661. private _uniformLocationPointer;
  28662. private _needSync;
  28663. private _noUBO;
  28664. private _currentEffect;
  28665. private static _MAX_UNIFORM_SIZE;
  28666. private static _tempBuffer;
  28667. /**
  28668. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  28669. * This is dynamic to allow compat with webgl 1 and 2.
  28670. * You will need to pass the name of the uniform as well as the value.
  28671. */
  28672. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  28673. /**
  28674. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  28675. * This is dynamic to allow compat with webgl 1 and 2.
  28676. * You will need to pass the name of the uniform as well as the value.
  28677. */
  28678. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  28679. /**
  28680. * Lambda to Update a single float in a uniform buffer.
  28681. * This is dynamic to allow compat with webgl 1 and 2.
  28682. * You will need to pass the name of the uniform as well as the value.
  28683. */
  28684. updateFloat: (name: string, x: number) => void;
  28685. /**
  28686. * Lambda to Update a vec2 of float in a uniform buffer.
  28687. * This is dynamic to allow compat with webgl 1 and 2.
  28688. * You will need to pass the name of the uniform as well as the value.
  28689. */
  28690. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  28691. /**
  28692. * Lambda to Update a vec3 of float in a uniform buffer.
  28693. * This is dynamic to allow compat with webgl 1 and 2.
  28694. * You will need to pass the name of the uniform as well as the value.
  28695. */
  28696. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  28697. /**
  28698. * Lambda to Update a vec4 of float in a uniform buffer.
  28699. * This is dynamic to allow compat with webgl 1 and 2.
  28700. * You will need to pass the name of the uniform as well as the value.
  28701. */
  28702. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  28703. /**
  28704. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  28705. * This is dynamic to allow compat with webgl 1 and 2.
  28706. * You will need to pass the name of the uniform as well as the value.
  28707. */
  28708. updateMatrix: (name: string, mat: Matrix) => void;
  28709. /**
  28710. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  28711. * This is dynamic to allow compat with webgl 1 and 2.
  28712. * You will need to pass the name of the uniform as well as the value.
  28713. */
  28714. updateVector3: (name: string, vector: Vector3) => void;
  28715. /**
  28716. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  28717. * This is dynamic to allow compat with webgl 1 and 2.
  28718. * You will need to pass the name of the uniform as well as the value.
  28719. */
  28720. updateVector4: (name: string, vector: Vector4) => void;
  28721. /**
  28722. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  28723. * This is dynamic to allow compat with webgl 1 and 2.
  28724. * You will need to pass the name of the uniform as well as the value.
  28725. */
  28726. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  28727. /**
  28728. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  28729. * This is dynamic to allow compat with webgl 1 and 2.
  28730. * You will need to pass the name of the uniform as well as the value.
  28731. */
  28732. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  28733. /**
  28734. * Instantiates a new Uniform buffer objects.
  28735. *
  28736. * Handles blocks of uniform on the GPU.
  28737. *
  28738. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28739. *
  28740. * For more information, please refer to :
  28741. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28742. * @param engine Define the engine the buffer is associated with
  28743. * @param data Define the data contained in the buffer
  28744. * @param dynamic Define if the buffer is updatable
  28745. */
  28746. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  28747. /**
  28748. * Indicates if the buffer is using the WebGL2 UBO implementation,
  28749. * or just falling back on setUniformXXX calls.
  28750. */
  28751. readonly useUbo: boolean;
  28752. /**
  28753. * Indicates if the WebGL underlying uniform buffer is in sync
  28754. * with the javascript cache data.
  28755. */
  28756. readonly isSync: boolean;
  28757. /**
  28758. * Indicates if the WebGL underlying uniform buffer is dynamic.
  28759. * Also, a dynamic UniformBuffer will disable cache verification and always
  28760. * update the underlying WebGL uniform buffer to the GPU.
  28761. * @returns if Dynamic, otherwise false
  28762. */
  28763. isDynamic(): boolean;
  28764. /**
  28765. * The data cache on JS side.
  28766. * @returns the underlying data as a float array
  28767. */
  28768. getData(): Float32Array;
  28769. /**
  28770. * The underlying WebGL Uniform buffer.
  28771. * @returns the webgl buffer
  28772. */
  28773. getBuffer(): Nullable<DataBuffer>;
  28774. /**
  28775. * std140 layout specifies how to align data within an UBO structure.
  28776. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  28777. * for specs.
  28778. */
  28779. private _fillAlignment;
  28780. /**
  28781. * Adds an uniform in the buffer.
  28782. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  28783. * for the layout to be correct !
  28784. * @param name Name of the uniform, as used in the uniform block in the shader.
  28785. * @param size Data size, or data directly.
  28786. */
  28787. addUniform(name: string, size: number | number[]): void;
  28788. /**
  28789. * Adds a Matrix 4x4 to the uniform buffer.
  28790. * @param name Name of the uniform, as used in the uniform block in the shader.
  28791. * @param mat A 4x4 matrix.
  28792. */
  28793. addMatrix(name: string, mat: Matrix): void;
  28794. /**
  28795. * Adds a vec2 to the uniform buffer.
  28796. * @param name Name of the uniform, as used in the uniform block in the shader.
  28797. * @param x Define the x component value of the vec2
  28798. * @param y Define the y component value of the vec2
  28799. */
  28800. addFloat2(name: string, x: number, y: number): void;
  28801. /**
  28802. * Adds a vec3 to the uniform buffer.
  28803. * @param name Name of the uniform, as used in the uniform block in the shader.
  28804. * @param x Define the x component value of the vec3
  28805. * @param y Define the y component value of the vec3
  28806. * @param z Define the z component value of the vec3
  28807. */
  28808. addFloat3(name: string, x: number, y: number, z: number): void;
  28809. /**
  28810. * Adds a vec3 to the uniform buffer.
  28811. * @param name Name of the uniform, as used in the uniform block in the shader.
  28812. * @param color Define the vec3 from a Color
  28813. */
  28814. addColor3(name: string, color: Color3): void;
  28815. /**
  28816. * Adds a vec4 to the uniform buffer.
  28817. * @param name Name of the uniform, as used in the uniform block in the shader.
  28818. * @param color Define the rgb components from a Color
  28819. * @param alpha Define the a component of the vec4
  28820. */
  28821. addColor4(name: string, color: Color3, alpha: number): void;
  28822. /**
  28823. * Adds a vec3 to the uniform buffer.
  28824. * @param name Name of the uniform, as used in the uniform block in the shader.
  28825. * @param vector Define the vec3 components from a Vector
  28826. */
  28827. addVector3(name: string, vector: Vector3): void;
  28828. /**
  28829. * Adds a Matrix 3x3 to the uniform buffer.
  28830. * @param name Name of the uniform, as used in the uniform block in the shader.
  28831. */
  28832. addMatrix3x3(name: string): void;
  28833. /**
  28834. * Adds a Matrix 2x2 to the uniform buffer.
  28835. * @param name Name of the uniform, as used in the uniform block in the shader.
  28836. */
  28837. addMatrix2x2(name: string): void;
  28838. /**
  28839. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  28840. */
  28841. create(): void;
  28842. /** @hidden */
  28843. _rebuild(): void;
  28844. /**
  28845. * Updates the WebGL Uniform Buffer on the GPU.
  28846. * If the `dynamic` flag is set to true, no cache comparison is done.
  28847. * Otherwise, the buffer will be updated only if the cache differs.
  28848. */
  28849. update(): void;
  28850. /**
  28851. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  28852. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28853. * @param data Define the flattened data
  28854. * @param size Define the size of the data.
  28855. */
  28856. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  28857. private _updateMatrix3x3ForUniform;
  28858. private _updateMatrix3x3ForEffect;
  28859. private _updateMatrix2x2ForEffect;
  28860. private _updateMatrix2x2ForUniform;
  28861. private _updateFloatForEffect;
  28862. private _updateFloatForUniform;
  28863. private _updateFloat2ForEffect;
  28864. private _updateFloat2ForUniform;
  28865. private _updateFloat3ForEffect;
  28866. private _updateFloat3ForUniform;
  28867. private _updateFloat4ForEffect;
  28868. private _updateFloat4ForUniform;
  28869. private _updateMatrixForEffect;
  28870. private _updateMatrixForUniform;
  28871. private _updateVector3ForEffect;
  28872. private _updateVector3ForUniform;
  28873. private _updateVector4ForEffect;
  28874. private _updateVector4ForUniform;
  28875. private _updateColor3ForEffect;
  28876. private _updateColor3ForUniform;
  28877. private _updateColor4ForEffect;
  28878. private _updateColor4ForUniform;
  28879. /**
  28880. * Sets a sampler uniform on the effect.
  28881. * @param name Define the name of the sampler.
  28882. * @param texture Define the texture to set in the sampler
  28883. */
  28884. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  28885. /**
  28886. * Directly updates the value of the uniform in the cache AND on the GPU.
  28887. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28888. * @param data Define the flattened data
  28889. */
  28890. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  28891. /**
  28892. * Binds this uniform buffer to an effect.
  28893. * @param effect Define the effect to bind the buffer to
  28894. * @param name Name of the uniform block in the shader.
  28895. */
  28896. bindToEffect(effect: Effect, name: string): void;
  28897. /**
  28898. * Disposes the uniform buffer.
  28899. */
  28900. dispose(): void;
  28901. }
  28902. }
  28903. declare module BABYLON {
  28904. /**
  28905. * Class used to work with sound analyzer using fast fourier transform (FFT)
  28906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28907. */
  28908. export class Analyser {
  28909. /**
  28910. * Gets or sets the smoothing
  28911. * @ignorenaming
  28912. */
  28913. SMOOTHING: number;
  28914. /**
  28915. * Gets or sets the FFT table size
  28916. * @ignorenaming
  28917. */
  28918. FFT_SIZE: number;
  28919. /**
  28920. * Gets or sets the bar graph amplitude
  28921. * @ignorenaming
  28922. */
  28923. BARGRAPHAMPLITUDE: number;
  28924. /**
  28925. * Gets or sets the position of the debug canvas
  28926. * @ignorenaming
  28927. */
  28928. DEBUGCANVASPOS: {
  28929. x: number;
  28930. y: number;
  28931. };
  28932. /**
  28933. * Gets or sets the debug canvas size
  28934. * @ignorenaming
  28935. */
  28936. DEBUGCANVASSIZE: {
  28937. width: number;
  28938. height: number;
  28939. };
  28940. private _byteFreqs;
  28941. private _byteTime;
  28942. private _floatFreqs;
  28943. private _webAudioAnalyser;
  28944. private _debugCanvas;
  28945. private _debugCanvasContext;
  28946. private _scene;
  28947. private _registerFunc;
  28948. private _audioEngine;
  28949. /**
  28950. * Creates a new analyser
  28951. * @param scene defines hosting scene
  28952. */
  28953. constructor(scene: Scene);
  28954. /**
  28955. * Get the number of data values you will have to play with for the visualization
  28956. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  28957. * @returns a number
  28958. */
  28959. getFrequencyBinCount(): number;
  28960. /**
  28961. * Gets the current frequency data as a byte array
  28962. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28963. * @returns a Uint8Array
  28964. */
  28965. getByteFrequencyData(): Uint8Array;
  28966. /**
  28967. * Gets the current waveform as a byte array
  28968. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  28969. * @returns a Uint8Array
  28970. */
  28971. getByteTimeDomainData(): Uint8Array;
  28972. /**
  28973. * Gets the current frequency data as a float array
  28974. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28975. * @returns a Float32Array
  28976. */
  28977. getFloatFrequencyData(): Float32Array;
  28978. /**
  28979. * Renders the debug canvas
  28980. */
  28981. drawDebugCanvas(): void;
  28982. /**
  28983. * Stops rendering the debug canvas and removes it
  28984. */
  28985. stopDebugCanvas(): void;
  28986. /**
  28987. * Connects two audio nodes
  28988. * @param inputAudioNode defines first node to connect
  28989. * @param outputAudioNode defines second node to connect
  28990. */
  28991. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  28992. /**
  28993. * Releases all associated resources
  28994. */
  28995. dispose(): void;
  28996. }
  28997. }
  28998. declare module BABYLON {
  28999. /**
  29000. * This represents an audio engine and it is responsible
  29001. * to play, synchronize and analyse sounds throughout the application.
  29002. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29003. */
  29004. export interface IAudioEngine extends IDisposable {
  29005. /**
  29006. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29007. */
  29008. readonly canUseWebAudio: boolean;
  29009. /**
  29010. * Gets the current AudioContext if available.
  29011. */
  29012. readonly audioContext: Nullable<AudioContext>;
  29013. /**
  29014. * The master gain node defines the global audio volume of your audio engine.
  29015. */
  29016. readonly masterGain: GainNode;
  29017. /**
  29018. * Gets whether or not mp3 are supported by your browser.
  29019. */
  29020. readonly isMP3supported: boolean;
  29021. /**
  29022. * Gets whether or not ogg are supported by your browser.
  29023. */
  29024. readonly isOGGsupported: boolean;
  29025. /**
  29026. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29027. * @ignoreNaming
  29028. */
  29029. WarnedWebAudioUnsupported: boolean;
  29030. /**
  29031. * Defines if the audio engine relies on a custom unlocked button.
  29032. * In this case, the embedded button will not be displayed.
  29033. */
  29034. useCustomUnlockedButton: boolean;
  29035. /**
  29036. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29037. */
  29038. readonly unlocked: boolean;
  29039. /**
  29040. * Event raised when audio has been unlocked on the browser.
  29041. */
  29042. onAudioUnlockedObservable: Observable<AudioEngine>;
  29043. /**
  29044. * Event raised when audio has been locked on the browser.
  29045. */
  29046. onAudioLockedObservable: Observable<AudioEngine>;
  29047. /**
  29048. * Flags the audio engine in Locked state.
  29049. * This happens due to new browser policies preventing audio to autoplay.
  29050. */
  29051. lock(): void;
  29052. /**
  29053. * Unlocks the audio engine once a user action has been done on the dom.
  29054. * This is helpful to resume play once browser policies have been satisfied.
  29055. */
  29056. unlock(): void;
  29057. }
  29058. /**
  29059. * This represents the default audio engine used in babylon.
  29060. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29061. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29062. */
  29063. export class AudioEngine implements IAudioEngine {
  29064. private _audioContext;
  29065. private _audioContextInitialized;
  29066. private _muteButton;
  29067. private _hostElement;
  29068. /**
  29069. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29070. */
  29071. canUseWebAudio: boolean;
  29072. /**
  29073. * The master gain node defines the global audio volume of your audio engine.
  29074. */
  29075. masterGain: GainNode;
  29076. /**
  29077. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29078. * @ignoreNaming
  29079. */
  29080. WarnedWebAudioUnsupported: boolean;
  29081. /**
  29082. * Gets whether or not mp3 are supported by your browser.
  29083. */
  29084. isMP3supported: boolean;
  29085. /**
  29086. * Gets whether or not ogg are supported by your browser.
  29087. */
  29088. isOGGsupported: boolean;
  29089. /**
  29090. * Gets whether audio has been unlocked on the device.
  29091. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29092. * a user interaction has happened.
  29093. */
  29094. unlocked: boolean;
  29095. /**
  29096. * Defines if the audio engine relies on a custom unlocked button.
  29097. * In this case, the embedded button will not be displayed.
  29098. */
  29099. useCustomUnlockedButton: boolean;
  29100. /**
  29101. * Event raised when audio has been unlocked on the browser.
  29102. */
  29103. onAudioUnlockedObservable: Observable<AudioEngine>;
  29104. /**
  29105. * Event raised when audio has been locked on the browser.
  29106. */
  29107. onAudioLockedObservable: Observable<AudioEngine>;
  29108. /**
  29109. * Gets the current AudioContext if available.
  29110. */
  29111. readonly audioContext: Nullable<AudioContext>;
  29112. private _connectedAnalyser;
  29113. /**
  29114. * Instantiates a new audio engine.
  29115. *
  29116. * There should be only one per page as some browsers restrict the number
  29117. * of audio contexts you can create.
  29118. * @param hostElement defines the host element where to display the mute icon if necessary
  29119. */
  29120. constructor(hostElement?: Nullable<HTMLElement>);
  29121. /**
  29122. * Flags the audio engine in Locked state.
  29123. * This happens due to new browser policies preventing audio to autoplay.
  29124. */
  29125. lock(): void;
  29126. /**
  29127. * Unlocks the audio engine once a user action has been done on the dom.
  29128. * This is helpful to resume play once browser policies have been satisfied.
  29129. */
  29130. unlock(): void;
  29131. private _resumeAudioContext;
  29132. private _initializeAudioContext;
  29133. private _tryToRun;
  29134. private _triggerRunningState;
  29135. private _triggerSuspendedState;
  29136. private _displayMuteButton;
  29137. private _moveButtonToTopLeft;
  29138. private _onResize;
  29139. private _hideMuteButton;
  29140. /**
  29141. * Destroy and release the resources associated with the audio ccontext.
  29142. */
  29143. dispose(): void;
  29144. /**
  29145. * Gets the global volume sets on the master gain.
  29146. * @returns the global volume if set or -1 otherwise
  29147. */
  29148. getGlobalVolume(): number;
  29149. /**
  29150. * Sets the global volume of your experience (sets on the master gain).
  29151. * @param newVolume Defines the new global volume of the application
  29152. */
  29153. setGlobalVolume(newVolume: number): void;
  29154. /**
  29155. * Connect the audio engine to an audio analyser allowing some amazing
  29156. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29158. * @param analyser The analyser to connect to the engine
  29159. */
  29160. connectToAnalyser(analyser: Analyser): void;
  29161. }
  29162. }
  29163. declare module BABYLON {
  29164. /**
  29165. * Interface used to present a loading screen while loading a scene
  29166. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29167. */
  29168. export interface ILoadingScreen {
  29169. /**
  29170. * Function called to display the loading screen
  29171. */
  29172. displayLoadingUI: () => void;
  29173. /**
  29174. * Function called to hide the loading screen
  29175. */
  29176. hideLoadingUI: () => void;
  29177. /**
  29178. * Gets or sets the color to use for the background
  29179. */
  29180. loadingUIBackgroundColor: string;
  29181. /**
  29182. * Gets or sets the text to display while loading
  29183. */
  29184. loadingUIText: string;
  29185. }
  29186. /**
  29187. * Class used for the default loading screen
  29188. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29189. */
  29190. export class DefaultLoadingScreen implements ILoadingScreen {
  29191. private _renderingCanvas;
  29192. private _loadingText;
  29193. private _loadingDivBackgroundColor;
  29194. private _loadingDiv;
  29195. private _loadingTextDiv;
  29196. /** Gets or sets the logo url to use for the default loading screen */
  29197. static DefaultLogoUrl: string;
  29198. /** Gets or sets the spinner url to use for the default loading screen */
  29199. static DefaultSpinnerUrl: string;
  29200. /**
  29201. * Creates a new default loading screen
  29202. * @param _renderingCanvas defines the canvas used to render the scene
  29203. * @param _loadingText defines the default text to display
  29204. * @param _loadingDivBackgroundColor defines the default background color
  29205. */
  29206. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  29207. /**
  29208. * Function called to display the loading screen
  29209. */
  29210. displayLoadingUI(): void;
  29211. /**
  29212. * Function called to hide the loading screen
  29213. */
  29214. hideLoadingUI(): void;
  29215. /**
  29216. * Gets or sets the text to display while loading
  29217. */
  29218. loadingUIText: string;
  29219. /**
  29220. * Gets or sets the color to use for the background
  29221. */
  29222. loadingUIBackgroundColor: string;
  29223. private _resizeLoadingUI;
  29224. }
  29225. }
  29226. declare module BABYLON {
  29227. /** @hidden */
  29228. export class WebGLPipelineContext implements IPipelineContext {
  29229. engine: Engine;
  29230. program: Nullable<WebGLProgram>;
  29231. context?: WebGLRenderingContext;
  29232. vertexShader?: WebGLShader;
  29233. fragmentShader?: WebGLShader;
  29234. isParallelCompiled: boolean;
  29235. onCompiled?: () => void;
  29236. transformFeedback?: WebGLTransformFeedback | null;
  29237. readonly isAsync: boolean;
  29238. readonly isReady: boolean;
  29239. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  29240. }
  29241. }
  29242. declare module BABYLON {
  29243. /** @hidden */
  29244. export class WebGLDataBuffer extends DataBuffer {
  29245. private _buffer;
  29246. constructor(resource: WebGLBuffer);
  29247. readonly underlyingResource: any;
  29248. }
  29249. }
  29250. declare module BABYLON {
  29251. /** @hidden */
  29252. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29253. attributeProcessor(attribute: string): string;
  29254. varyingProcessor(varying: string, isFragment: boolean): string;
  29255. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29256. }
  29257. }
  29258. declare module BABYLON {
  29259. /**
  29260. * This class is used to track a performance counter which is number based.
  29261. * The user has access to many properties which give statistics of different nature.
  29262. *
  29263. * The implementer can track two kinds of Performance Counter: time and count.
  29264. * 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.
  29265. * 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.
  29266. */
  29267. export class PerfCounter {
  29268. /**
  29269. * Gets or sets a global boolean to turn on and off all the counters
  29270. */
  29271. static Enabled: boolean;
  29272. /**
  29273. * Returns the smallest value ever
  29274. */
  29275. readonly min: number;
  29276. /**
  29277. * Returns the biggest value ever
  29278. */
  29279. readonly max: number;
  29280. /**
  29281. * Returns the average value since the performance counter is running
  29282. */
  29283. readonly average: number;
  29284. /**
  29285. * Returns the average value of the last second the counter was monitored
  29286. */
  29287. readonly lastSecAverage: number;
  29288. /**
  29289. * Returns the current value
  29290. */
  29291. readonly current: number;
  29292. /**
  29293. * Gets the accumulated total
  29294. */
  29295. readonly total: number;
  29296. /**
  29297. * Gets the total value count
  29298. */
  29299. readonly count: number;
  29300. /**
  29301. * Creates a new counter
  29302. */
  29303. constructor();
  29304. /**
  29305. * Call this method to start monitoring a new frame.
  29306. * 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.
  29307. */
  29308. fetchNewFrame(): void;
  29309. /**
  29310. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29311. * @param newCount the count value to add to the monitored count
  29312. * @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.
  29313. */
  29314. addCount(newCount: number, fetchResult: boolean): void;
  29315. /**
  29316. * Start monitoring this performance counter
  29317. */
  29318. beginMonitoring(): void;
  29319. /**
  29320. * Compute the time lapsed since the previous beginMonitoring() call.
  29321. * @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
  29322. */
  29323. endMonitoring(newFrame?: boolean): void;
  29324. private _fetchResult;
  29325. private _startMonitoringTime;
  29326. private _min;
  29327. private _max;
  29328. private _average;
  29329. private _current;
  29330. private _totalValueCount;
  29331. private _totalAccumulated;
  29332. private _lastSecAverage;
  29333. private _lastSecAccumulated;
  29334. private _lastSecTime;
  29335. private _lastSecValueCount;
  29336. }
  29337. }
  29338. declare module BABYLON {
  29339. /**
  29340. * Interface for any object that can request an animation frame
  29341. */
  29342. export interface ICustomAnimationFrameRequester {
  29343. /**
  29344. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29345. */
  29346. renderFunction?: Function;
  29347. /**
  29348. * Called to request the next frame to render to
  29349. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29350. */
  29351. requestAnimationFrame: Function;
  29352. /**
  29353. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29354. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29355. */
  29356. requestID?: number;
  29357. }
  29358. }
  29359. declare module BABYLON {
  29360. /**
  29361. * Settings for finer control over video usage
  29362. */
  29363. export interface VideoTextureSettings {
  29364. /**
  29365. * Applies `autoplay` to video, if specified
  29366. */
  29367. autoPlay?: boolean;
  29368. /**
  29369. * Applies `loop` to video, if specified
  29370. */
  29371. loop?: boolean;
  29372. /**
  29373. * Automatically updates internal texture from video at every frame in the render loop
  29374. */
  29375. autoUpdateTexture: boolean;
  29376. /**
  29377. * Image src displayed during the video loading or until the user interacts with the video.
  29378. */
  29379. poster?: string;
  29380. }
  29381. /**
  29382. * If you want to display a video in your scene, this is the special texture for that.
  29383. * This special texture works similar to other textures, with the exception of a few parameters.
  29384. * @see https://doc.babylonjs.com/how_to/video_texture
  29385. */
  29386. export class VideoTexture extends Texture {
  29387. /**
  29388. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29389. */
  29390. readonly autoUpdateTexture: boolean;
  29391. /**
  29392. * The video instance used by the texture internally
  29393. */
  29394. readonly video: HTMLVideoElement;
  29395. private _onUserActionRequestedObservable;
  29396. /**
  29397. * Event triggerd when a dom action is required by the user to play the video.
  29398. * This happens due to recent changes in browser policies preventing video to auto start.
  29399. */
  29400. readonly onUserActionRequestedObservable: Observable<Texture>;
  29401. private _generateMipMaps;
  29402. private _engine;
  29403. private _stillImageCaptured;
  29404. private _displayingPosterTexture;
  29405. private _settings;
  29406. private _createInternalTextureOnEvent;
  29407. /**
  29408. * Creates a video texture.
  29409. * If you want to display a video in your scene, this is the special texture for that.
  29410. * This special texture works similar to other textures, with the exception of a few parameters.
  29411. * @see https://doc.babylonjs.com/how_to/video_texture
  29412. * @param name optional name, will detect from video source, if not defined
  29413. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29414. * @param scene is obviously the current scene.
  29415. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29416. * @param invertY is false by default but can be used to invert video on Y axis
  29417. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29418. * @param settings allows finer control over video usage
  29419. */
  29420. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29421. private _getName;
  29422. private _getVideo;
  29423. private _createInternalTexture;
  29424. private reset;
  29425. /**
  29426. * @hidden Internal method to initiate `update`.
  29427. */
  29428. _rebuild(): void;
  29429. /**
  29430. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29431. */
  29432. update(): void;
  29433. /**
  29434. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29435. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29436. */
  29437. updateTexture(isVisible: boolean): void;
  29438. protected _updateInternalTexture: () => void;
  29439. /**
  29440. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29441. * @param url New url.
  29442. */
  29443. updateURL(url: string): void;
  29444. /**
  29445. * Dispose the texture and release its associated resources.
  29446. */
  29447. dispose(): void;
  29448. /**
  29449. * Creates a video texture straight from a stream.
  29450. * @param scene Define the scene the texture should be created in
  29451. * @param stream Define the stream the texture should be created from
  29452. * @returns The created video texture as a promise
  29453. */
  29454. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29455. /**
  29456. * Creates a video texture straight from your WebCam video feed.
  29457. * @param scene Define the scene the texture should be created in
  29458. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29459. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29460. * @returns The created video texture as a promise
  29461. */
  29462. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29463. minWidth: number;
  29464. maxWidth: number;
  29465. minHeight: number;
  29466. maxHeight: number;
  29467. deviceId: string;
  29468. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29469. /**
  29470. * Creates a video texture straight from your WebCam video feed.
  29471. * @param scene Define the scene the texture should be created in
  29472. * @param onReady Define a callback to triggered once the texture will be ready
  29473. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29474. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29475. */
  29476. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29477. minWidth: number;
  29478. maxWidth: number;
  29479. minHeight: number;
  29480. maxHeight: number;
  29481. deviceId: string;
  29482. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29483. }
  29484. }
  29485. declare module BABYLON {
  29486. /**
  29487. * Defines the interface used by objects containing a viewport (like a camera)
  29488. */
  29489. interface IViewportOwnerLike {
  29490. /**
  29491. * Gets or sets the viewport
  29492. */
  29493. viewport: IViewportLike;
  29494. }
  29495. /**
  29496. * Interface for attribute information associated with buffer instanciation
  29497. */
  29498. export class InstancingAttributeInfo {
  29499. /**
  29500. * Index/offset of the attribute in the vertex shader
  29501. */
  29502. index: number;
  29503. /**
  29504. * size of the attribute, 1, 2, 3 or 4
  29505. */
  29506. attributeSize: number;
  29507. /**
  29508. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29509. * default is FLOAT
  29510. */
  29511. attribyteType: number;
  29512. /**
  29513. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29514. */
  29515. normalized: boolean;
  29516. /**
  29517. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29518. */
  29519. offset: number;
  29520. /**
  29521. * Name of the GLSL attribute, for debugging purpose only
  29522. */
  29523. attributeName: string;
  29524. }
  29525. /**
  29526. * Define options used to create a depth texture
  29527. */
  29528. export class DepthTextureCreationOptions {
  29529. /** Specifies whether or not a stencil should be allocated in the texture */
  29530. generateStencil?: boolean;
  29531. /** Specifies whether or not bilinear filtering is enable on the texture */
  29532. bilinearFiltering?: boolean;
  29533. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  29534. comparisonFunction?: number;
  29535. /** Specifies if the created texture is a cube texture */
  29536. isCube?: boolean;
  29537. }
  29538. /**
  29539. * Class used to describe the capabilities of the engine relatively to the current browser
  29540. */
  29541. export class EngineCapabilities {
  29542. /** Maximum textures units per fragment shader */
  29543. maxTexturesImageUnits: number;
  29544. /** Maximum texture units per vertex shader */
  29545. maxVertexTextureImageUnits: number;
  29546. /** Maximum textures units in the entire pipeline */
  29547. maxCombinedTexturesImageUnits: number;
  29548. /** Maximum texture size */
  29549. maxTextureSize: number;
  29550. /** Maximum cube texture size */
  29551. maxCubemapTextureSize: number;
  29552. /** Maximum render texture size */
  29553. maxRenderTextureSize: number;
  29554. /** Maximum number of vertex attributes */
  29555. maxVertexAttribs: number;
  29556. /** Maximum number of varyings */
  29557. maxVaryingVectors: number;
  29558. /** Maximum number of uniforms per vertex shader */
  29559. maxVertexUniformVectors: number;
  29560. /** Maximum number of uniforms per fragment shader */
  29561. maxFragmentUniformVectors: number;
  29562. /** Defines if standard derivates (dx/dy) are supported */
  29563. standardDerivatives: boolean;
  29564. /** Defines if s3tc texture compression is supported */
  29565. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29566. /** Defines if pvrtc texture compression is supported */
  29567. pvrtc: any;
  29568. /** Defines if etc1 texture compression is supported */
  29569. etc1: any;
  29570. /** Defines if etc2 texture compression is supported */
  29571. etc2: any;
  29572. /** Defines if astc texture compression is supported */
  29573. astc: any;
  29574. /** Defines if float textures are supported */
  29575. textureFloat: boolean;
  29576. /** Defines if vertex array objects are supported */
  29577. vertexArrayObject: boolean;
  29578. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29579. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29580. /** Gets the maximum level of anisotropy supported */
  29581. maxAnisotropy: number;
  29582. /** Defines if instancing is supported */
  29583. instancedArrays: boolean;
  29584. /** Defines if 32 bits indices are supported */
  29585. uintIndices: boolean;
  29586. /** Defines if high precision shaders are supported */
  29587. highPrecisionShaderSupported: boolean;
  29588. /** Defines if depth reading in the fragment shader is supported */
  29589. fragmentDepthSupported: boolean;
  29590. /** Defines if float texture linear filtering is supported*/
  29591. textureFloatLinearFiltering: boolean;
  29592. /** Defines if rendering to float textures is supported */
  29593. textureFloatRender: boolean;
  29594. /** Defines if half float textures are supported*/
  29595. textureHalfFloat: boolean;
  29596. /** Defines if half float texture linear filtering is supported*/
  29597. textureHalfFloatLinearFiltering: boolean;
  29598. /** Defines if rendering to half float textures is supported */
  29599. textureHalfFloatRender: boolean;
  29600. /** Defines if textureLOD shader command is supported */
  29601. textureLOD: boolean;
  29602. /** Defines if draw buffers extension is supported */
  29603. drawBuffersExtension: boolean;
  29604. /** Defines if depth textures are supported */
  29605. depthTextureExtension: boolean;
  29606. /** Defines if float color buffer are supported */
  29607. colorBufferFloat: boolean;
  29608. /** Gets disjoint timer query extension (null if not supported) */
  29609. timerQuery: EXT_disjoint_timer_query;
  29610. /** Defines if timestamp can be used with timer query */
  29611. canUseTimestampForTimerQuery: boolean;
  29612. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29613. multiview: any;
  29614. /** Function used to let the system compiles shaders in background */
  29615. parallelShaderCompile: {
  29616. COMPLETION_STATUS_KHR: number;
  29617. };
  29618. }
  29619. /** Interface defining initialization parameters for Engine class */
  29620. export interface EngineOptions extends WebGLContextAttributes {
  29621. /**
  29622. * Defines if the engine should no exceed a specified device ratio
  29623. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29624. */
  29625. limitDeviceRatio?: number;
  29626. /**
  29627. * Defines if webvr should be enabled automatically
  29628. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29629. */
  29630. autoEnableWebVR?: boolean;
  29631. /**
  29632. * Defines if webgl2 should be turned off even if supported
  29633. * @see http://doc.babylonjs.com/features/webgl2
  29634. */
  29635. disableWebGL2Support?: boolean;
  29636. /**
  29637. * Defines if webaudio should be initialized as well
  29638. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29639. */
  29640. audioEngine?: boolean;
  29641. /**
  29642. * Defines if animations should run using a deterministic lock step
  29643. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29644. */
  29645. deterministicLockstep?: boolean;
  29646. /** Defines the maximum steps to use with deterministic lock step mode */
  29647. lockstepMaxSteps?: number;
  29648. /**
  29649. * Defines that engine should ignore context lost events
  29650. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29651. */
  29652. doNotHandleContextLost?: boolean;
  29653. /**
  29654. * Defines that engine should ignore modifying touch action attribute and style
  29655. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29656. */
  29657. doNotHandleTouchAction?: boolean;
  29658. /**
  29659. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29660. */
  29661. useHighPrecisionFloats?: boolean;
  29662. }
  29663. /**
  29664. * Defines the interface used by display changed events
  29665. */
  29666. export interface IDisplayChangedEventArgs {
  29667. /** Gets the vrDisplay object (if any) */
  29668. vrDisplay: Nullable<any>;
  29669. /** Gets a boolean indicating if webVR is supported */
  29670. vrSupported: boolean;
  29671. }
  29672. /**
  29673. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29674. */
  29675. export class Engine {
  29676. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29677. static ExceptionList: ({
  29678. key: string;
  29679. capture: string;
  29680. captureConstraint: number;
  29681. targets: string[];
  29682. } | {
  29683. key: string;
  29684. capture: null;
  29685. captureConstraint: null;
  29686. targets: string[];
  29687. })[];
  29688. /** Gets the list of created engines */
  29689. static readonly Instances: Engine[];
  29690. /**
  29691. * Gets the latest created engine
  29692. */
  29693. static readonly LastCreatedEngine: Nullable<Engine>;
  29694. /**
  29695. * Gets the latest created scene
  29696. */
  29697. static readonly LastCreatedScene: Nullable<Scene>;
  29698. /**
  29699. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29700. * @param flag defines which part of the materials must be marked as dirty
  29701. * @param predicate defines a predicate used to filter which materials should be affected
  29702. */
  29703. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29704. /** @hidden */
  29705. static _TextureLoaders: IInternalTextureLoader[];
  29706. /** Defines that alpha blending is disabled */
  29707. static readonly ALPHA_DISABLE: number;
  29708. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29709. static readonly ALPHA_ADD: number;
  29710. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29711. static readonly ALPHA_COMBINE: number;
  29712. /** Defines that alpha blending to DEST - SRC * DEST */
  29713. static readonly ALPHA_SUBTRACT: number;
  29714. /** Defines that alpha blending to SRC * DEST */
  29715. static readonly ALPHA_MULTIPLY: number;
  29716. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29717. static readonly ALPHA_MAXIMIZED: number;
  29718. /** Defines that alpha blending to SRC + DEST */
  29719. static readonly ALPHA_ONEONE: number;
  29720. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29721. static readonly ALPHA_PREMULTIPLIED: number;
  29722. /**
  29723. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29724. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29725. */
  29726. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29727. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29728. static readonly ALPHA_INTERPOLATE: number;
  29729. /**
  29730. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29731. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29732. */
  29733. static readonly ALPHA_SCREENMODE: number;
  29734. /** Defines that the ressource is not delayed*/
  29735. static readonly DELAYLOADSTATE_NONE: number;
  29736. /** Defines that the ressource was successfully delay loaded */
  29737. static readonly DELAYLOADSTATE_LOADED: number;
  29738. /** Defines that the ressource is currently delay loading */
  29739. static readonly DELAYLOADSTATE_LOADING: number;
  29740. /** Defines that the ressource is delayed and has not started loading */
  29741. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29742. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29743. static readonly NEVER: number;
  29744. /** 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 */
  29745. static readonly ALWAYS: number;
  29746. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29747. static readonly LESS: number;
  29748. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29749. static readonly EQUAL: number;
  29750. /** 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 */
  29751. static readonly LEQUAL: number;
  29752. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29753. static readonly GREATER: number;
  29754. /** 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 */
  29755. static readonly GEQUAL: number;
  29756. /** 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 */
  29757. static readonly NOTEQUAL: number;
  29758. /** Passed to stencilOperation to specify that stencil value must be kept */
  29759. static readonly KEEP: number;
  29760. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29761. static readonly REPLACE: number;
  29762. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29763. static readonly INCR: number;
  29764. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29765. static readonly DECR: number;
  29766. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29767. static readonly INVERT: number;
  29768. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29769. static readonly INCR_WRAP: number;
  29770. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29771. static readonly DECR_WRAP: number;
  29772. /** Texture is not repeating outside of 0..1 UVs */
  29773. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  29774. /** Texture is repeating outside of 0..1 UVs */
  29775. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  29776. /** Texture is repeating and mirrored */
  29777. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  29778. /** ALPHA */
  29779. static readonly TEXTUREFORMAT_ALPHA: number;
  29780. /** LUMINANCE */
  29781. static readonly TEXTUREFORMAT_LUMINANCE: number;
  29782. /** LUMINANCE_ALPHA */
  29783. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  29784. /** RGB */
  29785. static readonly TEXTUREFORMAT_RGB: number;
  29786. /** RGBA */
  29787. static readonly TEXTUREFORMAT_RGBA: number;
  29788. /** RED */
  29789. static readonly TEXTUREFORMAT_RED: number;
  29790. /** RED (2nd reference) */
  29791. static readonly TEXTUREFORMAT_R: number;
  29792. /** RG */
  29793. static readonly TEXTUREFORMAT_RG: number;
  29794. /** RED_INTEGER */
  29795. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  29796. /** RED_INTEGER (2nd reference) */
  29797. static readonly TEXTUREFORMAT_R_INTEGER: number;
  29798. /** RG_INTEGER */
  29799. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  29800. /** RGB_INTEGER */
  29801. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  29802. /** RGBA_INTEGER */
  29803. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  29804. /** UNSIGNED_BYTE */
  29805. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  29806. /** UNSIGNED_BYTE (2nd reference) */
  29807. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  29808. /** FLOAT */
  29809. static readonly TEXTURETYPE_FLOAT: number;
  29810. /** HALF_FLOAT */
  29811. static readonly TEXTURETYPE_HALF_FLOAT: number;
  29812. /** BYTE */
  29813. static readonly TEXTURETYPE_BYTE: number;
  29814. /** SHORT */
  29815. static readonly TEXTURETYPE_SHORT: number;
  29816. /** UNSIGNED_SHORT */
  29817. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  29818. /** INT */
  29819. static readonly TEXTURETYPE_INT: number;
  29820. /** UNSIGNED_INT */
  29821. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  29822. /** UNSIGNED_SHORT_4_4_4_4 */
  29823. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  29824. /** UNSIGNED_SHORT_5_5_5_1 */
  29825. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  29826. /** UNSIGNED_SHORT_5_6_5 */
  29827. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  29828. /** UNSIGNED_INT_2_10_10_10_REV */
  29829. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  29830. /** UNSIGNED_INT_24_8 */
  29831. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  29832. /** UNSIGNED_INT_10F_11F_11F_REV */
  29833. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  29834. /** UNSIGNED_INT_5_9_9_9_REV */
  29835. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  29836. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  29837. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  29838. /** nearest is mag = nearest and min = nearest and mip = linear */
  29839. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  29840. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29841. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  29842. /** Trilinear is mag = linear and min = linear and mip = linear */
  29843. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  29844. /** nearest is mag = nearest and min = nearest and mip = linear */
  29845. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  29846. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29847. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  29848. /** Trilinear is mag = linear and min = linear and mip = linear */
  29849. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  29850. /** mag = nearest and min = nearest and mip = nearest */
  29851. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  29852. /** mag = nearest and min = linear and mip = nearest */
  29853. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  29854. /** mag = nearest and min = linear and mip = linear */
  29855. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  29856. /** mag = nearest and min = linear and mip = none */
  29857. static readonly TEXTURE_NEAREST_LINEAR: number;
  29858. /** mag = nearest and min = nearest and mip = none */
  29859. static readonly TEXTURE_NEAREST_NEAREST: number;
  29860. /** mag = linear and min = nearest and mip = nearest */
  29861. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  29862. /** mag = linear and min = nearest and mip = linear */
  29863. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  29864. /** mag = linear and min = linear and mip = none */
  29865. static readonly TEXTURE_LINEAR_LINEAR: number;
  29866. /** mag = linear and min = nearest and mip = none */
  29867. static readonly TEXTURE_LINEAR_NEAREST: number;
  29868. /** Explicit coordinates mode */
  29869. static readonly TEXTURE_EXPLICIT_MODE: number;
  29870. /** Spherical coordinates mode */
  29871. static readonly TEXTURE_SPHERICAL_MODE: number;
  29872. /** Planar coordinates mode */
  29873. static readonly TEXTURE_PLANAR_MODE: number;
  29874. /** Cubic coordinates mode */
  29875. static readonly TEXTURE_CUBIC_MODE: number;
  29876. /** Projection coordinates mode */
  29877. static readonly TEXTURE_PROJECTION_MODE: number;
  29878. /** Skybox coordinates mode */
  29879. static readonly TEXTURE_SKYBOX_MODE: number;
  29880. /** Inverse Cubic coordinates mode */
  29881. static readonly TEXTURE_INVCUBIC_MODE: number;
  29882. /** Equirectangular coordinates mode */
  29883. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  29884. /** Equirectangular Fixed coordinates mode */
  29885. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  29886. /** Equirectangular Fixed Mirrored coordinates mode */
  29887. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29888. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  29889. static readonly SCALEMODE_FLOOR: number;
  29890. /** Defines that texture rescaling will look for the nearest power of 2 size */
  29891. static readonly SCALEMODE_NEAREST: number;
  29892. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  29893. static readonly SCALEMODE_CEILING: number;
  29894. /**
  29895. * Returns the current npm package of the sdk
  29896. */
  29897. static readonly NpmPackage: string;
  29898. /**
  29899. * Returns the current version of the framework
  29900. */
  29901. static readonly Version: string;
  29902. /**
  29903. * Returns a string describing the current engine
  29904. */
  29905. readonly description: string;
  29906. /**
  29907. * Gets or sets the epsilon value used by collision engine
  29908. */
  29909. static CollisionsEpsilon: number;
  29910. /**
  29911. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29912. */
  29913. static ShadersRepository: string;
  29914. /**
  29915. * Method called to create the default loading screen.
  29916. * This can be overriden in your own app.
  29917. * @param canvas The rendering canvas element
  29918. * @returns The loading screen
  29919. */
  29920. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  29921. /**
  29922. * Method called to create the default rescale post process on each engine.
  29923. */
  29924. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  29925. /** @hidden */
  29926. _shaderProcessor: IShaderProcessor;
  29927. /**
  29928. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29929. */
  29930. forcePOTTextures: boolean;
  29931. /**
  29932. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29933. */
  29934. isFullscreen: boolean;
  29935. /**
  29936. * Gets a boolean indicating if the pointer is currently locked
  29937. */
  29938. isPointerLock: boolean;
  29939. /**
  29940. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29941. */
  29942. cullBackFaces: boolean;
  29943. /**
  29944. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29945. */
  29946. renderEvenInBackground: boolean;
  29947. /**
  29948. * Gets or sets a boolean indicating that cache can be kept between frames
  29949. */
  29950. preventCacheWipeBetweenFrames: boolean;
  29951. /**
  29952. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  29953. **/
  29954. enableOfflineSupport: boolean;
  29955. /**
  29956. * 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)
  29957. **/
  29958. disableManifestCheck: boolean;
  29959. /**
  29960. * Gets the list of created scenes
  29961. */
  29962. scenes: Scene[];
  29963. /**
  29964. * Event raised when a new scene is created
  29965. */
  29966. onNewSceneAddedObservable: Observable<Scene>;
  29967. /**
  29968. * Gets the list of created postprocesses
  29969. */
  29970. postProcesses: PostProcess[];
  29971. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29972. validateShaderPrograms: boolean;
  29973. /**
  29974. * Observable event triggered each time the rendering canvas is resized
  29975. */
  29976. onResizeObservable: Observable<Engine>;
  29977. /**
  29978. * Observable event triggered each time the canvas loses focus
  29979. */
  29980. onCanvasBlurObservable: Observable<Engine>;
  29981. /**
  29982. * Observable event triggered each time the canvas gains focus
  29983. */
  29984. onCanvasFocusObservable: Observable<Engine>;
  29985. /**
  29986. * Observable event triggered each time the canvas receives pointerout event
  29987. */
  29988. onCanvasPointerOutObservable: Observable<PointerEvent>;
  29989. /**
  29990. * Observable event triggered before each texture is initialized
  29991. */
  29992. onBeforeTextureInitObservable: Observable<Texture>;
  29993. /**
  29994. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29995. */
  29996. disableUniformBuffers: boolean;
  29997. /** @hidden */
  29998. _uniformBuffers: UniformBuffer[];
  29999. /**
  30000. * Gets a boolean indicating that the engine supports uniform buffers
  30001. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30002. */
  30003. readonly supportsUniformBuffers: boolean;
  30004. /**
  30005. * Observable raised when the engine begins a new frame
  30006. */
  30007. onBeginFrameObservable: Observable<Engine>;
  30008. /**
  30009. * If set, will be used to request the next animation frame for the render loop
  30010. */
  30011. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30012. /**
  30013. * Observable raised when the engine ends the current frame
  30014. */
  30015. onEndFrameObservable: Observable<Engine>;
  30016. /**
  30017. * Observable raised when the engine is about to compile a shader
  30018. */
  30019. onBeforeShaderCompilationObservable: Observable<Engine>;
  30020. /**
  30021. * Observable raised when the engine has jsut compiled a shader
  30022. */
  30023. onAfterShaderCompilationObservable: Observable<Engine>;
  30024. /** @hidden */
  30025. _gl: WebGLRenderingContext;
  30026. private _renderingCanvas;
  30027. private _windowIsBackground;
  30028. private _webGLVersion;
  30029. protected _highPrecisionShadersAllowed: boolean;
  30030. /** @hidden */
  30031. readonly _shouldUseHighPrecisionShader: boolean;
  30032. /**
  30033. * Gets a boolean indicating that only power of 2 textures are supported
  30034. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30035. */
  30036. readonly needPOTTextures: boolean;
  30037. /** @hidden */
  30038. _badOS: boolean;
  30039. /** @hidden */
  30040. _badDesktopOS: boolean;
  30041. /**
  30042. * Gets the audio engine
  30043. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30044. * @ignorenaming
  30045. */
  30046. static audioEngine: IAudioEngine;
  30047. /**
  30048. * Default AudioEngine factory responsible of creating the Audio Engine.
  30049. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30050. */
  30051. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30052. /**
  30053. * Default offline support factory responsible of creating a tool used to store data locally.
  30054. * By default, this will create a Database object if the workload has been embedded.
  30055. */
  30056. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30057. private _onFocus;
  30058. private _onBlur;
  30059. private _onCanvasPointerOut;
  30060. private _onCanvasBlur;
  30061. private _onCanvasFocus;
  30062. private _onFullscreenChange;
  30063. private _onPointerLockChange;
  30064. private _hardwareScalingLevel;
  30065. /** @hidden */
  30066. _caps: EngineCapabilities;
  30067. private _pointerLockRequested;
  30068. private _isStencilEnable;
  30069. private _colorWrite;
  30070. private _loadingScreen;
  30071. /** @hidden */
  30072. _drawCalls: PerfCounter;
  30073. private _glVersion;
  30074. private _glRenderer;
  30075. private _glVendor;
  30076. private _videoTextureSupported;
  30077. private _renderingQueueLaunched;
  30078. private _activeRenderLoops;
  30079. private _deterministicLockstep;
  30080. private _lockstepMaxSteps;
  30081. /**
  30082. * Observable signaled when a context lost event is raised
  30083. */
  30084. onContextLostObservable: Observable<Engine>;
  30085. /**
  30086. * Observable signaled when a context restored event is raised
  30087. */
  30088. onContextRestoredObservable: Observable<Engine>;
  30089. private _onContextLost;
  30090. private _onContextRestored;
  30091. private _contextWasLost;
  30092. /** @hidden */
  30093. _doNotHandleContextLost: boolean;
  30094. /**
  30095. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30096. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30097. */
  30098. doNotHandleContextLost: boolean;
  30099. private _performanceMonitor;
  30100. private _fps;
  30101. private _deltaTime;
  30102. /**
  30103. * Turn this value on if you want to pause FPS computation when in background
  30104. */
  30105. disablePerformanceMonitorInBackground: boolean;
  30106. /**
  30107. * Gets the performance monitor attached to this engine
  30108. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30109. */
  30110. readonly performanceMonitor: PerformanceMonitor;
  30111. /**
  30112. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30113. */
  30114. disableVertexArrayObjects: boolean;
  30115. /** @hidden */
  30116. protected _depthCullingState: _DepthCullingState;
  30117. /** @hidden */
  30118. protected _stencilState: _StencilState;
  30119. /** @hidden */
  30120. protected _alphaState: _AlphaState;
  30121. /** @hidden */
  30122. protected _alphaMode: number;
  30123. /** @hidden */
  30124. _internalTexturesCache: InternalTexture[];
  30125. /** @hidden */
  30126. protected _activeChannel: number;
  30127. private _currentTextureChannel;
  30128. /** @hidden */
  30129. protected _boundTexturesCache: {
  30130. [key: string]: Nullable<InternalTexture>;
  30131. };
  30132. /** @hidden */
  30133. protected _currentEffect: Nullable<Effect>;
  30134. /** @hidden */
  30135. protected _currentProgram: Nullable<WebGLProgram>;
  30136. private _compiledEffects;
  30137. private _vertexAttribArraysEnabled;
  30138. /** @hidden */
  30139. protected _cachedViewport: Nullable<IViewportLike>;
  30140. private _cachedVertexArrayObject;
  30141. /** @hidden */
  30142. protected _cachedVertexBuffers: any;
  30143. /** @hidden */
  30144. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30145. /** @hidden */
  30146. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30147. /** @hidden */
  30148. _currentRenderTarget: Nullable<InternalTexture>;
  30149. private _uintIndicesCurrentlySet;
  30150. private _currentBoundBuffer;
  30151. /** @hidden */
  30152. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30153. private _currentBufferPointers;
  30154. private _currentInstanceLocations;
  30155. private _currentInstanceBuffers;
  30156. private _textureUnits;
  30157. /** @hidden */
  30158. _workingCanvas: Nullable<HTMLCanvasElement>;
  30159. /** @hidden */
  30160. _workingContext: Nullable<CanvasRenderingContext2D>;
  30161. private _rescalePostProcess;
  30162. private _dummyFramebuffer;
  30163. private _externalData;
  30164. /** @hidden */
  30165. _bindedRenderFunction: any;
  30166. private _vaoRecordInProgress;
  30167. private _mustWipeVertexAttributes;
  30168. private _emptyTexture;
  30169. private _emptyCubeTexture;
  30170. private _emptyTexture3D;
  30171. /** @hidden */
  30172. _frameHandler: number;
  30173. private _nextFreeTextureSlots;
  30174. private _maxSimultaneousTextures;
  30175. private _activeRequests;
  30176. private _texturesSupported;
  30177. /** @hidden */
  30178. _textureFormatInUse: Nullable<string>;
  30179. /**
  30180. * Gets the list of texture formats supported
  30181. */
  30182. readonly texturesSupported: Array<string>;
  30183. /**
  30184. * Gets the list of texture formats in use
  30185. */
  30186. readonly textureFormatInUse: Nullable<string>;
  30187. /**
  30188. * Gets the current viewport
  30189. */
  30190. readonly currentViewport: Nullable<IViewportLike>;
  30191. /**
  30192. * Gets the default empty texture
  30193. */
  30194. readonly emptyTexture: InternalTexture;
  30195. /**
  30196. * Gets the default empty 3D texture
  30197. */
  30198. readonly emptyTexture3D: InternalTexture;
  30199. /**
  30200. * Gets the default empty cube texture
  30201. */
  30202. readonly emptyCubeTexture: InternalTexture;
  30203. /**
  30204. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30205. */
  30206. readonly premultipliedAlpha: boolean;
  30207. /**
  30208. * Creates a new engine
  30209. * @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
  30210. * @param antialias defines enable antialiasing (default: false)
  30211. * @param options defines further options to be sent to the getContext() function
  30212. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30213. */
  30214. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30215. /**
  30216. * Initializes a webVR display and starts listening to display change events
  30217. * The onVRDisplayChangedObservable will be notified upon these changes
  30218. * @returns The onVRDisplayChangedObservable
  30219. */
  30220. initWebVR(): Observable<IDisplayChangedEventArgs>;
  30221. /** @hidden */
  30222. _prepareVRComponent(): void;
  30223. /** @hidden */
  30224. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  30225. /** @hidden */
  30226. _submitVRFrame(): void;
  30227. /**
  30228. * Call this function to leave webVR mode
  30229. * Will do nothing if webVR is not supported or if there is no webVR device
  30230. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30231. */
  30232. disableVR(): void;
  30233. /**
  30234. * Gets a boolean indicating that the system is in VR mode and is presenting
  30235. * @returns true if VR mode is engaged
  30236. */
  30237. isVRPresenting(): boolean;
  30238. /** @hidden */
  30239. _requestVRFrame(): void;
  30240. private _disableTouchAction;
  30241. private _rebuildInternalTextures;
  30242. private _rebuildEffects;
  30243. /**
  30244. * Gets a boolean indicating if all created effects are ready
  30245. * @returns true if all effects are ready
  30246. */
  30247. areAllEffectsReady(): boolean;
  30248. private _rebuildBuffers;
  30249. private _initGLContext;
  30250. /**
  30251. * Gets version of the current webGL context
  30252. */
  30253. readonly webGLVersion: number;
  30254. /**
  30255. * Gets a string idenfifying the name of the class
  30256. * @returns "Engine" string
  30257. */
  30258. getClassName(): string;
  30259. /**
  30260. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30261. */
  30262. readonly isStencilEnable: boolean;
  30263. /** @hidden */
  30264. _prepareWorkingCanvas(): void;
  30265. /**
  30266. * Reset the texture cache to empty state
  30267. */
  30268. resetTextureCache(): void;
  30269. /**
  30270. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30271. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30272. * @returns true if engine is in deterministic lock step mode
  30273. */
  30274. isDeterministicLockStep(): boolean;
  30275. /**
  30276. * Gets the max steps when engine is running in deterministic lock step
  30277. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30278. * @returns the max steps
  30279. */
  30280. getLockstepMaxSteps(): number;
  30281. /**
  30282. * Gets an object containing information about the current webGL context
  30283. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30284. */
  30285. getGlInfo(): {
  30286. vendor: string;
  30287. renderer: string;
  30288. version: string;
  30289. };
  30290. /**
  30291. * Gets current aspect ratio
  30292. * @param viewportOwner defines the camera to use to get the aspect ratio
  30293. * @param useScreen defines if screen size must be used (or the current render target if any)
  30294. * @returns a number defining the aspect ratio
  30295. */
  30296. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30297. /**
  30298. * Gets current screen aspect ratio
  30299. * @returns a number defining the aspect ratio
  30300. */
  30301. getScreenAspectRatio(): number;
  30302. /**
  30303. * Gets the current render width
  30304. * @param useScreen defines if screen size must be used (or the current render target if any)
  30305. * @returns a number defining the current render width
  30306. */
  30307. getRenderWidth(useScreen?: boolean): number;
  30308. /**
  30309. * Gets the current render height
  30310. * @param useScreen defines if screen size must be used (or the current render target if any)
  30311. * @returns a number defining the current render height
  30312. */
  30313. getRenderHeight(useScreen?: boolean): number;
  30314. /**
  30315. * Gets the HTML canvas attached with the current webGL context
  30316. * @returns a HTML canvas
  30317. */
  30318. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30319. /**
  30320. * Gets the client rect of the HTML canvas attached with the current webGL context
  30321. * @returns a client rectanglee
  30322. */
  30323. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30324. /**
  30325. * Defines the hardware scaling level.
  30326. * By default the hardware scaling level is computed from the window device ratio.
  30327. * 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.
  30328. * @param level defines the level to use
  30329. */
  30330. setHardwareScalingLevel(level: number): void;
  30331. /**
  30332. * Gets the current hardware scaling level.
  30333. * By default the hardware scaling level is computed from the window device ratio.
  30334. * 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.
  30335. * @returns a number indicating the current hardware scaling level
  30336. */
  30337. getHardwareScalingLevel(): number;
  30338. /**
  30339. * Gets the list of loaded textures
  30340. * @returns an array containing all loaded textures
  30341. */
  30342. getLoadedTexturesCache(): InternalTexture[];
  30343. /**
  30344. * Gets the object containing all engine capabilities
  30345. * @returns the EngineCapabilities object
  30346. */
  30347. getCaps(): EngineCapabilities;
  30348. /**
  30349. * Gets the current depth function
  30350. * @returns a number defining the depth function
  30351. */
  30352. getDepthFunction(): Nullable<number>;
  30353. /**
  30354. * Sets the current depth function
  30355. * @param depthFunc defines the function to use
  30356. */
  30357. setDepthFunction(depthFunc: number): void;
  30358. /**
  30359. * Sets the current depth function to GREATER
  30360. */
  30361. setDepthFunctionToGreater(): void;
  30362. /**
  30363. * Sets the current depth function to GEQUAL
  30364. */
  30365. setDepthFunctionToGreaterOrEqual(): void;
  30366. /**
  30367. * Sets the current depth function to LESS
  30368. */
  30369. setDepthFunctionToLess(): void;
  30370. private _cachedStencilBuffer;
  30371. private _cachedStencilFunction;
  30372. private _cachedStencilMask;
  30373. private _cachedStencilOperationPass;
  30374. private _cachedStencilOperationFail;
  30375. private _cachedStencilOperationDepthFail;
  30376. private _cachedStencilReference;
  30377. /**
  30378. * Caches the the state of the stencil buffer
  30379. */
  30380. cacheStencilState(): void;
  30381. /**
  30382. * Restores the state of the stencil buffer
  30383. */
  30384. restoreStencilState(): void;
  30385. /**
  30386. * Sets the current depth function to LEQUAL
  30387. */
  30388. setDepthFunctionToLessOrEqual(): void;
  30389. /**
  30390. * Gets a boolean indicating if stencil buffer is enabled
  30391. * @returns the current stencil buffer state
  30392. */
  30393. getStencilBuffer(): boolean;
  30394. /**
  30395. * Enable or disable the stencil buffer
  30396. * @param enable defines if the stencil buffer must be enabled or disabled
  30397. */
  30398. setStencilBuffer(enable: boolean): void;
  30399. /**
  30400. * Gets the current stencil mask
  30401. * @returns a number defining the new stencil mask to use
  30402. */
  30403. getStencilMask(): number;
  30404. /**
  30405. * Sets the current stencil mask
  30406. * @param mask defines the new stencil mask to use
  30407. */
  30408. setStencilMask(mask: number): void;
  30409. /**
  30410. * Gets the current stencil function
  30411. * @returns a number defining the stencil function to use
  30412. */
  30413. getStencilFunction(): number;
  30414. /**
  30415. * Gets the current stencil reference value
  30416. * @returns a number defining the stencil reference value to use
  30417. */
  30418. getStencilFunctionReference(): number;
  30419. /**
  30420. * Gets the current stencil mask
  30421. * @returns a number defining the stencil mask to use
  30422. */
  30423. getStencilFunctionMask(): number;
  30424. /**
  30425. * Sets the current stencil function
  30426. * @param stencilFunc defines the new stencil function to use
  30427. */
  30428. setStencilFunction(stencilFunc: number): void;
  30429. /**
  30430. * Sets the current stencil reference
  30431. * @param reference defines the new stencil reference to use
  30432. */
  30433. setStencilFunctionReference(reference: number): void;
  30434. /**
  30435. * Sets the current stencil mask
  30436. * @param mask defines the new stencil mask to use
  30437. */
  30438. setStencilFunctionMask(mask: number): void;
  30439. /**
  30440. * Gets the current stencil operation when stencil fails
  30441. * @returns a number defining stencil operation to use when stencil fails
  30442. */
  30443. getStencilOperationFail(): number;
  30444. /**
  30445. * Gets the current stencil operation when depth fails
  30446. * @returns a number defining stencil operation to use when depth fails
  30447. */
  30448. getStencilOperationDepthFail(): number;
  30449. /**
  30450. * Gets the current stencil operation when stencil passes
  30451. * @returns a number defining stencil operation to use when stencil passes
  30452. */
  30453. getStencilOperationPass(): number;
  30454. /**
  30455. * Sets the stencil operation to use when stencil fails
  30456. * @param operation defines the stencil operation to use when stencil fails
  30457. */
  30458. setStencilOperationFail(operation: number): void;
  30459. /**
  30460. * Sets the stencil operation to use when depth fails
  30461. * @param operation defines the stencil operation to use when depth fails
  30462. */
  30463. setStencilOperationDepthFail(operation: number): void;
  30464. /**
  30465. * Sets the stencil operation to use when stencil passes
  30466. * @param operation defines the stencil operation to use when stencil passes
  30467. */
  30468. setStencilOperationPass(operation: number): void;
  30469. /**
  30470. * Sets a boolean indicating if the dithering state is enabled or disabled
  30471. * @param value defines the dithering state
  30472. */
  30473. setDitheringState(value: boolean): void;
  30474. /**
  30475. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30476. * @param value defines the rasterizer state
  30477. */
  30478. setRasterizerState(value: boolean): void;
  30479. /**
  30480. * stop executing a render loop function and remove it from the execution array
  30481. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30482. */
  30483. stopRenderLoop(renderFunction?: () => void): void;
  30484. /** @hidden */
  30485. _renderLoop(): void;
  30486. /**
  30487. * Register and execute a render loop. The engine can have more than one render function
  30488. * @param renderFunction defines the function to continuously execute
  30489. */
  30490. runRenderLoop(renderFunction: () => void): void;
  30491. /**
  30492. * Toggle full screen mode
  30493. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30494. */
  30495. switchFullscreen(requestPointerLock: boolean): void;
  30496. /**
  30497. * Enters full screen mode
  30498. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30499. */
  30500. enterFullscreen(requestPointerLock: boolean): void;
  30501. /**
  30502. * Exits full screen mode
  30503. */
  30504. exitFullscreen(): void;
  30505. /**
  30506. * Enters Pointerlock mode
  30507. */
  30508. enterPointerlock(): void;
  30509. /**
  30510. * Exits Pointerlock mode
  30511. */
  30512. exitPointerlock(): void;
  30513. /**
  30514. * Clear the current render buffer or the current render target (if any is set up)
  30515. * @param color defines the color to use
  30516. * @param backBuffer defines if the back buffer must be cleared
  30517. * @param depth defines if the depth buffer must be cleared
  30518. * @param stencil defines if the stencil buffer must be cleared
  30519. */
  30520. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30521. /**
  30522. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30523. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30524. * @param y defines the y-coordinate of the corner of the clear rectangle
  30525. * @param width defines the width of the clear rectangle
  30526. * @param height defines the height of the clear rectangle
  30527. * @param clearColor defines the clear color
  30528. */
  30529. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30530. /**
  30531. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30532. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30533. * @param y defines the y-coordinate of the corner of the clear rectangle
  30534. * @param width defines the width of the clear rectangle
  30535. * @param height defines the height of the clear rectangle
  30536. */
  30537. enableScissor(x: number, y: number, width: number, height: number): void;
  30538. /**
  30539. * Disable previously set scissor test rectangle
  30540. */
  30541. disableScissor(): void;
  30542. private _viewportCached;
  30543. /** @hidden */
  30544. _viewport(x: number, y: number, width: number, height: number): void;
  30545. /**
  30546. * Set the WebGL's viewport
  30547. * @param viewport defines the viewport element to be used
  30548. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30549. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30550. */
  30551. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30552. /**
  30553. * Directly set the WebGL Viewport
  30554. * @param x defines the x coordinate of the viewport (in screen space)
  30555. * @param y defines the y coordinate of the viewport (in screen space)
  30556. * @param width defines the width of the viewport (in screen space)
  30557. * @param height defines the height of the viewport (in screen space)
  30558. * @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
  30559. */
  30560. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30561. /**
  30562. * Begin a new frame
  30563. */
  30564. beginFrame(): void;
  30565. /**
  30566. * Enf the current frame
  30567. */
  30568. endFrame(): void;
  30569. /**
  30570. * Resize the view according to the canvas' size
  30571. */
  30572. resize(): void;
  30573. /**
  30574. * Force a specific size of the canvas
  30575. * @param width defines the new canvas' width
  30576. * @param height defines the new canvas' height
  30577. */
  30578. setSize(width: number, height: number): void;
  30579. /**
  30580. * Binds the frame buffer to the specified texture.
  30581. * @param texture The texture to render to or null for the default canvas
  30582. * @param faceIndex The face of the texture to render to in case of cube texture
  30583. * @param requiredWidth The width of the target to render to
  30584. * @param requiredHeight The height of the target to render to
  30585. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30586. * @param depthStencilTexture The depth stencil texture to use to render
  30587. * @param lodLevel defines le lod level to bind to the frame buffer
  30588. */
  30589. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30590. /** @hidden */
  30591. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30592. /**
  30593. * Unbind the current render target texture from the webGL context
  30594. * @param texture defines the render target texture to unbind
  30595. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30596. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30597. */
  30598. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30599. /**
  30600. * Force the mipmap generation for the given render target texture
  30601. * @param texture defines the render target texture to use
  30602. */
  30603. generateMipMapsForCubemap(texture: InternalTexture): void;
  30604. /**
  30605. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30606. */
  30607. flushFramebuffer(): void;
  30608. /**
  30609. * Unbind the current render target and bind the default framebuffer
  30610. */
  30611. restoreDefaultFramebuffer(): void;
  30612. /**
  30613. * Create an uniform buffer
  30614. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30615. * @param elements defines the content of the uniform buffer
  30616. * @returns the webGL uniform buffer
  30617. */
  30618. createUniformBuffer(elements: FloatArray): DataBuffer;
  30619. /**
  30620. * Create a dynamic uniform buffer
  30621. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30622. * @param elements defines the content of the uniform buffer
  30623. * @returns the webGL uniform buffer
  30624. */
  30625. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30626. /**
  30627. * Update an existing uniform buffer
  30628. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30629. * @param uniformBuffer defines the target uniform buffer
  30630. * @param elements defines the content to update
  30631. * @param offset defines the offset in the uniform buffer where update should start
  30632. * @param count defines the size of the data to update
  30633. */
  30634. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30635. private _resetVertexBufferBinding;
  30636. /**
  30637. * Creates a vertex buffer
  30638. * @param data the data for the vertex buffer
  30639. * @returns the new WebGL static buffer
  30640. */
  30641. createVertexBuffer(data: DataArray): DataBuffer;
  30642. /**
  30643. * Creates a dynamic vertex buffer
  30644. * @param data the data for the dynamic vertex buffer
  30645. * @returns the new WebGL dynamic buffer
  30646. */
  30647. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30648. /**
  30649. * Update a dynamic index buffer
  30650. * @param indexBuffer defines the target index buffer
  30651. * @param indices defines the data to update
  30652. * @param offset defines the offset in the target index buffer where update should start
  30653. */
  30654. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30655. /**
  30656. * Updates a dynamic vertex buffer.
  30657. * @param vertexBuffer the vertex buffer to update
  30658. * @param data the data used to update the vertex buffer
  30659. * @param byteOffset the byte offset of the data
  30660. * @param byteLength the byte length of the data
  30661. */
  30662. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30663. private _resetIndexBufferBinding;
  30664. /**
  30665. * Creates a new index buffer
  30666. * @param indices defines the content of the index buffer
  30667. * @param updatable defines if the index buffer must be updatable
  30668. * @returns a new webGL buffer
  30669. */
  30670. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30671. /**
  30672. * Bind a webGL buffer to the webGL context
  30673. * @param buffer defines the buffer to bind
  30674. */
  30675. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30676. /**
  30677. * Bind an uniform buffer to the current webGL context
  30678. * @param buffer defines the buffer to bind
  30679. */
  30680. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30681. /**
  30682. * Bind a buffer to the current webGL context at a given location
  30683. * @param buffer defines the buffer to bind
  30684. * @param location defines the index where to bind the buffer
  30685. */
  30686. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  30687. /**
  30688. * Bind a specific block at a given index in a specific shader program
  30689. * @param pipelineContext defines the pipeline context to use
  30690. * @param blockName defines the block name
  30691. * @param index defines the index where to bind the block
  30692. */
  30693. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30694. private bindIndexBuffer;
  30695. private bindBuffer;
  30696. /**
  30697. * update the bound buffer with the given data
  30698. * @param data defines the data to update
  30699. */
  30700. updateArrayBuffer(data: Float32Array): void;
  30701. private _vertexAttribPointer;
  30702. private _bindIndexBufferWithCache;
  30703. private _bindVertexBuffersAttributes;
  30704. /**
  30705. * Records a vertex array object
  30706. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30707. * @param vertexBuffers defines the list of vertex buffers to store
  30708. * @param indexBuffer defines the index buffer to store
  30709. * @param effect defines the effect to store
  30710. * @returns the new vertex array object
  30711. */
  30712. recordVertexArrayObject(vertexBuffers: {
  30713. [key: string]: VertexBuffer;
  30714. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30715. /**
  30716. * Bind a specific vertex array object
  30717. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30718. * @param vertexArrayObject defines the vertex array object to bind
  30719. * @param indexBuffer defines the index buffer to bind
  30720. */
  30721. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30722. /**
  30723. * Bind webGl buffers directly to the webGL context
  30724. * @param vertexBuffer defines the vertex buffer to bind
  30725. * @param indexBuffer defines the index buffer to bind
  30726. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30727. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30728. * @param effect defines the effect associated with the vertex buffer
  30729. */
  30730. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30731. private _unbindVertexArrayObject;
  30732. /**
  30733. * Bind a list of vertex buffers to the webGL context
  30734. * @param vertexBuffers defines the list of vertex buffers to bind
  30735. * @param indexBuffer defines the index buffer to bind
  30736. * @param effect defines the effect associated with the vertex buffers
  30737. */
  30738. bindBuffers(vertexBuffers: {
  30739. [key: string]: Nullable<VertexBuffer>;
  30740. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30741. /**
  30742. * Unbind all instance attributes
  30743. */
  30744. unbindInstanceAttributes(): void;
  30745. /**
  30746. * Release and free the memory of a vertex array object
  30747. * @param vao defines the vertex array object to delete
  30748. */
  30749. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30750. /** @hidden */
  30751. _releaseBuffer(buffer: DataBuffer): boolean;
  30752. /**
  30753. * Creates a webGL buffer to use with instanciation
  30754. * @param capacity defines the size of the buffer
  30755. * @returns the webGL buffer
  30756. */
  30757. createInstancesBuffer(capacity: number): DataBuffer;
  30758. /**
  30759. * Delete a webGL buffer used with instanciation
  30760. * @param buffer defines the webGL buffer to delete
  30761. */
  30762. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30763. /**
  30764. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30765. * @param instancesBuffer defines the webGL buffer to update and bind
  30766. * @param data defines the data to store in the buffer
  30767. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30768. */
  30769. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30770. /**
  30771. * Apply all cached states (depth, culling, stencil and alpha)
  30772. */
  30773. applyStates(): void;
  30774. /**
  30775. * Send a draw order
  30776. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30777. * @param indexStart defines the starting index
  30778. * @param indexCount defines the number of index to draw
  30779. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30780. */
  30781. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30782. /**
  30783. * Draw a list of points
  30784. * @param verticesStart defines the index of first vertex to draw
  30785. * @param verticesCount defines the count of vertices to draw
  30786. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30787. */
  30788. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30789. /**
  30790. * Draw a list of unindexed primitives
  30791. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30792. * @param verticesStart defines the index of first vertex to draw
  30793. * @param verticesCount defines the count of vertices to draw
  30794. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30795. */
  30796. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30797. /**
  30798. * Draw a list of indexed primitives
  30799. * @param fillMode defines the primitive to use
  30800. * @param indexStart defines the starting index
  30801. * @param indexCount defines the number of index to draw
  30802. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30803. */
  30804. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30805. /**
  30806. * Draw a list of unindexed primitives
  30807. * @param fillMode defines the primitive to use
  30808. * @param verticesStart defines the index of first vertex to draw
  30809. * @param verticesCount defines the count of vertices to draw
  30810. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30811. */
  30812. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30813. private _drawMode;
  30814. /** @hidden */
  30815. _releaseEffect(effect: Effect): void;
  30816. /** @hidden */
  30817. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30818. /**
  30819. * Create a new effect (used to store vertex/fragment shaders)
  30820. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30821. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30822. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30823. * @param samplers defines an array of string used to represent textures
  30824. * @param defines defines the string containing the defines to use to compile the shaders
  30825. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30826. * @param onCompiled defines a function to call when the effect creation is successful
  30827. * @param onError defines a function to call when the effect creation has failed
  30828. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30829. * @returns the new Effect
  30830. */
  30831. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30832. private _compileShader;
  30833. private _compileRawShader;
  30834. /**
  30835. * Directly creates a webGL program
  30836. * @param pipelineContext defines the pipeline context to attach to
  30837. * @param vertexCode defines the vertex shader code to use
  30838. * @param fragmentCode defines the fragment shader code to use
  30839. * @param context defines the webGL context to use (if not set, the current one will be used)
  30840. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30841. * @returns the new webGL program
  30842. */
  30843. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30844. /**
  30845. * Creates a webGL program
  30846. * @param pipelineContext defines the pipeline context to attach to
  30847. * @param vertexCode defines the vertex shader code to use
  30848. * @param fragmentCode defines the fragment shader code to use
  30849. * @param defines defines the string containing the defines to use to compile the shaders
  30850. * @param context defines the webGL context to use (if not set, the current one will be used)
  30851. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30852. * @returns the new webGL program
  30853. */
  30854. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30855. /**
  30856. * Creates a new pipeline context
  30857. * @returns the new pipeline
  30858. */
  30859. createPipelineContext(): WebGLPipelineContext;
  30860. private _createShaderProgram;
  30861. private _finalizePipelineContext;
  30862. /** @hidden */
  30863. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30864. /** @hidden */
  30865. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30866. /** @hidden */
  30867. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30868. /**
  30869. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30870. * @param pipelineContext defines the pipeline context to use
  30871. * @param uniformsNames defines the list of uniform names
  30872. * @returns an array of webGL uniform locations
  30873. */
  30874. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30875. /**
  30876. * Gets the lsit of active attributes for a given webGL program
  30877. * @param pipelineContext defines the pipeline context to use
  30878. * @param attributesNames defines the list of attribute names to get
  30879. * @returns an array of indices indicating the offset of each attribute
  30880. */
  30881. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30882. /**
  30883. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30884. * @param effect defines the effect to activate
  30885. */
  30886. enableEffect(effect: Nullable<Effect>): void;
  30887. /**
  30888. * Set the value of an uniform to an array of int32
  30889. * @param uniform defines the webGL uniform location where to store the value
  30890. * @param array defines the array of int32 to store
  30891. */
  30892. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30893. /**
  30894. * Set the value of an uniform to an array of int32 (stored as vec2)
  30895. * @param uniform defines the webGL uniform location where to store the value
  30896. * @param array defines the array of int32 to store
  30897. */
  30898. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30899. /**
  30900. * Set the value of an uniform to an array of int32 (stored as vec3)
  30901. * @param uniform defines the webGL uniform location where to store the value
  30902. * @param array defines the array of int32 to store
  30903. */
  30904. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30905. /**
  30906. * Set the value of an uniform to an array of int32 (stored as vec4)
  30907. * @param uniform defines the webGL uniform location where to store the value
  30908. * @param array defines the array of int32 to store
  30909. */
  30910. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30911. /**
  30912. * Set the value of an uniform to an array of float32
  30913. * @param uniform defines the webGL uniform location where to store the value
  30914. * @param array defines the array of float32 to store
  30915. */
  30916. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30917. /**
  30918. * Set the value of an uniform to an array of float32 (stored as vec2)
  30919. * @param uniform defines the webGL uniform location where to store the value
  30920. * @param array defines the array of float32 to store
  30921. */
  30922. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30923. /**
  30924. * Set the value of an uniform to an array of float32 (stored as vec3)
  30925. * @param uniform defines the webGL uniform location where to store the value
  30926. * @param array defines the array of float32 to store
  30927. */
  30928. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30929. /**
  30930. * Set the value of an uniform to an array of float32 (stored as vec4)
  30931. * @param uniform defines the webGL uniform location where to store the value
  30932. * @param array defines the array of float32 to store
  30933. */
  30934. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30935. /**
  30936. * Set the value of an uniform to an array of number
  30937. * @param uniform defines the webGL uniform location where to store the value
  30938. * @param array defines the array of number to store
  30939. */
  30940. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30941. /**
  30942. * Set the value of an uniform to an array of number (stored as vec2)
  30943. * @param uniform defines the webGL uniform location where to store the value
  30944. * @param array defines the array of number to store
  30945. */
  30946. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30947. /**
  30948. * Set the value of an uniform to an array of number (stored as vec3)
  30949. * @param uniform defines the webGL uniform location where to store the value
  30950. * @param array defines the array of number to store
  30951. */
  30952. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30953. /**
  30954. * Set the value of an uniform to an array of number (stored as vec4)
  30955. * @param uniform defines the webGL uniform location where to store the value
  30956. * @param array defines the array of number to store
  30957. */
  30958. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30959. /**
  30960. * Set the value of an uniform to an array of float32 (stored as matrices)
  30961. * @param uniform defines the webGL uniform location where to store the value
  30962. * @param matrices defines the array of float32 to store
  30963. */
  30964. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30965. /**
  30966. * Set the value of an uniform to a matrix (3x3)
  30967. * @param uniform defines the webGL uniform location where to store the value
  30968. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30969. */
  30970. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30971. /**
  30972. * Set the value of an uniform to a matrix (2x2)
  30973. * @param uniform defines the webGL uniform location where to store the value
  30974. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30975. */
  30976. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30977. /**
  30978. * Set the value of an uniform to a number (int)
  30979. * @param uniform defines the webGL uniform location where to store the value
  30980. * @param value defines the int number to store
  30981. */
  30982. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30983. /**
  30984. * Set the value of an uniform to a number (float)
  30985. * @param uniform defines the webGL uniform location where to store the value
  30986. * @param value defines the float number to store
  30987. */
  30988. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30989. /**
  30990. * Set the value of an uniform to a vec2
  30991. * @param uniform defines the webGL uniform location where to store the value
  30992. * @param x defines the 1st component of the value
  30993. * @param y defines the 2nd component of the value
  30994. */
  30995. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30996. /**
  30997. * Set the value of an uniform to a vec3
  30998. * @param uniform defines the webGL uniform location where to store the value
  30999. * @param x defines the 1st component of the value
  31000. * @param y defines the 2nd component of the value
  31001. * @param z defines the 3rd component of the value
  31002. */
  31003. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31004. /**
  31005. * Set the value of an uniform to a boolean
  31006. * @param uniform defines the webGL uniform location where to store the value
  31007. * @param bool defines the boolean to store
  31008. */
  31009. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31010. /**
  31011. * Set the value of an uniform to a vec4
  31012. * @param uniform defines the webGL uniform location where to store the value
  31013. * @param x defines the 1st component of the value
  31014. * @param y defines the 2nd component of the value
  31015. * @param z defines the 3rd component of the value
  31016. * @param w defines the 4th component of the value
  31017. */
  31018. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31019. /**
  31020. * Sets a Color4 on a uniform variable
  31021. * @param uniform defines the uniform location
  31022. * @param color4 defines the value to be set
  31023. */
  31024. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31025. /**
  31026. * Set various states to the webGL context
  31027. * @param culling defines backface culling state
  31028. * @param zOffset defines the value to apply to zOffset (0 by default)
  31029. * @param force defines if states must be applied even if cache is up to date
  31030. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31031. */
  31032. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31033. /**
  31034. * Set the z offset to apply to current rendering
  31035. * @param value defines the offset to apply
  31036. */
  31037. setZOffset(value: number): void;
  31038. /**
  31039. * Gets the current value of the zOffset
  31040. * @returns the current zOffset state
  31041. */
  31042. getZOffset(): number;
  31043. /**
  31044. * Enable or disable depth buffering
  31045. * @param enable defines the state to set
  31046. */
  31047. setDepthBuffer(enable: boolean): void;
  31048. /**
  31049. * Gets a boolean indicating if depth writing is enabled
  31050. * @returns the current depth writing state
  31051. */
  31052. getDepthWrite(): boolean;
  31053. /**
  31054. * Enable or disable depth writing
  31055. * @param enable defines the state to set
  31056. */
  31057. setDepthWrite(enable: boolean): void;
  31058. /**
  31059. * Enable or disable color writing
  31060. * @param enable defines the state to set
  31061. */
  31062. setColorWrite(enable: boolean): void;
  31063. /**
  31064. * Gets a boolean indicating if color writing is enabled
  31065. * @returns the current color writing state
  31066. */
  31067. getColorWrite(): boolean;
  31068. /**
  31069. * Sets alpha constants used by some alpha blending modes
  31070. * @param r defines the red component
  31071. * @param g defines the green component
  31072. * @param b defines the blue component
  31073. * @param a defines the alpha component
  31074. */
  31075. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31076. /**
  31077. * Sets the current alpha mode
  31078. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31079. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31080. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31081. */
  31082. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31083. /**
  31084. * Gets the current alpha mode
  31085. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31086. * @returns the current alpha mode
  31087. */
  31088. getAlphaMode(): number;
  31089. /**
  31090. * Clears the list of texture accessible through engine.
  31091. * This can help preventing texture load conflict due to name collision.
  31092. */
  31093. clearInternalTexturesCache(): void;
  31094. /**
  31095. * Force the entire cache to be cleared
  31096. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31097. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31098. */
  31099. wipeCaches(bruteForce?: boolean): void;
  31100. /**
  31101. * Set the compressed texture format to use, based on the formats you have, and the formats
  31102. * supported by the hardware / browser.
  31103. *
  31104. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31105. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31106. * to API arguments needed to compressed textures. This puts the burden on the container
  31107. * generator to house the arcane code for determining these for current & future formats.
  31108. *
  31109. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31110. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31111. *
  31112. * Note: The result of this call is not taken into account when a texture is base64.
  31113. *
  31114. * @param formatsAvailable defines the list of those format families you have created
  31115. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31116. *
  31117. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31118. * @returns The extension selected.
  31119. */
  31120. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31121. /** @hidden */
  31122. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31123. min: number;
  31124. mag: number;
  31125. };
  31126. /** @hidden */
  31127. _createTexture(): WebGLTexture;
  31128. /**
  31129. * Usually called from Texture.ts.
  31130. * Passed information to create a WebGLTexture
  31131. * @param urlArg defines a value which contains one of the following:
  31132. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31133. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31134. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31135. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31136. * @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)
  31137. * @param scene needed for loading to the correct scene
  31138. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31139. * @param onLoad optional callback to be called upon successful completion
  31140. * @param onError optional callback to be called upon failure
  31141. * @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
  31142. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31143. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31144. * @param forcedExtension defines the extension to use to pick the right loader
  31145. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31146. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31147. */
  31148. 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 | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  31149. /**
  31150. * @hidden
  31151. * Rescales a texture
  31152. * @param source input texutre
  31153. * @param destination destination texture
  31154. * @param scene scene to use to render the resize
  31155. * @param internalFormat format to use when resizing
  31156. * @param onComplete callback to be called when resize has completed
  31157. */
  31158. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  31159. private _unpackFlipYCached;
  31160. /**
  31161. * In case you are sharing the context with other applications, it might
  31162. * be interested to not cache the unpack flip y state to ensure a consistent
  31163. * value would be set.
  31164. */
  31165. enableUnpackFlipYCached: boolean;
  31166. /** @hidden */
  31167. _unpackFlipY(value: boolean): void;
  31168. /** @hidden */
  31169. _getUnpackAlignement(): number;
  31170. /**
  31171. * Creates a dynamic texture
  31172. * @param width defines the width of the texture
  31173. * @param height defines the height of the texture
  31174. * @param generateMipMaps defines if the engine should generate the mip levels
  31175. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31176. * @returns the dynamic texture inside an InternalTexture
  31177. */
  31178. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  31179. /**
  31180. * Update the sampling mode of a given texture
  31181. * @param samplingMode defines the required sampling mode
  31182. * @param texture defines the texture to update
  31183. */
  31184. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31185. /**
  31186. * Update the content of a dynamic texture
  31187. * @param texture defines the texture to update
  31188. * @param canvas defines the canvas containing the source
  31189. * @param invertY defines if data must be stored with Y axis inverted
  31190. * @param premulAlpha defines if alpha is stored as premultiplied
  31191. * @param format defines the format of the data
  31192. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31193. */
  31194. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  31195. /**
  31196. * Update a video texture
  31197. * @param texture defines the texture to update
  31198. * @param video defines the video element to use
  31199. * @param invertY defines if data must be stored with Y axis inverted
  31200. */
  31201. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31202. /**
  31203. * Updates a depth texture Comparison Mode and Function.
  31204. * If the comparison Function is equal to 0, the mode will be set to none.
  31205. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31206. * @param texture The texture to set the comparison function for
  31207. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31208. */
  31209. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  31210. /** @hidden */
  31211. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31212. width: number;
  31213. height: number;
  31214. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31215. /**
  31216. * Creates a depth stencil texture.
  31217. * This is only available in WebGL 2 or with the depth texture extension available.
  31218. * @param size The size of face edge in the texture.
  31219. * @param options The options defining the texture.
  31220. * @returns The texture
  31221. */
  31222. createDepthStencilTexture(size: number | {
  31223. width: number;
  31224. height: number;
  31225. }, options: DepthTextureCreationOptions): InternalTexture;
  31226. /**
  31227. * Creates a depth stencil texture.
  31228. * This is only available in WebGL 2 or with the depth texture extension available.
  31229. * @param size The size of face edge in the texture.
  31230. * @param options The options defining the texture.
  31231. * @returns The texture
  31232. */
  31233. private _createDepthStencilTexture;
  31234. /**
  31235. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31236. * @param renderTarget The render target to set the frame buffer for
  31237. */
  31238. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31239. /**
  31240. * Creates a new render target texture
  31241. * @param size defines the size of the texture
  31242. * @param options defines the options used to create the texture
  31243. * @returns a new render target texture stored in an InternalTexture
  31244. */
  31245. createRenderTargetTexture(size: number | {
  31246. width: number;
  31247. height: number;
  31248. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31249. /** @hidden */
  31250. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31251. /**
  31252. * Updates the sample count of a render target texture
  31253. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31254. * @param texture defines the texture to update
  31255. * @param samples defines the sample count to set
  31256. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31257. */
  31258. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31259. /** @hidden */
  31260. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31261. /** @hidden */
  31262. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31263. /** @hidden */
  31264. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31265. /** @hidden */
  31266. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31267. /**
  31268. * @hidden
  31269. */
  31270. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31271. private _prepareWebGLTextureContinuation;
  31272. private _prepareWebGLTexture;
  31273. /** @hidden */
  31274. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31275. /** @hidden */
  31276. _releaseFramebufferObjects(texture: InternalTexture): void;
  31277. /** @hidden */
  31278. _releaseTexture(texture: InternalTexture): void;
  31279. private setProgram;
  31280. private _boundUniforms;
  31281. /**
  31282. * Binds an effect to the webGL context
  31283. * @param effect defines the effect to bind
  31284. */
  31285. bindSamplers(effect: Effect): void;
  31286. private _activateCurrentTexture;
  31287. /** @hidden */
  31288. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31289. /** @hidden */
  31290. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31291. /**
  31292. * Sets a texture to the webGL context from a postprocess
  31293. * @param channel defines the channel to use
  31294. * @param postProcess defines the source postprocess
  31295. */
  31296. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31297. /**
  31298. * Binds the output of the passed in post process to the texture channel specified
  31299. * @param channel The channel the texture should be bound to
  31300. * @param postProcess The post process which's output should be bound
  31301. */
  31302. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31303. /**
  31304. * Unbind all textures from the webGL context
  31305. */
  31306. unbindAllTextures(): void;
  31307. /**
  31308. * Sets a texture to the according uniform.
  31309. * @param channel The texture channel
  31310. * @param uniform The uniform to set
  31311. * @param texture The texture to apply
  31312. */
  31313. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31314. /**
  31315. * Sets a depth stencil texture from a render target to the according uniform.
  31316. * @param channel The texture channel
  31317. * @param uniform The uniform to set
  31318. * @param texture The render target texture containing the depth stencil texture to apply
  31319. */
  31320. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31321. private _bindSamplerUniformToChannel;
  31322. private _getTextureWrapMode;
  31323. private _setTexture;
  31324. /**
  31325. * Sets an array of texture to the webGL context
  31326. * @param channel defines the channel where the texture array must be set
  31327. * @param uniform defines the associated uniform location
  31328. * @param textures defines the array of textures to bind
  31329. */
  31330. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31331. /** @hidden */
  31332. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31333. private _setTextureParameterFloat;
  31334. private _setTextureParameterInteger;
  31335. /**
  31336. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31337. * @param x defines the x coordinate of the rectangle where pixels must be read
  31338. * @param y defines the y coordinate of the rectangle where pixels must be read
  31339. * @param width defines the width of the rectangle where pixels must be read
  31340. * @param height defines the height of the rectangle where pixels must be read
  31341. * @returns a Uint8Array containing RGBA colors
  31342. */
  31343. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31344. /**
  31345. * Add an externaly attached data from its key.
  31346. * This method call will fail and return false, if such key already exists.
  31347. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  31348. * @param key the unique key that identifies the data
  31349. * @param data the data object to associate to the key for this Engine instance
  31350. * @return true if no such key were already present and the data was added successfully, false otherwise
  31351. */
  31352. addExternalData<T>(key: string, data: T): boolean;
  31353. /**
  31354. * Get an externaly attached data from its key
  31355. * @param key the unique key that identifies the data
  31356. * @return the associated data, if present (can be null), or undefined if not present
  31357. */
  31358. getExternalData<T>(key: string): T;
  31359. /**
  31360. * Get an externaly attached data from its key, create it using a factory if it's not already present
  31361. * @param key the unique key that identifies the data
  31362. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  31363. * @return the associated data, can be null if the factory returned null.
  31364. */
  31365. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  31366. /**
  31367. * Remove an externaly attached data from the Engine instance
  31368. * @param key the unique key that identifies the data
  31369. * @return true if the data was successfully removed, false if it doesn't exist
  31370. */
  31371. removeExternalData(key: string): boolean;
  31372. /**
  31373. * Unbind all vertex attributes from the webGL context
  31374. */
  31375. unbindAllAttributes(): void;
  31376. /**
  31377. * 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
  31378. */
  31379. releaseEffects(): void;
  31380. /**
  31381. * Dispose and release all associated resources
  31382. */
  31383. dispose(): void;
  31384. /**
  31385. * Display the loading screen
  31386. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31387. */
  31388. displayLoadingUI(): void;
  31389. /**
  31390. * Hide the loading screen
  31391. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31392. */
  31393. hideLoadingUI(): void;
  31394. /**
  31395. * Gets the current loading screen object
  31396. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31397. */
  31398. /**
  31399. * Sets the current loading screen object
  31400. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31401. */
  31402. loadingScreen: ILoadingScreen;
  31403. /**
  31404. * Sets the current loading screen text
  31405. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31406. */
  31407. loadingUIText: string;
  31408. /**
  31409. * Sets the current loading screen background color
  31410. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31411. */
  31412. loadingUIBackgroundColor: string;
  31413. /**
  31414. * Attach a new callback raised when context lost event is fired
  31415. * @param callback defines the callback to call
  31416. */
  31417. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31418. /**
  31419. * Attach a new callback raised when context restored event is fired
  31420. * @param callback defines the callback to call
  31421. */
  31422. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31423. /**
  31424. * Gets the source code of the vertex shader associated with a specific webGL program
  31425. * @param program defines the program to use
  31426. * @returns a string containing the source code of the vertex shader associated with the program
  31427. */
  31428. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31429. /**
  31430. * Gets the source code of the fragment shader associated with a specific webGL program
  31431. * @param program defines the program to use
  31432. * @returns a string containing the source code of the fragment shader associated with the program
  31433. */
  31434. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31435. /**
  31436. * Get the current error code of the webGL context
  31437. * @returns the error code
  31438. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31439. */
  31440. getError(): number;
  31441. /**
  31442. * Gets the current framerate
  31443. * @returns a number representing the framerate
  31444. */
  31445. getFps(): number;
  31446. /**
  31447. * Gets the time spent between current and previous frame
  31448. * @returns a number representing the delta time in ms
  31449. */
  31450. getDeltaTime(): number;
  31451. private _measureFps;
  31452. /** @hidden */
  31453. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31454. private _canRenderToFloatFramebuffer;
  31455. private _canRenderToHalfFloatFramebuffer;
  31456. private _canRenderToFramebuffer;
  31457. /** @hidden */
  31458. _getWebGLTextureType(type: number): number;
  31459. /** @hidden */
  31460. _getInternalFormat(format: number): number;
  31461. /** @hidden */
  31462. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31463. /** @hidden */
  31464. _getRGBAMultiSampleBufferFormat(type: number): number;
  31465. /** @hidden */
  31466. _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;
  31467. /** @hidden */
  31468. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31469. /**
  31470. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31471. * @returns true if the engine can be created
  31472. * @ignorenaming
  31473. */
  31474. static isSupported(): boolean;
  31475. /**
  31476. * Find the next highest power of two.
  31477. * @param x Number to start search from.
  31478. * @return Next highest power of two.
  31479. */
  31480. static CeilingPOT(x: number): number;
  31481. /**
  31482. * Find the next lowest power of two.
  31483. * @param x Number to start search from.
  31484. * @return Next lowest power of two.
  31485. */
  31486. static FloorPOT(x: number): number;
  31487. /**
  31488. * Find the nearest power of two.
  31489. * @param x Number to start search from.
  31490. * @return Next nearest power of two.
  31491. */
  31492. static NearestPOT(x: number): number;
  31493. /**
  31494. * Get the closest exponent of two
  31495. * @param value defines the value to approximate
  31496. * @param max defines the maximum value to return
  31497. * @param mode defines how to define the closest value
  31498. * @returns closest exponent of two of the given value
  31499. */
  31500. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31501. /**
  31502. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31503. * @param func - the function to be called
  31504. * @param requester - the object that will request the next frame. Falls back to window.
  31505. * @returns frame number
  31506. */
  31507. static QueueNewFrame(func: () => void, requester?: any): number;
  31508. /**
  31509. * Ask the browser to promote the current element to pointerlock mode
  31510. * @param element defines the DOM element to promote
  31511. */
  31512. static _RequestPointerlock(element: HTMLElement): void;
  31513. /**
  31514. * Asks the browser to exit pointerlock mode
  31515. */
  31516. static _ExitPointerlock(): void;
  31517. /**
  31518. * Ask the browser to promote the current element to fullscreen rendering mode
  31519. * @param element defines the DOM element to promote
  31520. */
  31521. static _RequestFullscreen(element: HTMLElement): void;
  31522. /**
  31523. * Asks the browser to exit fullscreen mode
  31524. */
  31525. static _ExitFullscreen(): void;
  31526. }
  31527. }
  31528. declare module BABYLON {
  31529. /**
  31530. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31531. * during the life time of the application.
  31532. */
  31533. export class EngineStore {
  31534. /** Gets the list of created engines */
  31535. static Instances: Engine[];
  31536. /** @hidden */
  31537. static _LastCreatedScene: Nullable<Scene>;
  31538. /**
  31539. * Gets the latest created engine
  31540. */
  31541. static readonly LastCreatedEngine: Nullable<Engine>;
  31542. /**
  31543. * Gets the latest created scene
  31544. */
  31545. static readonly LastCreatedScene: Nullable<Scene>;
  31546. /**
  31547. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31548. * @ignorenaming
  31549. */
  31550. static UseFallbackTexture: boolean;
  31551. /**
  31552. * Texture content used if a texture cannot loaded
  31553. * @ignorenaming
  31554. */
  31555. static FallbackTexture: string;
  31556. }
  31557. }
  31558. declare module BABYLON {
  31559. /**
  31560. * Helper class that provides a small promise polyfill
  31561. */
  31562. export class PromisePolyfill {
  31563. /**
  31564. * Static function used to check if the polyfill is required
  31565. * If this is the case then the function will inject the polyfill to window.Promise
  31566. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31567. */
  31568. static Apply(force?: boolean): void;
  31569. }
  31570. }
  31571. declare module BABYLON {
  31572. interface IColor4Like {
  31573. r: float;
  31574. g: float;
  31575. b: float;
  31576. a: float;
  31577. }
  31578. /**
  31579. * Class containing a set of static utilities functions
  31580. */
  31581. export class Tools {
  31582. /**
  31583. * Gets or sets the base URL to use to load assets
  31584. */
  31585. static BaseUrl: string;
  31586. /**
  31587. * Enable/Disable Custom HTTP Request Headers globally.
  31588. * default = false
  31589. * @see CustomRequestHeaders
  31590. */
  31591. static UseCustomRequestHeaders: boolean;
  31592. /**
  31593. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31594. * i.e. when loading files, where the server/service expects an Authorization header
  31595. */
  31596. static CustomRequestHeaders: {
  31597. [key: string]: string;
  31598. };
  31599. /**
  31600. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31601. */
  31602. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31603. /**
  31604. * Default behaviour for cors in the application.
  31605. * It can be a string if the expected behavior is identical in the entire app.
  31606. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31607. */
  31608. static CorsBehavior: string | ((url: string | string[]) => string);
  31609. /**
  31610. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31611. * @ignorenaming
  31612. */
  31613. static UseFallbackTexture: boolean;
  31614. /**
  31615. * Use this object to register external classes like custom textures or material
  31616. * to allow the laoders to instantiate them
  31617. */
  31618. static RegisteredExternalClasses: {
  31619. [key: string]: Object;
  31620. };
  31621. /**
  31622. * Texture content used if a texture cannot loaded
  31623. * @ignorenaming
  31624. */
  31625. static fallbackTexture: string;
  31626. /**
  31627. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31628. * @param u defines the coordinate on X axis
  31629. * @param v defines the coordinate on Y axis
  31630. * @param width defines the width of the source data
  31631. * @param height defines the height of the source data
  31632. * @param pixels defines the source byte array
  31633. * @param color defines the output color
  31634. */
  31635. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31636. /**
  31637. * Interpolates between a and b via alpha
  31638. * @param a The lower value (returned when alpha = 0)
  31639. * @param b The upper value (returned when alpha = 1)
  31640. * @param alpha The interpolation-factor
  31641. * @return The mixed value
  31642. */
  31643. static Mix(a: number, b: number, alpha: number): number;
  31644. /**
  31645. * Tries to instantiate a new object from a given class name
  31646. * @param className defines the class name to instantiate
  31647. * @returns the new object or null if the system was not able to do the instantiation
  31648. */
  31649. static Instantiate(className: string): any;
  31650. /**
  31651. * Provides a slice function that will work even on IE
  31652. * @param data defines the array to slice
  31653. * @param start defines the start of the data (optional)
  31654. * @param end defines the end of the data (optional)
  31655. * @returns the new sliced array
  31656. */
  31657. static Slice<T>(data: T, start?: number, end?: number): T;
  31658. /**
  31659. * Polyfill for setImmediate
  31660. * @param action defines the action to execute after the current execution block
  31661. */
  31662. static SetImmediate(action: () => void): void;
  31663. /**
  31664. * Function indicating if a number is an exponent of 2
  31665. * @param value defines the value to test
  31666. * @returns true if the value is an exponent of 2
  31667. */
  31668. static IsExponentOfTwo(value: number): boolean;
  31669. private static _tmpFloatArray;
  31670. /**
  31671. * Returns the nearest 32-bit single precision float representation of a Number
  31672. * @param value A Number. If the parameter is of a different type, it will get converted
  31673. * to a number or to NaN if it cannot be converted
  31674. * @returns number
  31675. */
  31676. static FloatRound(value: number): number;
  31677. /**
  31678. * Extracts the filename from a path
  31679. * @param path defines the path to use
  31680. * @returns the filename
  31681. */
  31682. static GetFilename(path: string): string;
  31683. /**
  31684. * Extracts the "folder" part of a path (everything before the filename).
  31685. * @param uri The URI to extract the info from
  31686. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31687. * @returns The "folder" part of the path
  31688. */
  31689. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31690. /**
  31691. * Extracts text content from a DOM element hierarchy
  31692. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31693. */
  31694. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31695. /**
  31696. * Convert an angle in radians to degrees
  31697. * @param angle defines the angle to convert
  31698. * @returns the angle in degrees
  31699. */
  31700. static ToDegrees(angle: number): number;
  31701. /**
  31702. * Convert an angle in degrees to radians
  31703. * @param angle defines the angle to convert
  31704. * @returns the angle in radians
  31705. */
  31706. static ToRadians(angle: number): number;
  31707. /**
  31708. * Encode a buffer to a base64 string
  31709. * @param buffer defines the buffer to encode
  31710. * @returns the encoded string
  31711. */
  31712. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31713. /**
  31714. * Returns an array if obj is not an array
  31715. * @param obj defines the object to evaluate as an array
  31716. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31717. * @returns either obj directly if obj is an array or a new array containing obj
  31718. */
  31719. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31720. /**
  31721. * Gets the pointer prefix to use
  31722. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31723. */
  31724. static GetPointerPrefix(): string;
  31725. /**
  31726. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31727. * @param url define the url we are trying
  31728. * @param element define the dom element where to configure the cors policy
  31729. */
  31730. static SetCorsBehavior(url: string | string[], element: {
  31731. crossOrigin: string | null;
  31732. }): void;
  31733. /**
  31734. * Removes unwanted characters from an url
  31735. * @param url defines the url to clean
  31736. * @returns the cleaned url
  31737. */
  31738. static CleanUrl(url: string): string;
  31739. /**
  31740. * Gets or sets a function used to pre-process url before using them to load assets
  31741. */
  31742. static PreprocessUrl: (url: string) => string;
  31743. /**
  31744. * Loads an image as an HTMLImageElement.
  31745. * @param input url string, ArrayBuffer, or Blob to load
  31746. * @param onLoad callback called when the image successfully loads
  31747. * @param onError callback called when the image fails to load
  31748. * @param offlineProvider offline provider for caching
  31749. * @returns the HTMLImageElement of the loaded image
  31750. */
  31751. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31752. /**
  31753. * Loads a file
  31754. * @param url url string, ArrayBuffer, or Blob to load
  31755. * @param onSuccess callback called when the file successfully loads
  31756. * @param onProgress callback called while file is loading (if the server supports this mode)
  31757. * @param offlineProvider defines the offline provider for caching
  31758. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31759. * @param onError callback called when the file fails to load
  31760. * @returns a file request object
  31761. */
  31762. 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;
  31763. /**
  31764. * Loads a file from a url
  31765. * @param url the file url to load
  31766. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31767. */
  31768. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31769. /**
  31770. * Load a script (identified by an url). When the url returns, the
  31771. * content of this file is added into a new script element, attached to the DOM (body element)
  31772. * @param scriptUrl defines the url of the script to laod
  31773. * @param onSuccess defines the callback called when the script is loaded
  31774. * @param onError defines the callback to call if an error occurs
  31775. * @param scriptId defines the id of the script element
  31776. */
  31777. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31778. /**
  31779. * Load an asynchronous script (identified by an url). When the url returns, the
  31780. * content of this file is added into a new script element, attached to the DOM (body element)
  31781. * @param scriptUrl defines the url of the script to laod
  31782. * @param scriptId defines the id of the script element
  31783. * @returns a promise request object
  31784. */
  31785. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31786. /**
  31787. * Loads a file from a blob
  31788. * @param fileToLoad defines the blob to use
  31789. * @param callback defines the callback to call when data is loaded
  31790. * @param progressCallback defines the callback to call during loading process
  31791. * @returns a file request object
  31792. */
  31793. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31794. /**
  31795. * Loads a file
  31796. * @param fileToLoad defines the file to load
  31797. * @param callback defines the callback to call when data is loaded
  31798. * @param progressCallBack defines the callback to call during loading process
  31799. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31800. * @returns a file request object
  31801. */
  31802. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31803. /**
  31804. * Creates a data url from a given string content
  31805. * @param content defines the content to convert
  31806. * @returns the new data url link
  31807. */
  31808. static FileAsURL(content: string): string;
  31809. /**
  31810. * Format the given number to a specific decimal format
  31811. * @param value defines the number to format
  31812. * @param decimals defines the number of decimals to use
  31813. * @returns the formatted string
  31814. */
  31815. static Format(value: number, decimals?: number): string;
  31816. /**
  31817. * Tries to copy an object by duplicating every property
  31818. * @param source defines the source object
  31819. * @param destination defines the target object
  31820. * @param doNotCopyList defines a list of properties to avoid
  31821. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31822. */
  31823. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31824. /**
  31825. * Gets a boolean indicating if the given object has no own property
  31826. * @param obj defines the object to test
  31827. * @returns true if object has no own property
  31828. */
  31829. static IsEmpty(obj: any): boolean;
  31830. /**
  31831. * Function used to register events at window level
  31832. * @param events defines the events to register
  31833. */
  31834. static RegisterTopRootEvents(events: {
  31835. name: string;
  31836. handler: Nullable<(e: FocusEvent) => any>;
  31837. }[]): void;
  31838. /**
  31839. * Function used to unregister events from window level
  31840. * @param events defines the events to unregister
  31841. */
  31842. static UnregisterTopRootEvents(events: {
  31843. name: string;
  31844. handler: Nullable<(e: FocusEvent) => any>;
  31845. }[]): void;
  31846. /**
  31847. * @ignore
  31848. */
  31849. static _ScreenshotCanvas: HTMLCanvasElement;
  31850. /**
  31851. * Dumps the current bound framebuffer
  31852. * @param width defines the rendering width
  31853. * @param height defines the rendering height
  31854. * @param engine defines the hosting engine
  31855. * @param successCallback defines the callback triggered once the data are available
  31856. * @param mimeType defines the mime type of the result
  31857. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31858. */
  31859. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31860. /**
  31861. * Converts the canvas data to blob.
  31862. * This acts as a polyfill for browsers not supporting the to blob function.
  31863. * @param canvas Defines the canvas to extract the data from
  31864. * @param successCallback Defines the callback triggered once the data are available
  31865. * @param mimeType Defines the mime type of the result
  31866. */
  31867. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31868. /**
  31869. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31870. * @param successCallback defines the callback triggered once the data are available
  31871. * @param mimeType defines the mime type of the result
  31872. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31873. */
  31874. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31875. /**
  31876. * Downloads a blob in the browser
  31877. * @param blob defines the blob to download
  31878. * @param fileName defines the name of the downloaded file
  31879. */
  31880. static Download(blob: Blob, fileName: string): void;
  31881. /**
  31882. * Captures a screenshot of the current rendering
  31883. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31884. * @param engine defines the rendering engine
  31885. * @param camera defines the source camera
  31886. * @param size This parameter can be set to a single number or to an object with the
  31887. * following (optional) properties: precision, width, height. If a single number is passed,
  31888. * it will be used for both width and height. If an object is passed, the screenshot size
  31889. * will be derived from the parameters. The precision property is a multiplier allowing
  31890. * rendering at a higher or lower resolution
  31891. * @param successCallback defines the callback receives a single parameter which contains the
  31892. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31893. * src parameter of an <img> to display it
  31894. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31895. * Check your browser for supported MIME types
  31896. */
  31897. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31898. /**
  31899. * Captures a screenshot of the current rendering
  31900. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31901. * @param engine defines the rendering engine
  31902. * @param camera defines the source camera
  31903. * @param size This parameter can be set to a single number or to an object with the
  31904. * following (optional) properties: precision, width, height. If a single number is passed,
  31905. * it will be used for both width and height. If an object is passed, the screenshot size
  31906. * will be derived from the parameters. The precision property is a multiplier allowing
  31907. * rendering at a higher or lower resolution
  31908. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31909. * Check your browser for supported MIME types
  31910. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31911. * to the src parameter of an <img> to display it
  31912. */
  31913. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  31914. /**
  31915. * Generates an image screenshot from the specified camera.
  31916. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31917. * @param engine The engine to use for rendering
  31918. * @param camera The camera to use for rendering
  31919. * @param size This parameter can be set to a single number or to an object with the
  31920. * following (optional) properties: precision, width, height. If a single number is passed,
  31921. * it will be used for both width and height. If an object is passed, the screenshot size
  31922. * will be derived from the parameters. The precision property is a multiplier allowing
  31923. * rendering at a higher or lower resolution
  31924. * @param successCallback The callback receives a single parameter which contains the
  31925. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31926. * src parameter of an <img> to display it
  31927. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31928. * Check your browser for supported MIME types
  31929. * @param samples Texture samples (default: 1)
  31930. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31931. * @param fileName A name for for the downloaded file.
  31932. */
  31933. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31934. /**
  31935. * Generates an image screenshot from the specified camera.
  31936. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31937. * @param engine The engine to use for rendering
  31938. * @param camera The camera to use for rendering
  31939. * @param size This parameter can be set to a single number or to an object with the
  31940. * following (optional) properties: precision, width, height. If a single number is passed,
  31941. * it will be used for both width and height. If an object is passed, the screenshot size
  31942. * will be derived from the parameters. The precision property is a multiplier allowing
  31943. * rendering at a higher or lower resolution
  31944. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31945. * Check your browser for supported MIME types
  31946. * @param samples Texture samples (default: 1)
  31947. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31948. * @param fileName A name for for the downloaded file.
  31949. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31950. * to the src parameter of an <img> to display it
  31951. */
  31952. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  31953. /**
  31954. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31955. * Be aware Math.random() could cause collisions, but:
  31956. * "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"
  31957. * @returns a pseudo random id
  31958. */
  31959. static RandomId(): string;
  31960. /**
  31961. * Test if the given uri is a base64 string
  31962. * @param uri The uri to test
  31963. * @return True if the uri is a base64 string or false otherwise
  31964. */
  31965. static IsBase64(uri: string): boolean;
  31966. /**
  31967. * Decode the given base64 uri.
  31968. * @param uri The uri to decode
  31969. * @return The decoded base64 data.
  31970. */
  31971. static DecodeBase64(uri: string): ArrayBuffer;
  31972. /**
  31973. * Gets the absolute url.
  31974. * @param url the input url
  31975. * @return the absolute url
  31976. */
  31977. static GetAbsoluteUrl(url: string): string;
  31978. /**
  31979. * No log
  31980. */
  31981. static readonly NoneLogLevel: number;
  31982. /**
  31983. * Only message logs
  31984. */
  31985. static readonly MessageLogLevel: number;
  31986. /**
  31987. * Only warning logs
  31988. */
  31989. static readonly WarningLogLevel: number;
  31990. /**
  31991. * Only error logs
  31992. */
  31993. static readonly ErrorLogLevel: number;
  31994. /**
  31995. * All logs
  31996. */
  31997. static readonly AllLogLevel: number;
  31998. /**
  31999. * Gets a value indicating the number of loading errors
  32000. * @ignorenaming
  32001. */
  32002. static readonly errorsCount: number;
  32003. /**
  32004. * Callback called when a new log is added
  32005. */
  32006. static OnNewCacheEntry: (entry: string) => void;
  32007. /**
  32008. * Log a message to the console
  32009. * @param message defines the message to log
  32010. */
  32011. static Log(message: string): void;
  32012. /**
  32013. * Write a warning message to the console
  32014. * @param message defines the message to log
  32015. */
  32016. static Warn(message: string): void;
  32017. /**
  32018. * Write an error message to the console
  32019. * @param message defines the message to log
  32020. */
  32021. static Error(message: string): void;
  32022. /**
  32023. * Gets current log cache (list of logs)
  32024. */
  32025. static readonly LogCache: string;
  32026. /**
  32027. * Clears the log cache
  32028. */
  32029. static ClearLogCache(): void;
  32030. /**
  32031. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32032. */
  32033. static LogLevels: number;
  32034. /**
  32035. * Checks if the window object exists
  32036. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32037. */
  32038. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32039. /**
  32040. * No performance log
  32041. */
  32042. static readonly PerformanceNoneLogLevel: number;
  32043. /**
  32044. * Use user marks to log performance
  32045. */
  32046. static readonly PerformanceUserMarkLogLevel: number;
  32047. /**
  32048. * Log performance to the console
  32049. */
  32050. static readonly PerformanceConsoleLogLevel: number;
  32051. private static _performance;
  32052. /**
  32053. * Sets the current performance log level
  32054. */
  32055. static PerformanceLogLevel: number;
  32056. private static _StartPerformanceCounterDisabled;
  32057. private static _EndPerformanceCounterDisabled;
  32058. private static _StartUserMark;
  32059. private static _EndUserMark;
  32060. private static _StartPerformanceConsole;
  32061. private static _EndPerformanceConsole;
  32062. /**
  32063. * Starts a performance counter
  32064. */
  32065. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32066. /**
  32067. * Ends a specific performance coutner
  32068. */
  32069. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32070. /**
  32071. * Gets either window.performance.now() if supported or Date.now() else
  32072. */
  32073. static readonly Now: number;
  32074. /**
  32075. * This method will return the name of the class used to create the instance of the given object.
  32076. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32077. * @param object the object to get the class name from
  32078. * @param isType defines if the object is actually a type
  32079. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32080. */
  32081. static GetClassName(object: any, isType?: boolean): string;
  32082. /**
  32083. * Gets the first element of an array satisfying a given predicate
  32084. * @param array defines the array to browse
  32085. * @param predicate defines the predicate to use
  32086. * @returns null if not found or the element
  32087. */
  32088. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32089. /**
  32090. * This method will return the name of the full name of the class, including its owning module (if any).
  32091. * 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).
  32092. * @param object the object to get the class name from
  32093. * @param isType defines if the object is actually a type
  32094. * @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.
  32095. * @ignorenaming
  32096. */
  32097. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32098. /**
  32099. * Returns a promise that resolves after the given amount of time.
  32100. * @param delay Number of milliseconds to delay
  32101. * @returns Promise that resolves after the given amount of time
  32102. */
  32103. static DelayAsync(delay: number): Promise<void>;
  32104. }
  32105. /**
  32106. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32107. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32108. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32109. * @param name The name of the class, case should be preserved
  32110. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32111. */
  32112. export function className(name: string, module?: string): (target: Object) => void;
  32113. /**
  32114. * An implementation of a loop for asynchronous functions.
  32115. */
  32116. export class AsyncLoop {
  32117. /**
  32118. * Defines the number of iterations for the loop
  32119. */
  32120. iterations: number;
  32121. /**
  32122. * Defines the current index of the loop.
  32123. */
  32124. index: number;
  32125. private _done;
  32126. private _fn;
  32127. private _successCallback;
  32128. /**
  32129. * Constructor.
  32130. * @param iterations the number of iterations.
  32131. * @param func the function to run each iteration
  32132. * @param successCallback the callback that will be called upon succesful execution
  32133. * @param offset starting offset.
  32134. */
  32135. constructor(
  32136. /**
  32137. * Defines the number of iterations for the loop
  32138. */
  32139. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32140. /**
  32141. * Execute the next iteration. Must be called after the last iteration was finished.
  32142. */
  32143. executeNext(): void;
  32144. /**
  32145. * Break the loop and run the success callback.
  32146. */
  32147. breakLoop(): void;
  32148. /**
  32149. * Create and run an async loop.
  32150. * @param iterations the number of iterations.
  32151. * @param fn the function to run each iteration
  32152. * @param successCallback the callback that will be called upon succesful execution
  32153. * @param offset starting offset.
  32154. * @returns the created async loop object
  32155. */
  32156. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32157. /**
  32158. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32159. * @param iterations total number of iterations
  32160. * @param syncedIterations number of synchronous iterations in each async iteration.
  32161. * @param fn the function to call each iteration.
  32162. * @param callback a success call back that will be called when iterating stops.
  32163. * @param breakFunction a break condition (optional)
  32164. * @param timeout timeout settings for the setTimeout function. default - 0.
  32165. * @returns the created async loop object
  32166. */
  32167. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32168. }
  32169. }
  32170. declare module BABYLON {
  32171. /** @hidden */
  32172. export interface ICollisionCoordinator {
  32173. createCollider(): Collider;
  32174. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32175. init(scene: Scene): void;
  32176. }
  32177. /** @hidden */
  32178. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32179. private _scene;
  32180. private _scaledPosition;
  32181. private _scaledVelocity;
  32182. private _finalPosition;
  32183. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32184. createCollider(): Collider;
  32185. init(scene: Scene): void;
  32186. private _collideWithWorld;
  32187. }
  32188. }
  32189. declare module BABYLON {
  32190. /**
  32191. * Class used to manage all inputs for the scene.
  32192. */
  32193. export class InputManager {
  32194. /** The distance in pixel that you have to move to prevent some events */
  32195. static DragMovementThreshold: number;
  32196. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32197. static LongPressDelay: number;
  32198. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32199. static DoubleClickDelay: number;
  32200. /** If you need to check double click without raising a single click at first click, enable this flag */
  32201. static ExclusiveDoubleClickMode: boolean;
  32202. private _wheelEventName;
  32203. private _onPointerMove;
  32204. private _onPointerDown;
  32205. private _onPointerUp;
  32206. private _initClickEvent;
  32207. private _initActionManager;
  32208. private _delayedSimpleClick;
  32209. private _delayedSimpleClickTimeout;
  32210. private _previousDelayedSimpleClickTimeout;
  32211. private _meshPickProceed;
  32212. private _previousButtonPressed;
  32213. private _currentPickResult;
  32214. private _previousPickResult;
  32215. private _totalPointersPressed;
  32216. private _doubleClickOccured;
  32217. private _pointerOverMesh;
  32218. private _pickedDownMesh;
  32219. private _pickedUpMesh;
  32220. private _pointerX;
  32221. private _pointerY;
  32222. private _unTranslatedPointerX;
  32223. private _unTranslatedPointerY;
  32224. private _startingPointerPosition;
  32225. private _previousStartingPointerPosition;
  32226. private _startingPointerTime;
  32227. private _previousStartingPointerTime;
  32228. private _pointerCaptures;
  32229. private _onKeyDown;
  32230. private _onKeyUp;
  32231. private _onCanvasFocusObserver;
  32232. private _onCanvasBlurObserver;
  32233. private _scene;
  32234. /**
  32235. * Creates a new InputManager
  32236. * @param scene defines the hosting scene
  32237. */
  32238. constructor(scene: Scene);
  32239. /**
  32240. * Gets the mesh that is currently under the pointer
  32241. */
  32242. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32243. /**
  32244. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32245. */
  32246. readonly unTranslatedPointer: Vector2;
  32247. /**
  32248. * Gets or sets the current on-screen X position of the pointer
  32249. */
  32250. pointerX: number;
  32251. /**
  32252. * Gets or sets the current on-screen Y position of the pointer
  32253. */
  32254. pointerY: number;
  32255. private _updatePointerPosition;
  32256. private _processPointerMove;
  32257. private _setRayOnPointerInfo;
  32258. private _checkPrePointerObservable;
  32259. /**
  32260. * Use this method to simulate a pointer move on a mesh
  32261. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32262. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32263. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32264. */
  32265. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32266. /**
  32267. * Use this method to simulate a pointer down on a mesh
  32268. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32269. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32270. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32271. */
  32272. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32273. private _processPointerDown;
  32274. /** @hidden */
  32275. _isPointerSwiping(): boolean;
  32276. /**
  32277. * Use this method to simulate a pointer up on a mesh
  32278. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32279. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32280. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32281. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32282. */
  32283. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32284. private _processPointerUp;
  32285. /**
  32286. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32287. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32288. * @returns true if the pointer was captured
  32289. */
  32290. isPointerCaptured(pointerId?: number): boolean;
  32291. /**
  32292. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32293. * @param attachUp defines if you want to attach events to pointerup
  32294. * @param attachDown defines if you want to attach events to pointerdown
  32295. * @param attachMove defines if you want to attach events to pointermove
  32296. */
  32297. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32298. /**
  32299. * Detaches all event handlers
  32300. */
  32301. detachControl(): void;
  32302. /**
  32303. * Force the value of meshUnderPointer
  32304. * @param mesh defines the mesh to use
  32305. */
  32306. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32307. /**
  32308. * Gets the mesh under the pointer
  32309. * @returns a Mesh or null if no mesh is under the pointer
  32310. */
  32311. getPointerOverMesh(): Nullable<AbstractMesh>;
  32312. }
  32313. }
  32314. declare module BABYLON {
  32315. /**
  32316. * Helper class used to generate session unique ID
  32317. */
  32318. export class UniqueIdGenerator {
  32319. private static _UniqueIdCounter;
  32320. /**
  32321. * Gets an unique (relatively to the current scene) Id
  32322. */
  32323. static readonly UniqueId: number;
  32324. }
  32325. }
  32326. declare module BABYLON {
  32327. /**
  32328. * This class defines the direct association between an animation and a target
  32329. */
  32330. export class TargetedAnimation {
  32331. /**
  32332. * Animation to perform
  32333. */
  32334. animation: Animation;
  32335. /**
  32336. * Target to animate
  32337. */
  32338. target: any;
  32339. /**
  32340. * Serialize the object
  32341. * @returns the JSON object representing the current entity
  32342. */
  32343. serialize(): any;
  32344. }
  32345. /**
  32346. * Use this class to create coordinated animations on multiple targets
  32347. */
  32348. export class AnimationGroup implements IDisposable {
  32349. /** The name of the animation group */
  32350. name: string;
  32351. private _scene;
  32352. private _targetedAnimations;
  32353. private _animatables;
  32354. private _from;
  32355. private _to;
  32356. private _isStarted;
  32357. private _isPaused;
  32358. private _speedRatio;
  32359. private _loopAnimation;
  32360. /**
  32361. * Gets or sets the unique id of the node
  32362. */
  32363. uniqueId: number;
  32364. /**
  32365. * This observable will notify when one animation have ended
  32366. */
  32367. onAnimationEndObservable: Observable<TargetedAnimation>;
  32368. /**
  32369. * Observer raised when one animation loops
  32370. */
  32371. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32372. /**
  32373. * This observable will notify when all animations have ended.
  32374. */
  32375. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32376. /**
  32377. * This observable will notify when all animations have paused.
  32378. */
  32379. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32380. /**
  32381. * This observable will notify when all animations are playing.
  32382. */
  32383. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32384. /**
  32385. * Gets the first frame
  32386. */
  32387. readonly from: number;
  32388. /**
  32389. * Gets the last frame
  32390. */
  32391. readonly to: number;
  32392. /**
  32393. * Define if the animations are started
  32394. */
  32395. readonly isStarted: boolean;
  32396. /**
  32397. * Gets a value indicating that the current group is playing
  32398. */
  32399. readonly isPlaying: boolean;
  32400. /**
  32401. * Gets or sets the speed ratio to use for all animations
  32402. */
  32403. /**
  32404. * Gets or sets the speed ratio to use for all animations
  32405. */
  32406. speedRatio: number;
  32407. /**
  32408. * Gets or sets if all animations should loop or not
  32409. */
  32410. loopAnimation: boolean;
  32411. /**
  32412. * Gets the targeted animations for this animation group
  32413. */
  32414. readonly targetedAnimations: Array<TargetedAnimation>;
  32415. /**
  32416. * returning the list of animatables controlled by this animation group.
  32417. */
  32418. readonly animatables: Array<Animatable>;
  32419. /**
  32420. * Instantiates a new Animation Group.
  32421. * This helps managing several animations at once.
  32422. * @see http://doc.babylonjs.com/how_to/group
  32423. * @param name Defines the name of the group
  32424. * @param scene Defines the scene the group belongs to
  32425. */
  32426. constructor(
  32427. /** The name of the animation group */
  32428. name: string, scene?: Nullable<Scene>);
  32429. /**
  32430. * Add an animation (with its target) in the group
  32431. * @param animation defines the animation we want to add
  32432. * @param target defines the target of the animation
  32433. * @returns the TargetedAnimation object
  32434. */
  32435. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32436. /**
  32437. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32438. * It can add constant keys at begin or end
  32439. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32440. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32441. * @returns the animation group
  32442. */
  32443. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32444. /**
  32445. * Start all animations on given targets
  32446. * @param loop defines if animations must loop
  32447. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32448. * @param from defines the from key (optional)
  32449. * @param to defines the to key (optional)
  32450. * @returns the current animation group
  32451. */
  32452. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32453. /**
  32454. * Pause all animations
  32455. * @returns the animation group
  32456. */
  32457. pause(): AnimationGroup;
  32458. /**
  32459. * Play all animations to initial state
  32460. * This function will start() the animations if they were not started or will restart() them if they were paused
  32461. * @param loop defines if animations must loop
  32462. * @returns the animation group
  32463. */
  32464. play(loop?: boolean): AnimationGroup;
  32465. /**
  32466. * Reset all animations to initial state
  32467. * @returns the animation group
  32468. */
  32469. reset(): AnimationGroup;
  32470. /**
  32471. * Restart animations from key 0
  32472. * @returns the animation group
  32473. */
  32474. restart(): AnimationGroup;
  32475. /**
  32476. * Stop all animations
  32477. * @returns the animation group
  32478. */
  32479. stop(): AnimationGroup;
  32480. /**
  32481. * Set animation weight for all animatables
  32482. * @param weight defines the weight to use
  32483. * @return the animationGroup
  32484. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32485. */
  32486. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32487. /**
  32488. * Synchronize and normalize all animatables with a source animatable
  32489. * @param root defines the root animatable to synchronize with
  32490. * @return the animationGroup
  32491. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32492. */
  32493. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32494. /**
  32495. * Goes to a specific frame in this animation group
  32496. * @param frame the frame number to go to
  32497. * @return the animationGroup
  32498. */
  32499. goToFrame(frame: number): AnimationGroup;
  32500. /**
  32501. * Dispose all associated resources
  32502. */
  32503. dispose(): void;
  32504. private _checkAnimationGroupEnded;
  32505. /**
  32506. * Clone the current animation group and returns a copy
  32507. * @param newName defines the name of the new group
  32508. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32509. * @returns the new aniamtion group
  32510. */
  32511. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32512. /**
  32513. * Serializes the animationGroup to an object
  32514. * @returns Serialized object
  32515. */
  32516. serialize(): any;
  32517. /**
  32518. * Returns a new AnimationGroup object parsed from the source provided.
  32519. * @param parsedAnimationGroup defines the source
  32520. * @param scene defines the scene that will receive the animationGroup
  32521. * @returns a new AnimationGroup
  32522. */
  32523. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32524. /**
  32525. * Returns the string "AnimationGroup"
  32526. * @returns "AnimationGroup"
  32527. */
  32528. getClassName(): string;
  32529. /**
  32530. * Creates a detailled string about the object
  32531. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32532. * @returns a string representing the object
  32533. */
  32534. toString(fullDetails?: boolean): string;
  32535. }
  32536. }
  32537. declare module BABYLON {
  32538. /**
  32539. * Define an interface for all classes that will hold resources
  32540. */
  32541. export interface IDisposable {
  32542. /**
  32543. * Releases all held resources
  32544. */
  32545. dispose(): void;
  32546. }
  32547. /** Interface defining initialization parameters for Scene class */
  32548. export interface SceneOptions {
  32549. /**
  32550. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32551. * It will improve performance when the number of geometries becomes important.
  32552. */
  32553. useGeometryUniqueIdsMap?: boolean;
  32554. /**
  32555. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32556. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32557. */
  32558. useMaterialMeshMap?: boolean;
  32559. /**
  32560. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32561. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32562. */
  32563. useClonedMeshhMap?: boolean;
  32564. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32565. virtual?: boolean;
  32566. }
  32567. /**
  32568. * Represents a scene to be rendered by the engine.
  32569. * @see http://doc.babylonjs.com/features/scene
  32570. */
  32571. export class Scene extends AbstractScene implements IAnimatable {
  32572. /** The fog is deactivated */
  32573. static readonly FOGMODE_NONE: number;
  32574. /** The fog density is following an exponential function */
  32575. static readonly FOGMODE_EXP: number;
  32576. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32577. static readonly FOGMODE_EXP2: number;
  32578. /** The fog density is following a linear function. */
  32579. static readonly FOGMODE_LINEAR: number;
  32580. /**
  32581. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32582. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32583. */
  32584. static MinDeltaTime: number;
  32585. /**
  32586. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32587. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32588. */
  32589. static MaxDeltaTime: number;
  32590. /**
  32591. * Factory used to create the default material.
  32592. * @param name The name of the material to create
  32593. * @param scene The scene to create the material for
  32594. * @returns The default material
  32595. */
  32596. static DefaultMaterialFactory(scene: Scene): Material;
  32597. /**
  32598. * Factory used to create the a collision coordinator.
  32599. * @returns The collision coordinator
  32600. */
  32601. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32602. /** @hidden */
  32603. _inputManager: InputManager;
  32604. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32605. cameraToUseForPointers: Nullable<Camera>;
  32606. /** @hidden */
  32607. readonly _isScene: boolean;
  32608. /**
  32609. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32610. */
  32611. autoClear: boolean;
  32612. /**
  32613. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32614. */
  32615. autoClearDepthAndStencil: boolean;
  32616. /**
  32617. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32618. */
  32619. clearColor: Color4;
  32620. /**
  32621. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32622. */
  32623. ambientColor: Color3;
  32624. /**
  32625. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32626. * It should only be one of the following (if not the default embedded one):
  32627. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32628. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32629. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32630. * The material properties need to be setup according to the type of texture in use.
  32631. */
  32632. environmentBRDFTexture: BaseTexture;
  32633. /** @hidden */
  32634. protected _environmentTexture: Nullable<BaseTexture>;
  32635. /**
  32636. * Texture used in all pbr material as the reflection texture.
  32637. * As in the majority of the scene they are the same (exception for multi room and so on),
  32638. * this is easier to reference from here than from all the materials.
  32639. */
  32640. /**
  32641. * Texture used in all pbr material as the reflection texture.
  32642. * As in the majority of the scene they are the same (exception for multi room and so on),
  32643. * this is easier to set here than in all the materials.
  32644. */
  32645. environmentTexture: Nullable<BaseTexture>;
  32646. /** @hidden */
  32647. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32648. /**
  32649. * Default image processing configuration used either in the rendering
  32650. * Forward main pass or through the imageProcessingPostProcess if present.
  32651. * As in the majority of the scene they are the same (exception for multi camera),
  32652. * this is easier to reference from here than from all the materials and post process.
  32653. *
  32654. * No setter as we it is a shared configuration, you can set the values instead.
  32655. */
  32656. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32657. private _forceWireframe;
  32658. /**
  32659. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32660. */
  32661. forceWireframe: boolean;
  32662. private _forcePointsCloud;
  32663. /**
  32664. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32665. */
  32666. forcePointsCloud: boolean;
  32667. /**
  32668. * Gets or sets the active clipplane 1
  32669. */
  32670. clipPlane: Nullable<Plane>;
  32671. /**
  32672. * Gets or sets the active clipplane 2
  32673. */
  32674. clipPlane2: Nullable<Plane>;
  32675. /**
  32676. * Gets or sets the active clipplane 3
  32677. */
  32678. clipPlane3: Nullable<Plane>;
  32679. /**
  32680. * Gets or sets the active clipplane 4
  32681. */
  32682. clipPlane4: Nullable<Plane>;
  32683. /**
  32684. * Gets or sets a boolean indicating if animations are enabled
  32685. */
  32686. animationsEnabled: boolean;
  32687. private _animationPropertiesOverride;
  32688. /**
  32689. * Gets or sets the animation properties override
  32690. */
  32691. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32692. /**
  32693. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32694. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32695. */
  32696. useConstantAnimationDeltaTime: boolean;
  32697. /**
  32698. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32699. * Please note that it requires to run a ray cast through the scene on every frame
  32700. */
  32701. constantlyUpdateMeshUnderPointer: boolean;
  32702. /**
  32703. * Defines the HTML cursor to use when hovering over interactive elements
  32704. */
  32705. hoverCursor: string;
  32706. /**
  32707. * Defines the HTML default cursor to use (empty by default)
  32708. */
  32709. defaultCursor: string;
  32710. /**
  32711. * This is used to call preventDefault() on pointer down
  32712. * in order to block unwanted artifacts like system double clicks
  32713. */
  32714. preventDefaultOnPointerDown: boolean;
  32715. /**
  32716. * This is used to call preventDefault() on pointer up
  32717. * in order to block unwanted artifacts like system double clicks
  32718. */
  32719. preventDefaultOnPointerUp: boolean;
  32720. /**
  32721. * Gets or sets user defined metadata
  32722. */
  32723. metadata: any;
  32724. /**
  32725. * For internal use only. Please do not use.
  32726. */
  32727. reservedDataStore: any;
  32728. /**
  32729. * Gets the name of the plugin used to load this scene (null by default)
  32730. */
  32731. loadingPluginName: string;
  32732. /**
  32733. * Use this array to add regular expressions used to disable offline support for specific urls
  32734. */
  32735. disableOfflineSupportExceptionRules: RegExp[];
  32736. /**
  32737. * An event triggered when the scene is disposed.
  32738. */
  32739. onDisposeObservable: Observable<Scene>;
  32740. private _onDisposeObserver;
  32741. /** Sets a function to be executed when this scene is disposed. */
  32742. onDispose: () => void;
  32743. /**
  32744. * An event triggered before rendering the scene (right after animations and physics)
  32745. */
  32746. onBeforeRenderObservable: Observable<Scene>;
  32747. private _onBeforeRenderObserver;
  32748. /** Sets a function to be executed before rendering this scene */
  32749. beforeRender: Nullable<() => void>;
  32750. /**
  32751. * An event triggered after rendering the scene
  32752. */
  32753. onAfterRenderObservable: Observable<Scene>;
  32754. /**
  32755. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32756. */
  32757. onAfterRenderCameraObservable: Observable<Camera>;
  32758. private _onAfterRenderObserver;
  32759. /** Sets a function to be executed after rendering this scene */
  32760. afterRender: Nullable<() => void>;
  32761. /**
  32762. * An event triggered before animating the scene
  32763. */
  32764. onBeforeAnimationsObservable: Observable<Scene>;
  32765. /**
  32766. * An event triggered after animations processing
  32767. */
  32768. onAfterAnimationsObservable: Observable<Scene>;
  32769. /**
  32770. * An event triggered before draw calls are ready to be sent
  32771. */
  32772. onBeforeDrawPhaseObservable: Observable<Scene>;
  32773. /**
  32774. * An event triggered after draw calls have been sent
  32775. */
  32776. onAfterDrawPhaseObservable: Observable<Scene>;
  32777. /**
  32778. * An event triggered when the scene is ready
  32779. */
  32780. onReadyObservable: Observable<Scene>;
  32781. /**
  32782. * An event triggered before rendering a camera
  32783. */
  32784. onBeforeCameraRenderObservable: Observable<Camera>;
  32785. private _onBeforeCameraRenderObserver;
  32786. /** Sets a function to be executed before rendering a camera*/
  32787. beforeCameraRender: () => void;
  32788. /**
  32789. * An event triggered after rendering a camera
  32790. */
  32791. onAfterCameraRenderObservable: Observable<Camera>;
  32792. private _onAfterCameraRenderObserver;
  32793. /** Sets a function to be executed after rendering a camera*/
  32794. afterCameraRender: () => void;
  32795. /**
  32796. * An event triggered when active meshes evaluation is about to start
  32797. */
  32798. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32799. /**
  32800. * An event triggered when active meshes evaluation is done
  32801. */
  32802. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32803. /**
  32804. * An event triggered when particles rendering is about to start
  32805. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32806. */
  32807. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32808. /**
  32809. * An event triggered when particles rendering is done
  32810. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32811. */
  32812. onAfterParticlesRenderingObservable: Observable<Scene>;
  32813. /**
  32814. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32815. */
  32816. onDataLoadedObservable: Observable<Scene>;
  32817. /**
  32818. * An event triggered when a camera is created
  32819. */
  32820. onNewCameraAddedObservable: Observable<Camera>;
  32821. /**
  32822. * An event triggered when a camera is removed
  32823. */
  32824. onCameraRemovedObservable: Observable<Camera>;
  32825. /**
  32826. * An event triggered when a light is created
  32827. */
  32828. onNewLightAddedObservable: Observable<Light>;
  32829. /**
  32830. * An event triggered when a light is removed
  32831. */
  32832. onLightRemovedObservable: Observable<Light>;
  32833. /**
  32834. * An event triggered when a geometry is created
  32835. */
  32836. onNewGeometryAddedObservable: Observable<Geometry>;
  32837. /**
  32838. * An event triggered when a geometry is removed
  32839. */
  32840. onGeometryRemovedObservable: Observable<Geometry>;
  32841. /**
  32842. * An event triggered when a transform node is created
  32843. */
  32844. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32845. /**
  32846. * An event triggered when a transform node is removed
  32847. */
  32848. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32849. /**
  32850. * An event triggered when a mesh is created
  32851. */
  32852. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32853. /**
  32854. * An event triggered when a mesh is removed
  32855. */
  32856. onMeshRemovedObservable: Observable<AbstractMesh>;
  32857. /**
  32858. * An event triggered when a skeleton is created
  32859. */
  32860. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32861. /**
  32862. * An event triggered when a skeleton is removed
  32863. */
  32864. onSkeletonRemovedObservable: Observable<Skeleton>;
  32865. /**
  32866. * An event triggered when a material is created
  32867. */
  32868. onNewMaterialAddedObservable: Observable<Material>;
  32869. /**
  32870. * An event triggered when a material is removed
  32871. */
  32872. onMaterialRemovedObservable: Observable<Material>;
  32873. /**
  32874. * An event triggered when a texture is created
  32875. */
  32876. onNewTextureAddedObservable: Observable<BaseTexture>;
  32877. /**
  32878. * An event triggered when a texture is removed
  32879. */
  32880. onTextureRemovedObservable: Observable<BaseTexture>;
  32881. /**
  32882. * An event triggered when render targets are about to be rendered
  32883. * Can happen multiple times per frame.
  32884. */
  32885. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32886. /**
  32887. * An event triggered when render targets were rendered.
  32888. * Can happen multiple times per frame.
  32889. */
  32890. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32891. /**
  32892. * An event triggered before calculating deterministic simulation step
  32893. */
  32894. onBeforeStepObservable: Observable<Scene>;
  32895. /**
  32896. * An event triggered after calculating deterministic simulation step
  32897. */
  32898. onAfterStepObservable: Observable<Scene>;
  32899. /**
  32900. * An event triggered when the activeCamera property is updated
  32901. */
  32902. onActiveCameraChanged: Observable<Scene>;
  32903. /**
  32904. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32905. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32906. * 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)
  32907. */
  32908. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32909. /**
  32910. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32911. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32912. * 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)
  32913. */
  32914. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32915. /**
  32916. * This Observable will when a mesh has been imported into the scene.
  32917. */
  32918. onMeshImportedObservable: Observable<AbstractMesh>;
  32919. /**
  32920. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32921. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32922. */
  32923. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32924. /** @hidden */
  32925. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32926. /**
  32927. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32928. */
  32929. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32930. /**
  32931. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32932. */
  32933. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32934. /**
  32935. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32936. */
  32937. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32938. /** Callback called when a pointer move is detected */
  32939. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32940. /** Callback called when a pointer down is detected */
  32941. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32942. /** Callback called when a pointer up is detected */
  32943. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32944. /** Callback called when a pointer pick is detected */
  32945. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32946. /**
  32947. * 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).
  32948. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32949. */
  32950. onPrePointerObservable: Observable<PointerInfoPre>;
  32951. /**
  32952. * Observable event triggered each time an input event is received from the rendering canvas
  32953. */
  32954. onPointerObservable: Observable<PointerInfo>;
  32955. /**
  32956. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32957. */
  32958. readonly unTranslatedPointer: Vector2;
  32959. /**
  32960. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32961. */
  32962. static DragMovementThreshold: number;
  32963. /**
  32964. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32965. */
  32966. static LongPressDelay: number;
  32967. /**
  32968. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32969. */
  32970. static DoubleClickDelay: number;
  32971. /** If you need to check double click without raising a single click at first click, enable this flag */
  32972. static ExclusiveDoubleClickMode: boolean;
  32973. /** @hidden */
  32974. _mirroredCameraPosition: Nullable<Vector3>;
  32975. /**
  32976. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32977. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32978. */
  32979. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32980. /**
  32981. * Observable event triggered each time an keyboard event is received from the hosting window
  32982. */
  32983. onKeyboardObservable: Observable<KeyboardInfo>;
  32984. private _useRightHandedSystem;
  32985. /**
  32986. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32987. */
  32988. useRightHandedSystem: boolean;
  32989. private _timeAccumulator;
  32990. private _currentStepId;
  32991. private _currentInternalStep;
  32992. /**
  32993. * Sets the step Id used by deterministic lock step
  32994. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32995. * @param newStepId defines the step Id
  32996. */
  32997. setStepId(newStepId: number): void;
  32998. /**
  32999. * Gets the step Id used by deterministic lock step
  33000. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33001. * @returns the step Id
  33002. */
  33003. getStepId(): number;
  33004. /**
  33005. * Gets the internal step used by deterministic lock step
  33006. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33007. * @returns the internal step
  33008. */
  33009. getInternalStep(): number;
  33010. private _fogEnabled;
  33011. /**
  33012. * Gets or sets a boolean indicating if fog is enabled on this scene
  33013. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33014. * (Default is true)
  33015. */
  33016. fogEnabled: boolean;
  33017. private _fogMode;
  33018. /**
  33019. * Gets or sets the fog mode to use
  33020. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33021. * | mode | value |
  33022. * | --- | --- |
  33023. * | FOGMODE_NONE | 0 |
  33024. * | FOGMODE_EXP | 1 |
  33025. * | FOGMODE_EXP2 | 2 |
  33026. * | FOGMODE_LINEAR | 3 |
  33027. */
  33028. fogMode: number;
  33029. /**
  33030. * Gets or sets the fog color to use
  33031. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33032. * (Default is Color3(0.2, 0.2, 0.3))
  33033. */
  33034. fogColor: Color3;
  33035. /**
  33036. * Gets or sets the fog density to use
  33037. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33038. * (Default is 0.1)
  33039. */
  33040. fogDensity: number;
  33041. /**
  33042. * Gets or sets the fog start distance to use
  33043. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33044. * (Default is 0)
  33045. */
  33046. fogStart: number;
  33047. /**
  33048. * Gets or sets the fog end distance to use
  33049. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33050. * (Default is 1000)
  33051. */
  33052. fogEnd: number;
  33053. private _shadowsEnabled;
  33054. /**
  33055. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33056. */
  33057. shadowsEnabled: boolean;
  33058. private _lightsEnabled;
  33059. /**
  33060. * Gets or sets a boolean indicating if lights are enabled on this scene
  33061. */
  33062. lightsEnabled: boolean;
  33063. /** All of the active cameras added to this scene. */
  33064. activeCameras: Camera[];
  33065. /** @hidden */
  33066. _activeCamera: Nullable<Camera>;
  33067. /** Gets or sets the current active camera */
  33068. activeCamera: Nullable<Camera>;
  33069. private _defaultMaterial;
  33070. /** The default material used on meshes when no material is affected */
  33071. /** The default material used on meshes when no material is affected */
  33072. defaultMaterial: Material;
  33073. private _texturesEnabled;
  33074. /**
  33075. * Gets or sets a boolean indicating if textures are enabled on this scene
  33076. */
  33077. texturesEnabled: boolean;
  33078. /**
  33079. * Gets or sets a boolean indicating if particles are enabled on this scene
  33080. */
  33081. particlesEnabled: boolean;
  33082. /**
  33083. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33084. */
  33085. spritesEnabled: boolean;
  33086. private _skeletonsEnabled;
  33087. /**
  33088. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33089. */
  33090. skeletonsEnabled: boolean;
  33091. /**
  33092. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33093. */
  33094. lensFlaresEnabled: boolean;
  33095. /**
  33096. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33097. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33098. */
  33099. collisionsEnabled: boolean;
  33100. private _collisionCoordinator;
  33101. /** @hidden */
  33102. readonly collisionCoordinator: ICollisionCoordinator;
  33103. /**
  33104. * Defines the gravity applied to this scene (used only for collisions)
  33105. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33106. */
  33107. gravity: Vector3;
  33108. /**
  33109. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33110. */
  33111. postProcessesEnabled: boolean;
  33112. /**
  33113. * The list of postprocesses added to the scene
  33114. */
  33115. postProcesses: PostProcess[];
  33116. /**
  33117. * Gets the current postprocess manager
  33118. */
  33119. postProcessManager: PostProcessManager;
  33120. /**
  33121. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33122. */
  33123. renderTargetsEnabled: boolean;
  33124. /**
  33125. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33126. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33127. */
  33128. dumpNextRenderTargets: boolean;
  33129. /**
  33130. * The list of user defined render targets added to the scene
  33131. */
  33132. customRenderTargets: RenderTargetTexture[];
  33133. /**
  33134. * Defines if texture loading must be delayed
  33135. * If true, textures will only be loaded when they need to be rendered
  33136. */
  33137. useDelayedTextureLoading: boolean;
  33138. /**
  33139. * Gets the list of meshes imported to the scene through SceneLoader
  33140. */
  33141. importedMeshesFiles: String[];
  33142. /**
  33143. * Gets or sets a boolean indicating if probes are enabled on this scene
  33144. */
  33145. probesEnabled: boolean;
  33146. /**
  33147. * Gets or sets the current offline provider to use to store scene data
  33148. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33149. */
  33150. offlineProvider: IOfflineProvider;
  33151. /**
  33152. * Gets or sets the action manager associated with the scene
  33153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33154. */
  33155. actionManager: AbstractActionManager;
  33156. private _meshesForIntersections;
  33157. /**
  33158. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33159. */
  33160. proceduralTexturesEnabled: boolean;
  33161. private _engine;
  33162. private _totalVertices;
  33163. /** @hidden */
  33164. _activeIndices: PerfCounter;
  33165. /** @hidden */
  33166. _activeParticles: PerfCounter;
  33167. /** @hidden */
  33168. _activeBones: PerfCounter;
  33169. private _animationRatio;
  33170. /** @hidden */
  33171. _animationTimeLast: number;
  33172. /** @hidden */
  33173. _animationTime: number;
  33174. /**
  33175. * Gets or sets a general scale for animation speed
  33176. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33177. */
  33178. animationTimeScale: number;
  33179. /** @hidden */
  33180. _cachedMaterial: Nullable<Material>;
  33181. /** @hidden */
  33182. _cachedEffect: Nullable<Effect>;
  33183. /** @hidden */
  33184. _cachedVisibility: Nullable<number>;
  33185. private _renderId;
  33186. private _frameId;
  33187. private _executeWhenReadyTimeoutId;
  33188. private _intermediateRendering;
  33189. private _viewUpdateFlag;
  33190. private _projectionUpdateFlag;
  33191. /** @hidden */
  33192. _toBeDisposed: Nullable<IDisposable>[];
  33193. private _activeRequests;
  33194. /** @hidden */
  33195. _pendingData: any[];
  33196. private _isDisposed;
  33197. /**
  33198. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33199. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33200. */
  33201. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33202. private _activeMeshes;
  33203. private _processedMaterials;
  33204. private _renderTargets;
  33205. /** @hidden */
  33206. _activeParticleSystems: SmartArray<IParticleSystem>;
  33207. private _activeSkeletons;
  33208. private _softwareSkinnedMeshes;
  33209. private _renderingManager;
  33210. /** @hidden */
  33211. _activeAnimatables: Animatable[];
  33212. private _transformMatrix;
  33213. private _sceneUbo;
  33214. /** @hidden */
  33215. _viewMatrix: Matrix;
  33216. private _projectionMatrix;
  33217. /** @hidden */
  33218. _forcedViewPosition: Nullable<Vector3>;
  33219. /** @hidden */
  33220. _frustumPlanes: Plane[];
  33221. /**
  33222. * Gets the list of frustum planes (built from the active camera)
  33223. */
  33224. readonly frustumPlanes: Plane[];
  33225. /**
  33226. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33227. * This is useful if there are more lights that the maximum simulteanous authorized
  33228. */
  33229. requireLightSorting: boolean;
  33230. /** @hidden */
  33231. readonly useMaterialMeshMap: boolean;
  33232. /** @hidden */
  33233. readonly useClonedMeshhMap: boolean;
  33234. private _externalData;
  33235. private _uid;
  33236. /**
  33237. * @hidden
  33238. * Backing store of defined scene components.
  33239. */
  33240. _components: ISceneComponent[];
  33241. /**
  33242. * @hidden
  33243. * Backing store of defined scene components.
  33244. */
  33245. _serializableComponents: ISceneSerializableComponent[];
  33246. /**
  33247. * List of components to register on the next registration step.
  33248. */
  33249. private _transientComponents;
  33250. /**
  33251. * Registers the transient components if needed.
  33252. */
  33253. private _registerTransientComponents;
  33254. /**
  33255. * @hidden
  33256. * Add a component to the scene.
  33257. * Note that the ccomponent could be registered on th next frame if this is called after
  33258. * the register component stage.
  33259. * @param component Defines the component to add to the scene
  33260. */
  33261. _addComponent(component: ISceneComponent): void;
  33262. /**
  33263. * @hidden
  33264. * Gets a component from the scene.
  33265. * @param name defines the name of the component to retrieve
  33266. * @returns the component or null if not present
  33267. */
  33268. _getComponent(name: string): Nullable<ISceneComponent>;
  33269. /**
  33270. * @hidden
  33271. * Defines the actions happening before camera updates.
  33272. */
  33273. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33274. /**
  33275. * @hidden
  33276. * Defines the actions happening before clear the canvas.
  33277. */
  33278. _beforeClearStage: Stage<SimpleStageAction>;
  33279. /**
  33280. * @hidden
  33281. * Defines the actions when collecting render targets for the frame.
  33282. */
  33283. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33284. /**
  33285. * @hidden
  33286. * Defines the actions happening for one camera in the frame.
  33287. */
  33288. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33289. /**
  33290. * @hidden
  33291. * Defines the actions happening during the per mesh ready checks.
  33292. */
  33293. _isReadyForMeshStage: Stage<MeshStageAction>;
  33294. /**
  33295. * @hidden
  33296. * Defines the actions happening before evaluate active mesh checks.
  33297. */
  33298. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33299. /**
  33300. * @hidden
  33301. * Defines the actions happening during the evaluate sub mesh checks.
  33302. */
  33303. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33304. /**
  33305. * @hidden
  33306. * Defines the actions happening during the active mesh stage.
  33307. */
  33308. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33309. /**
  33310. * @hidden
  33311. * Defines the actions happening during the per camera render target step.
  33312. */
  33313. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33314. /**
  33315. * @hidden
  33316. * Defines the actions happening just before the active camera is drawing.
  33317. */
  33318. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33319. /**
  33320. * @hidden
  33321. * Defines the actions happening just before a render target is drawing.
  33322. */
  33323. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33324. /**
  33325. * @hidden
  33326. * Defines the actions happening just before a rendering group is drawing.
  33327. */
  33328. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33329. /**
  33330. * @hidden
  33331. * Defines the actions happening just before a mesh is drawing.
  33332. */
  33333. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33334. /**
  33335. * @hidden
  33336. * Defines the actions happening just after a mesh has been drawn.
  33337. */
  33338. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33339. /**
  33340. * @hidden
  33341. * Defines the actions happening just after a rendering group has been drawn.
  33342. */
  33343. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33344. /**
  33345. * @hidden
  33346. * Defines the actions happening just after the active camera has been drawn.
  33347. */
  33348. _afterCameraDrawStage: Stage<CameraStageAction>;
  33349. /**
  33350. * @hidden
  33351. * Defines the actions happening just after a render target has been drawn.
  33352. */
  33353. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33354. /**
  33355. * @hidden
  33356. * Defines the actions happening just after rendering all cameras and computing intersections.
  33357. */
  33358. _afterRenderStage: Stage<SimpleStageAction>;
  33359. /**
  33360. * @hidden
  33361. * Defines the actions happening when a pointer move event happens.
  33362. */
  33363. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33364. /**
  33365. * @hidden
  33366. * Defines the actions happening when a pointer down event happens.
  33367. */
  33368. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33369. /**
  33370. * @hidden
  33371. * Defines the actions happening when a pointer up event happens.
  33372. */
  33373. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33374. /**
  33375. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33376. */
  33377. private geometriesByUniqueId;
  33378. /**
  33379. * Creates a new Scene
  33380. * @param engine defines the engine to use to render this scene
  33381. * @param options defines the scene options
  33382. */
  33383. constructor(engine: Engine, options?: SceneOptions);
  33384. /**
  33385. * Gets a string idenfifying the name of the class
  33386. * @returns "Scene" string
  33387. */
  33388. getClassName(): string;
  33389. private _defaultMeshCandidates;
  33390. /**
  33391. * @hidden
  33392. */
  33393. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33394. private _defaultSubMeshCandidates;
  33395. /**
  33396. * @hidden
  33397. */
  33398. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33399. /**
  33400. * Sets the default candidate providers for the scene.
  33401. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33402. * and getCollidingSubMeshCandidates to their default function
  33403. */
  33404. setDefaultCandidateProviders(): void;
  33405. /**
  33406. * Gets the mesh that is currently under the pointer
  33407. */
  33408. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33409. /**
  33410. * Gets or sets the current on-screen X position of the pointer
  33411. */
  33412. pointerX: number;
  33413. /**
  33414. * Gets or sets the current on-screen Y position of the pointer
  33415. */
  33416. pointerY: number;
  33417. /**
  33418. * Gets the cached material (ie. the latest rendered one)
  33419. * @returns the cached material
  33420. */
  33421. getCachedMaterial(): Nullable<Material>;
  33422. /**
  33423. * Gets the cached effect (ie. the latest rendered one)
  33424. * @returns the cached effect
  33425. */
  33426. getCachedEffect(): Nullable<Effect>;
  33427. /**
  33428. * Gets the cached visibility state (ie. the latest rendered one)
  33429. * @returns the cached visibility state
  33430. */
  33431. getCachedVisibility(): Nullable<number>;
  33432. /**
  33433. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33434. * @param material defines the current material
  33435. * @param effect defines the current effect
  33436. * @param visibility defines the current visibility state
  33437. * @returns true if one parameter is not cached
  33438. */
  33439. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33440. /**
  33441. * Gets the engine associated with the scene
  33442. * @returns an Engine
  33443. */
  33444. getEngine(): Engine;
  33445. /**
  33446. * Gets the total number of vertices rendered per frame
  33447. * @returns the total number of vertices rendered per frame
  33448. */
  33449. getTotalVertices(): number;
  33450. /**
  33451. * Gets the performance counter for total vertices
  33452. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33453. */
  33454. readonly totalVerticesPerfCounter: PerfCounter;
  33455. /**
  33456. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33457. * @returns the total number of active indices rendered per frame
  33458. */
  33459. getActiveIndices(): number;
  33460. /**
  33461. * Gets the performance counter for active indices
  33462. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33463. */
  33464. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33465. /**
  33466. * Gets the total number of active particles rendered per frame
  33467. * @returns the total number of active particles rendered per frame
  33468. */
  33469. getActiveParticles(): number;
  33470. /**
  33471. * Gets the performance counter for active particles
  33472. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33473. */
  33474. readonly activeParticlesPerfCounter: PerfCounter;
  33475. /**
  33476. * Gets the total number of active bones rendered per frame
  33477. * @returns the total number of active bones rendered per frame
  33478. */
  33479. getActiveBones(): number;
  33480. /**
  33481. * Gets the performance counter for active bones
  33482. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33483. */
  33484. readonly activeBonesPerfCounter: PerfCounter;
  33485. /**
  33486. * Gets the array of active meshes
  33487. * @returns an array of AbstractMesh
  33488. */
  33489. getActiveMeshes(): SmartArray<AbstractMesh>;
  33490. /**
  33491. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33492. * @returns a number
  33493. */
  33494. getAnimationRatio(): number;
  33495. /**
  33496. * Gets an unique Id for the current render phase
  33497. * @returns a number
  33498. */
  33499. getRenderId(): number;
  33500. /**
  33501. * Gets an unique Id for the current frame
  33502. * @returns a number
  33503. */
  33504. getFrameId(): number;
  33505. /** Call this function if you want to manually increment the render Id*/
  33506. incrementRenderId(): void;
  33507. private _createUbo;
  33508. /**
  33509. * Use this method to simulate a pointer move on a mesh
  33510. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33511. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33512. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33513. * @returns the current scene
  33514. */
  33515. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33516. /**
  33517. * Use this method to simulate a pointer down on a mesh
  33518. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33519. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33520. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33521. * @returns the current scene
  33522. */
  33523. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33524. /**
  33525. * Use this method to simulate a pointer up on a mesh
  33526. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33527. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33528. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33529. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33530. * @returns the current scene
  33531. */
  33532. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33533. /**
  33534. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33535. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33536. * @returns true if the pointer was captured
  33537. */
  33538. isPointerCaptured(pointerId?: number): boolean;
  33539. /**
  33540. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33541. * @param attachUp defines if you want to attach events to pointerup
  33542. * @param attachDown defines if you want to attach events to pointerdown
  33543. * @param attachMove defines if you want to attach events to pointermove
  33544. */
  33545. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33546. /** Detaches all event handlers*/
  33547. detachControl(): void;
  33548. /**
  33549. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33550. * Delay loaded resources are not taking in account
  33551. * @return true if all required resources are ready
  33552. */
  33553. isReady(): boolean;
  33554. /** Resets all cached information relative to material (including effect and visibility) */
  33555. resetCachedMaterial(): void;
  33556. /**
  33557. * Registers a function to be called before every frame render
  33558. * @param func defines the function to register
  33559. */
  33560. registerBeforeRender(func: () => void): void;
  33561. /**
  33562. * Unregisters a function called before every frame render
  33563. * @param func defines the function to unregister
  33564. */
  33565. unregisterBeforeRender(func: () => void): void;
  33566. /**
  33567. * Registers a function to be called after every frame render
  33568. * @param func defines the function to register
  33569. */
  33570. registerAfterRender(func: () => void): void;
  33571. /**
  33572. * Unregisters a function called after every frame render
  33573. * @param func defines the function to unregister
  33574. */
  33575. unregisterAfterRender(func: () => void): void;
  33576. private _executeOnceBeforeRender;
  33577. /**
  33578. * The provided function will run before render once and will be disposed afterwards.
  33579. * A timeout delay can be provided so that the function will be executed in N ms.
  33580. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33581. * @param func The function to be executed.
  33582. * @param timeout optional delay in ms
  33583. */
  33584. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33585. /** @hidden */
  33586. _addPendingData(data: any): void;
  33587. /** @hidden */
  33588. _removePendingData(data: any): void;
  33589. /**
  33590. * Returns the number of items waiting to be loaded
  33591. * @returns the number of items waiting to be loaded
  33592. */
  33593. getWaitingItemsCount(): number;
  33594. /**
  33595. * Returns a boolean indicating if the scene is still loading data
  33596. */
  33597. readonly isLoading: boolean;
  33598. /**
  33599. * Registers a function to be executed when the scene is ready
  33600. * @param {Function} func - the function to be executed
  33601. */
  33602. executeWhenReady(func: () => void): void;
  33603. /**
  33604. * Returns a promise that resolves when the scene is ready
  33605. * @returns A promise that resolves when the scene is ready
  33606. */
  33607. whenReadyAsync(): Promise<void>;
  33608. /** @hidden */
  33609. _checkIsReady(): void;
  33610. /**
  33611. * Gets all animatable attached to the scene
  33612. */
  33613. readonly animatables: Animatable[];
  33614. /**
  33615. * Resets the last animation time frame.
  33616. * Useful to override when animations start running when loading a scene for the first time.
  33617. */
  33618. resetLastAnimationTimeFrame(): void;
  33619. /**
  33620. * Gets the current view matrix
  33621. * @returns a Matrix
  33622. */
  33623. getViewMatrix(): Matrix;
  33624. /**
  33625. * Gets the current projection matrix
  33626. * @returns a Matrix
  33627. */
  33628. getProjectionMatrix(): Matrix;
  33629. /**
  33630. * Gets the current transform matrix
  33631. * @returns a Matrix made of View * Projection
  33632. */
  33633. getTransformMatrix(): Matrix;
  33634. /**
  33635. * Sets the current transform matrix
  33636. * @param viewL defines the View matrix to use
  33637. * @param projectionL defines the Projection matrix to use
  33638. * @param viewR defines the right View matrix to use (if provided)
  33639. * @param projectionR defines the right Projection matrix to use (if provided)
  33640. */
  33641. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33642. /**
  33643. * Gets the uniform buffer used to store scene data
  33644. * @returns a UniformBuffer
  33645. */
  33646. getSceneUniformBuffer(): UniformBuffer;
  33647. /**
  33648. * Gets an unique (relatively to the current scene) Id
  33649. * @returns an unique number for the scene
  33650. */
  33651. getUniqueId(): number;
  33652. /**
  33653. * Add a mesh to the list of scene's meshes
  33654. * @param newMesh defines the mesh to add
  33655. * @param recursive if all child meshes should also be added to the scene
  33656. */
  33657. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33658. /**
  33659. * Remove a mesh for the list of scene's meshes
  33660. * @param toRemove defines the mesh to remove
  33661. * @param recursive if all child meshes should also be removed from the scene
  33662. * @returns the index where the mesh was in the mesh list
  33663. */
  33664. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33665. /**
  33666. * Add a transform node to the list of scene's transform nodes
  33667. * @param newTransformNode defines the transform node to add
  33668. */
  33669. addTransformNode(newTransformNode: TransformNode): void;
  33670. /**
  33671. * Remove a transform node for the list of scene's transform nodes
  33672. * @param toRemove defines the transform node to remove
  33673. * @returns the index where the transform node was in the transform node list
  33674. */
  33675. removeTransformNode(toRemove: TransformNode): number;
  33676. /**
  33677. * Remove a skeleton for the list of scene's skeletons
  33678. * @param toRemove defines the skeleton to remove
  33679. * @returns the index where the skeleton was in the skeleton list
  33680. */
  33681. removeSkeleton(toRemove: Skeleton): number;
  33682. /**
  33683. * Remove a morph target for the list of scene's morph targets
  33684. * @param toRemove defines the morph target to remove
  33685. * @returns the index where the morph target was in the morph target list
  33686. */
  33687. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33688. /**
  33689. * Remove a light for the list of scene's lights
  33690. * @param toRemove defines the light to remove
  33691. * @returns the index where the light was in the light list
  33692. */
  33693. removeLight(toRemove: Light): number;
  33694. /**
  33695. * Remove a camera for the list of scene's cameras
  33696. * @param toRemove defines the camera to remove
  33697. * @returns the index where the camera was in the camera list
  33698. */
  33699. removeCamera(toRemove: Camera): number;
  33700. /**
  33701. * Remove a particle system for the list of scene's particle systems
  33702. * @param toRemove defines the particle system to remove
  33703. * @returns the index where the particle system was in the particle system list
  33704. */
  33705. removeParticleSystem(toRemove: IParticleSystem): number;
  33706. /**
  33707. * Remove a animation for the list of scene's animations
  33708. * @param toRemove defines the animation to remove
  33709. * @returns the index where the animation was in the animation list
  33710. */
  33711. removeAnimation(toRemove: Animation): number;
  33712. /**
  33713. * Will stop the animation of the given target
  33714. * @param target - the target
  33715. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33716. * @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)
  33717. */
  33718. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33719. /**
  33720. * Removes the given animation group from this scene.
  33721. * @param toRemove The animation group to remove
  33722. * @returns The index of the removed animation group
  33723. */
  33724. removeAnimationGroup(toRemove: AnimationGroup): number;
  33725. /**
  33726. * Removes the given multi-material from this scene.
  33727. * @param toRemove The multi-material to remove
  33728. * @returns The index of the removed multi-material
  33729. */
  33730. removeMultiMaterial(toRemove: MultiMaterial): number;
  33731. /**
  33732. * Removes the given material from this scene.
  33733. * @param toRemove The material to remove
  33734. * @returns The index of the removed material
  33735. */
  33736. removeMaterial(toRemove: Material): number;
  33737. /**
  33738. * Removes the given action manager from this scene.
  33739. * @param toRemove The action manager to remove
  33740. * @returns The index of the removed action manager
  33741. */
  33742. removeActionManager(toRemove: AbstractActionManager): number;
  33743. /**
  33744. * Removes the given texture from this scene.
  33745. * @param toRemove The texture to remove
  33746. * @returns The index of the removed texture
  33747. */
  33748. removeTexture(toRemove: BaseTexture): number;
  33749. /**
  33750. * Adds the given light to this scene
  33751. * @param newLight The light to add
  33752. */
  33753. addLight(newLight: Light): void;
  33754. /**
  33755. * Sorts the list list based on light priorities
  33756. */
  33757. sortLightsByPriority(): void;
  33758. /**
  33759. * Adds the given camera to this scene
  33760. * @param newCamera The camera to add
  33761. */
  33762. addCamera(newCamera: Camera): void;
  33763. /**
  33764. * Adds the given skeleton to this scene
  33765. * @param newSkeleton The skeleton to add
  33766. */
  33767. addSkeleton(newSkeleton: Skeleton): void;
  33768. /**
  33769. * Adds the given particle system to this scene
  33770. * @param newParticleSystem The particle system to add
  33771. */
  33772. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33773. /**
  33774. * Adds the given animation to this scene
  33775. * @param newAnimation The animation to add
  33776. */
  33777. addAnimation(newAnimation: Animation): void;
  33778. /**
  33779. * Adds the given animation group to this scene.
  33780. * @param newAnimationGroup The animation group to add
  33781. */
  33782. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33783. /**
  33784. * Adds the given multi-material to this scene
  33785. * @param newMultiMaterial The multi-material to add
  33786. */
  33787. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33788. /**
  33789. * Adds the given material to this scene
  33790. * @param newMaterial The material to add
  33791. */
  33792. addMaterial(newMaterial: Material): void;
  33793. /**
  33794. * Adds the given morph target to this scene
  33795. * @param newMorphTargetManager The morph target to add
  33796. */
  33797. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33798. /**
  33799. * Adds the given geometry to this scene
  33800. * @param newGeometry The geometry to add
  33801. */
  33802. addGeometry(newGeometry: Geometry): void;
  33803. /**
  33804. * Adds the given action manager to this scene
  33805. * @param newActionManager The action manager to add
  33806. */
  33807. addActionManager(newActionManager: AbstractActionManager): void;
  33808. /**
  33809. * Adds the given texture to this scene.
  33810. * @param newTexture The texture to add
  33811. */
  33812. addTexture(newTexture: BaseTexture): void;
  33813. /**
  33814. * Switch active camera
  33815. * @param newCamera defines the new active camera
  33816. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33817. */
  33818. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33819. /**
  33820. * sets the active camera of the scene using its ID
  33821. * @param id defines the camera's ID
  33822. * @return the new active camera or null if none found.
  33823. */
  33824. setActiveCameraByID(id: string): Nullable<Camera>;
  33825. /**
  33826. * sets the active camera of the scene using its name
  33827. * @param name defines the camera's name
  33828. * @returns the new active camera or null if none found.
  33829. */
  33830. setActiveCameraByName(name: string): Nullable<Camera>;
  33831. /**
  33832. * get an animation group using its name
  33833. * @param name defines the material's name
  33834. * @return the animation group or null if none found.
  33835. */
  33836. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33837. /**
  33838. * Get a material using its unique id
  33839. * @param uniqueId defines the material's unique id
  33840. * @return the material or null if none found.
  33841. */
  33842. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33843. /**
  33844. * get a material using its id
  33845. * @param id defines the material's ID
  33846. * @return the material or null if none found.
  33847. */
  33848. getMaterialByID(id: string): Nullable<Material>;
  33849. /**
  33850. * Gets a the last added material using a given id
  33851. * @param id defines the material's ID
  33852. * @return the last material with the given id or null if none found.
  33853. */
  33854. getLastMaterialByID(id: string): Nullable<Material>;
  33855. /**
  33856. * Gets a material using its name
  33857. * @param name defines the material's name
  33858. * @return the material or null if none found.
  33859. */
  33860. getMaterialByName(name: string): Nullable<Material>;
  33861. /**
  33862. * Gets a camera using its id
  33863. * @param id defines the id to look for
  33864. * @returns the camera or null if not found
  33865. */
  33866. getCameraByID(id: string): Nullable<Camera>;
  33867. /**
  33868. * Gets a camera using its unique id
  33869. * @param uniqueId defines the unique id to look for
  33870. * @returns the camera or null if not found
  33871. */
  33872. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33873. /**
  33874. * Gets a camera using its name
  33875. * @param name defines the camera's name
  33876. * @return the camera or null if none found.
  33877. */
  33878. getCameraByName(name: string): Nullable<Camera>;
  33879. /**
  33880. * Gets a bone using its id
  33881. * @param id defines the bone's id
  33882. * @return the bone or null if not found
  33883. */
  33884. getBoneByID(id: string): Nullable<Bone>;
  33885. /**
  33886. * Gets a bone using its id
  33887. * @param name defines the bone's name
  33888. * @return the bone or null if not found
  33889. */
  33890. getBoneByName(name: string): Nullable<Bone>;
  33891. /**
  33892. * Gets a light node using its name
  33893. * @param name defines the the light's name
  33894. * @return the light or null if none found.
  33895. */
  33896. getLightByName(name: string): Nullable<Light>;
  33897. /**
  33898. * Gets a light node using its id
  33899. * @param id defines the light's id
  33900. * @return the light or null if none found.
  33901. */
  33902. getLightByID(id: string): Nullable<Light>;
  33903. /**
  33904. * Gets a light node using its scene-generated unique ID
  33905. * @param uniqueId defines the light's unique id
  33906. * @return the light or null if none found.
  33907. */
  33908. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33909. /**
  33910. * Gets a particle system by id
  33911. * @param id defines the particle system id
  33912. * @return the corresponding system or null if none found
  33913. */
  33914. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33915. /**
  33916. * Gets a geometry using its ID
  33917. * @param id defines the geometry's id
  33918. * @return the geometry or null if none found.
  33919. */
  33920. getGeometryByID(id: string): Nullable<Geometry>;
  33921. private _getGeometryByUniqueID;
  33922. /**
  33923. * Add a new geometry to this scene
  33924. * @param geometry defines the geometry to be added to the scene.
  33925. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33926. * @return a boolean defining if the geometry was added or not
  33927. */
  33928. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33929. /**
  33930. * Removes an existing geometry
  33931. * @param geometry defines the geometry to be removed from the scene
  33932. * @return a boolean defining if the geometry was removed or not
  33933. */
  33934. removeGeometry(geometry: Geometry): boolean;
  33935. /**
  33936. * Gets the list of geometries attached to the scene
  33937. * @returns an array of Geometry
  33938. */
  33939. getGeometries(): Geometry[];
  33940. /**
  33941. * Gets the first added mesh found of a given ID
  33942. * @param id defines the id to search for
  33943. * @return the mesh found or null if not found at all
  33944. */
  33945. getMeshByID(id: string): Nullable<AbstractMesh>;
  33946. /**
  33947. * Gets a list of meshes using their id
  33948. * @param id defines the id to search for
  33949. * @returns a list of meshes
  33950. */
  33951. getMeshesByID(id: string): Array<AbstractMesh>;
  33952. /**
  33953. * Gets the first added transform node found of a given ID
  33954. * @param id defines the id to search for
  33955. * @return the found transform node or null if not found at all.
  33956. */
  33957. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33958. /**
  33959. * Gets a transform node with its auto-generated unique id
  33960. * @param uniqueId efines the unique id to search for
  33961. * @return the found transform node or null if not found at all.
  33962. */
  33963. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33964. /**
  33965. * Gets a list of transform nodes using their id
  33966. * @param id defines the id to search for
  33967. * @returns a list of transform nodes
  33968. */
  33969. getTransformNodesByID(id: string): Array<TransformNode>;
  33970. /**
  33971. * Gets a mesh with its auto-generated unique id
  33972. * @param uniqueId defines the unique id to search for
  33973. * @return the found mesh or null if not found at all.
  33974. */
  33975. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33976. /**
  33977. * Gets a the last added mesh using a given id
  33978. * @param id defines the id to search for
  33979. * @return the found mesh or null if not found at all.
  33980. */
  33981. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33982. /**
  33983. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33984. * @param id defines the id to search for
  33985. * @return the found node or null if not found at all
  33986. */
  33987. getLastEntryByID(id: string): Nullable<Node>;
  33988. /**
  33989. * Gets a node (Mesh, Camera, Light) using a given id
  33990. * @param id defines the id to search for
  33991. * @return the found node or null if not found at all
  33992. */
  33993. getNodeByID(id: string): Nullable<Node>;
  33994. /**
  33995. * Gets a node (Mesh, Camera, Light) using a given name
  33996. * @param name defines the name to search for
  33997. * @return the found node or null if not found at all.
  33998. */
  33999. getNodeByName(name: string): Nullable<Node>;
  34000. /**
  34001. * Gets a mesh using a given name
  34002. * @param name defines the name to search for
  34003. * @return the found mesh or null if not found at all.
  34004. */
  34005. getMeshByName(name: string): Nullable<AbstractMesh>;
  34006. /**
  34007. * Gets a transform node using a given name
  34008. * @param name defines the name to search for
  34009. * @return the found transform node or null if not found at all.
  34010. */
  34011. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34012. /**
  34013. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34014. * @param id defines the id to search for
  34015. * @return the found skeleton or null if not found at all.
  34016. */
  34017. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34018. /**
  34019. * Gets a skeleton using a given auto generated unique id
  34020. * @param uniqueId defines the unique id to search for
  34021. * @return the found skeleton or null if not found at all.
  34022. */
  34023. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34024. /**
  34025. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34026. * @param id defines the id to search for
  34027. * @return the found skeleton or null if not found at all.
  34028. */
  34029. getSkeletonById(id: string): Nullable<Skeleton>;
  34030. /**
  34031. * Gets a skeleton using a given name
  34032. * @param name defines the name to search for
  34033. * @return the found skeleton or null if not found at all.
  34034. */
  34035. getSkeletonByName(name: string): Nullable<Skeleton>;
  34036. /**
  34037. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34038. * @param id defines the id to search for
  34039. * @return the found morph target manager or null if not found at all.
  34040. */
  34041. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34042. /**
  34043. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34044. * @param id defines the id to search for
  34045. * @return the found morph target or null if not found at all.
  34046. */
  34047. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34048. /**
  34049. * Gets a boolean indicating if the given mesh is active
  34050. * @param mesh defines the mesh to look for
  34051. * @returns true if the mesh is in the active list
  34052. */
  34053. isActiveMesh(mesh: AbstractMesh): boolean;
  34054. /**
  34055. * Return a unique id as a string which can serve as an identifier for the scene
  34056. */
  34057. readonly uid: string;
  34058. /**
  34059. * Add an externaly attached data from its key.
  34060. * This method call will fail and return false, if such key already exists.
  34061. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34062. * @param key the unique key that identifies the data
  34063. * @param data the data object to associate to the key for this Engine instance
  34064. * @return true if no such key were already present and the data was added successfully, false otherwise
  34065. */
  34066. addExternalData<T>(key: string, data: T): boolean;
  34067. /**
  34068. * Get an externaly attached data from its key
  34069. * @param key the unique key that identifies the data
  34070. * @return the associated data, if present (can be null), or undefined if not present
  34071. */
  34072. getExternalData<T>(key: string): Nullable<T>;
  34073. /**
  34074. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34075. * @param key the unique key that identifies the data
  34076. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34077. * @return the associated data, can be null if the factory returned null.
  34078. */
  34079. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34080. /**
  34081. * Remove an externaly attached data from the Engine instance
  34082. * @param key the unique key that identifies the data
  34083. * @return true if the data was successfully removed, false if it doesn't exist
  34084. */
  34085. removeExternalData(key: string): boolean;
  34086. private _evaluateSubMesh;
  34087. /**
  34088. * Clear the processed materials smart array preventing retention point in material dispose.
  34089. */
  34090. freeProcessedMaterials(): void;
  34091. private _preventFreeActiveMeshesAndRenderingGroups;
  34092. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34093. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34094. * when disposing several meshes in a row or a hierarchy of meshes.
  34095. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34096. */
  34097. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34098. /**
  34099. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34100. */
  34101. freeActiveMeshes(): void;
  34102. /**
  34103. * Clear the info related to rendering groups preventing retention points during dispose.
  34104. */
  34105. freeRenderingGroups(): void;
  34106. /** @hidden */
  34107. _isInIntermediateRendering(): boolean;
  34108. /**
  34109. * Lambda returning the list of potentially active meshes.
  34110. */
  34111. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34112. /**
  34113. * Lambda returning the list of potentially active sub meshes.
  34114. */
  34115. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34116. /**
  34117. * Lambda returning the list of potentially intersecting sub meshes.
  34118. */
  34119. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34120. /**
  34121. * Lambda returning the list of potentially colliding sub meshes.
  34122. */
  34123. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34124. private _activeMeshesFrozen;
  34125. /**
  34126. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34127. * @returns the current scene
  34128. */
  34129. freezeActiveMeshes(): Scene;
  34130. /**
  34131. * Use this function to restart evaluating active meshes on every frame
  34132. * @returns the current scene
  34133. */
  34134. unfreezeActiveMeshes(): Scene;
  34135. private _evaluateActiveMeshes;
  34136. private _activeMesh;
  34137. /**
  34138. * Update the transform matrix to update from the current active camera
  34139. * @param force defines a boolean used to force the update even if cache is up to date
  34140. */
  34141. updateTransformMatrix(force?: boolean): void;
  34142. private _bindFrameBuffer;
  34143. /** @hidden */
  34144. _allowPostProcessClearColor: boolean;
  34145. /** @hidden */
  34146. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34147. private _processSubCameras;
  34148. private _checkIntersections;
  34149. /** @hidden */
  34150. _advancePhysicsEngineStep(step: number): void;
  34151. /**
  34152. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34153. */
  34154. getDeterministicFrameTime: () => number;
  34155. /** @hidden */
  34156. _animate(): void;
  34157. /** Execute all animations (for a frame) */
  34158. animate(): void;
  34159. /**
  34160. * Render the scene
  34161. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34162. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34163. */
  34164. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34165. /**
  34166. * Freeze all materials
  34167. * A frozen material will not be updatable but should be faster to render
  34168. */
  34169. freezeMaterials(): void;
  34170. /**
  34171. * Unfreeze all materials
  34172. * A frozen material will not be updatable but should be faster to render
  34173. */
  34174. unfreezeMaterials(): void;
  34175. /**
  34176. * Releases all held ressources
  34177. */
  34178. dispose(): void;
  34179. /**
  34180. * Gets if the scene is already disposed
  34181. */
  34182. readonly isDisposed: boolean;
  34183. /**
  34184. * Call this function to reduce memory footprint of the scene.
  34185. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34186. */
  34187. clearCachedVertexData(): void;
  34188. /**
  34189. * This function will remove the local cached buffer data from texture.
  34190. * It will save memory but will prevent the texture from being rebuilt
  34191. */
  34192. cleanCachedTextureBuffer(): void;
  34193. /**
  34194. * Get the world extend vectors with an optional filter
  34195. *
  34196. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34197. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34198. */
  34199. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34200. min: Vector3;
  34201. max: Vector3;
  34202. };
  34203. /**
  34204. * Creates a ray that can be used to pick in the scene
  34205. * @param x defines the x coordinate of the origin (on-screen)
  34206. * @param y defines the y coordinate of the origin (on-screen)
  34207. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34208. * @param camera defines the camera to use for the picking
  34209. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34210. * @returns a Ray
  34211. */
  34212. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34213. /**
  34214. * Creates a ray that can be used to pick in the scene
  34215. * @param x defines the x coordinate of the origin (on-screen)
  34216. * @param y defines the y coordinate of the origin (on-screen)
  34217. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34218. * @param result defines the ray where to store the picking ray
  34219. * @param camera defines the camera to use for the picking
  34220. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34221. * @returns the current scene
  34222. */
  34223. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34224. /**
  34225. * Creates a ray that can be used to pick in the scene
  34226. * @param x defines the x coordinate of the origin (on-screen)
  34227. * @param y defines the y coordinate of the origin (on-screen)
  34228. * @param camera defines the camera to use for the picking
  34229. * @returns a Ray
  34230. */
  34231. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34232. /**
  34233. * Creates a ray that can be used to pick in the scene
  34234. * @param x defines the x coordinate of the origin (on-screen)
  34235. * @param y defines the y coordinate of the origin (on-screen)
  34236. * @param result defines the ray where to store the picking ray
  34237. * @param camera defines the camera to use for the picking
  34238. * @returns the current scene
  34239. */
  34240. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34241. /** Launch a ray to try to pick a mesh in the scene
  34242. * @param x position on screen
  34243. * @param y position on screen
  34244. * @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
  34245. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34246. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34247. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34248. * @returns a PickingInfo
  34249. */
  34250. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34251. /** Use the given ray to pick a mesh in the scene
  34252. * @param ray The ray to use to pick meshes
  34253. * @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
  34254. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34255. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34256. * @returns a PickingInfo
  34257. */
  34258. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34259. /**
  34260. * Launch a ray to try to pick a mesh in the scene
  34261. * @param x X position on screen
  34262. * @param y Y position on screen
  34263. * @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
  34264. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34265. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34266. * @returns an array of PickingInfo
  34267. */
  34268. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34269. /**
  34270. * Launch a ray to try to pick a mesh in the scene
  34271. * @param ray Ray to use
  34272. * @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
  34273. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34274. * @returns an array of PickingInfo
  34275. */
  34276. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34277. /**
  34278. * Force the value of meshUnderPointer
  34279. * @param mesh defines the mesh to use
  34280. */
  34281. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34282. /**
  34283. * Gets the mesh under the pointer
  34284. * @returns a Mesh or null if no mesh is under the pointer
  34285. */
  34286. getPointerOverMesh(): Nullable<AbstractMesh>;
  34287. /** @hidden */
  34288. _rebuildGeometries(): void;
  34289. /** @hidden */
  34290. _rebuildTextures(): void;
  34291. private _getByTags;
  34292. /**
  34293. * Get a list of meshes by tags
  34294. * @param tagsQuery defines the tags query to use
  34295. * @param forEach defines a predicate used to filter results
  34296. * @returns an array of Mesh
  34297. */
  34298. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34299. /**
  34300. * Get a list of cameras by tags
  34301. * @param tagsQuery defines the tags query to use
  34302. * @param forEach defines a predicate used to filter results
  34303. * @returns an array of Camera
  34304. */
  34305. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34306. /**
  34307. * Get a list of lights by tags
  34308. * @param tagsQuery defines the tags query to use
  34309. * @param forEach defines a predicate used to filter results
  34310. * @returns an array of Light
  34311. */
  34312. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34313. /**
  34314. * Get a list of materials by tags
  34315. * @param tagsQuery defines the tags query to use
  34316. * @param forEach defines a predicate used to filter results
  34317. * @returns an array of Material
  34318. */
  34319. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34320. /**
  34321. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34322. * This allowed control for front to back rendering or reversly depending of the special needs.
  34323. *
  34324. * @param renderingGroupId The rendering group id corresponding to its index
  34325. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34326. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34327. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34328. */
  34329. 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;
  34330. /**
  34331. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34332. *
  34333. * @param renderingGroupId The rendering group id corresponding to its index
  34334. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34335. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34336. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34337. */
  34338. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34339. /**
  34340. * Gets the current auto clear configuration for one rendering group of the rendering
  34341. * manager.
  34342. * @param index the rendering group index to get the information for
  34343. * @returns The auto clear setup for the requested rendering group
  34344. */
  34345. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34346. private _blockMaterialDirtyMechanism;
  34347. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34348. blockMaterialDirtyMechanism: boolean;
  34349. /**
  34350. * Will flag all materials as dirty to trigger new shader compilation
  34351. * @param flag defines the flag used to specify which material part must be marked as dirty
  34352. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34353. */
  34354. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34355. /** @hidden */
  34356. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  34357. /** @hidden */
  34358. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34359. }
  34360. }
  34361. declare module BABYLON {
  34362. /**
  34363. * Set of assets to keep when moving a scene into an asset container.
  34364. */
  34365. export class KeepAssets extends AbstractScene {
  34366. }
  34367. /**
  34368. * Container with a set of assets that can be added or removed from a scene.
  34369. */
  34370. export class AssetContainer extends AbstractScene {
  34371. /**
  34372. * The scene the AssetContainer belongs to.
  34373. */
  34374. scene: Scene;
  34375. /**
  34376. * Instantiates an AssetContainer.
  34377. * @param scene The scene the AssetContainer belongs to.
  34378. */
  34379. constructor(scene: Scene);
  34380. /**
  34381. * Adds all the assets from the container to the scene.
  34382. */
  34383. addAllToScene(): void;
  34384. /**
  34385. * Removes all the assets in the container from the scene
  34386. */
  34387. removeAllFromScene(): void;
  34388. /**
  34389. * Disposes all the assets in the container
  34390. */
  34391. dispose(): void;
  34392. private _moveAssets;
  34393. /**
  34394. * Removes all the assets contained in the scene and adds them to the container.
  34395. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34396. */
  34397. moveAllFromScene(keepAssets?: KeepAssets): void;
  34398. /**
  34399. * 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.
  34400. * @returns the root mesh
  34401. */
  34402. createRootMesh(): Mesh;
  34403. }
  34404. }
  34405. declare module BABYLON {
  34406. /**
  34407. * Defines how the parser contract is defined.
  34408. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34409. */
  34410. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34411. /**
  34412. * Defines how the individual parser contract is defined.
  34413. * These parser can parse an individual asset
  34414. */
  34415. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34416. /**
  34417. * Base class of the scene acting as a container for the different elements composing a scene.
  34418. * This class is dynamically extended by the different components of the scene increasing
  34419. * flexibility and reducing coupling
  34420. */
  34421. export abstract class AbstractScene {
  34422. /**
  34423. * Stores the list of available parsers in the application.
  34424. */
  34425. private static _BabylonFileParsers;
  34426. /**
  34427. * Stores the list of available individual parsers in the application.
  34428. */
  34429. private static _IndividualBabylonFileParsers;
  34430. /**
  34431. * Adds a parser in the list of available ones
  34432. * @param name Defines the name of the parser
  34433. * @param parser Defines the parser to add
  34434. */
  34435. static AddParser(name: string, parser: BabylonFileParser): void;
  34436. /**
  34437. * Gets a general parser from the list of avaialble ones
  34438. * @param name Defines the name of the parser
  34439. * @returns the requested parser or null
  34440. */
  34441. static GetParser(name: string): Nullable<BabylonFileParser>;
  34442. /**
  34443. * Adds n individual parser in the list of available ones
  34444. * @param name Defines the name of the parser
  34445. * @param parser Defines the parser to add
  34446. */
  34447. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34448. /**
  34449. * Gets an individual parser from the list of avaialble ones
  34450. * @param name Defines the name of the parser
  34451. * @returns the requested parser or null
  34452. */
  34453. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34454. /**
  34455. * Parser json data and populate both a scene and its associated container object
  34456. * @param jsonData Defines the data to parse
  34457. * @param scene Defines the scene to parse the data for
  34458. * @param container Defines the container attached to the parsing sequence
  34459. * @param rootUrl Defines the root url of the data
  34460. */
  34461. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34462. /**
  34463. * Gets the list of root nodes (ie. nodes with no parent)
  34464. */
  34465. rootNodes: Node[];
  34466. /** All of the cameras added to this scene
  34467. * @see http://doc.babylonjs.com/babylon101/cameras
  34468. */
  34469. cameras: Camera[];
  34470. /**
  34471. * All of the lights added to this scene
  34472. * @see http://doc.babylonjs.com/babylon101/lights
  34473. */
  34474. lights: Light[];
  34475. /**
  34476. * All of the (abstract) meshes added to this scene
  34477. */
  34478. meshes: AbstractMesh[];
  34479. /**
  34480. * The list of skeletons added to the scene
  34481. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34482. */
  34483. skeletons: Skeleton[];
  34484. /**
  34485. * All of the particle systems added to this scene
  34486. * @see http://doc.babylonjs.com/babylon101/particles
  34487. */
  34488. particleSystems: IParticleSystem[];
  34489. /**
  34490. * Gets a list of Animations associated with the scene
  34491. */
  34492. animations: Animation[];
  34493. /**
  34494. * All of the animation groups added to this scene
  34495. * @see http://doc.babylonjs.com/how_to/group
  34496. */
  34497. animationGroups: AnimationGroup[];
  34498. /**
  34499. * All of the multi-materials added to this scene
  34500. * @see http://doc.babylonjs.com/how_to/multi_materials
  34501. */
  34502. multiMaterials: MultiMaterial[];
  34503. /**
  34504. * All of the materials added to this scene
  34505. * In the context of a Scene, it is not supposed to be modified manually.
  34506. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34507. * Note also that the order of the Material wihin the array is not significant and might change.
  34508. * @see http://doc.babylonjs.com/babylon101/materials
  34509. */
  34510. materials: Material[];
  34511. /**
  34512. * The list of morph target managers added to the scene
  34513. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34514. */
  34515. morphTargetManagers: MorphTargetManager[];
  34516. /**
  34517. * The list of geometries used in the scene.
  34518. */
  34519. geometries: Geometry[];
  34520. /**
  34521. * All of the tranform nodes added to this scene
  34522. * In the context of a Scene, it is not supposed to be modified manually.
  34523. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34524. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34525. * @see http://doc.babylonjs.com/how_to/transformnode
  34526. */
  34527. transformNodes: TransformNode[];
  34528. /**
  34529. * ActionManagers available on the scene.
  34530. */
  34531. actionManagers: AbstractActionManager[];
  34532. /**
  34533. * Textures to keep.
  34534. */
  34535. textures: BaseTexture[];
  34536. /**
  34537. * Environment texture for the scene
  34538. */
  34539. environmentTexture: Nullable<BaseTexture>;
  34540. }
  34541. }
  34542. declare module BABYLON {
  34543. /**
  34544. * Interface used to define options for Sound class
  34545. */
  34546. export interface ISoundOptions {
  34547. /**
  34548. * Does the sound autoplay once loaded.
  34549. */
  34550. autoplay?: boolean;
  34551. /**
  34552. * Does the sound loop after it finishes playing once.
  34553. */
  34554. loop?: boolean;
  34555. /**
  34556. * Sound's volume
  34557. */
  34558. volume?: number;
  34559. /**
  34560. * Is it a spatial sound?
  34561. */
  34562. spatialSound?: boolean;
  34563. /**
  34564. * Maximum distance to hear that sound
  34565. */
  34566. maxDistance?: number;
  34567. /**
  34568. * Uses user defined attenuation function
  34569. */
  34570. useCustomAttenuation?: boolean;
  34571. /**
  34572. * Define the roll off factor of spatial sounds.
  34573. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34574. */
  34575. rolloffFactor?: number;
  34576. /**
  34577. * Define the reference distance the sound should be heard perfectly.
  34578. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34579. */
  34580. refDistance?: number;
  34581. /**
  34582. * Define the distance attenuation model the sound will follow.
  34583. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34584. */
  34585. distanceModel?: string;
  34586. /**
  34587. * Defines the playback speed (1 by default)
  34588. */
  34589. playbackRate?: number;
  34590. /**
  34591. * Defines if the sound is from a streaming source
  34592. */
  34593. streaming?: boolean;
  34594. /**
  34595. * Defines an optional length (in seconds) inside the sound file
  34596. */
  34597. length?: number;
  34598. /**
  34599. * Defines an optional offset (in seconds) inside the sound file
  34600. */
  34601. offset?: number;
  34602. /**
  34603. * If true, URLs will not be required to state the audio file codec to use.
  34604. */
  34605. skipCodecCheck?: boolean;
  34606. }
  34607. /**
  34608. * Defines a sound that can be played in the application.
  34609. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34611. */
  34612. export class Sound {
  34613. /**
  34614. * The name of the sound in the scene.
  34615. */
  34616. name: string;
  34617. /**
  34618. * Does the sound autoplay once loaded.
  34619. */
  34620. autoplay: boolean;
  34621. /**
  34622. * Does the sound loop after it finishes playing once.
  34623. */
  34624. loop: boolean;
  34625. /**
  34626. * Does the sound use a custom attenuation curve to simulate the falloff
  34627. * happening when the source gets further away from the camera.
  34628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34629. */
  34630. useCustomAttenuation: boolean;
  34631. /**
  34632. * The sound track id this sound belongs to.
  34633. */
  34634. soundTrackId: number;
  34635. /**
  34636. * Is this sound currently played.
  34637. */
  34638. isPlaying: boolean;
  34639. /**
  34640. * Is this sound currently paused.
  34641. */
  34642. isPaused: boolean;
  34643. /**
  34644. * Does this sound enables spatial sound.
  34645. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34646. */
  34647. spatialSound: boolean;
  34648. /**
  34649. * Define the reference distance the sound should be heard perfectly.
  34650. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34651. */
  34652. refDistance: number;
  34653. /**
  34654. * Define the roll off factor of spatial sounds.
  34655. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34656. */
  34657. rolloffFactor: number;
  34658. /**
  34659. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34660. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34661. */
  34662. maxDistance: number;
  34663. /**
  34664. * Define the distance attenuation model the sound will follow.
  34665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34666. */
  34667. distanceModel: string;
  34668. /**
  34669. * @hidden
  34670. * Back Compat
  34671. **/
  34672. onended: () => any;
  34673. /**
  34674. * Observable event when the current playing sound finishes.
  34675. */
  34676. onEndedObservable: Observable<Sound>;
  34677. private _panningModel;
  34678. private _playbackRate;
  34679. private _streaming;
  34680. private _startTime;
  34681. private _startOffset;
  34682. private _position;
  34683. /** @hidden */
  34684. _positionInEmitterSpace: boolean;
  34685. private _localDirection;
  34686. private _volume;
  34687. private _isReadyToPlay;
  34688. private _isDirectional;
  34689. private _readyToPlayCallback;
  34690. private _audioBuffer;
  34691. private _soundSource;
  34692. private _streamingSource;
  34693. private _soundPanner;
  34694. private _soundGain;
  34695. private _inputAudioNode;
  34696. private _outputAudioNode;
  34697. private _coneInnerAngle;
  34698. private _coneOuterAngle;
  34699. private _coneOuterGain;
  34700. private _scene;
  34701. private _connectedTransformNode;
  34702. private _customAttenuationFunction;
  34703. private _registerFunc;
  34704. private _isOutputConnected;
  34705. private _htmlAudioElement;
  34706. private _urlType;
  34707. private _length?;
  34708. private _offset?;
  34709. /** @hidden */
  34710. static _SceneComponentInitialization: (scene: Scene) => void;
  34711. /**
  34712. * Create a sound and attach it to a scene
  34713. * @param name Name of your sound
  34714. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34715. * @param scene defines the scene the sound belongs to
  34716. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34717. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34718. */
  34719. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34720. /**
  34721. * Release the sound and its associated resources
  34722. */
  34723. dispose(): void;
  34724. /**
  34725. * Gets if the sounds is ready to be played or not.
  34726. * @returns true if ready, otherwise false
  34727. */
  34728. isReady(): boolean;
  34729. private _soundLoaded;
  34730. /**
  34731. * Sets the data of the sound from an audiobuffer
  34732. * @param audioBuffer The audioBuffer containing the data
  34733. */
  34734. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34735. /**
  34736. * Updates the current sounds options such as maxdistance, loop...
  34737. * @param options A JSON object containing values named as the object properties
  34738. */
  34739. updateOptions(options: ISoundOptions): void;
  34740. private _createSpatialParameters;
  34741. private _updateSpatialParameters;
  34742. /**
  34743. * Switch the panning model to HRTF:
  34744. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34745. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34746. */
  34747. switchPanningModelToHRTF(): void;
  34748. /**
  34749. * Switch the panning model to Equal Power:
  34750. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34751. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34752. */
  34753. switchPanningModelToEqualPower(): void;
  34754. private _switchPanningModel;
  34755. /**
  34756. * Connect this sound to a sound track audio node like gain...
  34757. * @param soundTrackAudioNode the sound track audio node to connect to
  34758. */
  34759. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34760. /**
  34761. * Transform this sound into a directional source
  34762. * @param coneInnerAngle Size of the inner cone in degree
  34763. * @param coneOuterAngle Size of the outer cone in degree
  34764. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34765. */
  34766. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34767. /**
  34768. * Gets or sets the inner angle for the directional cone.
  34769. */
  34770. /**
  34771. * Gets or sets the inner angle for the directional cone.
  34772. */
  34773. directionalConeInnerAngle: number;
  34774. /**
  34775. * Gets or sets the outer angle for the directional cone.
  34776. */
  34777. /**
  34778. * Gets or sets the outer angle for the directional cone.
  34779. */
  34780. directionalConeOuterAngle: number;
  34781. /**
  34782. * Sets the position of the emitter if spatial sound is enabled
  34783. * @param newPosition Defines the new posisiton
  34784. */
  34785. setPosition(newPosition: Vector3): void;
  34786. /**
  34787. * Sets the local direction of the emitter if spatial sound is enabled
  34788. * @param newLocalDirection Defines the new local direction
  34789. */
  34790. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34791. private _updateDirection;
  34792. /** @hidden */
  34793. updateDistanceFromListener(): void;
  34794. /**
  34795. * Sets a new custom attenuation function for the sound.
  34796. * @param callback Defines the function used for the attenuation
  34797. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34798. */
  34799. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34800. /**
  34801. * Play the sound
  34802. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34803. * @param offset (optional) Start the sound at a specific time in seconds
  34804. * @param length (optional) Sound duration (in seconds)
  34805. */
  34806. play(time?: number, offset?: number, length?: number): void;
  34807. private _onended;
  34808. /**
  34809. * Stop the sound
  34810. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34811. */
  34812. stop(time?: number): void;
  34813. /**
  34814. * Put the sound in pause
  34815. */
  34816. pause(): void;
  34817. /**
  34818. * Sets a dedicated volume for this sounds
  34819. * @param newVolume Define the new volume of the sound
  34820. * @param time Define time for gradual change to new volume
  34821. */
  34822. setVolume(newVolume: number, time?: number): void;
  34823. /**
  34824. * Set the sound play back rate
  34825. * @param newPlaybackRate Define the playback rate the sound should be played at
  34826. */
  34827. setPlaybackRate(newPlaybackRate: number): void;
  34828. /**
  34829. * Gets the volume of the sound.
  34830. * @returns the volume of the sound
  34831. */
  34832. getVolume(): number;
  34833. /**
  34834. * Attach the sound to a dedicated mesh
  34835. * @param transformNode The transform node to connect the sound with
  34836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34837. */
  34838. attachToMesh(transformNode: TransformNode): void;
  34839. /**
  34840. * Detach the sound from the previously attached mesh
  34841. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34842. */
  34843. detachFromMesh(): void;
  34844. private _onRegisterAfterWorldMatrixUpdate;
  34845. /**
  34846. * Clone the current sound in the scene.
  34847. * @returns the new sound clone
  34848. */
  34849. clone(): Nullable<Sound>;
  34850. /**
  34851. * Gets the current underlying audio buffer containing the data
  34852. * @returns the audio buffer
  34853. */
  34854. getAudioBuffer(): Nullable<AudioBuffer>;
  34855. /**
  34856. * Serializes the Sound in a JSON representation
  34857. * @returns the JSON representation of the sound
  34858. */
  34859. serialize(): any;
  34860. /**
  34861. * Parse a JSON representation of a sound to innstantiate in a given scene
  34862. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34863. * @param scene Define the scene the new parsed sound should be created in
  34864. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34865. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34866. * @returns the newly parsed sound
  34867. */
  34868. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34869. }
  34870. }
  34871. declare module BABYLON {
  34872. /**
  34873. * This defines an action helpful to play a defined sound on a triggered action.
  34874. */
  34875. export class PlaySoundAction extends Action {
  34876. private _sound;
  34877. /**
  34878. * Instantiate the action
  34879. * @param triggerOptions defines the trigger options
  34880. * @param sound defines the sound to play
  34881. * @param condition defines the trigger related conditions
  34882. */
  34883. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34884. /** @hidden */
  34885. _prepare(): void;
  34886. /**
  34887. * Execute the action and play the sound.
  34888. */
  34889. execute(): void;
  34890. /**
  34891. * Serializes the actions and its related information.
  34892. * @param parent defines the object to serialize in
  34893. * @returns the serialized object
  34894. */
  34895. serialize(parent: any): any;
  34896. }
  34897. /**
  34898. * This defines an action helpful to stop a defined sound on a triggered action.
  34899. */
  34900. export class StopSoundAction extends Action {
  34901. private _sound;
  34902. /**
  34903. * Instantiate the action
  34904. * @param triggerOptions defines the trigger options
  34905. * @param sound defines the sound to stop
  34906. * @param condition defines the trigger related conditions
  34907. */
  34908. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34909. /** @hidden */
  34910. _prepare(): void;
  34911. /**
  34912. * Execute the action and stop the sound.
  34913. */
  34914. execute(): void;
  34915. /**
  34916. * Serializes the actions and its related information.
  34917. * @param parent defines the object to serialize in
  34918. * @returns the serialized object
  34919. */
  34920. serialize(parent: any): any;
  34921. }
  34922. }
  34923. declare module BABYLON {
  34924. /**
  34925. * This defines an action responsible to change the value of a property
  34926. * by interpolating between its current value and the newly set one once triggered.
  34927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34928. */
  34929. export class InterpolateValueAction extends Action {
  34930. /**
  34931. * Defines the path of the property where the value should be interpolated
  34932. */
  34933. propertyPath: string;
  34934. /**
  34935. * Defines the target value at the end of the interpolation.
  34936. */
  34937. value: any;
  34938. /**
  34939. * Defines the time it will take for the property to interpolate to the value.
  34940. */
  34941. duration: number;
  34942. /**
  34943. * Defines if the other scene animations should be stopped when the action has been triggered
  34944. */
  34945. stopOtherAnimations?: boolean;
  34946. /**
  34947. * Defines a callback raised once the interpolation animation has been done.
  34948. */
  34949. onInterpolationDone?: () => void;
  34950. /**
  34951. * Observable triggered once the interpolation animation has been done.
  34952. */
  34953. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34954. private _target;
  34955. private _effectiveTarget;
  34956. private _property;
  34957. /**
  34958. * Instantiate the action
  34959. * @param triggerOptions defines the trigger options
  34960. * @param target defines the object containing the value to interpolate
  34961. * @param propertyPath defines the path to the property in the target object
  34962. * @param value defines the target value at the end of the interpolation
  34963. * @param duration deines the time it will take for the property to interpolate to the value.
  34964. * @param condition defines the trigger related conditions
  34965. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34966. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34967. */
  34968. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34969. /** @hidden */
  34970. _prepare(): void;
  34971. /**
  34972. * Execute the action starts the value interpolation.
  34973. */
  34974. execute(): void;
  34975. /**
  34976. * Serializes the actions and its related information.
  34977. * @param parent defines the object to serialize in
  34978. * @returns the serialized object
  34979. */
  34980. serialize(parent: any): any;
  34981. }
  34982. }
  34983. declare module BABYLON {
  34984. /**
  34985. * Options allowed during the creation of a sound track.
  34986. */
  34987. export interface ISoundTrackOptions {
  34988. /**
  34989. * The volume the sound track should take during creation
  34990. */
  34991. volume?: number;
  34992. /**
  34993. * Define if the sound track is the main sound track of the scene
  34994. */
  34995. mainTrack?: boolean;
  34996. }
  34997. /**
  34998. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34999. * It will be also used in a future release to apply effects on a specific track.
  35000. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35001. */
  35002. export class SoundTrack {
  35003. /**
  35004. * The unique identifier of the sound track in the scene.
  35005. */
  35006. id: number;
  35007. /**
  35008. * The list of sounds included in the sound track.
  35009. */
  35010. soundCollection: Array<Sound>;
  35011. private _outputAudioNode;
  35012. private _scene;
  35013. private _isMainTrack;
  35014. private _connectedAnalyser;
  35015. private _options;
  35016. private _isInitialized;
  35017. /**
  35018. * Creates a new sound track.
  35019. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35020. * @param scene Define the scene the sound track belongs to
  35021. * @param options
  35022. */
  35023. constructor(scene: Scene, options?: ISoundTrackOptions);
  35024. private _initializeSoundTrackAudioGraph;
  35025. /**
  35026. * Release the sound track and its associated resources
  35027. */
  35028. dispose(): void;
  35029. /**
  35030. * Adds a sound to this sound track
  35031. * @param sound define the cound to add
  35032. * @ignoreNaming
  35033. */
  35034. AddSound(sound: Sound): void;
  35035. /**
  35036. * Removes a sound to this sound track
  35037. * @param sound define the cound to remove
  35038. * @ignoreNaming
  35039. */
  35040. RemoveSound(sound: Sound): void;
  35041. /**
  35042. * Set a global volume for the full sound track.
  35043. * @param newVolume Define the new volume of the sound track
  35044. */
  35045. setVolume(newVolume: number): void;
  35046. /**
  35047. * Switch the panning model to HRTF:
  35048. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35049. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35050. */
  35051. switchPanningModelToHRTF(): void;
  35052. /**
  35053. * Switch the panning model to Equal Power:
  35054. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35055. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35056. */
  35057. switchPanningModelToEqualPower(): void;
  35058. /**
  35059. * Connect the sound track to an audio analyser allowing some amazing
  35060. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35061. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35062. * @param analyser The analyser to connect to the engine
  35063. */
  35064. connectToAnalyser(analyser: Analyser): void;
  35065. }
  35066. }
  35067. declare module BABYLON {
  35068. interface AbstractScene {
  35069. /**
  35070. * The list of sounds used in the scene.
  35071. */
  35072. sounds: Nullable<Array<Sound>>;
  35073. }
  35074. interface Scene {
  35075. /**
  35076. * @hidden
  35077. * Backing field
  35078. */
  35079. _mainSoundTrack: SoundTrack;
  35080. /**
  35081. * The main sound track played by the scene.
  35082. * It cotains your primary collection of sounds.
  35083. */
  35084. mainSoundTrack: SoundTrack;
  35085. /**
  35086. * The list of sound tracks added to the scene
  35087. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35088. */
  35089. soundTracks: Nullable<Array<SoundTrack>>;
  35090. /**
  35091. * Gets a sound using a given name
  35092. * @param name defines the name to search for
  35093. * @return the found sound or null if not found at all.
  35094. */
  35095. getSoundByName(name: string): Nullable<Sound>;
  35096. /**
  35097. * Gets or sets if audio support is enabled
  35098. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35099. */
  35100. audioEnabled: boolean;
  35101. /**
  35102. * Gets or sets if audio will be output to headphones
  35103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35104. */
  35105. headphone: boolean;
  35106. }
  35107. /**
  35108. * Defines the sound scene component responsible to manage any sounds
  35109. * in a given scene.
  35110. */
  35111. export class AudioSceneComponent implements ISceneSerializableComponent {
  35112. /**
  35113. * The component name helpfull to identify the component in the list of scene components.
  35114. */
  35115. readonly name: string;
  35116. /**
  35117. * The scene the component belongs to.
  35118. */
  35119. scene: Scene;
  35120. private _audioEnabled;
  35121. /**
  35122. * Gets whether audio is enabled or not.
  35123. * Please use related enable/disable method to switch state.
  35124. */
  35125. readonly audioEnabled: boolean;
  35126. private _headphone;
  35127. /**
  35128. * Gets whether audio is outputing to headphone or not.
  35129. * Please use the according Switch methods to change output.
  35130. */
  35131. readonly headphone: boolean;
  35132. /**
  35133. * Creates a new instance of the component for the given scene
  35134. * @param scene Defines the scene to register the component in
  35135. */
  35136. constructor(scene: Scene);
  35137. /**
  35138. * Registers the component in a given scene
  35139. */
  35140. register(): void;
  35141. /**
  35142. * Rebuilds the elements related to this component in case of
  35143. * context lost for instance.
  35144. */
  35145. rebuild(): void;
  35146. /**
  35147. * Serializes the component data to the specified json object
  35148. * @param serializationObject The object to serialize to
  35149. */
  35150. serialize(serializationObject: any): void;
  35151. /**
  35152. * Adds all the elements from the container to the scene
  35153. * @param container the container holding the elements
  35154. */
  35155. addFromContainer(container: AbstractScene): void;
  35156. /**
  35157. * Removes all the elements in the container from the scene
  35158. * @param container contains the elements to remove
  35159. * @param dispose if the removed element should be disposed (default: false)
  35160. */
  35161. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35162. /**
  35163. * Disposes the component and the associated ressources.
  35164. */
  35165. dispose(): void;
  35166. /**
  35167. * Disables audio in the associated scene.
  35168. */
  35169. disableAudio(): void;
  35170. /**
  35171. * Enables audio in the associated scene.
  35172. */
  35173. enableAudio(): void;
  35174. /**
  35175. * Switch audio to headphone output.
  35176. */
  35177. switchAudioModeForHeadphones(): void;
  35178. /**
  35179. * Switch audio to normal speakers.
  35180. */
  35181. switchAudioModeForNormalSpeakers(): void;
  35182. private _afterRender;
  35183. }
  35184. }
  35185. declare module BABYLON {
  35186. /**
  35187. * Wraps one or more Sound objects and selects one with random weight for playback.
  35188. */
  35189. export class WeightedSound {
  35190. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35191. loop: boolean;
  35192. private _coneInnerAngle;
  35193. private _coneOuterAngle;
  35194. private _volume;
  35195. /** A Sound is currently playing. */
  35196. isPlaying: boolean;
  35197. /** A Sound is currently paused. */
  35198. isPaused: boolean;
  35199. private _sounds;
  35200. private _weights;
  35201. private _currentIndex?;
  35202. /**
  35203. * Creates a new WeightedSound from the list of sounds given.
  35204. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35205. * @param sounds Array of Sounds that will be selected from.
  35206. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35207. */
  35208. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35209. /**
  35210. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35211. */
  35212. /**
  35213. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35214. */
  35215. directionalConeInnerAngle: number;
  35216. /**
  35217. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35218. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35219. */
  35220. /**
  35221. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35222. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35223. */
  35224. directionalConeOuterAngle: number;
  35225. /**
  35226. * Playback volume.
  35227. */
  35228. /**
  35229. * Playback volume.
  35230. */
  35231. volume: number;
  35232. private _onended;
  35233. /**
  35234. * Suspend playback
  35235. */
  35236. pause(): void;
  35237. /**
  35238. * Stop playback
  35239. */
  35240. stop(): void;
  35241. /**
  35242. * Start playback.
  35243. * @param startOffset Position the clip head at a specific time in seconds.
  35244. */
  35245. play(startOffset?: number): void;
  35246. }
  35247. }
  35248. declare module BABYLON {
  35249. /**
  35250. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35251. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35252. */
  35253. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35254. /**
  35255. * Gets the name of the behavior.
  35256. */
  35257. readonly name: string;
  35258. /**
  35259. * The easing function used by animations
  35260. */
  35261. static EasingFunction: BackEase;
  35262. /**
  35263. * The easing mode used by animations
  35264. */
  35265. static EasingMode: number;
  35266. /**
  35267. * The duration of the animation, in milliseconds
  35268. */
  35269. transitionDuration: number;
  35270. /**
  35271. * Length of the distance animated by the transition when lower radius is reached
  35272. */
  35273. lowerRadiusTransitionRange: number;
  35274. /**
  35275. * Length of the distance animated by the transition when upper radius is reached
  35276. */
  35277. upperRadiusTransitionRange: number;
  35278. private _autoTransitionRange;
  35279. /**
  35280. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35281. */
  35282. /**
  35283. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35284. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35285. */
  35286. autoTransitionRange: boolean;
  35287. private _attachedCamera;
  35288. private _onAfterCheckInputsObserver;
  35289. private _onMeshTargetChangedObserver;
  35290. /**
  35291. * Initializes the behavior.
  35292. */
  35293. init(): void;
  35294. /**
  35295. * Attaches the behavior to its arc rotate camera.
  35296. * @param camera Defines the camera to attach the behavior to
  35297. */
  35298. attach(camera: ArcRotateCamera): void;
  35299. /**
  35300. * Detaches the behavior from its current arc rotate camera.
  35301. */
  35302. detach(): void;
  35303. private _radiusIsAnimating;
  35304. private _radiusBounceTransition;
  35305. private _animatables;
  35306. private _cachedWheelPrecision;
  35307. /**
  35308. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35309. * @param radiusLimit The limit to check against.
  35310. * @return Bool to indicate if at limit.
  35311. */
  35312. private _isRadiusAtLimit;
  35313. /**
  35314. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35315. * @param radiusDelta The delta by which to animate to. Can be negative.
  35316. */
  35317. private _applyBoundRadiusAnimation;
  35318. /**
  35319. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35320. */
  35321. protected _clearAnimationLocks(): void;
  35322. /**
  35323. * Stops and removes all animations that have been applied to the camera
  35324. */
  35325. stopAllAnimations(): void;
  35326. }
  35327. }
  35328. declare module BABYLON {
  35329. /**
  35330. * 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.
  35331. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35332. */
  35333. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35334. /**
  35335. * Gets the name of the behavior.
  35336. */
  35337. readonly name: string;
  35338. private _mode;
  35339. private _radiusScale;
  35340. private _positionScale;
  35341. private _defaultElevation;
  35342. private _elevationReturnTime;
  35343. private _elevationReturnWaitTime;
  35344. private _zoomStopsAnimation;
  35345. private _framingTime;
  35346. /**
  35347. * The easing function used by animations
  35348. */
  35349. static EasingFunction: ExponentialEase;
  35350. /**
  35351. * The easing mode used by animations
  35352. */
  35353. static EasingMode: number;
  35354. /**
  35355. * Sets the current mode used by the behavior
  35356. */
  35357. /**
  35358. * Gets current mode used by the behavior.
  35359. */
  35360. mode: number;
  35361. /**
  35362. * Sets the scale applied to the radius (1 by default)
  35363. */
  35364. /**
  35365. * Gets the scale applied to the radius
  35366. */
  35367. radiusScale: number;
  35368. /**
  35369. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35370. */
  35371. /**
  35372. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35373. */
  35374. positionScale: number;
  35375. /**
  35376. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35377. * behaviour is triggered, in radians.
  35378. */
  35379. /**
  35380. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35381. * behaviour is triggered, in radians.
  35382. */
  35383. defaultElevation: number;
  35384. /**
  35385. * Sets the time (in milliseconds) taken to return to the default beta position.
  35386. * Negative value indicates camera should not return to default.
  35387. */
  35388. /**
  35389. * Gets the time (in milliseconds) taken to return to the default beta position.
  35390. * Negative value indicates camera should not return to default.
  35391. */
  35392. elevationReturnTime: number;
  35393. /**
  35394. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35395. */
  35396. /**
  35397. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35398. */
  35399. elevationReturnWaitTime: number;
  35400. /**
  35401. * Sets the flag that indicates if user zooming should stop animation.
  35402. */
  35403. /**
  35404. * Gets the flag that indicates if user zooming should stop animation.
  35405. */
  35406. zoomStopsAnimation: boolean;
  35407. /**
  35408. * Sets the transition time when framing the mesh, in milliseconds
  35409. */
  35410. /**
  35411. * Gets the transition time when framing the mesh, in milliseconds
  35412. */
  35413. framingTime: number;
  35414. /**
  35415. * Define if the behavior should automatically change the configured
  35416. * camera limits and sensibilities.
  35417. */
  35418. autoCorrectCameraLimitsAndSensibility: boolean;
  35419. private _onPrePointerObservableObserver;
  35420. private _onAfterCheckInputsObserver;
  35421. private _onMeshTargetChangedObserver;
  35422. private _attachedCamera;
  35423. private _isPointerDown;
  35424. private _lastInteractionTime;
  35425. /**
  35426. * Initializes the behavior.
  35427. */
  35428. init(): void;
  35429. /**
  35430. * Attaches the behavior to its arc rotate camera.
  35431. * @param camera Defines the camera to attach the behavior to
  35432. */
  35433. attach(camera: ArcRotateCamera): void;
  35434. /**
  35435. * Detaches the behavior from its current arc rotate camera.
  35436. */
  35437. detach(): void;
  35438. private _animatables;
  35439. private _betaIsAnimating;
  35440. private _betaTransition;
  35441. private _radiusTransition;
  35442. private _vectorTransition;
  35443. /**
  35444. * Targets the given mesh and updates zoom level accordingly.
  35445. * @param mesh The mesh to target.
  35446. * @param radius Optional. If a cached radius position already exists, overrides default.
  35447. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35448. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35449. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35450. */
  35451. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35452. /**
  35453. * Targets the given mesh with its children and updates zoom level accordingly.
  35454. * @param mesh The mesh to target.
  35455. * @param radius Optional. If a cached radius position already exists, overrides default.
  35456. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35457. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35458. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35459. */
  35460. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35461. /**
  35462. * Targets the given meshes with their children and updates zoom level accordingly.
  35463. * @param meshes The mesh to target.
  35464. * @param radius Optional. If a cached radius position already exists, overrides default.
  35465. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35466. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35467. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35468. */
  35469. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35470. /**
  35471. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35472. * @param minimumWorld Determines the smaller position of the bounding box extend
  35473. * @param maximumWorld Determines the bigger position of the bounding box extend
  35474. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35475. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35476. */
  35477. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35478. /**
  35479. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35480. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35481. * frustum width.
  35482. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35483. * to fully enclose the mesh in the viewing frustum.
  35484. */
  35485. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35486. /**
  35487. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35488. * is automatically returned to its default position (expected to be above ground plane).
  35489. */
  35490. private _maintainCameraAboveGround;
  35491. /**
  35492. * Returns the frustum slope based on the canvas ratio and camera FOV
  35493. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35494. */
  35495. private _getFrustumSlope;
  35496. /**
  35497. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35498. */
  35499. private _clearAnimationLocks;
  35500. /**
  35501. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35502. */
  35503. private _applyUserInteraction;
  35504. /**
  35505. * Stops and removes all animations that have been applied to the camera
  35506. */
  35507. stopAllAnimations(): void;
  35508. /**
  35509. * Gets a value indicating if the user is moving the camera
  35510. */
  35511. readonly isUserIsMoving: boolean;
  35512. /**
  35513. * The camera can move all the way towards the mesh.
  35514. */
  35515. static IgnoreBoundsSizeMode: number;
  35516. /**
  35517. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35518. */
  35519. static FitFrustumSidesMode: number;
  35520. }
  35521. }
  35522. declare module BABYLON {
  35523. /**
  35524. * Base class for Camera Pointer Inputs.
  35525. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35526. * for example usage.
  35527. */
  35528. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35529. /**
  35530. * Defines the camera the input is attached to.
  35531. */
  35532. abstract camera: Camera;
  35533. /**
  35534. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35535. */
  35536. protected _altKey: boolean;
  35537. protected _ctrlKey: boolean;
  35538. protected _metaKey: boolean;
  35539. protected _shiftKey: boolean;
  35540. /**
  35541. * Which mouse buttons were pressed at time of last mouse event.
  35542. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35543. */
  35544. protected _buttonsPressed: number;
  35545. /**
  35546. * Defines the buttons associated with the input to handle camera move.
  35547. */
  35548. buttons: number[];
  35549. /**
  35550. * Attach the input controls to a specific dom element to get the input from.
  35551. * @param element Defines the element the controls should be listened from
  35552. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35553. */
  35554. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35555. /**
  35556. * Detach the current controls from the specified dom element.
  35557. * @param element Defines the element to stop listening the inputs from
  35558. */
  35559. detachControl(element: Nullable<HTMLElement>): void;
  35560. /**
  35561. * Gets the class name of the current input.
  35562. * @returns the class name
  35563. */
  35564. getClassName(): string;
  35565. /**
  35566. * Get the friendly name associated with the input class.
  35567. * @returns the input friendly name
  35568. */
  35569. getSimpleName(): string;
  35570. /**
  35571. * Called on pointer POINTERDOUBLETAP event.
  35572. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35573. */
  35574. protected onDoubleTap(type: string): void;
  35575. /**
  35576. * Called on pointer POINTERMOVE event if only a single touch is active.
  35577. * Override this method to provide functionality.
  35578. */
  35579. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35580. /**
  35581. * Called on pointer POINTERMOVE event if multiple touches are active.
  35582. * Override this method to provide functionality.
  35583. */
  35584. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35585. /**
  35586. * Called on JS contextmenu event.
  35587. * Override this method to provide functionality.
  35588. */
  35589. protected onContextMenu(evt: PointerEvent): void;
  35590. /**
  35591. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35592. * press.
  35593. * Override this method to provide functionality.
  35594. */
  35595. protected onButtonDown(evt: PointerEvent): void;
  35596. /**
  35597. * Called each time a new POINTERUP event occurs. Ie, for each button
  35598. * release.
  35599. * Override this method to provide functionality.
  35600. */
  35601. protected onButtonUp(evt: PointerEvent): void;
  35602. /**
  35603. * Called when window becomes inactive.
  35604. * Override this method to provide functionality.
  35605. */
  35606. protected onLostFocus(): void;
  35607. private _pointerInput;
  35608. private _observer;
  35609. private _onLostFocus;
  35610. private pointA;
  35611. private pointB;
  35612. }
  35613. }
  35614. declare module BABYLON {
  35615. /**
  35616. * Manage the pointers inputs to control an arc rotate camera.
  35617. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35618. */
  35619. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35620. /**
  35621. * Defines the camera the input is attached to.
  35622. */
  35623. camera: ArcRotateCamera;
  35624. /**
  35625. * Gets the class name of the current input.
  35626. * @returns the class name
  35627. */
  35628. getClassName(): string;
  35629. /**
  35630. * Defines the buttons associated with the input to handle camera move.
  35631. */
  35632. buttons: number[];
  35633. /**
  35634. * Defines the pointer angular sensibility along the X axis or how fast is
  35635. * the camera rotating.
  35636. */
  35637. angularSensibilityX: number;
  35638. /**
  35639. * Defines the pointer angular sensibility along the Y axis or how fast is
  35640. * the camera rotating.
  35641. */
  35642. angularSensibilityY: number;
  35643. /**
  35644. * Defines the pointer pinch precision or how fast is the camera zooming.
  35645. */
  35646. pinchPrecision: number;
  35647. /**
  35648. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35649. * from 0.
  35650. * It defines the percentage of current camera.radius to use as delta when
  35651. * pinch zoom is used.
  35652. */
  35653. pinchDeltaPercentage: number;
  35654. /**
  35655. * Defines the pointer panning sensibility or how fast is the camera moving.
  35656. */
  35657. panningSensibility: number;
  35658. /**
  35659. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35660. */
  35661. multiTouchPanning: boolean;
  35662. /**
  35663. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35664. * zoom (pinch) through multitouch.
  35665. */
  35666. multiTouchPanAndZoom: boolean;
  35667. /**
  35668. * Revers pinch action direction.
  35669. */
  35670. pinchInwards: boolean;
  35671. private _isPanClick;
  35672. private _twoFingerActivityCount;
  35673. private _isPinching;
  35674. /**
  35675. * Called on pointer POINTERMOVE event if only a single touch is active.
  35676. */
  35677. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35678. /**
  35679. * Called on pointer POINTERDOUBLETAP event.
  35680. */
  35681. protected onDoubleTap(type: string): void;
  35682. /**
  35683. * Called on pointer POINTERMOVE event if multiple touches are active.
  35684. */
  35685. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35686. /**
  35687. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35688. * press.
  35689. */
  35690. protected onButtonDown(evt: PointerEvent): void;
  35691. /**
  35692. * Called each time a new POINTERUP event occurs. Ie, for each button
  35693. * release.
  35694. */
  35695. protected onButtonUp(evt: PointerEvent): void;
  35696. /**
  35697. * Called when window becomes inactive.
  35698. */
  35699. protected onLostFocus(): void;
  35700. }
  35701. }
  35702. declare module BABYLON {
  35703. /**
  35704. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35705. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35706. */
  35707. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35708. /**
  35709. * Defines the camera the input is attached to.
  35710. */
  35711. camera: ArcRotateCamera;
  35712. /**
  35713. * Defines the list of key codes associated with the up action (increase alpha)
  35714. */
  35715. keysUp: number[];
  35716. /**
  35717. * Defines the list of key codes associated with the down action (decrease alpha)
  35718. */
  35719. keysDown: number[];
  35720. /**
  35721. * Defines the list of key codes associated with the left action (increase beta)
  35722. */
  35723. keysLeft: number[];
  35724. /**
  35725. * Defines the list of key codes associated with the right action (decrease beta)
  35726. */
  35727. keysRight: number[];
  35728. /**
  35729. * Defines the list of key codes associated with the reset action.
  35730. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35731. */
  35732. keysReset: number[];
  35733. /**
  35734. * Defines the panning sensibility of the inputs.
  35735. * (How fast is the camera paning)
  35736. */
  35737. panningSensibility: number;
  35738. /**
  35739. * Defines the zooming sensibility of the inputs.
  35740. * (How fast is the camera zooming)
  35741. */
  35742. zoomingSensibility: number;
  35743. /**
  35744. * Defines wether maintaining the alt key down switch the movement mode from
  35745. * orientation to zoom.
  35746. */
  35747. useAltToZoom: boolean;
  35748. /**
  35749. * Rotation speed of the camera
  35750. */
  35751. angularSpeed: number;
  35752. private _keys;
  35753. private _ctrlPressed;
  35754. private _altPressed;
  35755. private _onCanvasBlurObserver;
  35756. private _onKeyboardObserver;
  35757. private _engine;
  35758. private _scene;
  35759. /**
  35760. * Attach the input controls to a specific dom element to get the input from.
  35761. * @param element Defines the element the controls should be listened from
  35762. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35763. */
  35764. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35765. /**
  35766. * Detach the current controls from the specified dom element.
  35767. * @param element Defines the element to stop listening the inputs from
  35768. */
  35769. detachControl(element: Nullable<HTMLElement>): void;
  35770. /**
  35771. * Update the current camera state depending on the inputs that have been used this frame.
  35772. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35773. */
  35774. checkInputs(): void;
  35775. /**
  35776. * Gets the class name of the current intput.
  35777. * @returns the class name
  35778. */
  35779. getClassName(): string;
  35780. /**
  35781. * Get the friendly name associated with the input class.
  35782. * @returns the input friendly name
  35783. */
  35784. getSimpleName(): string;
  35785. }
  35786. }
  35787. declare module BABYLON {
  35788. /**
  35789. * Manage the mouse wheel inputs to control an arc rotate camera.
  35790. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35791. */
  35792. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35793. /**
  35794. * Defines the camera the input is attached to.
  35795. */
  35796. camera: ArcRotateCamera;
  35797. /**
  35798. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35799. */
  35800. wheelPrecision: number;
  35801. /**
  35802. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35803. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35804. */
  35805. wheelDeltaPercentage: number;
  35806. private _wheel;
  35807. private _observer;
  35808. private computeDeltaFromMouseWheelLegacyEvent;
  35809. /**
  35810. * Attach the input controls to a specific dom element to get the input from.
  35811. * @param element Defines the element the controls should be listened from
  35812. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35813. */
  35814. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35815. /**
  35816. * Detach the current controls from the specified dom element.
  35817. * @param element Defines the element to stop listening the inputs from
  35818. */
  35819. detachControl(element: Nullable<HTMLElement>): void;
  35820. /**
  35821. * Gets the class name of the current intput.
  35822. * @returns the class name
  35823. */
  35824. getClassName(): string;
  35825. /**
  35826. * Get the friendly name associated with the input class.
  35827. * @returns the input friendly name
  35828. */
  35829. getSimpleName(): string;
  35830. }
  35831. }
  35832. declare module BABYLON {
  35833. /**
  35834. * Default Inputs manager for the ArcRotateCamera.
  35835. * It groups all the default supported inputs for ease of use.
  35836. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35837. */
  35838. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35839. /**
  35840. * Instantiates a new ArcRotateCameraInputsManager.
  35841. * @param camera Defines the camera the inputs belong to
  35842. */
  35843. constructor(camera: ArcRotateCamera);
  35844. /**
  35845. * Add mouse wheel input support to the input manager.
  35846. * @returns the current input manager
  35847. */
  35848. addMouseWheel(): ArcRotateCameraInputsManager;
  35849. /**
  35850. * Add pointers input support to the input manager.
  35851. * @returns the current input manager
  35852. */
  35853. addPointers(): ArcRotateCameraInputsManager;
  35854. /**
  35855. * Add keyboard input support to the input manager.
  35856. * @returns the current input manager
  35857. */
  35858. addKeyboard(): ArcRotateCameraInputsManager;
  35859. }
  35860. }
  35861. declare module BABYLON {
  35862. /**
  35863. * This represents an orbital type of camera.
  35864. *
  35865. * 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.
  35866. * 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.
  35867. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35868. */
  35869. export class ArcRotateCamera extends TargetCamera {
  35870. /**
  35871. * Defines the rotation angle of the camera along the longitudinal axis.
  35872. */
  35873. alpha: number;
  35874. /**
  35875. * Defines the rotation angle of the camera along the latitudinal axis.
  35876. */
  35877. beta: number;
  35878. /**
  35879. * Defines the radius of the camera from it s target point.
  35880. */
  35881. radius: number;
  35882. protected _target: Vector3;
  35883. protected _targetHost: Nullable<AbstractMesh>;
  35884. /**
  35885. * Defines the target point of the camera.
  35886. * The camera looks towards it form the radius distance.
  35887. */
  35888. target: Vector3;
  35889. /**
  35890. * Define the current local position of the camera in the scene
  35891. */
  35892. position: Vector3;
  35893. protected _upVector: Vector3;
  35894. protected _upToYMatrix: Matrix;
  35895. protected _YToUpMatrix: Matrix;
  35896. /**
  35897. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35898. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35899. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35900. */
  35901. upVector: Vector3;
  35902. /**
  35903. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35904. */
  35905. setMatUp(): void;
  35906. /**
  35907. * Current inertia value on the longitudinal axis.
  35908. * The bigger this number the longer it will take for the camera to stop.
  35909. */
  35910. inertialAlphaOffset: number;
  35911. /**
  35912. * Current inertia value on the latitudinal axis.
  35913. * The bigger this number the longer it will take for the camera to stop.
  35914. */
  35915. inertialBetaOffset: number;
  35916. /**
  35917. * Current inertia value on the radius axis.
  35918. * The bigger this number the longer it will take for the camera to stop.
  35919. */
  35920. inertialRadiusOffset: number;
  35921. /**
  35922. * Minimum allowed angle on the longitudinal axis.
  35923. * This can help limiting how the Camera is able to move in the scene.
  35924. */
  35925. lowerAlphaLimit: Nullable<number>;
  35926. /**
  35927. * Maximum allowed angle on the longitudinal axis.
  35928. * This can help limiting how the Camera is able to move in the scene.
  35929. */
  35930. upperAlphaLimit: Nullable<number>;
  35931. /**
  35932. * Minimum allowed angle on the latitudinal axis.
  35933. * This can help limiting how the Camera is able to move in the scene.
  35934. */
  35935. lowerBetaLimit: number;
  35936. /**
  35937. * Maximum allowed angle on the latitudinal axis.
  35938. * This can help limiting how the Camera is able to move in the scene.
  35939. */
  35940. upperBetaLimit: number;
  35941. /**
  35942. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35943. * This can help limiting how the Camera is able to move in the scene.
  35944. */
  35945. lowerRadiusLimit: Nullable<number>;
  35946. /**
  35947. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35948. * This can help limiting how the Camera is able to move in the scene.
  35949. */
  35950. upperRadiusLimit: Nullable<number>;
  35951. /**
  35952. * Defines the current inertia value used during panning of the camera along the X axis.
  35953. */
  35954. inertialPanningX: number;
  35955. /**
  35956. * Defines the current inertia value used during panning of the camera along the Y axis.
  35957. */
  35958. inertialPanningY: number;
  35959. /**
  35960. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35961. * Basically if your fingers moves away from more than this distance you will be considered
  35962. * in pinch mode.
  35963. */
  35964. pinchToPanMaxDistance: number;
  35965. /**
  35966. * Defines the maximum distance the camera can pan.
  35967. * This could help keeping the cammera always in your scene.
  35968. */
  35969. panningDistanceLimit: Nullable<number>;
  35970. /**
  35971. * Defines the target of the camera before paning.
  35972. */
  35973. panningOriginTarget: Vector3;
  35974. /**
  35975. * Defines the value of the inertia used during panning.
  35976. * 0 would mean stop inertia and one would mean no decelleration at all.
  35977. */
  35978. panningInertia: number;
  35979. /**
  35980. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35981. */
  35982. angularSensibilityX: number;
  35983. /**
  35984. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35985. */
  35986. angularSensibilityY: number;
  35987. /**
  35988. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35989. */
  35990. pinchPrecision: number;
  35991. /**
  35992. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35993. * It will be used instead of pinchDeltaPrecision if different from 0.
  35994. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35995. */
  35996. pinchDeltaPercentage: number;
  35997. /**
  35998. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35999. */
  36000. panningSensibility: number;
  36001. /**
  36002. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36003. */
  36004. keysUp: number[];
  36005. /**
  36006. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36007. */
  36008. keysDown: number[];
  36009. /**
  36010. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36011. */
  36012. keysLeft: number[];
  36013. /**
  36014. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36015. */
  36016. keysRight: number[];
  36017. /**
  36018. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36019. */
  36020. wheelPrecision: number;
  36021. /**
  36022. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36023. * It will be used instead of pinchDeltaPrecision if different from 0.
  36024. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36025. */
  36026. wheelDeltaPercentage: number;
  36027. /**
  36028. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36029. */
  36030. zoomOnFactor: number;
  36031. /**
  36032. * Defines a screen offset for the camera position.
  36033. */
  36034. targetScreenOffset: Vector2;
  36035. /**
  36036. * Allows the camera to be completely reversed.
  36037. * If false the camera can not arrive upside down.
  36038. */
  36039. allowUpsideDown: boolean;
  36040. /**
  36041. * Define if double tap/click is used to restore the previously saved state of the camera.
  36042. */
  36043. useInputToRestoreState: boolean;
  36044. /** @hidden */
  36045. _viewMatrix: Matrix;
  36046. /** @hidden */
  36047. _useCtrlForPanning: boolean;
  36048. /** @hidden */
  36049. _panningMouseButton: number;
  36050. /**
  36051. * Defines the input associated to the camera.
  36052. */
  36053. inputs: ArcRotateCameraInputsManager;
  36054. /** @hidden */
  36055. _reset: () => void;
  36056. /**
  36057. * Defines the allowed panning axis.
  36058. */
  36059. panningAxis: Vector3;
  36060. protected _localDirection: Vector3;
  36061. protected _transformedDirection: Vector3;
  36062. private _bouncingBehavior;
  36063. /**
  36064. * Gets the bouncing behavior of the camera if it has been enabled.
  36065. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36066. */
  36067. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36068. /**
  36069. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36070. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36071. */
  36072. useBouncingBehavior: boolean;
  36073. private _framingBehavior;
  36074. /**
  36075. * Gets the framing behavior of the camera if it has been enabled.
  36076. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36077. */
  36078. readonly framingBehavior: Nullable<FramingBehavior>;
  36079. /**
  36080. * Defines if the framing behavior of the camera is enabled on the camera.
  36081. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36082. */
  36083. useFramingBehavior: boolean;
  36084. private _autoRotationBehavior;
  36085. /**
  36086. * Gets the auto rotation behavior of the camera if it has been enabled.
  36087. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36088. */
  36089. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36090. /**
  36091. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36092. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36093. */
  36094. useAutoRotationBehavior: boolean;
  36095. /**
  36096. * Observable triggered when the mesh target has been changed on the camera.
  36097. */
  36098. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36099. /**
  36100. * Event raised when the camera is colliding with a mesh.
  36101. */
  36102. onCollide: (collidedMesh: AbstractMesh) => void;
  36103. /**
  36104. * Defines whether the camera should check collision with the objects oh the scene.
  36105. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36106. */
  36107. checkCollisions: boolean;
  36108. /**
  36109. * Defines the collision radius of the camera.
  36110. * This simulates a sphere around the camera.
  36111. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36112. */
  36113. collisionRadius: Vector3;
  36114. protected _collider: Collider;
  36115. protected _previousPosition: Vector3;
  36116. protected _collisionVelocity: Vector3;
  36117. protected _newPosition: Vector3;
  36118. protected _previousAlpha: number;
  36119. protected _previousBeta: number;
  36120. protected _previousRadius: number;
  36121. protected _collisionTriggered: boolean;
  36122. protected _targetBoundingCenter: Nullable<Vector3>;
  36123. private _computationVector;
  36124. /**
  36125. * Instantiates a new ArcRotateCamera in a given scene
  36126. * @param name Defines the name of the camera
  36127. * @param alpha Defines the camera rotation along the logitudinal axis
  36128. * @param beta Defines the camera rotation along the latitudinal axis
  36129. * @param radius Defines the camera distance from its target
  36130. * @param target Defines the camera target
  36131. * @param scene Defines the scene the camera belongs to
  36132. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36133. */
  36134. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36135. /** @hidden */
  36136. _initCache(): void;
  36137. /** @hidden */
  36138. _updateCache(ignoreParentClass?: boolean): void;
  36139. protected _getTargetPosition(): Vector3;
  36140. private _storedAlpha;
  36141. private _storedBeta;
  36142. private _storedRadius;
  36143. private _storedTarget;
  36144. /**
  36145. * Stores the current state of the camera (alpha, beta, radius and target)
  36146. * @returns the camera itself
  36147. */
  36148. storeState(): Camera;
  36149. /**
  36150. * @hidden
  36151. * Restored camera state. You must call storeState() first
  36152. */
  36153. _restoreStateValues(): boolean;
  36154. /** @hidden */
  36155. _isSynchronizedViewMatrix(): boolean;
  36156. /**
  36157. * Attached controls to the current camera.
  36158. * @param element Defines the element the controls should be listened from
  36159. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36160. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36161. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36162. */
  36163. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36164. /**
  36165. * Detach the current controls from the camera.
  36166. * The camera will stop reacting to inputs.
  36167. * @param element Defines the element to stop listening the inputs from
  36168. */
  36169. detachControl(element: HTMLElement): void;
  36170. /** @hidden */
  36171. _checkInputs(): void;
  36172. protected _checkLimits(): void;
  36173. /**
  36174. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36175. */
  36176. rebuildAnglesAndRadius(): void;
  36177. /**
  36178. * Use a position to define the current camera related information like aplha, beta and radius
  36179. * @param position Defines the position to set the camera at
  36180. */
  36181. setPosition(position: Vector3): void;
  36182. /**
  36183. * Defines the target the camera should look at.
  36184. * This will automatically adapt alpha beta and radius to fit within the new target.
  36185. * @param target Defines the new target as a Vector or a mesh
  36186. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36187. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36188. */
  36189. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36190. /** @hidden */
  36191. _getViewMatrix(): Matrix;
  36192. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36193. /**
  36194. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36195. * @param meshes Defines the mesh to zoom on
  36196. * @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)
  36197. */
  36198. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36199. /**
  36200. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36201. * The target will be changed but the radius
  36202. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36203. * @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)
  36204. */
  36205. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36206. min: Vector3;
  36207. max: Vector3;
  36208. distance: number;
  36209. }, doNotUpdateMaxZ?: boolean): void;
  36210. /**
  36211. * @override
  36212. * Override Camera.createRigCamera
  36213. */
  36214. createRigCamera(name: string, cameraIndex: number): Camera;
  36215. /**
  36216. * @hidden
  36217. * @override
  36218. * Override Camera._updateRigCameras
  36219. */
  36220. _updateRigCameras(): void;
  36221. /**
  36222. * Destroy the camera and release the current resources hold by it.
  36223. */
  36224. dispose(): void;
  36225. /**
  36226. * Gets the current object class name.
  36227. * @return the class name
  36228. */
  36229. getClassName(): string;
  36230. }
  36231. }
  36232. declare module BABYLON {
  36233. /**
  36234. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36235. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36236. */
  36237. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36238. /**
  36239. * Gets the name of the behavior.
  36240. */
  36241. readonly name: string;
  36242. private _zoomStopsAnimation;
  36243. private _idleRotationSpeed;
  36244. private _idleRotationWaitTime;
  36245. private _idleRotationSpinupTime;
  36246. /**
  36247. * Sets the flag that indicates if user zooming should stop animation.
  36248. */
  36249. /**
  36250. * Gets the flag that indicates if user zooming should stop animation.
  36251. */
  36252. zoomStopsAnimation: boolean;
  36253. /**
  36254. * Sets the default speed at which the camera rotates around the model.
  36255. */
  36256. /**
  36257. * Gets the default speed at which the camera rotates around the model.
  36258. */
  36259. idleRotationSpeed: number;
  36260. /**
  36261. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36262. */
  36263. /**
  36264. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36265. */
  36266. idleRotationWaitTime: number;
  36267. /**
  36268. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36269. */
  36270. /**
  36271. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36272. */
  36273. idleRotationSpinupTime: number;
  36274. /**
  36275. * Gets a value indicating if the camera is currently rotating because of this behavior
  36276. */
  36277. readonly rotationInProgress: boolean;
  36278. private _onPrePointerObservableObserver;
  36279. private _onAfterCheckInputsObserver;
  36280. private _attachedCamera;
  36281. private _isPointerDown;
  36282. private _lastFrameTime;
  36283. private _lastInteractionTime;
  36284. private _cameraRotationSpeed;
  36285. /**
  36286. * Initializes the behavior.
  36287. */
  36288. init(): void;
  36289. /**
  36290. * Attaches the behavior to its arc rotate camera.
  36291. * @param camera Defines the camera to attach the behavior to
  36292. */
  36293. attach(camera: ArcRotateCamera): void;
  36294. /**
  36295. * Detaches the behavior from its current arc rotate camera.
  36296. */
  36297. detach(): void;
  36298. /**
  36299. * Returns true if user is scrolling.
  36300. * @return true if user is scrolling.
  36301. */
  36302. private _userIsZooming;
  36303. private _lastFrameRadius;
  36304. private _shouldAnimationStopForInteraction;
  36305. /**
  36306. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36307. */
  36308. private _applyUserInteraction;
  36309. private _userIsMoving;
  36310. }
  36311. }
  36312. declare module BABYLON {
  36313. /**
  36314. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36315. */
  36316. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36317. private ui;
  36318. /**
  36319. * The name of the behavior
  36320. */
  36321. name: string;
  36322. /**
  36323. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36324. */
  36325. distanceAwayFromFace: number;
  36326. /**
  36327. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36328. */
  36329. distanceAwayFromBottomOfFace: number;
  36330. private _faceVectors;
  36331. private _target;
  36332. private _scene;
  36333. private _onRenderObserver;
  36334. private _tmpMatrix;
  36335. private _tmpVector;
  36336. /**
  36337. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36338. * @param ui The transform node that should be attched to the mesh
  36339. */
  36340. constructor(ui: TransformNode);
  36341. /**
  36342. * Initializes the behavior
  36343. */
  36344. init(): void;
  36345. private _closestFace;
  36346. private _zeroVector;
  36347. private _lookAtTmpMatrix;
  36348. private _lookAtToRef;
  36349. /**
  36350. * Attaches the AttachToBoxBehavior to the passed in mesh
  36351. * @param target The mesh that the specified node will be attached to
  36352. */
  36353. attach(target: Mesh): void;
  36354. /**
  36355. * Detaches the behavior from the mesh
  36356. */
  36357. detach(): void;
  36358. }
  36359. }
  36360. declare module BABYLON {
  36361. /**
  36362. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36363. */
  36364. export class FadeInOutBehavior implements Behavior<Mesh> {
  36365. /**
  36366. * Time in milliseconds to delay before fading in (Default: 0)
  36367. */
  36368. delay: number;
  36369. /**
  36370. * Time in milliseconds for the mesh to fade in (Default: 300)
  36371. */
  36372. fadeInTime: number;
  36373. private _millisecondsPerFrame;
  36374. private _hovered;
  36375. private _hoverValue;
  36376. private _ownerNode;
  36377. /**
  36378. * Instatiates the FadeInOutBehavior
  36379. */
  36380. constructor();
  36381. /**
  36382. * The name of the behavior
  36383. */
  36384. readonly name: string;
  36385. /**
  36386. * Initializes the behavior
  36387. */
  36388. init(): void;
  36389. /**
  36390. * Attaches the fade behavior on the passed in mesh
  36391. * @param ownerNode The mesh that will be faded in/out once attached
  36392. */
  36393. attach(ownerNode: Mesh): void;
  36394. /**
  36395. * Detaches the behavior from the mesh
  36396. */
  36397. detach(): void;
  36398. /**
  36399. * Triggers the mesh to begin fading in or out
  36400. * @param value if the object should fade in or out (true to fade in)
  36401. */
  36402. fadeIn(value: boolean): void;
  36403. private _update;
  36404. private _setAllVisibility;
  36405. }
  36406. }
  36407. declare module BABYLON {
  36408. /**
  36409. * Class containing a set of static utilities functions for managing Pivots
  36410. * @hidden
  36411. */
  36412. export class PivotTools {
  36413. private static _PivotCached;
  36414. private static _OldPivotPoint;
  36415. private static _PivotTranslation;
  36416. private static _PivotTmpVector;
  36417. /** @hidden */
  36418. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36419. /** @hidden */
  36420. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36421. }
  36422. }
  36423. declare module BABYLON {
  36424. /**
  36425. * Class containing static functions to help procedurally build meshes
  36426. */
  36427. export class PlaneBuilder {
  36428. /**
  36429. * Creates a plane mesh
  36430. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36431. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36432. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36434. * * 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
  36435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36436. * @param name defines the name of the mesh
  36437. * @param options defines the options used to create the mesh
  36438. * @param scene defines the hosting scene
  36439. * @returns the plane mesh
  36440. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36441. */
  36442. static CreatePlane(name: string, options: {
  36443. size?: number;
  36444. width?: number;
  36445. height?: number;
  36446. sideOrientation?: number;
  36447. frontUVs?: Vector4;
  36448. backUVs?: Vector4;
  36449. updatable?: boolean;
  36450. sourcePlane?: Plane;
  36451. }, scene?: Nullable<Scene>): Mesh;
  36452. }
  36453. }
  36454. declare module BABYLON {
  36455. /**
  36456. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36457. */
  36458. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36459. private static _AnyMouseID;
  36460. /**
  36461. * Abstract mesh the behavior is set on
  36462. */
  36463. attachedNode: AbstractMesh;
  36464. private _dragPlane;
  36465. private _scene;
  36466. private _pointerObserver;
  36467. private _beforeRenderObserver;
  36468. private static _planeScene;
  36469. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36470. /**
  36471. * 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)
  36472. */
  36473. maxDragAngle: number;
  36474. /**
  36475. * @hidden
  36476. */
  36477. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36478. /**
  36479. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36480. */
  36481. currentDraggingPointerID: number;
  36482. /**
  36483. * The last position where the pointer hit the drag plane in world space
  36484. */
  36485. lastDragPosition: Vector3;
  36486. /**
  36487. * If the behavior is currently in a dragging state
  36488. */
  36489. dragging: boolean;
  36490. /**
  36491. * 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)
  36492. */
  36493. dragDeltaRatio: number;
  36494. /**
  36495. * If the drag plane orientation should be updated during the dragging (Default: true)
  36496. */
  36497. updateDragPlane: boolean;
  36498. private _debugMode;
  36499. private _moving;
  36500. /**
  36501. * Fires each time the attached mesh is dragged with the pointer
  36502. * * delta between last drag position and current drag position in world space
  36503. * * dragDistance along the drag axis
  36504. * * dragPlaneNormal normal of the current drag plane used during the drag
  36505. * * dragPlanePoint in world space where the drag intersects the drag plane
  36506. */
  36507. onDragObservable: Observable<{
  36508. delta: Vector3;
  36509. dragPlanePoint: Vector3;
  36510. dragPlaneNormal: Vector3;
  36511. dragDistance: number;
  36512. pointerId: number;
  36513. }>;
  36514. /**
  36515. * Fires each time a drag begins (eg. mouse down on mesh)
  36516. */
  36517. onDragStartObservable: Observable<{
  36518. dragPlanePoint: Vector3;
  36519. pointerId: number;
  36520. }>;
  36521. /**
  36522. * Fires each time a drag ends (eg. mouse release after drag)
  36523. */
  36524. onDragEndObservable: Observable<{
  36525. dragPlanePoint: Vector3;
  36526. pointerId: number;
  36527. }>;
  36528. /**
  36529. * If the attached mesh should be moved when dragged
  36530. */
  36531. moveAttached: boolean;
  36532. /**
  36533. * If the drag behavior will react to drag events (Default: true)
  36534. */
  36535. enabled: boolean;
  36536. /**
  36537. * If pointer events should start and release the drag (Default: true)
  36538. */
  36539. startAndReleaseDragOnPointerEvents: boolean;
  36540. /**
  36541. * If camera controls should be detached during the drag
  36542. */
  36543. detachCameraControls: boolean;
  36544. /**
  36545. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36546. */
  36547. useObjectOrienationForDragging: boolean;
  36548. private _options;
  36549. /**
  36550. * Creates a pointer drag behavior that can be attached to a mesh
  36551. * @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)
  36552. */
  36553. constructor(options?: {
  36554. dragAxis?: Vector3;
  36555. dragPlaneNormal?: Vector3;
  36556. });
  36557. /**
  36558. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36559. */
  36560. validateDrag: (targetPosition: Vector3) => boolean;
  36561. /**
  36562. * The name of the behavior
  36563. */
  36564. readonly name: string;
  36565. /**
  36566. * Initializes the behavior
  36567. */
  36568. init(): void;
  36569. private _tmpVector;
  36570. private _alternatePickedPoint;
  36571. private _worldDragAxis;
  36572. private _targetPosition;
  36573. private _attachedElement;
  36574. /**
  36575. * Attaches the drag behavior the passed in mesh
  36576. * @param ownerNode The mesh that will be dragged around once attached
  36577. */
  36578. attach(ownerNode: AbstractMesh): void;
  36579. /**
  36580. * Force relase the drag action by code.
  36581. */
  36582. releaseDrag(): void;
  36583. private _startDragRay;
  36584. private _lastPointerRay;
  36585. /**
  36586. * Simulates the start of a pointer drag event on the behavior
  36587. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36588. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36589. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36590. */
  36591. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36592. private _startDrag;
  36593. private _dragDelta;
  36594. private _moveDrag;
  36595. private _pickWithRayOnDragPlane;
  36596. private _pointA;
  36597. private _pointB;
  36598. private _pointC;
  36599. private _lineA;
  36600. private _lineB;
  36601. private _localAxis;
  36602. private _lookAt;
  36603. private _updateDragPlanePosition;
  36604. /**
  36605. * Detaches the behavior from the mesh
  36606. */
  36607. detach(): void;
  36608. }
  36609. }
  36610. declare module BABYLON {
  36611. /**
  36612. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36613. */
  36614. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36615. private _dragBehaviorA;
  36616. private _dragBehaviorB;
  36617. private _startDistance;
  36618. private _initialScale;
  36619. private _targetScale;
  36620. private _ownerNode;
  36621. private _sceneRenderObserver;
  36622. /**
  36623. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36624. */
  36625. constructor();
  36626. /**
  36627. * The name of the behavior
  36628. */
  36629. readonly name: string;
  36630. /**
  36631. * Initializes the behavior
  36632. */
  36633. init(): void;
  36634. private _getCurrentDistance;
  36635. /**
  36636. * Attaches the scale behavior the passed in mesh
  36637. * @param ownerNode The mesh that will be scaled around once attached
  36638. */
  36639. attach(ownerNode: Mesh): void;
  36640. /**
  36641. * Detaches the behavior from the mesh
  36642. */
  36643. detach(): void;
  36644. }
  36645. }
  36646. declare module BABYLON {
  36647. /**
  36648. * 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
  36649. */
  36650. export class SixDofDragBehavior implements Behavior<Mesh> {
  36651. private static _virtualScene;
  36652. private _ownerNode;
  36653. private _sceneRenderObserver;
  36654. private _scene;
  36655. private _targetPosition;
  36656. private _virtualOriginMesh;
  36657. private _virtualDragMesh;
  36658. private _pointerObserver;
  36659. private _moving;
  36660. private _startingOrientation;
  36661. /**
  36662. * 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)
  36663. */
  36664. private zDragFactor;
  36665. /**
  36666. * If the object should rotate to face the drag origin
  36667. */
  36668. rotateDraggedObject: boolean;
  36669. /**
  36670. * If the behavior is currently in a dragging state
  36671. */
  36672. dragging: boolean;
  36673. /**
  36674. * 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)
  36675. */
  36676. dragDeltaRatio: number;
  36677. /**
  36678. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36679. */
  36680. currentDraggingPointerID: number;
  36681. /**
  36682. * If camera controls should be detached during the drag
  36683. */
  36684. detachCameraControls: boolean;
  36685. /**
  36686. * Fires each time a drag starts
  36687. */
  36688. onDragStartObservable: Observable<{}>;
  36689. /**
  36690. * Fires each time a drag ends (eg. mouse release after drag)
  36691. */
  36692. onDragEndObservable: Observable<{}>;
  36693. /**
  36694. * 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
  36695. */
  36696. constructor();
  36697. /**
  36698. * The name of the behavior
  36699. */
  36700. readonly name: string;
  36701. /**
  36702. * Initializes the behavior
  36703. */
  36704. init(): void;
  36705. /**
  36706. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36707. */
  36708. private readonly _pointerCamera;
  36709. /**
  36710. * Attaches the scale behavior the passed in mesh
  36711. * @param ownerNode The mesh that will be scaled around once attached
  36712. */
  36713. attach(ownerNode: Mesh): void;
  36714. /**
  36715. * Detaches the behavior from the mesh
  36716. */
  36717. detach(): void;
  36718. }
  36719. }
  36720. declare module BABYLON {
  36721. /**
  36722. * Class used to apply inverse kinematics to bones
  36723. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36724. */
  36725. export class BoneIKController {
  36726. private static _tmpVecs;
  36727. private static _tmpQuat;
  36728. private static _tmpMats;
  36729. /**
  36730. * Gets or sets the target mesh
  36731. */
  36732. targetMesh: AbstractMesh;
  36733. /** Gets or sets the mesh used as pole */
  36734. poleTargetMesh: AbstractMesh;
  36735. /**
  36736. * Gets or sets the bone used as pole
  36737. */
  36738. poleTargetBone: Nullable<Bone>;
  36739. /**
  36740. * Gets or sets the target position
  36741. */
  36742. targetPosition: Vector3;
  36743. /**
  36744. * Gets or sets the pole target position
  36745. */
  36746. poleTargetPosition: Vector3;
  36747. /**
  36748. * Gets or sets the pole target local offset
  36749. */
  36750. poleTargetLocalOffset: Vector3;
  36751. /**
  36752. * Gets or sets the pole angle
  36753. */
  36754. poleAngle: number;
  36755. /**
  36756. * Gets or sets the mesh associated with the controller
  36757. */
  36758. mesh: AbstractMesh;
  36759. /**
  36760. * 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)
  36761. */
  36762. slerpAmount: number;
  36763. private _bone1Quat;
  36764. private _bone1Mat;
  36765. private _bone2Ang;
  36766. private _bone1;
  36767. private _bone2;
  36768. private _bone1Length;
  36769. private _bone2Length;
  36770. private _maxAngle;
  36771. private _maxReach;
  36772. private _rightHandedSystem;
  36773. private _bendAxis;
  36774. private _slerping;
  36775. private _adjustRoll;
  36776. /**
  36777. * Gets or sets maximum allowed angle
  36778. */
  36779. maxAngle: number;
  36780. /**
  36781. * Creates a new BoneIKController
  36782. * @param mesh defines the mesh to control
  36783. * @param bone defines the bone to control
  36784. * @param options defines options to set up the controller
  36785. */
  36786. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36787. targetMesh?: AbstractMesh;
  36788. poleTargetMesh?: AbstractMesh;
  36789. poleTargetBone?: Bone;
  36790. poleTargetLocalOffset?: Vector3;
  36791. poleAngle?: number;
  36792. bendAxis?: Vector3;
  36793. maxAngle?: number;
  36794. slerpAmount?: number;
  36795. });
  36796. private _setMaxAngle;
  36797. /**
  36798. * Force the controller to update the bones
  36799. */
  36800. update(): void;
  36801. }
  36802. }
  36803. declare module BABYLON {
  36804. /**
  36805. * Class used to make a bone look toward a point in space
  36806. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36807. */
  36808. export class BoneLookController {
  36809. private static _tmpVecs;
  36810. private static _tmpQuat;
  36811. private static _tmpMats;
  36812. /**
  36813. * The target Vector3 that the bone will look at
  36814. */
  36815. target: Vector3;
  36816. /**
  36817. * The mesh that the bone is attached to
  36818. */
  36819. mesh: AbstractMesh;
  36820. /**
  36821. * The bone that will be looking to the target
  36822. */
  36823. bone: Bone;
  36824. /**
  36825. * The up axis of the coordinate system that is used when the bone is rotated
  36826. */
  36827. upAxis: Vector3;
  36828. /**
  36829. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36830. */
  36831. upAxisSpace: Space;
  36832. /**
  36833. * Used to make an adjustment to the yaw of the bone
  36834. */
  36835. adjustYaw: number;
  36836. /**
  36837. * Used to make an adjustment to the pitch of the bone
  36838. */
  36839. adjustPitch: number;
  36840. /**
  36841. * Used to make an adjustment to the roll of the bone
  36842. */
  36843. adjustRoll: number;
  36844. /**
  36845. * 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)
  36846. */
  36847. slerpAmount: number;
  36848. private _minYaw;
  36849. private _maxYaw;
  36850. private _minPitch;
  36851. private _maxPitch;
  36852. private _minYawSin;
  36853. private _minYawCos;
  36854. private _maxYawSin;
  36855. private _maxYawCos;
  36856. private _midYawConstraint;
  36857. private _minPitchTan;
  36858. private _maxPitchTan;
  36859. private _boneQuat;
  36860. private _slerping;
  36861. private _transformYawPitch;
  36862. private _transformYawPitchInv;
  36863. private _firstFrameSkipped;
  36864. private _yawRange;
  36865. private _fowardAxis;
  36866. /**
  36867. * Gets or sets the minimum yaw angle that the bone can look to
  36868. */
  36869. minYaw: number;
  36870. /**
  36871. * Gets or sets the maximum yaw angle that the bone can look to
  36872. */
  36873. maxYaw: number;
  36874. /**
  36875. * Gets or sets the minimum pitch angle that the bone can look to
  36876. */
  36877. minPitch: number;
  36878. /**
  36879. * Gets or sets the maximum pitch angle that the bone can look to
  36880. */
  36881. maxPitch: number;
  36882. /**
  36883. * Create a BoneLookController
  36884. * @param mesh the mesh that the bone belongs to
  36885. * @param bone the bone that will be looking to the target
  36886. * @param target the target Vector3 to look at
  36887. * @param options optional settings:
  36888. * * maxYaw: the maximum angle the bone will yaw to
  36889. * * minYaw: the minimum angle the bone will yaw to
  36890. * * maxPitch: the maximum angle the bone will pitch to
  36891. * * minPitch: the minimum angle the bone will yaw to
  36892. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36893. * * upAxis: the up axis of the coordinate system
  36894. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36895. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36896. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36897. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36898. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36899. * * adjustRoll: used to make an adjustment to the roll of the bone
  36900. **/
  36901. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36902. maxYaw?: number;
  36903. minYaw?: number;
  36904. maxPitch?: number;
  36905. minPitch?: number;
  36906. slerpAmount?: number;
  36907. upAxis?: Vector3;
  36908. upAxisSpace?: Space;
  36909. yawAxis?: Vector3;
  36910. pitchAxis?: Vector3;
  36911. adjustYaw?: number;
  36912. adjustPitch?: number;
  36913. adjustRoll?: number;
  36914. });
  36915. /**
  36916. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36917. */
  36918. update(): void;
  36919. private _getAngleDiff;
  36920. private _getAngleBetween;
  36921. private _isAngleBetween;
  36922. }
  36923. }
  36924. declare module BABYLON {
  36925. /**
  36926. * Manage the gamepad inputs to control an arc rotate camera.
  36927. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36928. */
  36929. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36930. /**
  36931. * Defines the camera the input is attached to.
  36932. */
  36933. camera: ArcRotateCamera;
  36934. /**
  36935. * Defines the gamepad the input is gathering event from.
  36936. */
  36937. gamepad: Nullable<Gamepad>;
  36938. /**
  36939. * Defines the gamepad rotation sensiblity.
  36940. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36941. */
  36942. gamepadRotationSensibility: number;
  36943. /**
  36944. * Defines the gamepad move sensiblity.
  36945. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36946. */
  36947. gamepadMoveSensibility: number;
  36948. private _onGamepadConnectedObserver;
  36949. private _onGamepadDisconnectedObserver;
  36950. /**
  36951. * Attach the input controls to a specific dom element to get the input from.
  36952. * @param element Defines the element the controls should be listened from
  36953. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36954. */
  36955. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36956. /**
  36957. * Detach the current controls from the specified dom element.
  36958. * @param element Defines the element to stop listening the inputs from
  36959. */
  36960. detachControl(element: Nullable<HTMLElement>): void;
  36961. /**
  36962. * Update the current camera state depending on the inputs that have been used this frame.
  36963. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36964. */
  36965. checkInputs(): void;
  36966. /**
  36967. * Gets the class name of the current intput.
  36968. * @returns the class name
  36969. */
  36970. getClassName(): string;
  36971. /**
  36972. * Get the friendly name associated with the input class.
  36973. * @returns the input friendly name
  36974. */
  36975. getSimpleName(): string;
  36976. }
  36977. }
  36978. declare module BABYLON {
  36979. interface ArcRotateCameraInputsManager {
  36980. /**
  36981. * Add orientation input support to the input manager.
  36982. * @returns the current input manager
  36983. */
  36984. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36985. }
  36986. /**
  36987. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36988. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36989. */
  36990. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36991. /**
  36992. * Defines the camera the input is attached to.
  36993. */
  36994. camera: ArcRotateCamera;
  36995. /**
  36996. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36997. */
  36998. alphaCorrection: number;
  36999. /**
  37000. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37001. */
  37002. gammaCorrection: number;
  37003. private _alpha;
  37004. private _gamma;
  37005. private _dirty;
  37006. private _deviceOrientationHandler;
  37007. /**
  37008. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37009. */
  37010. constructor();
  37011. /**
  37012. * Attach the input controls to a specific dom element to get the input from.
  37013. * @param element Defines the element the controls should be listened from
  37014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37015. */
  37016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37017. /** @hidden */
  37018. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37019. /**
  37020. * Update the current camera state depending on the inputs that have been used this frame.
  37021. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37022. */
  37023. checkInputs(): void;
  37024. /**
  37025. * Detach the current controls from the specified dom element.
  37026. * @param element Defines the element to stop listening the inputs from
  37027. */
  37028. detachControl(element: Nullable<HTMLElement>): void;
  37029. /**
  37030. * Gets the class name of the current intput.
  37031. * @returns the class name
  37032. */
  37033. getClassName(): string;
  37034. /**
  37035. * Get the friendly name associated with the input class.
  37036. * @returns the input friendly name
  37037. */
  37038. getSimpleName(): string;
  37039. }
  37040. }
  37041. declare module BABYLON {
  37042. /**
  37043. * Listen to mouse events to control the camera.
  37044. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37045. */
  37046. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37047. /**
  37048. * Defines the camera the input is attached to.
  37049. */
  37050. camera: FlyCamera;
  37051. /**
  37052. * Defines if touch is enabled. (Default is true.)
  37053. */
  37054. touchEnabled: boolean;
  37055. /**
  37056. * Defines the buttons associated with the input to handle camera rotation.
  37057. */
  37058. buttons: number[];
  37059. /**
  37060. * Assign buttons for Yaw control.
  37061. */
  37062. buttonsYaw: number[];
  37063. /**
  37064. * Assign buttons for Pitch control.
  37065. */
  37066. buttonsPitch: number[];
  37067. /**
  37068. * Assign buttons for Roll control.
  37069. */
  37070. buttonsRoll: number[];
  37071. /**
  37072. * Detect if any button is being pressed while mouse is moved.
  37073. * -1 = Mouse locked.
  37074. * 0 = Left button.
  37075. * 1 = Middle Button.
  37076. * 2 = Right Button.
  37077. */
  37078. activeButton: number;
  37079. /**
  37080. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37081. * Higher values reduce its sensitivity.
  37082. */
  37083. angularSensibility: number;
  37084. private _mousemoveCallback;
  37085. private _observer;
  37086. private _rollObserver;
  37087. private previousPosition;
  37088. private noPreventDefault;
  37089. private element;
  37090. /**
  37091. * Listen to mouse events to control the camera.
  37092. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37093. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37094. */
  37095. constructor(touchEnabled?: boolean);
  37096. /**
  37097. * Attach the mouse control to the HTML DOM element.
  37098. * @param element Defines the element that listens to the input events.
  37099. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37100. */
  37101. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37102. /**
  37103. * Detach the current controls from the specified dom element.
  37104. * @param element Defines the element to stop listening the inputs from
  37105. */
  37106. detachControl(element: Nullable<HTMLElement>): void;
  37107. /**
  37108. * Gets the class name of the current input.
  37109. * @returns the class name.
  37110. */
  37111. getClassName(): string;
  37112. /**
  37113. * Get the friendly name associated with the input class.
  37114. * @returns the input's friendly name.
  37115. */
  37116. getSimpleName(): string;
  37117. private _pointerInput;
  37118. private _onMouseMove;
  37119. /**
  37120. * Rotate camera by mouse offset.
  37121. */
  37122. private rotateCamera;
  37123. }
  37124. }
  37125. declare module BABYLON {
  37126. /**
  37127. * Default Inputs manager for the FlyCamera.
  37128. * It groups all the default supported inputs for ease of use.
  37129. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37130. */
  37131. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37132. /**
  37133. * Instantiates a new FlyCameraInputsManager.
  37134. * @param camera Defines the camera the inputs belong to.
  37135. */
  37136. constructor(camera: FlyCamera);
  37137. /**
  37138. * Add keyboard input support to the input manager.
  37139. * @returns the new FlyCameraKeyboardMoveInput().
  37140. */
  37141. addKeyboard(): FlyCameraInputsManager;
  37142. /**
  37143. * Add mouse input support to the input manager.
  37144. * @param touchEnabled Enable touch screen support.
  37145. * @returns the new FlyCameraMouseInput().
  37146. */
  37147. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37148. }
  37149. }
  37150. declare module BABYLON {
  37151. /**
  37152. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37153. * such as in a 3D Space Shooter or a Flight Simulator.
  37154. */
  37155. export class FlyCamera extends TargetCamera {
  37156. /**
  37157. * Define the collision ellipsoid of the camera.
  37158. * This is helpful for simulating a camera body, like a player's body.
  37159. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37160. */
  37161. ellipsoid: Vector3;
  37162. /**
  37163. * Define an offset for the position of the ellipsoid around the camera.
  37164. * This can be helpful if the camera is attached away from the player's body center,
  37165. * such as at its head.
  37166. */
  37167. ellipsoidOffset: Vector3;
  37168. /**
  37169. * Enable or disable collisions of the camera with the rest of the scene objects.
  37170. */
  37171. checkCollisions: boolean;
  37172. /**
  37173. * Enable or disable gravity on the camera.
  37174. */
  37175. applyGravity: boolean;
  37176. /**
  37177. * Define the current direction the camera is moving to.
  37178. */
  37179. cameraDirection: Vector3;
  37180. /**
  37181. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37182. * This overrides and empties cameraRotation.
  37183. */
  37184. rotationQuaternion: Quaternion;
  37185. /**
  37186. * Track Roll to maintain the wanted Rolling when looking around.
  37187. */
  37188. _trackRoll: number;
  37189. /**
  37190. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37191. */
  37192. rollCorrect: number;
  37193. /**
  37194. * Mimic a banked turn, Rolling the camera when Yawing.
  37195. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37196. */
  37197. bankedTurn: boolean;
  37198. /**
  37199. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37200. */
  37201. bankedTurnLimit: number;
  37202. /**
  37203. * Value of 0 disables the banked Roll.
  37204. * Value of 1 is equal to the Yaw angle in radians.
  37205. */
  37206. bankedTurnMultiplier: number;
  37207. /**
  37208. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37209. */
  37210. inputs: FlyCameraInputsManager;
  37211. /**
  37212. * Gets the input sensibility for mouse input.
  37213. * Higher values reduce sensitivity.
  37214. */
  37215. /**
  37216. * Sets the input sensibility for a mouse input.
  37217. * Higher values reduce sensitivity.
  37218. */
  37219. angularSensibility: number;
  37220. /**
  37221. * Get the keys for camera movement forward.
  37222. */
  37223. /**
  37224. * Set the keys for camera movement forward.
  37225. */
  37226. keysForward: number[];
  37227. /**
  37228. * Get the keys for camera movement backward.
  37229. */
  37230. keysBackward: number[];
  37231. /**
  37232. * Get the keys for camera movement up.
  37233. */
  37234. /**
  37235. * Set the keys for camera movement up.
  37236. */
  37237. keysUp: number[];
  37238. /**
  37239. * Get the keys for camera movement down.
  37240. */
  37241. /**
  37242. * Set the keys for camera movement down.
  37243. */
  37244. keysDown: number[];
  37245. /**
  37246. * Get the keys for camera movement left.
  37247. */
  37248. /**
  37249. * Set the keys for camera movement left.
  37250. */
  37251. keysLeft: number[];
  37252. /**
  37253. * Set the keys for camera movement right.
  37254. */
  37255. /**
  37256. * Set the keys for camera movement right.
  37257. */
  37258. keysRight: number[];
  37259. /**
  37260. * Event raised when the camera collides with a mesh in the scene.
  37261. */
  37262. onCollide: (collidedMesh: AbstractMesh) => void;
  37263. private _collider;
  37264. private _needMoveForGravity;
  37265. private _oldPosition;
  37266. private _diffPosition;
  37267. private _newPosition;
  37268. /** @hidden */
  37269. _localDirection: Vector3;
  37270. /** @hidden */
  37271. _transformedDirection: Vector3;
  37272. /**
  37273. * Instantiates a FlyCamera.
  37274. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37275. * such as in a 3D Space Shooter or a Flight Simulator.
  37276. * @param name Define the name of the camera in the scene.
  37277. * @param position Define the starting position of the camera in the scene.
  37278. * @param scene Define the scene the camera belongs to.
  37279. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37280. */
  37281. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37282. /**
  37283. * Attach a control to the HTML DOM element.
  37284. * @param element Defines the element that listens to the input events.
  37285. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37286. */
  37287. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37288. /**
  37289. * Detach a control from the HTML DOM element.
  37290. * The camera will stop reacting to that input.
  37291. * @param element Defines the element that listens to the input events.
  37292. */
  37293. detachControl(element: HTMLElement): void;
  37294. private _collisionMask;
  37295. /**
  37296. * Get the mask that the camera ignores in collision events.
  37297. */
  37298. /**
  37299. * Set the mask that the camera ignores in collision events.
  37300. */
  37301. collisionMask: number;
  37302. /** @hidden */
  37303. _collideWithWorld(displacement: Vector3): void;
  37304. /** @hidden */
  37305. private _onCollisionPositionChange;
  37306. /** @hidden */
  37307. _checkInputs(): void;
  37308. /** @hidden */
  37309. _decideIfNeedsToMove(): boolean;
  37310. /** @hidden */
  37311. _updatePosition(): void;
  37312. /**
  37313. * Restore the Roll to its target value at the rate specified.
  37314. * @param rate - Higher means slower restoring.
  37315. * @hidden
  37316. */
  37317. restoreRoll(rate: number): void;
  37318. /**
  37319. * Destroy the camera and release the current resources held by it.
  37320. */
  37321. dispose(): void;
  37322. /**
  37323. * Get the current object class name.
  37324. * @returns the class name.
  37325. */
  37326. getClassName(): string;
  37327. }
  37328. }
  37329. declare module BABYLON {
  37330. /**
  37331. * Listen to keyboard events to control the camera.
  37332. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37333. */
  37334. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37335. /**
  37336. * Defines the camera the input is attached to.
  37337. */
  37338. camera: FlyCamera;
  37339. /**
  37340. * The list of keyboard keys used to control the forward move of the camera.
  37341. */
  37342. keysForward: number[];
  37343. /**
  37344. * The list of keyboard keys used to control the backward move of the camera.
  37345. */
  37346. keysBackward: number[];
  37347. /**
  37348. * The list of keyboard keys used to control the forward move of the camera.
  37349. */
  37350. keysUp: number[];
  37351. /**
  37352. * The list of keyboard keys used to control the backward move of the camera.
  37353. */
  37354. keysDown: number[];
  37355. /**
  37356. * The list of keyboard keys used to control the right strafe move of the camera.
  37357. */
  37358. keysRight: number[];
  37359. /**
  37360. * The list of keyboard keys used to control the left strafe move of the camera.
  37361. */
  37362. keysLeft: number[];
  37363. private _keys;
  37364. private _onCanvasBlurObserver;
  37365. private _onKeyboardObserver;
  37366. private _engine;
  37367. private _scene;
  37368. /**
  37369. * Attach the input controls to a specific dom element to get the input from.
  37370. * @param element Defines the element the controls should be listened from
  37371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37372. */
  37373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37374. /**
  37375. * Detach the current controls from the specified dom element.
  37376. * @param element Defines the element to stop listening the inputs from
  37377. */
  37378. detachControl(element: Nullable<HTMLElement>): void;
  37379. /**
  37380. * Gets the class name of the current intput.
  37381. * @returns the class name
  37382. */
  37383. getClassName(): string;
  37384. /** @hidden */
  37385. _onLostFocus(e: FocusEvent): void;
  37386. /**
  37387. * Get the friendly name associated with the input class.
  37388. * @returns the input friendly name
  37389. */
  37390. getSimpleName(): string;
  37391. /**
  37392. * Update the current camera state depending on the inputs that have been used this frame.
  37393. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37394. */
  37395. checkInputs(): void;
  37396. }
  37397. }
  37398. declare module BABYLON {
  37399. /**
  37400. * Manage the mouse wheel inputs to control a follow camera.
  37401. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37402. */
  37403. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37404. /**
  37405. * Defines the camera the input is attached to.
  37406. */
  37407. camera: FollowCamera;
  37408. /**
  37409. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37410. */
  37411. axisControlRadius: boolean;
  37412. /**
  37413. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37414. */
  37415. axisControlHeight: boolean;
  37416. /**
  37417. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37418. */
  37419. axisControlRotation: boolean;
  37420. /**
  37421. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37422. * relation to mouseWheel events.
  37423. */
  37424. wheelPrecision: number;
  37425. /**
  37426. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37427. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37428. */
  37429. wheelDeltaPercentage: number;
  37430. private _wheel;
  37431. private _observer;
  37432. /**
  37433. * Attach the input controls to a specific dom element to get the input from.
  37434. * @param element Defines the element the controls should be listened from
  37435. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37436. */
  37437. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37438. /**
  37439. * Detach the current controls from the specified dom element.
  37440. * @param element Defines the element to stop listening the inputs from
  37441. */
  37442. detachControl(element: Nullable<HTMLElement>): void;
  37443. /**
  37444. * Gets the class name of the current intput.
  37445. * @returns the class name
  37446. */
  37447. getClassName(): string;
  37448. /**
  37449. * Get the friendly name associated with the input class.
  37450. * @returns the input friendly name
  37451. */
  37452. getSimpleName(): string;
  37453. }
  37454. }
  37455. declare module BABYLON {
  37456. /**
  37457. * Manage the pointers inputs to control an follow camera.
  37458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37459. */
  37460. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37461. /**
  37462. * Defines the camera the input is attached to.
  37463. */
  37464. camera: FollowCamera;
  37465. /**
  37466. * Gets the class name of the current input.
  37467. * @returns the class name
  37468. */
  37469. getClassName(): string;
  37470. /**
  37471. * Defines the pointer angular sensibility along the X axis or how fast is
  37472. * the camera rotating.
  37473. * A negative number will reverse the axis direction.
  37474. */
  37475. angularSensibilityX: number;
  37476. /**
  37477. * Defines the pointer angular sensibility along the Y axis or how fast is
  37478. * the camera rotating.
  37479. * A negative number will reverse the axis direction.
  37480. */
  37481. angularSensibilityY: number;
  37482. /**
  37483. * Defines the pointer pinch precision or how fast is the camera zooming.
  37484. * A negative number will reverse the axis direction.
  37485. */
  37486. pinchPrecision: number;
  37487. /**
  37488. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37489. * from 0.
  37490. * It defines the percentage of current camera.radius to use as delta when
  37491. * pinch zoom is used.
  37492. */
  37493. pinchDeltaPercentage: number;
  37494. /**
  37495. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37496. */
  37497. axisXControlRadius: boolean;
  37498. /**
  37499. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37500. */
  37501. axisXControlHeight: boolean;
  37502. /**
  37503. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37504. */
  37505. axisXControlRotation: boolean;
  37506. /**
  37507. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37508. */
  37509. axisYControlRadius: boolean;
  37510. /**
  37511. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37512. */
  37513. axisYControlHeight: boolean;
  37514. /**
  37515. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37516. */
  37517. axisYControlRotation: boolean;
  37518. /**
  37519. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37520. */
  37521. axisPinchControlRadius: boolean;
  37522. /**
  37523. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37524. */
  37525. axisPinchControlHeight: boolean;
  37526. /**
  37527. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37528. */
  37529. axisPinchControlRotation: boolean;
  37530. /**
  37531. * Log error messages if basic misconfiguration has occurred.
  37532. */
  37533. warningEnable: boolean;
  37534. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37535. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37536. private _warningCounter;
  37537. private _warning;
  37538. }
  37539. }
  37540. declare module BABYLON {
  37541. /**
  37542. * Default Inputs manager for the FollowCamera.
  37543. * It groups all the default supported inputs for ease of use.
  37544. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37545. */
  37546. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37547. /**
  37548. * Instantiates a new FollowCameraInputsManager.
  37549. * @param camera Defines the camera the inputs belong to
  37550. */
  37551. constructor(camera: FollowCamera);
  37552. /**
  37553. * Add keyboard input support to the input manager.
  37554. * @returns the current input manager
  37555. */
  37556. addKeyboard(): FollowCameraInputsManager;
  37557. /**
  37558. * Add mouse wheel input support to the input manager.
  37559. * @returns the current input manager
  37560. */
  37561. addMouseWheel(): FollowCameraInputsManager;
  37562. /**
  37563. * Add pointers input support to the input manager.
  37564. * @returns the current input manager
  37565. */
  37566. addPointers(): FollowCameraInputsManager;
  37567. /**
  37568. * Add orientation input support to the input manager.
  37569. * @returns the current input manager
  37570. */
  37571. addVRDeviceOrientation(): FollowCameraInputsManager;
  37572. }
  37573. }
  37574. declare module BABYLON {
  37575. /**
  37576. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37577. * an arc rotate version arcFollowCamera are available.
  37578. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37579. */
  37580. export class FollowCamera extends TargetCamera {
  37581. /**
  37582. * Distance the follow camera should follow an object at
  37583. */
  37584. radius: number;
  37585. /**
  37586. * Minimum allowed distance of the camera to the axis of rotation
  37587. * (The camera can not get closer).
  37588. * This can help limiting how the Camera is able to move in the scene.
  37589. */
  37590. lowerRadiusLimit: Nullable<number>;
  37591. /**
  37592. * Maximum allowed distance of the camera to the axis of rotation
  37593. * (The camera can not get further).
  37594. * This can help limiting how the Camera is able to move in the scene.
  37595. */
  37596. upperRadiusLimit: Nullable<number>;
  37597. /**
  37598. * Define a rotation offset between the camera and the object it follows
  37599. */
  37600. rotationOffset: number;
  37601. /**
  37602. * Minimum allowed angle to camera position relative to target object.
  37603. * This can help limiting how the Camera is able to move in the scene.
  37604. */
  37605. lowerRotationOffsetLimit: Nullable<number>;
  37606. /**
  37607. * Maximum allowed angle to camera position relative to target object.
  37608. * This can help limiting how the Camera is able to move in the scene.
  37609. */
  37610. upperRotationOffsetLimit: Nullable<number>;
  37611. /**
  37612. * Define a height offset between the camera and the object it follows.
  37613. * It can help following an object from the top (like a car chaing a plane)
  37614. */
  37615. heightOffset: number;
  37616. /**
  37617. * Minimum allowed height of camera position relative to target object.
  37618. * This can help limiting how the Camera is able to move in the scene.
  37619. */
  37620. lowerHeightOffsetLimit: Nullable<number>;
  37621. /**
  37622. * Maximum allowed height of camera position relative to target object.
  37623. * This can help limiting how the Camera is able to move in the scene.
  37624. */
  37625. upperHeightOffsetLimit: Nullable<number>;
  37626. /**
  37627. * Define how fast the camera can accelerate to follow it s target.
  37628. */
  37629. cameraAcceleration: number;
  37630. /**
  37631. * Define the speed limit of the camera following an object.
  37632. */
  37633. maxCameraSpeed: number;
  37634. /**
  37635. * Define the target of the camera.
  37636. */
  37637. lockedTarget: Nullable<AbstractMesh>;
  37638. /**
  37639. * Defines the input associated with the camera.
  37640. */
  37641. inputs: FollowCameraInputsManager;
  37642. /**
  37643. * Instantiates the follow camera.
  37644. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37645. * @param name Define the name of the camera in the scene
  37646. * @param position Define the position of the camera
  37647. * @param scene Define the scene the camera belong to
  37648. * @param lockedTarget Define the target of the camera
  37649. */
  37650. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37651. private _follow;
  37652. /**
  37653. * Attached controls to the current camera.
  37654. * @param element Defines the element the controls should be listened from
  37655. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37656. */
  37657. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37658. /**
  37659. * Detach the current controls from the camera.
  37660. * The camera will stop reacting to inputs.
  37661. * @param element Defines the element to stop listening the inputs from
  37662. */
  37663. detachControl(element: HTMLElement): void;
  37664. /** @hidden */
  37665. _checkInputs(): void;
  37666. private _checkLimits;
  37667. /**
  37668. * Gets the camera class name.
  37669. * @returns the class name
  37670. */
  37671. getClassName(): string;
  37672. }
  37673. /**
  37674. * Arc Rotate version of the follow camera.
  37675. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37676. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37677. */
  37678. export class ArcFollowCamera extends TargetCamera {
  37679. /** The longitudinal angle of the camera */
  37680. alpha: number;
  37681. /** The latitudinal angle of the camera */
  37682. beta: number;
  37683. /** The radius of the camera from its target */
  37684. radius: number;
  37685. /** Define the camera target (the messh it should follow) */
  37686. target: Nullable<AbstractMesh>;
  37687. private _cartesianCoordinates;
  37688. /**
  37689. * Instantiates a new ArcFollowCamera
  37690. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37691. * @param name Define the name of the camera
  37692. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37693. * @param beta Define the rotation angle of the camera around the elevation axis
  37694. * @param radius Define the radius of the camera from its target point
  37695. * @param target Define the target of the camera
  37696. * @param scene Define the scene the camera belongs to
  37697. */
  37698. constructor(name: string,
  37699. /** The longitudinal angle of the camera */
  37700. alpha: number,
  37701. /** The latitudinal angle of the camera */
  37702. beta: number,
  37703. /** The radius of the camera from its target */
  37704. radius: number,
  37705. /** Define the camera target (the messh it should follow) */
  37706. target: Nullable<AbstractMesh>, scene: Scene);
  37707. private _follow;
  37708. /** @hidden */
  37709. _checkInputs(): void;
  37710. /**
  37711. * Returns the class name of the object.
  37712. * It is mostly used internally for serialization purposes.
  37713. */
  37714. getClassName(): string;
  37715. }
  37716. }
  37717. declare module BABYLON {
  37718. /**
  37719. * Manage the keyboard inputs to control the movement of a follow camera.
  37720. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37721. */
  37722. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37723. /**
  37724. * Defines the camera the input is attached to.
  37725. */
  37726. camera: FollowCamera;
  37727. /**
  37728. * Defines the list of key codes associated with the up action (increase heightOffset)
  37729. */
  37730. keysHeightOffsetIncr: number[];
  37731. /**
  37732. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37733. */
  37734. keysHeightOffsetDecr: number[];
  37735. /**
  37736. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37737. */
  37738. keysHeightOffsetModifierAlt: boolean;
  37739. /**
  37740. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37741. */
  37742. keysHeightOffsetModifierCtrl: boolean;
  37743. /**
  37744. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37745. */
  37746. keysHeightOffsetModifierShift: boolean;
  37747. /**
  37748. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37749. */
  37750. keysRotationOffsetIncr: number[];
  37751. /**
  37752. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37753. */
  37754. keysRotationOffsetDecr: number[];
  37755. /**
  37756. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37757. */
  37758. keysRotationOffsetModifierAlt: boolean;
  37759. /**
  37760. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37761. */
  37762. keysRotationOffsetModifierCtrl: boolean;
  37763. /**
  37764. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37765. */
  37766. keysRotationOffsetModifierShift: boolean;
  37767. /**
  37768. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37769. */
  37770. keysRadiusIncr: number[];
  37771. /**
  37772. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37773. */
  37774. keysRadiusDecr: number[];
  37775. /**
  37776. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37777. */
  37778. keysRadiusModifierAlt: boolean;
  37779. /**
  37780. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37781. */
  37782. keysRadiusModifierCtrl: boolean;
  37783. /**
  37784. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37785. */
  37786. keysRadiusModifierShift: boolean;
  37787. /**
  37788. * Defines the rate of change of heightOffset.
  37789. */
  37790. heightSensibility: number;
  37791. /**
  37792. * Defines the rate of change of rotationOffset.
  37793. */
  37794. rotationSensibility: number;
  37795. /**
  37796. * Defines the rate of change of radius.
  37797. */
  37798. radiusSensibility: number;
  37799. private _keys;
  37800. private _ctrlPressed;
  37801. private _altPressed;
  37802. private _shiftPressed;
  37803. private _onCanvasBlurObserver;
  37804. private _onKeyboardObserver;
  37805. private _engine;
  37806. private _scene;
  37807. /**
  37808. * Attach the input controls to a specific dom element to get the input from.
  37809. * @param element Defines the element the controls should be listened from
  37810. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37811. */
  37812. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37813. /**
  37814. * Detach the current controls from the specified dom element.
  37815. * @param element Defines the element to stop listening the inputs from
  37816. */
  37817. detachControl(element: Nullable<HTMLElement>): void;
  37818. /**
  37819. * Update the current camera state depending on the inputs that have been used this frame.
  37820. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37821. */
  37822. checkInputs(): void;
  37823. /**
  37824. * Gets the class name of the current input.
  37825. * @returns the class name
  37826. */
  37827. getClassName(): string;
  37828. /**
  37829. * Get the friendly name associated with the input class.
  37830. * @returns the input friendly name
  37831. */
  37832. getSimpleName(): string;
  37833. /**
  37834. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37835. * allow modification of the heightOffset value.
  37836. */
  37837. private _modifierHeightOffset;
  37838. /**
  37839. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37840. * allow modification of the rotationOffset value.
  37841. */
  37842. private _modifierRotationOffset;
  37843. /**
  37844. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37845. * allow modification of the radius value.
  37846. */
  37847. private _modifierRadius;
  37848. }
  37849. }
  37850. declare module BABYLON {
  37851. interface FreeCameraInputsManager {
  37852. /**
  37853. * @hidden
  37854. */
  37855. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37856. /**
  37857. * Add orientation input support to the input manager.
  37858. * @returns the current input manager
  37859. */
  37860. addDeviceOrientation(): FreeCameraInputsManager;
  37861. }
  37862. /**
  37863. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37864. * Screen rotation is taken into account.
  37865. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37866. */
  37867. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37868. private _camera;
  37869. private _screenOrientationAngle;
  37870. private _constantTranform;
  37871. private _screenQuaternion;
  37872. private _alpha;
  37873. private _beta;
  37874. private _gamma;
  37875. /**
  37876. * Can be used to detect if a device orientation sensor is availible on a device
  37877. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37878. * @returns a promise that will resolve on orientation change
  37879. */
  37880. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37881. /**
  37882. * @hidden
  37883. */
  37884. _onDeviceOrientationChangedObservable: Observable<void>;
  37885. /**
  37886. * Instantiates a new input
  37887. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37888. */
  37889. constructor();
  37890. /**
  37891. * Define the camera controlled by the input.
  37892. */
  37893. camera: FreeCamera;
  37894. /**
  37895. * Attach the input controls to a specific dom element to get the input from.
  37896. * @param element Defines the element the controls should be listened from
  37897. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37898. */
  37899. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37900. private _orientationChanged;
  37901. private _deviceOrientation;
  37902. /**
  37903. * Detach the current controls from the specified dom element.
  37904. * @param element Defines the element to stop listening the inputs from
  37905. */
  37906. detachControl(element: Nullable<HTMLElement>): void;
  37907. /**
  37908. * Update the current camera state depending on the inputs that have been used this frame.
  37909. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37910. */
  37911. checkInputs(): void;
  37912. /**
  37913. * Gets the class name of the current intput.
  37914. * @returns the class name
  37915. */
  37916. getClassName(): string;
  37917. /**
  37918. * Get the friendly name associated with the input class.
  37919. * @returns the input friendly name
  37920. */
  37921. getSimpleName(): string;
  37922. }
  37923. }
  37924. declare module BABYLON {
  37925. /**
  37926. * Manage the gamepad inputs to control a free camera.
  37927. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37928. */
  37929. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37930. /**
  37931. * Define the camera the input is attached to.
  37932. */
  37933. camera: FreeCamera;
  37934. /**
  37935. * Define the Gamepad controlling the input
  37936. */
  37937. gamepad: Nullable<Gamepad>;
  37938. /**
  37939. * Defines the gamepad rotation sensiblity.
  37940. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37941. */
  37942. gamepadAngularSensibility: number;
  37943. /**
  37944. * Defines the gamepad move sensiblity.
  37945. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37946. */
  37947. gamepadMoveSensibility: number;
  37948. private _onGamepadConnectedObserver;
  37949. private _onGamepadDisconnectedObserver;
  37950. private _cameraTransform;
  37951. private _deltaTransform;
  37952. private _vector3;
  37953. private _vector2;
  37954. /**
  37955. * Attach the input controls to a specific dom element to get the input from.
  37956. * @param element Defines the element the controls should be listened from
  37957. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37958. */
  37959. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37960. /**
  37961. * Detach the current controls from the specified dom element.
  37962. * @param element Defines the element to stop listening the inputs from
  37963. */
  37964. detachControl(element: Nullable<HTMLElement>): void;
  37965. /**
  37966. * Update the current camera state depending on the inputs that have been used this frame.
  37967. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37968. */
  37969. checkInputs(): void;
  37970. /**
  37971. * Gets the class name of the current intput.
  37972. * @returns the class name
  37973. */
  37974. getClassName(): string;
  37975. /**
  37976. * Get the friendly name associated with the input class.
  37977. * @returns the input friendly name
  37978. */
  37979. getSimpleName(): string;
  37980. }
  37981. }
  37982. declare module BABYLON {
  37983. /**
  37984. * Defines the potential axis of a Joystick
  37985. */
  37986. export enum JoystickAxis {
  37987. /** X axis */
  37988. X = 0,
  37989. /** Y axis */
  37990. Y = 1,
  37991. /** Z axis */
  37992. Z = 2
  37993. }
  37994. /**
  37995. * Class used to define virtual joystick (used in touch mode)
  37996. */
  37997. export class VirtualJoystick {
  37998. /**
  37999. * Gets or sets a boolean indicating that left and right values must be inverted
  38000. */
  38001. reverseLeftRight: boolean;
  38002. /**
  38003. * Gets or sets a boolean indicating that up and down values must be inverted
  38004. */
  38005. reverseUpDown: boolean;
  38006. /**
  38007. * Gets the offset value for the position (ie. the change of the position value)
  38008. */
  38009. deltaPosition: Vector3;
  38010. /**
  38011. * Gets a boolean indicating if the virtual joystick was pressed
  38012. */
  38013. pressed: boolean;
  38014. /**
  38015. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38016. */
  38017. static Canvas: Nullable<HTMLCanvasElement>;
  38018. private static _globalJoystickIndex;
  38019. private static vjCanvasContext;
  38020. private static vjCanvasWidth;
  38021. private static vjCanvasHeight;
  38022. private static halfWidth;
  38023. private _action;
  38024. private _axisTargetedByLeftAndRight;
  38025. private _axisTargetedByUpAndDown;
  38026. private _joystickSensibility;
  38027. private _inversedSensibility;
  38028. private _joystickPointerID;
  38029. private _joystickColor;
  38030. private _joystickPointerPos;
  38031. private _joystickPreviousPointerPos;
  38032. private _joystickPointerStartPos;
  38033. private _deltaJoystickVector;
  38034. private _leftJoystick;
  38035. private _touches;
  38036. private _onPointerDownHandlerRef;
  38037. private _onPointerMoveHandlerRef;
  38038. private _onPointerUpHandlerRef;
  38039. private _onResize;
  38040. /**
  38041. * Creates a new virtual joystick
  38042. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38043. */
  38044. constructor(leftJoystick?: boolean);
  38045. /**
  38046. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38047. * @param newJoystickSensibility defines the new sensibility
  38048. */
  38049. setJoystickSensibility(newJoystickSensibility: number): void;
  38050. private _onPointerDown;
  38051. private _onPointerMove;
  38052. private _onPointerUp;
  38053. /**
  38054. * Change the color of the virtual joystick
  38055. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38056. */
  38057. setJoystickColor(newColor: string): void;
  38058. /**
  38059. * Defines a callback to call when the joystick is touched
  38060. * @param action defines the callback
  38061. */
  38062. setActionOnTouch(action: () => any): void;
  38063. /**
  38064. * Defines which axis you'd like to control for left & right
  38065. * @param axis defines the axis to use
  38066. */
  38067. setAxisForLeftRight(axis: JoystickAxis): void;
  38068. /**
  38069. * Defines which axis you'd like to control for up & down
  38070. * @param axis defines the axis to use
  38071. */
  38072. setAxisForUpDown(axis: JoystickAxis): void;
  38073. private _drawVirtualJoystick;
  38074. /**
  38075. * Release internal HTML canvas
  38076. */
  38077. releaseCanvas(): void;
  38078. }
  38079. }
  38080. declare module BABYLON {
  38081. interface FreeCameraInputsManager {
  38082. /**
  38083. * Add virtual joystick input support to the input manager.
  38084. * @returns the current input manager
  38085. */
  38086. addVirtualJoystick(): FreeCameraInputsManager;
  38087. }
  38088. /**
  38089. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38090. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38091. */
  38092. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38093. /**
  38094. * Defines the camera the input is attached to.
  38095. */
  38096. camera: FreeCamera;
  38097. private _leftjoystick;
  38098. private _rightjoystick;
  38099. /**
  38100. * Gets the left stick of the virtual joystick.
  38101. * @returns The virtual Joystick
  38102. */
  38103. getLeftJoystick(): VirtualJoystick;
  38104. /**
  38105. * Gets the right stick of the virtual joystick.
  38106. * @returns The virtual Joystick
  38107. */
  38108. getRightJoystick(): VirtualJoystick;
  38109. /**
  38110. * Update the current camera state depending on the inputs that have been used this frame.
  38111. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38112. */
  38113. checkInputs(): void;
  38114. /**
  38115. * Attach the input controls to a specific dom element to get the input from.
  38116. * @param element Defines the element the controls should be listened from
  38117. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38118. */
  38119. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38120. /**
  38121. * Detach the current controls from the specified dom element.
  38122. * @param element Defines the element to stop listening the inputs from
  38123. */
  38124. detachControl(element: Nullable<HTMLElement>): void;
  38125. /**
  38126. * Gets the class name of the current intput.
  38127. * @returns the class name
  38128. */
  38129. getClassName(): string;
  38130. /**
  38131. * Get the friendly name associated with the input class.
  38132. * @returns the input friendly name
  38133. */
  38134. getSimpleName(): string;
  38135. }
  38136. }
  38137. declare module BABYLON {
  38138. /**
  38139. * This represents a FPS type of camera controlled by touch.
  38140. * This is like a universal camera minus the Gamepad controls.
  38141. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38142. */
  38143. export class TouchCamera extends FreeCamera {
  38144. /**
  38145. * Defines the touch sensibility for rotation.
  38146. * The higher the faster.
  38147. */
  38148. touchAngularSensibility: number;
  38149. /**
  38150. * Defines the touch sensibility for move.
  38151. * The higher the faster.
  38152. */
  38153. touchMoveSensibility: number;
  38154. /**
  38155. * Instantiates a new touch camera.
  38156. * This represents a FPS type of camera controlled by touch.
  38157. * This is like a universal camera minus the Gamepad controls.
  38158. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38159. * @param name Define the name of the camera in the scene
  38160. * @param position Define the start position of the camera in the scene
  38161. * @param scene Define the scene the camera belongs to
  38162. */
  38163. constructor(name: string, position: Vector3, scene: Scene);
  38164. /**
  38165. * Gets the current object class name.
  38166. * @return the class name
  38167. */
  38168. getClassName(): string;
  38169. /** @hidden */
  38170. _setupInputs(): void;
  38171. }
  38172. }
  38173. declare module BABYLON {
  38174. /**
  38175. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38176. * being tilted forward or back and left or right.
  38177. */
  38178. export class DeviceOrientationCamera extends FreeCamera {
  38179. private _initialQuaternion;
  38180. private _quaternionCache;
  38181. private _tmpDragQuaternion;
  38182. /**
  38183. * Creates a new device orientation camera
  38184. * @param name The name of the camera
  38185. * @param position The start position camera
  38186. * @param scene The scene the camera belongs to
  38187. */
  38188. constructor(name: string, position: Vector3, scene: Scene);
  38189. /**
  38190. * @hidden
  38191. * Disabled pointer input on first orientation sensor update (Default: true)
  38192. */
  38193. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38194. private _dragFactor;
  38195. /**
  38196. * Enabled turning on the y axis when the orientation sensor is active
  38197. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38198. */
  38199. enableHorizontalDragging(dragFactor?: number): void;
  38200. /**
  38201. * Gets the current instance class name ("DeviceOrientationCamera").
  38202. * This helps avoiding instanceof at run time.
  38203. * @returns the class name
  38204. */
  38205. getClassName(): string;
  38206. /**
  38207. * @hidden
  38208. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38209. */
  38210. _checkInputs(): void;
  38211. /**
  38212. * Reset the camera to its default orientation on the specified axis only.
  38213. * @param axis The axis to reset
  38214. */
  38215. resetToCurrentRotation(axis?: Axis): void;
  38216. }
  38217. }
  38218. declare module BABYLON {
  38219. /**
  38220. * Defines supported buttons for XBox360 compatible gamepads
  38221. */
  38222. export enum Xbox360Button {
  38223. /** A */
  38224. A = 0,
  38225. /** B */
  38226. B = 1,
  38227. /** X */
  38228. X = 2,
  38229. /** Y */
  38230. Y = 3,
  38231. /** Start */
  38232. Start = 4,
  38233. /** Back */
  38234. Back = 5,
  38235. /** Left button */
  38236. LB = 6,
  38237. /** Right button */
  38238. RB = 7,
  38239. /** Left stick */
  38240. LeftStick = 8,
  38241. /** Right stick */
  38242. RightStick = 9
  38243. }
  38244. /** Defines values for XBox360 DPad */
  38245. export enum Xbox360Dpad {
  38246. /** Up */
  38247. Up = 0,
  38248. /** Down */
  38249. Down = 1,
  38250. /** Left */
  38251. Left = 2,
  38252. /** Right */
  38253. Right = 3
  38254. }
  38255. /**
  38256. * Defines a XBox360 gamepad
  38257. */
  38258. export class Xbox360Pad extends Gamepad {
  38259. private _leftTrigger;
  38260. private _rightTrigger;
  38261. private _onlefttriggerchanged;
  38262. private _onrighttriggerchanged;
  38263. private _onbuttondown;
  38264. private _onbuttonup;
  38265. private _ondpaddown;
  38266. private _ondpadup;
  38267. /** Observable raised when a button is pressed */
  38268. onButtonDownObservable: Observable<Xbox360Button>;
  38269. /** Observable raised when a button is released */
  38270. onButtonUpObservable: Observable<Xbox360Button>;
  38271. /** Observable raised when a pad is pressed */
  38272. onPadDownObservable: Observable<Xbox360Dpad>;
  38273. /** Observable raised when a pad is released */
  38274. onPadUpObservable: Observable<Xbox360Dpad>;
  38275. private _buttonA;
  38276. private _buttonB;
  38277. private _buttonX;
  38278. private _buttonY;
  38279. private _buttonBack;
  38280. private _buttonStart;
  38281. private _buttonLB;
  38282. private _buttonRB;
  38283. private _buttonLeftStick;
  38284. private _buttonRightStick;
  38285. private _dPadUp;
  38286. private _dPadDown;
  38287. private _dPadLeft;
  38288. private _dPadRight;
  38289. private _isXboxOnePad;
  38290. /**
  38291. * Creates a new XBox360 gamepad object
  38292. * @param id defines the id of this gamepad
  38293. * @param index defines its index
  38294. * @param gamepad defines the internal HTML gamepad object
  38295. * @param xboxOne defines if it is a XBox One gamepad
  38296. */
  38297. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38298. /**
  38299. * Defines the callback to call when left trigger is pressed
  38300. * @param callback defines the callback to use
  38301. */
  38302. onlefttriggerchanged(callback: (value: number) => void): void;
  38303. /**
  38304. * Defines the callback to call when right trigger is pressed
  38305. * @param callback defines the callback to use
  38306. */
  38307. onrighttriggerchanged(callback: (value: number) => void): void;
  38308. /**
  38309. * Gets the left trigger value
  38310. */
  38311. /**
  38312. * Sets the left trigger value
  38313. */
  38314. leftTrigger: number;
  38315. /**
  38316. * Gets the right trigger value
  38317. */
  38318. /**
  38319. * Sets the right trigger value
  38320. */
  38321. rightTrigger: number;
  38322. /**
  38323. * Defines the callback to call when a button is pressed
  38324. * @param callback defines the callback to use
  38325. */
  38326. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38327. /**
  38328. * Defines the callback to call when a button is released
  38329. * @param callback defines the callback to use
  38330. */
  38331. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38332. /**
  38333. * Defines the callback to call when a pad is pressed
  38334. * @param callback defines the callback to use
  38335. */
  38336. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38337. /**
  38338. * Defines the callback to call when a pad is released
  38339. * @param callback defines the callback to use
  38340. */
  38341. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38342. private _setButtonValue;
  38343. private _setDPadValue;
  38344. /**
  38345. * Gets the value of the `A` button
  38346. */
  38347. /**
  38348. * Sets the value of the `A` button
  38349. */
  38350. buttonA: number;
  38351. /**
  38352. * Gets the value of the `B` button
  38353. */
  38354. /**
  38355. * Sets the value of the `B` button
  38356. */
  38357. buttonB: number;
  38358. /**
  38359. * Gets the value of the `X` button
  38360. */
  38361. /**
  38362. * Sets the value of the `X` button
  38363. */
  38364. buttonX: number;
  38365. /**
  38366. * Gets the value of the `Y` button
  38367. */
  38368. /**
  38369. * Sets the value of the `Y` button
  38370. */
  38371. buttonY: number;
  38372. /**
  38373. * Gets the value of the `Start` button
  38374. */
  38375. /**
  38376. * Sets the value of the `Start` button
  38377. */
  38378. buttonStart: number;
  38379. /**
  38380. * Gets the value of the `Back` button
  38381. */
  38382. /**
  38383. * Sets the value of the `Back` button
  38384. */
  38385. buttonBack: number;
  38386. /**
  38387. * Gets the value of the `Left` button
  38388. */
  38389. /**
  38390. * Sets the value of the `Left` button
  38391. */
  38392. buttonLB: number;
  38393. /**
  38394. * Gets the value of the `Right` button
  38395. */
  38396. /**
  38397. * Sets the value of the `Right` button
  38398. */
  38399. buttonRB: number;
  38400. /**
  38401. * Gets the value of the Left joystick
  38402. */
  38403. /**
  38404. * Sets the value of the Left joystick
  38405. */
  38406. buttonLeftStick: number;
  38407. /**
  38408. * Gets the value of the Right joystick
  38409. */
  38410. /**
  38411. * Sets the value of the Right joystick
  38412. */
  38413. buttonRightStick: number;
  38414. /**
  38415. * Gets the value of D-pad up
  38416. */
  38417. /**
  38418. * Sets the value of D-pad up
  38419. */
  38420. dPadUp: number;
  38421. /**
  38422. * Gets the value of D-pad down
  38423. */
  38424. /**
  38425. * Sets the value of D-pad down
  38426. */
  38427. dPadDown: number;
  38428. /**
  38429. * Gets the value of D-pad left
  38430. */
  38431. /**
  38432. * Sets the value of D-pad left
  38433. */
  38434. dPadLeft: number;
  38435. /**
  38436. * Gets the value of D-pad right
  38437. */
  38438. /**
  38439. * Sets the value of D-pad right
  38440. */
  38441. dPadRight: number;
  38442. /**
  38443. * Force the gamepad to synchronize with device values
  38444. */
  38445. update(): void;
  38446. /**
  38447. * Disposes the gamepad
  38448. */
  38449. dispose(): void;
  38450. }
  38451. }
  38452. declare module BABYLON {
  38453. /**
  38454. * Manager for handling gamepads
  38455. */
  38456. export class GamepadManager {
  38457. private _scene?;
  38458. private _babylonGamepads;
  38459. private _oneGamepadConnected;
  38460. /** @hidden */
  38461. _isMonitoring: boolean;
  38462. private _gamepadEventSupported;
  38463. private _gamepadSupport;
  38464. /**
  38465. * observable to be triggered when the gamepad controller has been connected
  38466. */
  38467. onGamepadConnectedObservable: Observable<Gamepad>;
  38468. /**
  38469. * observable to be triggered when the gamepad controller has been disconnected
  38470. */
  38471. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38472. private _onGamepadConnectedEvent;
  38473. private _onGamepadDisconnectedEvent;
  38474. /**
  38475. * Initializes the gamepad manager
  38476. * @param _scene BabylonJS scene
  38477. */
  38478. constructor(_scene?: Scene | undefined);
  38479. /**
  38480. * The gamepads in the game pad manager
  38481. */
  38482. readonly gamepads: Gamepad[];
  38483. /**
  38484. * Get the gamepad controllers based on type
  38485. * @param type The type of gamepad controller
  38486. * @returns Nullable gamepad
  38487. */
  38488. getGamepadByType(type?: number): Nullable<Gamepad>;
  38489. /**
  38490. * Disposes the gamepad manager
  38491. */
  38492. dispose(): void;
  38493. private _addNewGamepad;
  38494. private _startMonitoringGamepads;
  38495. private _stopMonitoringGamepads;
  38496. /** @hidden */
  38497. _checkGamepadsStatus(): void;
  38498. private _updateGamepadObjects;
  38499. }
  38500. }
  38501. declare module BABYLON {
  38502. interface Scene {
  38503. /** @hidden */
  38504. _gamepadManager: Nullable<GamepadManager>;
  38505. /**
  38506. * Gets the gamepad manager associated with the scene
  38507. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38508. */
  38509. gamepadManager: GamepadManager;
  38510. }
  38511. /**
  38512. * Interface representing a free camera inputs manager
  38513. */
  38514. interface FreeCameraInputsManager {
  38515. /**
  38516. * Adds gamepad input support to the FreeCameraInputsManager.
  38517. * @returns the FreeCameraInputsManager
  38518. */
  38519. addGamepad(): FreeCameraInputsManager;
  38520. }
  38521. /**
  38522. * Interface representing an arc rotate camera inputs manager
  38523. */
  38524. interface ArcRotateCameraInputsManager {
  38525. /**
  38526. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38527. * @returns the camera inputs manager
  38528. */
  38529. addGamepad(): ArcRotateCameraInputsManager;
  38530. }
  38531. /**
  38532. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38533. */
  38534. export class GamepadSystemSceneComponent implements ISceneComponent {
  38535. /**
  38536. * The component name helpfull to identify the component in the list of scene components.
  38537. */
  38538. readonly name: string;
  38539. /**
  38540. * The scene the component belongs to.
  38541. */
  38542. scene: Scene;
  38543. /**
  38544. * Creates a new instance of the component for the given scene
  38545. * @param scene Defines the scene to register the component in
  38546. */
  38547. constructor(scene: Scene);
  38548. /**
  38549. * Registers the component in a given scene
  38550. */
  38551. register(): void;
  38552. /**
  38553. * Rebuilds the elements related to this component in case of
  38554. * context lost for instance.
  38555. */
  38556. rebuild(): void;
  38557. /**
  38558. * Disposes the component and the associated ressources
  38559. */
  38560. dispose(): void;
  38561. private _beforeCameraUpdate;
  38562. }
  38563. }
  38564. declare module BABYLON {
  38565. /**
  38566. * 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,
  38567. * which still works and will still be found in many Playgrounds.
  38568. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38569. */
  38570. export class UniversalCamera extends TouchCamera {
  38571. /**
  38572. * Defines the gamepad rotation sensiblity.
  38573. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38574. */
  38575. gamepadAngularSensibility: number;
  38576. /**
  38577. * Defines the gamepad move sensiblity.
  38578. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38579. */
  38580. gamepadMoveSensibility: number;
  38581. /**
  38582. * 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,
  38583. * which still works and will still be found in many Playgrounds.
  38584. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38585. * @param name Define the name of the camera in the scene
  38586. * @param position Define the start position of the camera in the scene
  38587. * @param scene Define the scene the camera belongs to
  38588. */
  38589. constructor(name: string, position: Vector3, scene: Scene);
  38590. /**
  38591. * Gets the current object class name.
  38592. * @return the class name
  38593. */
  38594. getClassName(): string;
  38595. }
  38596. }
  38597. declare module BABYLON {
  38598. /**
  38599. * This represents a FPS type of camera. This is only here for back compat purpose.
  38600. * Please use the UniversalCamera instead as both are identical.
  38601. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38602. */
  38603. export class GamepadCamera extends UniversalCamera {
  38604. /**
  38605. * Instantiates a new Gamepad Camera
  38606. * This represents a FPS type of camera. This is only here for back compat purpose.
  38607. * Please use the UniversalCamera instead as both are identical.
  38608. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38609. * @param name Define the name of the camera in the scene
  38610. * @param position Define the start position of the camera in the scene
  38611. * @param scene Define the scene the camera belongs to
  38612. */
  38613. constructor(name: string, position: Vector3, scene: Scene);
  38614. /**
  38615. * Gets the current object class name.
  38616. * @return the class name
  38617. */
  38618. getClassName(): string;
  38619. }
  38620. }
  38621. declare module BABYLON {
  38622. /** @hidden */
  38623. export var passPixelShader: {
  38624. name: string;
  38625. shader: string;
  38626. };
  38627. }
  38628. declare module BABYLON {
  38629. /** @hidden */
  38630. export var passCubePixelShader: {
  38631. name: string;
  38632. shader: string;
  38633. };
  38634. }
  38635. declare module BABYLON {
  38636. /**
  38637. * PassPostProcess which produces an output the same as it's input
  38638. */
  38639. export class PassPostProcess extends PostProcess {
  38640. /**
  38641. * Creates the PassPostProcess
  38642. * @param name The name of the effect.
  38643. * @param options The required width/height ratio to downsize to before computing the render pass.
  38644. * @param camera The camera to apply the render pass to.
  38645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38646. * @param engine The engine which the post process will be applied. (default: current engine)
  38647. * @param reusable If the post process can be reused on the same frame. (default: false)
  38648. * @param textureType The type of texture to be used when performing the post processing.
  38649. * @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)
  38650. */
  38651. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38652. }
  38653. /**
  38654. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38655. */
  38656. export class PassCubePostProcess extends PostProcess {
  38657. private _face;
  38658. /**
  38659. * Gets or sets the cube face to display.
  38660. * * 0 is +X
  38661. * * 1 is -X
  38662. * * 2 is +Y
  38663. * * 3 is -Y
  38664. * * 4 is +Z
  38665. * * 5 is -Z
  38666. */
  38667. face: number;
  38668. /**
  38669. * Creates the PassCubePostProcess
  38670. * @param name The name of the effect.
  38671. * @param options The required width/height ratio to downsize to before computing the render pass.
  38672. * @param camera The camera to apply the render pass to.
  38673. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38674. * @param engine The engine which the post process will be applied. (default: current engine)
  38675. * @param reusable If the post process can be reused on the same frame. (default: false)
  38676. * @param textureType The type of texture to be used when performing the post processing.
  38677. * @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)
  38678. */
  38679. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38680. }
  38681. }
  38682. declare module BABYLON {
  38683. /** @hidden */
  38684. export var anaglyphPixelShader: {
  38685. name: string;
  38686. shader: string;
  38687. };
  38688. }
  38689. declare module BABYLON {
  38690. /**
  38691. * Postprocess used to generate anaglyphic rendering
  38692. */
  38693. export class AnaglyphPostProcess extends PostProcess {
  38694. private _passedProcess;
  38695. /**
  38696. * Creates a new AnaglyphPostProcess
  38697. * @param name defines postprocess name
  38698. * @param options defines creation options or target ratio scale
  38699. * @param rigCameras defines cameras using this postprocess
  38700. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38701. * @param engine defines hosting engine
  38702. * @param reusable defines if the postprocess will be reused multiple times per frame
  38703. */
  38704. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38705. }
  38706. }
  38707. declare module BABYLON {
  38708. /**
  38709. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38710. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38711. */
  38712. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38713. /**
  38714. * Creates a new AnaglyphArcRotateCamera
  38715. * @param name defines camera name
  38716. * @param alpha defines alpha angle (in radians)
  38717. * @param beta defines beta angle (in radians)
  38718. * @param radius defines radius
  38719. * @param target defines camera target
  38720. * @param interaxialDistance defines distance between each color axis
  38721. * @param scene defines the hosting scene
  38722. */
  38723. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38724. /**
  38725. * Gets camera class name
  38726. * @returns AnaglyphArcRotateCamera
  38727. */
  38728. getClassName(): string;
  38729. }
  38730. }
  38731. declare module BABYLON {
  38732. /**
  38733. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38734. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38735. */
  38736. export class AnaglyphFreeCamera extends FreeCamera {
  38737. /**
  38738. * Creates a new AnaglyphFreeCamera
  38739. * @param name defines camera name
  38740. * @param position defines initial position
  38741. * @param interaxialDistance defines distance between each color axis
  38742. * @param scene defines the hosting scene
  38743. */
  38744. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38745. /**
  38746. * Gets camera class name
  38747. * @returns AnaglyphFreeCamera
  38748. */
  38749. getClassName(): string;
  38750. }
  38751. }
  38752. declare module BABYLON {
  38753. /**
  38754. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38755. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38756. */
  38757. export class AnaglyphGamepadCamera extends GamepadCamera {
  38758. /**
  38759. * Creates a new AnaglyphGamepadCamera
  38760. * @param name defines camera name
  38761. * @param position defines initial position
  38762. * @param interaxialDistance defines distance between each color axis
  38763. * @param scene defines the hosting scene
  38764. */
  38765. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38766. /**
  38767. * Gets camera class name
  38768. * @returns AnaglyphGamepadCamera
  38769. */
  38770. getClassName(): string;
  38771. }
  38772. }
  38773. declare module BABYLON {
  38774. /**
  38775. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38776. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38777. */
  38778. export class AnaglyphUniversalCamera extends UniversalCamera {
  38779. /**
  38780. * Creates a new AnaglyphUniversalCamera
  38781. * @param name defines camera name
  38782. * @param position defines initial position
  38783. * @param interaxialDistance defines distance between each color axis
  38784. * @param scene defines the hosting scene
  38785. */
  38786. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38787. /**
  38788. * Gets camera class name
  38789. * @returns AnaglyphUniversalCamera
  38790. */
  38791. getClassName(): string;
  38792. }
  38793. }
  38794. declare module BABYLON {
  38795. /** @hidden */
  38796. export var stereoscopicInterlacePixelShader: {
  38797. name: string;
  38798. shader: string;
  38799. };
  38800. }
  38801. declare module BABYLON {
  38802. /**
  38803. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38804. */
  38805. export class StereoscopicInterlacePostProcess extends PostProcess {
  38806. private _stepSize;
  38807. private _passedProcess;
  38808. /**
  38809. * Initializes a StereoscopicInterlacePostProcess
  38810. * @param name The name of the effect.
  38811. * @param rigCameras The rig cameras to be appled to the post process
  38812. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38813. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38814. * @param engine The engine which the post process will be applied. (default: current engine)
  38815. * @param reusable If the post process can be reused on the same frame. (default: false)
  38816. */
  38817. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38818. }
  38819. }
  38820. declare module BABYLON {
  38821. /**
  38822. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38823. * @see http://doc.babylonjs.com/features/cameras
  38824. */
  38825. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38826. /**
  38827. * Creates a new StereoscopicArcRotateCamera
  38828. * @param name defines camera name
  38829. * @param alpha defines alpha angle (in radians)
  38830. * @param beta defines beta angle (in radians)
  38831. * @param radius defines radius
  38832. * @param target defines camera target
  38833. * @param interaxialDistance defines distance between each color axis
  38834. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38835. * @param scene defines the hosting scene
  38836. */
  38837. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38838. /**
  38839. * Gets camera class name
  38840. * @returns StereoscopicArcRotateCamera
  38841. */
  38842. getClassName(): string;
  38843. }
  38844. }
  38845. declare module BABYLON {
  38846. /**
  38847. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38848. * @see http://doc.babylonjs.com/features/cameras
  38849. */
  38850. export class StereoscopicFreeCamera extends FreeCamera {
  38851. /**
  38852. * Creates a new StereoscopicFreeCamera
  38853. * @param name defines camera name
  38854. * @param position defines initial position
  38855. * @param interaxialDistance defines distance between each color axis
  38856. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38857. * @param scene defines the hosting scene
  38858. */
  38859. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38860. /**
  38861. * Gets camera class name
  38862. * @returns StereoscopicFreeCamera
  38863. */
  38864. getClassName(): string;
  38865. }
  38866. }
  38867. declare module BABYLON {
  38868. /**
  38869. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38870. * @see http://doc.babylonjs.com/features/cameras
  38871. */
  38872. export class StereoscopicGamepadCamera extends GamepadCamera {
  38873. /**
  38874. * Creates a new StereoscopicGamepadCamera
  38875. * @param name defines camera name
  38876. * @param position defines initial position
  38877. * @param interaxialDistance defines distance between each color axis
  38878. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38879. * @param scene defines the hosting scene
  38880. */
  38881. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38882. /**
  38883. * Gets camera class name
  38884. * @returns StereoscopicGamepadCamera
  38885. */
  38886. getClassName(): string;
  38887. }
  38888. }
  38889. declare module BABYLON {
  38890. /**
  38891. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38892. * @see http://doc.babylonjs.com/features/cameras
  38893. */
  38894. export class StereoscopicUniversalCamera extends UniversalCamera {
  38895. /**
  38896. * Creates a new StereoscopicUniversalCamera
  38897. * @param name defines camera name
  38898. * @param position defines initial position
  38899. * @param interaxialDistance defines distance between each color axis
  38900. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38901. * @param scene defines the hosting scene
  38902. */
  38903. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38904. /**
  38905. * Gets camera class name
  38906. * @returns StereoscopicUniversalCamera
  38907. */
  38908. getClassName(): string;
  38909. }
  38910. }
  38911. declare module BABYLON {
  38912. /**
  38913. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38914. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38915. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38916. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38917. */
  38918. export class VirtualJoysticksCamera extends FreeCamera {
  38919. /**
  38920. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38921. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38922. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38923. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38924. * @param name Define the name of the camera in the scene
  38925. * @param position Define the start position of the camera in the scene
  38926. * @param scene Define the scene the camera belongs to
  38927. */
  38928. constructor(name: string, position: Vector3, scene: Scene);
  38929. /**
  38930. * Gets the current object class name.
  38931. * @return the class name
  38932. */
  38933. getClassName(): string;
  38934. }
  38935. }
  38936. declare module BABYLON {
  38937. /**
  38938. * This represents all the required metrics to create a VR camera.
  38939. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38940. */
  38941. export class VRCameraMetrics {
  38942. /**
  38943. * Define the horizontal resolution off the screen.
  38944. */
  38945. hResolution: number;
  38946. /**
  38947. * Define the vertical resolution off the screen.
  38948. */
  38949. vResolution: number;
  38950. /**
  38951. * Define the horizontal screen size.
  38952. */
  38953. hScreenSize: number;
  38954. /**
  38955. * Define the vertical screen size.
  38956. */
  38957. vScreenSize: number;
  38958. /**
  38959. * Define the vertical screen center position.
  38960. */
  38961. vScreenCenter: number;
  38962. /**
  38963. * Define the distance of the eyes to the screen.
  38964. */
  38965. eyeToScreenDistance: number;
  38966. /**
  38967. * Define the distance between both lenses
  38968. */
  38969. lensSeparationDistance: number;
  38970. /**
  38971. * Define the distance between both viewer's eyes.
  38972. */
  38973. interpupillaryDistance: number;
  38974. /**
  38975. * Define the distortion factor of the VR postprocess.
  38976. * Please, touch with care.
  38977. */
  38978. distortionK: number[];
  38979. /**
  38980. * Define the chromatic aberration correction factors for the VR post process.
  38981. */
  38982. chromaAbCorrection: number[];
  38983. /**
  38984. * Define the scale factor of the post process.
  38985. * The smaller the better but the slower.
  38986. */
  38987. postProcessScaleFactor: number;
  38988. /**
  38989. * Define an offset for the lens center.
  38990. */
  38991. lensCenterOffset: number;
  38992. /**
  38993. * Define if the current vr camera should compensate the distortion of the lense or not.
  38994. */
  38995. compensateDistortion: boolean;
  38996. /**
  38997. * Defines if multiview should be enabled when rendering (Default: false)
  38998. */
  38999. multiviewEnabled: boolean;
  39000. /**
  39001. * Gets the rendering aspect ratio based on the provided resolutions.
  39002. */
  39003. readonly aspectRatio: number;
  39004. /**
  39005. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39006. */
  39007. readonly aspectRatioFov: number;
  39008. /**
  39009. * @hidden
  39010. */
  39011. readonly leftHMatrix: Matrix;
  39012. /**
  39013. * @hidden
  39014. */
  39015. readonly rightHMatrix: Matrix;
  39016. /**
  39017. * @hidden
  39018. */
  39019. readonly leftPreViewMatrix: Matrix;
  39020. /**
  39021. * @hidden
  39022. */
  39023. readonly rightPreViewMatrix: Matrix;
  39024. /**
  39025. * Get the default VRMetrics based on the most generic setup.
  39026. * @returns the default vr metrics
  39027. */
  39028. static GetDefault(): VRCameraMetrics;
  39029. }
  39030. }
  39031. declare module BABYLON {
  39032. /** @hidden */
  39033. export var vrDistortionCorrectionPixelShader: {
  39034. name: string;
  39035. shader: string;
  39036. };
  39037. }
  39038. declare module BABYLON {
  39039. /**
  39040. * VRDistortionCorrectionPostProcess used for mobile VR
  39041. */
  39042. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39043. private _isRightEye;
  39044. private _distortionFactors;
  39045. private _postProcessScaleFactor;
  39046. private _lensCenterOffset;
  39047. private _scaleIn;
  39048. private _scaleFactor;
  39049. private _lensCenter;
  39050. /**
  39051. * Initializes the VRDistortionCorrectionPostProcess
  39052. * @param name The name of the effect.
  39053. * @param camera The camera to apply the render pass to.
  39054. * @param isRightEye If this is for the right eye distortion
  39055. * @param vrMetrics All the required metrics for the VR camera
  39056. */
  39057. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39058. }
  39059. }
  39060. declare module BABYLON {
  39061. /**
  39062. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39063. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39064. */
  39065. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39066. /**
  39067. * Creates a new VRDeviceOrientationArcRotateCamera
  39068. * @param name defines camera name
  39069. * @param alpha defines the camera rotation along the logitudinal axis
  39070. * @param beta defines the camera rotation along the latitudinal axis
  39071. * @param radius defines the camera distance from its target
  39072. * @param target defines the camera target
  39073. * @param scene defines the scene the camera belongs to
  39074. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39075. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39076. */
  39077. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39078. /**
  39079. * Gets camera class name
  39080. * @returns VRDeviceOrientationArcRotateCamera
  39081. */
  39082. getClassName(): string;
  39083. }
  39084. }
  39085. declare module BABYLON {
  39086. /**
  39087. * Camera used to simulate VR rendering (based on FreeCamera)
  39088. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39089. */
  39090. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39091. /**
  39092. * Creates a new VRDeviceOrientationFreeCamera
  39093. * @param name defines camera name
  39094. * @param position defines the start position of the camera
  39095. * @param scene defines the scene the camera belongs to
  39096. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39097. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39098. */
  39099. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39100. /**
  39101. * Gets camera class name
  39102. * @returns VRDeviceOrientationFreeCamera
  39103. */
  39104. getClassName(): string;
  39105. }
  39106. }
  39107. declare module BABYLON {
  39108. /**
  39109. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39110. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39111. */
  39112. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39113. /**
  39114. * Creates a new VRDeviceOrientationGamepadCamera
  39115. * @param name defines camera name
  39116. * @param position defines the start position of the camera
  39117. * @param scene defines the scene the camera belongs to
  39118. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39119. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39120. */
  39121. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39122. /**
  39123. * Gets camera class name
  39124. * @returns VRDeviceOrientationGamepadCamera
  39125. */
  39126. getClassName(): string;
  39127. }
  39128. }
  39129. declare module BABYLON {
  39130. /**
  39131. * Base class of materials working in push mode in babylon JS
  39132. * @hidden
  39133. */
  39134. export class PushMaterial extends Material {
  39135. protected _activeEffect: Effect;
  39136. protected _normalMatrix: Matrix;
  39137. /**
  39138. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39139. * This means that the material can keep using a previous shader while a new one is being compiled.
  39140. * This is mostly used when shader parallel compilation is supported (true by default)
  39141. */
  39142. allowShaderHotSwapping: boolean;
  39143. constructor(name: string, scene: Scene);
  39144. getEffect(): Effect;
  39145. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39146. /**
  39147. * Binds the given world matrix to the active effect
  39148. *
  39149. * @param world the matrix to bind
  39150. */
  39151. bindOnlyWorldMatrix(world: Matrix): void;
  39152. /**
  39153. * Binds the given normal matrix to the active effect
  39154. *
  39155. * @param normalMatrix the matrix to bind
  39156. */
  39157. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39158. bind(world: Matrix, mesh?: Mesh): void;
  39159. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39160. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39161. }
  39162. }
  39163. declare module BABYLON {
  39164. /**
  39165. * This groups all the flags used to control the materials channel.
  39166. */
  39167. export class MaterialFlags {
  39168. private static _DiffuseTextureEnabled;
  39169. /**
  39170. * Are diffuse textures enabled in the application.
  39171. */
  39172. static DiffuseTextureEnabled: boolean;
  39173. private static _AmbientTextureEnabled;
  39174. /**
  39175. * Are ambient textures enabled in the application.
  39176. */
  39177. static AmbientTextureEnabled: boolean;
  39178. private static _OpacityTextureEnabled;
  39179. /**
  39180. * Are opacity textures enabled in the application.
  39181. */
  39182. static OpacityTextureEnabled: boolean;
  39183. private static _ReflectionTextureEnabled;
  39184. /**
  39185. * Are reflection textures enabled in the application.
  39186. */
  39187. static ReflectionTextureEnabled: boolean;
  39188. private static _EmissiveTextureEnabled;
  39189. /**
  39190. * Are emissive textures enabled in the application.
  39191. */
  39192. static EmissiveTextureEnabled: boolean;
  39193. private static _SpecularTextureEnabled;
  39194. /**
  39195. * Are specular textures enabled in the application.
  39196. */
  39197. static SpecularTextureEnabled: boolean;
  39198. private static _BumpTextureEnabled;
  39199. /**
  39200. * Are bump textures enabled in the application.
  39201. */
  39202. static BumpTextureEnabled: boolean;
  39203. private static _LightmapTextureEnabled;
  39204. /**
  39205. * Are lightmap textures enabled in the application.
  39206. */
  39207. static LightmapTextureEnabled: boolean;
  39208. private static _RefractionTextureEnabled;
  39209. /**
  39210. * Are refraction textures enabled in the application.
  39211. */
  39212. static RefractionTextureEnabled: boolean;
  39213. private static _ColorGradingTextureEnabled;
  39214. /**
  39215. * Are color grading textures enabled in the application.
  39216. */
  39217. static ColorGradingTextureEnabled: boolean;
  39218. private static _FresnelEnabled;
  39219. /**
  39220. * Are fresnels enabled in the application.
  39221. */
  39222. static FresnelEnabled: boolean;
  39223. private static _ClearCoatTextureEnabled;
  39224. /**
  39225. * Are clear coat textures enabled in the application.
  39226. */
  39227. static ClearCoatTextureEnabled: boolean;
  39228. private static _ClearCoatBumpTextureEnabled;
  39229. /**
  39230. * Are clear coat bump textures enabled in the application.
  39231. */
  39232. static ClearCoatBumpTextureEnabled: boolean;
  39233. private static _ClearCoatTintTextureEnabled;
  39234. /**
  39235. * Are clear coat tint textures enabled in the application.
  39236. */
  39237. static ClearCoatTintTextureEnabled: boolean;
  39238. private static _SheenTextureEnabled;
  39239. /**
  39240. * Are sheen textures enabled in the application.
  39241. */
  39242. static SheenTextureEnabled: boolean;
  39243. private static _AnisotropicTextureEnabled;
  39244. /**
  39245. * Are anisotropic textures enabled in the application.
  39246. */
  39247. static AnisotropicTextureEnabled: boolean;
  39248. private static _ThicknessTextureEnabled;
  39249. /**
  39250. * Are thickness textures enabled in the application.
  39251. */
  39252. static ThicknessTextureEnabled: boolean;
  39253. }
  39254. }
  39255. declare module BABYLON {
  39256. /** @hidden */
  39257. export var defaultFragmentDeclaration: {
  39258. name: string;
  39259. shader: string;
  39260. };
  39261. }
  39262. declare module BABYLON {
  39263. /** @hidden */
  39264. export var defaultUboDeclaration: {
  39265. name: string;
  39266. shader: string;
  39267. };
  39268. }
  39269. declare module BABYLON {
  39270. /** @hidden */
  39271. export var lightFragmentDeclaration: {
  39272. name: string;
  39273. shader: string;
  39274. };
  39275. }
  39276. declare module BABYLON {
  39277. /** @hidden */
  39278. export var lightUboDeclaration: {
  39279. name: string;
  39280. shader: string;
  39281. };
  39282. }
  39283. declare module BABYLON {
  39284. /** @hidden */
  39285. export var lightsFragmentFunctions: {
  39286. name: string;
  39287. shader: string;
  39288. };
  39289. }
  39290. declare module BABYLON {
  39291. /** @hidden */
  39292. export var shadowsFragmentFunctions: {
  39293. name: string;
  39294. shader: string;
  39295. };
  39296. }
  39297. declare module BABYLON {
  39298. /** @hidden */
  39299. export var fresnelFunction: {
  39300. name: string;
  39301. shader: string;
  39302. };
  39303. }
  39304. declare module BABYLON {
  39305. /** @hidden */
  39306. export var reflectionFunction: {
  39307. name: string;
  39308. shader: string;
  39309. };
  39310. }
  39311. declare module BABYLON {
  39312. /** @hidden */
  39313. export var bumpFragmentFunctions: {
  39314. name: string;
  39315. shader: string;
  39316. };
  39317. }
  39318. declare module BABYLON {
  39319. /** @hidden */
  39320. export var logDepthDeclaration: {
  39321. name: string;
  39322. shader: string;
  39323. };
  39324. }
  39325. declare module BABYLON {
  39326. /** @hidden */
  39327. export var bumpFragment: {
  39328. name: string;
  39329. shader: string;
  39330. };
  39331. }
  39332. declare module BABYLON {
  39333. /** @hidden */
  39334. export var depthPrePass: {
  39335. name: string;
  39336. shader: string;
  39337. };
  39338. }
  39339. declare module BABYLON {
  39340. /** @hidden */
  39341. export var lightFragment: {
  39342. name: string;
  39343. shader: string;
  39344. };
  39345. }
  39346. declare module BABYLON {
  39347. /** @hidden */
  39348. export var logDepthFragment: {
  39349. name: string;
  39350. shader: string;
  39351. };
  39352. }
  39353. declare module BABYLON {
  39354. /** @hidden */
  39355. export var defaultPixelShader: {
  39356. name: string;
  39357. shader: string;
  39358. };
  39359. }
  39360. declare module BABYLON {
  39361. /** @hidden */
  39362. export var defaultVertexDeclaration: {
  39363. name: string;
  39364. shader: string;
  39365. };
  39366. }
  39367. declare module BABYLON {
  39368. /** @hidden */
  39369. export var bumpVertexDeclaration: {
  39370. name: string;
  39371. shader: string;
  39372. };
  39373. }
  39374. declare module BABYLON {
  39375. /** @hidden */
  39376. export var bumpVertex: {
  39377. name: string;
  39378. shader: string;
  39379. };
  39380. }
  39381. declare module BABYLON {
  39382. /** @hidden */
  39383. export var fogVertex: {
  39384. name: string;
  39385. shader: string;
  39386. };
  39387. }
  39388. declare module BABYLON {
  39389. /** @hidden */
  39390. export var shadowsVertex: {
  39391. name: string;
  39392. shader: string;
  39393. };
  39394. }
  39395. declare module BABYLON {
  39396. /** @hidden */
  39397. export var pointCloudVertex: {
  39398. name: string;
  39399. shader: string;
  39400. };
  39401. }
  39402. declare module BABYLON {
  39403. /** @hidden */
  39404. export var logDepthVertex: {
  39405. name: string;
  39406. shader: string;
  39407. };
  39408. }
  39409. declare module BABYLON {
  39410. /** @hidden */
  39411. export var defaultVertexShader: {
  39412. name: string;
  39413. shader: string;
  39414. };
  39415. }
  39416. declare module BABYLON {
  39417. /** @hidden */
  39418. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39419. MAINUV1: boolean;
  39420. MAINUV2: boolean;
  39421. DIFFUSE: boolean;
  39422. DIFFUSEDIRECTUV: number;
  39423. AMBIENT: boolean;
  39424. AMBIENTDIRECTUV: number;
  39425. OPACITY: boolean;
  39426. OPACITYDIRECTUV: number;
  39427. OPACITYRGB: boolean;
  39428. REFLECTION: boolean;
  39429. EMISSIVE: boolean;
  39430. EMISSIVEDIRECTUV: number;
  39431. SPECULAR: boolean;
  39432. SPECULARDIRECTUV: number;
  39433. BUMP: boolean;
  39434. BUMPDIRECTUV: number;
  39435. PARALLAX: boolean;
  39436. PARALLAXOCCLUSION: boolean;
  39437. SPECULAROVERALPHA: boolean;
  39438. CLIPPLANE: boolean;
  39439. CLIPPLANE2: boolean;
  39440. CLIPPLANE3: boolean;
  39441. CLIPPLANE4: boolean;
  39442. ALPHATEST: boolean;
  39443. DEPTHPREPASS: boolean;
  39444. ALPHAFROMDIFFUSE: boolean;
  39445. POINTSIZE: boolean;
  39446. FOG: boolean;
  39447. SPECULARTERM: boolean;
  39448. DIFFUSEFRESNEL: boolean;
  39449. OPACITYFRESNEL: boolean;
  39450. REFLECTIONFRESNEL: boolean;
  39451. REFRACTIONFRESNEL: boolean;
  39452. EMISSIVEFRESNEL: boolean;
  39453. FRESNEL: boolean;
  39454. NORMAL: boolean;
  39455. UV1: boolean;
  39456. UV2: boolean;
  39457. VERTEXCOLOR: boolean;
  39458. VERTEXALPHA: boolean;
  39459. NUM_BONE_INFLUENCERS: number;
  39460. BonesPerMesh: number;
  39461. BONETEXTURE: boolean;
  39462. INSTANCES: boolean;
  39463. GLOSSINESS: boolean;
  39464. ROUGHNESS: boolean;
  39465. EMISSIVEASILLUMINATION: boolean;
  39466. LINKEMISSIVEWITHDIFFUSE: boolean;
  39467. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39468. LIGHTMAP: boolean;
  39469. LIGHTMAPDIRECTUV: number;
  39470. OBJECTSPACE_NORMALMAP: boolean;
  39471. USELIGHTMAPASSHADOWMAP: boolean;
  39472. REFLECTIONMAP_3D: boolean;
  39473. REFLECTIONMAP_SPHERICAL: boolean;
  39474. REFLECTIONMAP_PLANAR: boolean;
  39475. REFLECTIONMAP_CUBIC: boolean;
  39476. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39477. REFLECTIONMAP_PROJECTION: boolean;
  39478. REFLECTIONMAP_SKYBOX: boolean;
  39479. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39480. REFLECTIONMAP_EXPLICIT: boolean;
  39481. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39482. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39483. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39484. INVERTCUBICMAP: boolean;
  39485. LOGARITHMICDEPTH: boolean;
  39486. REFRACTION: boolean;
  39487. REFRACTIONMAP_3D: boolean;
  39488. REFLECTIONOVERALPHA: boolean;
  39489. TWOSIDEDLIGHTING: boolean;
  39490. SHADOWFLOAT: boolean;
  39491. MORPHTARGETS: boolean;
  39492. MORPHTARGETS_NORMAL: boolean;
  39493. MORPHTARGETS_TANGENT: boolean;
  39494. MORPHTARGETS_UV: boolean;
  39495. NUM_MORPH_INFLUENCERS: number;
  39496. NONUNIFORMSCALING: boolean;
  39497. PREMULTIPLYALPHA: boolean;
  39498. IMAGEPROCESSING: boolean;
  39499. VIGNETTE: boolean;
  39500. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39501. VIGNETTEBLENDMODEOPAQUE: boolean;
  39502. TONEMAPPING: boolean;
  39503. TONEMAPPING_ACES: boolean;
  39504. CONTRAST: boolean;
  39505. COLORCURVES: boolean;
  39506. COLORGRADING: boolean;
  39507. COLORGRADING3D: boolean;
  39508. SAMPLER3DGREENDEPTH: boolean;
  39509. SAMPLER3DBGRMAP: boolean;
  39510. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39511. MULTIVIEW: boolean;
  39512. /**
  39513. * If the reflection texture on this material is in linear color space
  39514. * @hidden
  39515. */
  39516. IS_REFLECTION_LINEAR: boolean;
  39517. /**
  39518. * If the refraction texture on this material is in linear color space
  39519. * @hidden
  39520. */
  39521. IS_REFRACTION_LINEAR: boolean;
  39522. EXPOSURE: boolean;
  39523. constructor();
  39524. setReflectionMode(modeToEnable: string): void;
  39525. }
  39526. /**
  39527. * This is the default material used in Babylon. It is the best trade off between quality
  39528. * and performances.
  39529. * @see http://doc.babylonjs.com/babylon101/materials
  39530. */
  39531. export class StandardMaterial extends PushMaterial {
  39532. private _diffuseTexture;
  39533. /**
  39534. * The basic texture of the material as viewed under a light.
  39535. */
  39536. diffuseTexture: Nullable<BaseTexture>;
  39537. private _ambientTexture;
  39538. /**
  39539. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39540. */
  39541. ambientTexture: Nullable<BaseTexture>;
  39542. private _opacityTexture;
  39543. /**
  39544. * Define the transparency of the material from a texture.
  39545. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39546. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39547. */
  39548. opacityTexture: Nullable<BaseTexture>;
  39549. private _reflectionTexture;
  39550. /**
  39551. * Define the texture used to display the reflection.
  39552. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39553. */
  39554. reflectionTexture: Nullable<BaseTexture>;
  39555. private _emissiveTexture;
  39556. /**
  39557. * Define texture of the material as if self lit.
  39558. * This will be mixed in the final result even in the absence of light.
  39559. */
  39560. emissiveTexture: Nullable<BaseTexture>;
  39561. private _specularTexture;
  39562. /**
  39563. * Define how the color and intensity of the highlight given by the light in the material.
  39564. */
  39565. specularTexture: Nullable<BaseTexture>;
  39566. private _bumpTexture;
  39567. /**
  39568. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39569. * 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.
  39570. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39571. */
  39572. bumpTexture: Nullable<BaseTexture>;
  39573. private _lightmapTexture;
  39574. /**
  39575. * Complex lighting can be computationally expensive to compute at runtime.
  39576. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39577. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39578. */
  39579. lightmapTexture: Nullable<BaseTexture>;
  39580. private _refractionTexture;
  39581. /**
  39582. * Define the texture used to display the refraction.
  39583. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39584. */
  39585. refractionTexture: Nullable<BaseTexture>;
  39586. /**
  39587. * The color of the material lit by the environmental background lighting.
  39588. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39589. */
  39590. ambientColor: Color3;
  39591. /**
  39592. * The basic color of the material as viewed under a light.
  39593. */
  39594. diffuseColor: Color3;
  39595. /**
  39596. * Define how the color and intensity of the highlight given by the light in the material.
  39597. */
  39598. specularColor: Color3;
  39599. /**
  39600. * Define the color of the material as if self lit.
  39601. * This will be mixed in the final result even in the absence of light.
  39602. */
  39603. emissiveColor: Color3;
  39604. /**
  39605. * Defines how sharp are the highlights in the material.
  39606. * The bigger the value the sharper giving a more glossy feeling to the result.
  39607. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39608. */
  39609. specularPower: number;
  39610. private _useAlphaFromDiffuseTexture;
  39611. /**
  39612. * Does the transparency come from the diffuse texture alpha channel.
  39613. */
  39614. useAlphaFromDiffuseTexture: boolean;
  39615. private _useEmissiveAsIllumination;
  39616. /**
  39617. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39618. */
  39619. useEmissiveAsIllumination: boolean;
  39620. private _linkEmissiveWithDiffuse;
  39621. /**
  39622. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39623. * the emissive level when the final color is close to one.
  39624. */
  39625. linkEmissiveWithDiffuse: boolean;
  39626. private _useSpecularOverAlpha;
  39627. /**
  39628. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39629. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39630. */
  39631. useSpecularOverAlpha: boolean;
  39632. private _useReflectionOverAlpha;
  39633. /**
  39634. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39635. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39636. */
  39637. useReflectionOverAlpha: boolean;
  39638. private _disableLighting;
  39639. /**
  39640. * Does lights from the scene impacts this material.
  39641. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39642. */
  39643. disableLighting: boolean;
  39644. private _useObjectSpaceNormalMap;
  39645. /**
  39646. * Allows using an object space normal map (instead of tangent space).
  39647. */
  39648. useObjectSpaceNormalMap: boolean;
  39649. private _useParallax;
  39650. /**
  39651. * Is parallax enabled or not.
  39652. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39653. */
  39654. useParallax: boolean;
  39655. private _useParallaxOcclusion;
  39656. /**
  39657. * Is parallax occlusion enabled or not.
  39658. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39659. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39660. */
  39661. useParallaxOcclusion: boolean;
  39662. /**
  39663. * 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.
  39664. */
  39665. parallaxScaleBias: number;
  39666. private _roughness;
  39667. /**
  39668. * Helps to define how blurry the reflections should appears in the material.
  39669. */
  39670. roughness: number;
  39671. /**
  39672. * In case of refraction, define the value of the index of refraction.
  39673. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39674. */
  39675. indexOfRefraction: number;
  39676. /**
  39677. * Invert the refraction texture alongside the y axis.
  39678. * It can be useful with procedural textures or probe for instance.
  39679. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39680. */
  39681. invertRefractionY: boolean;
  39682. /**
  39683. * Defines the alpha limits in alpha test mode.
  39684. */
  39685. alphaCutOff: number;
  39686. private _useLightmapAsShadowmap;
  39687. /**
  39688. * In case of light mapping, define whether the map contains light or shadow informations.
  39689. */
  39690. useLightmapAsShadowmap: boolean;
  39691. private _diffuseFresnelParameters;
  39692. /**
  39693. * Define the diffuse fresnel parameters of the material.
  39694. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39695. */
  39696. diffuseFresnelParameters: FresnelParameters;
  39697. private _opacityFresnelParameters;
  39698. /**
  39699. * Define the opacity fresnel parameters of the material.
  39700. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39701. */
  39702. opacityFresnelParameters: FresnelParameters;
  39703. private _reflectionFresnelParameters;
  39704. /**
  39705. * Define the reflection fresnel parameters of the material.
  39706. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39707. */
  39708. reflectionFresnelParameters: FresnelParameters;
  39709. private _refractionFresnelParameters;
  39710. /**
  39711. * Define the refraction fresnel parameters of the material.
  39712. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39713. */
  39714. refractionFresnelParameters: FresnelParameters;
  39715. private _emissiveFresnelParameters;
  39716. /**
  39717. * Define the emissive fresnel parameters of the material.
  39718. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39719. */
  39720. emissiveFresnelParameters: FresnelParameters;
  39721. private _useReflectionFresnelFromSpecular;
  39722. /**
  39723. * If true automatically deducts the fresnels values from the material specularity.
  39724. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39725. */
  39726. useReflectionFresnelFromSpecular: boolean;
  39727. private _useGlossinessFromSpecularMapAlpha;
  39728. /**
  39729. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39730. */
  39731. useGlossinessFromSpecularMapAlpha: boolean;
  39732. private _maxSimultaneousLights;
  39733. /**
  39734. * Defines the maximum number of lights that can be used in the material
  39735. */
  39736. maxSimultaneousLights: number;
  39737. private _invertNormalMapX;
  39738. /**
  39739. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39740. */
  39741. invertNormalMapX: boolean;
  39742. private _invertNormalMapY;
  39743. /**
  39744. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39745. */
  39746. invertNormalMapY: boolean;
  39747. private _twoSidedLighting;
  39748. /**
  39749. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39750. */
  39751. twoSidedLighting: boolean;
  39752. /**
  39753. * Default configuration related to image processing available in the standard Material.
  39754. */
  39755. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39756. /**
  39757. * Gets the image processing configuration used either in this material.
  39758. */
  39759. /**
  39760. * Sets the Default image processing configuration used either in the this material.
  39761. *
  39762. * If sets to null, the scene one is in use.
  39763. */
  39764. imageProcessingConfiguration: ImageProcessingConfiguration;
  39765. /**
  39766. * Keep track of the image processing observer to allow dispose and replace.
  39767. */
  39768. private _imageProcessingObserver;
  39769. /**
  39770. * Attaches a new image processing configuration to the Standard Material.
  39771. * @param configuration
  39772. */
  39773. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39774. /**
  39775. * Gets wether the color curves effect is enabled.
  39776. */
  39777. /**
  39778. * Sets wether the color curves effect is enabled.
  39779. */
  39780. cameraColorCurvesEnabled: boolean;
  39781. /**
  39782. * Gets wether the color grading effect is enabled.
  39783. */
  39784. /**
  39785. * Gets wether the color grading effect is enabled.
  39786. */
  39787. cameraColorGradingEnabled: boolean;
  39788. /**
  39789. * Gets wether tonemapping is enabled or not.
  39790. */
  39791. /**
  39792. * Sets wether tonemapping is enabled or not
  39793. */
  39794. cameraToneMappingEnabled: boolean;
  39795. /**
  39796. * The camera exposure used on this material.
  39797. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39798. * This corresponds to a photographic exposure.
  39799. */
  39800. /**
  39801. * The camera exposure used on this material.
  39802. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39803. * This corresponds to a photographic exposure.
  39804. */
  39805. cameraExposure: number;
  39806. /**
  39807. * Gets The camera contrast used on this material.
  39808. */
  39809. /**
  39810. * Sets The camera contrast used on this material.
  39811. */
  39812. cameraContrast: number;
  39813. /**
  39814. * Gets the Color Grading 2D Lookup Texture.
  39815. */
  39816. /**
  39817. * Sets the Color Grading 2D Lookup Texture.
  39818. */
  39819. cameraColorGradingTexture: Nullable<BaseTexture>;
  39820. /**
  39821. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39822. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39823. * 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;
  39824. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39825. */
  39826. /**
  39827. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39828. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39829. * 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;
  39830. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39831. */
  39832. cameraColorCurves: Nullable<ColorCurves>;
  39833. /**
  39834. * Custom callback helping to override the default shader used in the material.
  39835. */
  39836. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39837. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39838. protected _worldViewProjectionMatrix: Matrix;
  39839. protected _globalAmbientColor: Color3;
  39840. protected _useLogarithmicDepth: boolean;
  39841. /**
  39842. * Instantiates a new standard material.
  39843. * This is the default material used in Babylon. It is the best trade off between quality
  39844. * and performances.
  39845. * @see http://doc.babylonjs.com/babylon101/materials
  39846. * @param name Define the name of the material in the scene
  39847. * @param scene Define the scene the material belong to
  39848. */
  39849. constructor(name: string, scene: Scene);
  39850. /**
  39851. * Gets a boolean indicating that current material needs to register RTT
  39852. */
  39853. readonly hasRenderTargetTextures: boolean;
  39854. /**
  39855. * Gets the current class name of the material e.g. "StandardMaterial"
  39856. * Mainly use in serialization.
  39857. * @returns the class name
  39858. */
  39859. getClassName(): string;
  39860. /**
  39861. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39862. * You can try switching to logarithmic depth.
  39863. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39864. */
  39865. useLogarithmicDepth: boolean;
  39866. /**
  39867. * Specifies if the material will require alpha blending
  39868. * @returns a boolean specifying if alpha blending is needed
  39869. */
  39870. needAlphaBlending(): boolean;
  39871. /**
  39872. * Specifies if this material should be rendered in alpha test mode
  39873. * @returns a boolean specifying if an alpha test is needed.
  39874. */
  39875. needAlphaTesting(): boolean;
  39876. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39877. /**
  39878. * Get the texture used for alpha test purpose.
  39879. * @returns the diffuse texture in case of the standard material.
  39880. */
  39881. getAlphaTestTexture(): Nullable<BaseTexture>;
  39882. /**
  39883. * Get if the submesh is ready to be used and all its information available.
  39884. * Child classes can use it to update shaders
  39885. * @param mesh defines the mesh to check
  39886. * @param subMesh defines which submesh to check
  39887. * @param useInstances specifies that instances should be used
  39888. * @returns a boolean indicating that the submesh is ready or not
  39889. */
  39890. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39891. /**
  39892. * Builds the material UBO layouts.
  39893. * Used internally during the effect preparation.
  39894. */
  39895. buildUniformLayout(): void;
  39896. /**
  39897. * Unbinds the material from the mesh
  39898. */
  39899. unbind(): void;
  39900. /**
  39901. * Binds the submesh to this material by preparing the effect and shader to draw
  39902. * @param world defines the world transformation matrix
  39903. * @param mesh defines the mesh containing the submesh
  39904. * @param subMesh defines the submesh to bind the material to
  39905. */
  39906. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39907. /**
  39908. * Get the list of animatables in the material.
  39909. * @returns the list of animatables object used in the material
  39910. */
  39911. getAnimatables(): IAnimatable[];
  39912. /**
  39913. * Gets the active textures from the material
  39914. * @returns an array of textures
  39915. */
  39916. getActiveTextures(): BaseTexture[];
  39917. /**
  39918. * Specifies if the material uses a texture
  39919. * @param texture defines the texture to check against the material
  39920. * @returns a boolean specifying if the material uses the texture
  39921. */
  39922. hasTexture(texture: BaseTexture): boolean;
  39923. /**
  39924. * Disposes the material
  39925. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39926. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39927. */
  39928. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39929. /**
  39930. * Makes a duplicate of the material, and gives it a new name
  39931. * @param name defines the new name for the duplicated material
  39932. * @returns the cloned material
  39933. */
  39934. clone(name: string): StandardMaterial;
  39935. /**
  39936. * Serializes this material in a JSON representation
  39937. * @returns the serialized material object
  39938. */
  39939. serialize(): any;
  39940. /**
  39941. * Creates a standard material from parsed material data
  39942. * @param source defines the JSON representation of the material
  39943. * @param scene defines the hosting scene
  39944. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39945. * @returns a new standard material
  39946. */
  39947. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39948. /**
  39949. * Are diffuse textures enabled in the application.
  39950. */
  39951. static DiffuseTextureEnabled: boolean;
  39952. /**
  39953. * Are ambient textures enabled in the application.
  39954. */
  39955. static AmbientTextureEnabled: boolean;
  39956. /**
  39957. * Are opacity textures enabled in the application.
  39958. */
  39959. static OpacityTextureEnabled: boolean;
  39960. /**
  39961. * Are reflection textures enabled in the application.
  39962. */
  39963. static ReflectionTextureEnabled: boolean;
  39964. /**
  39965. * Are emissive textures enabled in the application.
  39966. */
  39967. static EmissiveTextureEnabled: boolean;
  39968. /**
  39969. * Are specular textures enabled in the application.
  39970. */
  39971. static SpecularTextureEnabled: boolean;
  39972. /**
  39973. * Are bump textures enabled in the application.
  39974. */
  39975. static BumpTextureEnabled: boolean;
  39976. /**
  39977. * Are lightmap textures enabled in the application.
  39978. */
  39979. static LightmapTextureEnabled: boolean;
  39980. /**
  39981. * Are refraction textures enabled in the application.
  39982. */
  39983. static RefractionTextureEnabled: boolean;
  39984. /**
  39985. * Are color grading textures enabled in the application.
  39986. */
  39987. static ColorGradingTextureEnabled: boolean;
  39988. /**
  39989. * Are fresnels enabled in the application.
  39990. */
  39991. static FresnelEnabled: boolean;
  39992. }
  39993. }
  39994. declare module BABYLON {
  39995. /**
  39996. * A class extending Texture allowing drawing on a texture
  39997. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39998. */
  39999. export class DynamicTexture extends Texture {
  40000. private _generateMipMaps;
  40001. private _canvas;
  40002. private _context;
  40003. private _engine;
  40004. /**
  40005. * Creates a DynamicTexture
  40006. * @param name defines the name of the texture
  40007. * @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
  40008. * @param scene defines the scene where you want the texture
  40009. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40010. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40011. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40012. */
  40013. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40014. /**
  40015. * Get the current class name of the texture useful for serialization or dynamic coding.
  40016. * @returns "DynamicTexture"
  40017. */
  40018. getClassName(): string;
  40019. /**
  40020. * Gets the current state of canRescale
  40021. */
  40022. readonly canRescale: boolean;
  40023. private _recreate;
  40024. /**
  40025. * Scales the texture
  40026. * @param ratio the scale factor to apply to both width and height
  40027. */
  40028. scale(ratio: number): void;
  40029. /**
  40030. * Resizes the texture
  40031. * @param width the new width
  40032. * @param height the new height
  40033. */
  40034. scaleTo(width: number, height: number): void;
  40035. /**
  40036. * Gets the context of the canvas used by the texture
  40037. * @returns the canvas context of the dynamic texture
  40038. */
  40039. getContext(): CanvasRenderingContext2D;
  40040. /**
  40041. * Clears the texture
  40042. */
  40043. clear(): void;
  40044. /**
  40045. * Updates the texture
  40046. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40047. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40048. */
  40049. update(invertY?: boolean, premulAlpha?: boolean): void;
  40050. /**
  40051. * Draws text onto the texture
  40052. * @param text defines the text to be drawn
  40053. * @param x defines the placement of the text from the left
  40054. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40055. * @param font defines the font to be used with font-style, font-size, font-name
  40056. * @param color defines the color used for the text
  40057. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40058. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40059. * @param update defines whether texture is immediately update (default is true)
  40060. */
  40061. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40062. /**
  40063. * Clones the texture
  40064. * @returns the clone of the texture.
  40065. */
  40066. clone(): DynamicTexture;
  40067. /**
  40068. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40069. * @returns a serialized dynamic texture object
  40070. */
  40071. serialize(): any;
  40072. /** @hidden */
  40073. _rebuild(): void;
  40074. }
  40075. }
  40076. declare module BABYLON {
  40077. /** @hidden */
  40078. export var imageProcessingPixelShader: {
  40079. name: string;
  40080. shader: string;
  40081. };
  40082. }
  40083. declare module BABYLON {
  40084. /**
  40085. * ImageProcessingPostProcess
  40086. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40087. */
  40088. export class ImageProcessingPostProcess extends PostProcess {
  40089. /**
  40090. * Default configuration related to image processing available in the PBR Material.
  40091. */
  40092. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40093. /**
  40094. * Gets the image processing configuration used either in this material.
  40095. */
  40096. /**
  40097. * Sets the Default image processing configuration used either in the this material.
  40098. *
  40099. * If sets to null, the scene one is in use.
  40100. */
  40101. imageProcessingConfiguration: ImageProcessingConfiguration;
  40102. /**
  40103. * Keep track of the image processing observer to allow dispose and replace.
  40104. */
  40105. private _imageProcessingObserver;
  40106. /**
  40107. * Attaches a new image processing configuration to the PBR Material.
  40108. * @param configuration
  40109. */
  40110. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40111. /**
  40112. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40113. */
  40114. /**
  40115. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40116. */
  40117. colorCurves: Nullable<ColorCurves>;
  40118. /**
  40119. * Gets wether the color curves effect is enabled.
  40120. */
  40121. /**
  40122. * Sets wether the color curves effect is enabled.
  40123. */
  40124. colorCurvesEnabled: boolean;
  40125. /**
  40126. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40127. */
  40128. /**
  40129. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40130. */
  40131. colorGradingTexture: Nullable<BaseTexture>;
  40132. /**
  40133. * Gets wether the color grading effect is enabled.
  40134. */
  40135. /**
  40136. * Gets wether the color grading effect is enabled.
  40137. */
  40138. colorGradingEnabled: boolean;
  40139. /**
  40140. * Gets exposure used in the effect.
  40141. */
  40142. /**
  40143. * Sets exposure used in the effect.
  40144. */
  40145. exposure: number;
  40146. /**
  40147. * Gets wether tonemapping is enabled or not.
  40148. */
  40149. /**
  40150. * Sets wether tonemapping is enabled or not
  40151. */
  40152. toneMappingEnabled: boolean;
  40153. /**
  40154. * Gets the type of tone mapping effect.
  40155. */
  40156. /**
  40157. * Sets the type of tone mapping effect.
  40158. */
  40159. toneMappingType: number;
  40160. /**
  40161. * Gets contrast used in the effect.
  40162. */
  40163. /**
  40164. * Sets contrast used in the effect.
  40165. */
  40166. contrast: number;
  40167. /**
  40168. * Gets Vignette stretch size.
  40169. */
  40170. /**
  40171. * Sets Vignette stretch size.
  40172. */
  40173. vignetteStretch: number;
  40174. /**
  40175. * Gets Vignette centre X Offset.
  40176. */
  40177. /**
  40178. * Sets Vignette centre X Offset.
  40179. */
  40180. vignetteCentreX: number;
  40181. /**
  40182. * Gets Vignette centre Y Offset.
  40183. */
  40184. /**
  40185. * Sets Vignette centre Y Offset.
  40186. */
  40187. vignetteCentreY: number;
  40188. /**
  40189. * Gets Vignette weight or intensity of the vignette effect.
  40190. */
  40191. /**
  40192. * Sets Vignette weight or intensity of the vignette effect.
  40193. */
  40194. vignetteWeight: number;
  40195. /**
  40196. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40197. * if vignetteEnabled is set to true.
  40198. */
  40199. /**
  40200. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40201. * if vignetteEnabled is set to true.
  40202. */
  40203. vignetteColor: Color4;
  40204. /**
  40205. * Gets Camera field of view used by the Vignette effect.
  40206. */
  40207. /**
  40208. * Sets Camera field of view used by the Vignette effect.
  40209. */
  40210. vignetteCameraFov: number;
  40211. /**
  40212. * Gets the vignette blend mode allowing different kind of effect.
  40213. */
  40214. /**
  40215. * Sets the vignette blend mode allowing different kind of effect.
  40216. */
  40217. vignetteBlendMode: number;
  40218. /**
  40219. * Gets wether the vignette effect is enabled.
  40220. */
  40221. /**
  40222. * Sets wether the vignette effect is enabled.
  40223. */
  40224. vignetteEnabled: boolean;
  40225. private _fromLinearSpace;
  40226. /**
  40227. * Gets wether the input of the processing is in Gamma or Linear Space.
  40228. */
  40229. /**
  40230. * Sets wether the input of the processing is in Gamma or Linear Space.
  40231. */
  40232. fromLinearSpace: boolean;
  40233. /**
  40234. * Defines cache preventing GC.
  40235. */
  40236. private _defines;
  40237. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40238. /**
  40239. * "ImageProcessingPostProcess"
  40240. * @returns "ImageProcessingPostProcess"
  40241. */
  40242. getClassName(): string;
  40243. protected _updateParameters(): void;
  40244. dispose(camera?: Camera): void;
  40245. }
  40246. }
  40247. declare module BABYLON {
  40248. /**
  40249. * Class containing static functions to help procedurally build meshes
  40250. */
  40251. export class GroundBuilder {
  40252. /**
  40253. * Creates a ground mesh
  40254. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40255. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40257. * @param name defines the name of the mesh
  40258. * @param options defines the options used to create the mesh
  40259. * @param scene defines the hosting scene
  40260. * @returns the ground mesh
  40261. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40262. */
  40263. static CreateGround(name: string, options: {
  40264. width?: number;
  40265. height?: number;
  40266. subdivisions?: number;
  40267. subdivisionsX?: number;
  40268. subdivisionsY?: number;
  40269. updatable?: boolean;
  40270. }, scene: any): Mesh;
  40271. /**
  40272. * Creates a tiled ground mesh
  40273. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40274. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40275. * * 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
  40276. * * 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
  40277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40278. * @param name defines the name of the mesh
  40279. * @param options defines the options used to create the mesh
  40280. * @param scene defines the hosting scene
  40281. * @returns the tiled ground mesh
  40282. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40283. */
  40284. static CreateTiledGround(name: string, options: {
  40285. xmin: number;
  40286. zmin: number;
  40287. xmax: number;
  40288. zmax: number;
  40289. subdivisions?: {
  40290. w: number;
  40291. h: number;
  40292. };
  40293. precision?: {
  40294. w: number;
  40295. h: number;
  40296. };
  40297. updatable?: boolean;
  40298. }, scene?: Nullable<Scene>): Mesh;
  40299. /**
  40300. * Creates a ground mesh from a height map
  40301. * * The parameter `url` sets the URL of the height map image resource.
  40302. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40303. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40304. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40305. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40306. * * 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.
  40307. * * 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).
  40308. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40310. * @param name defines the name of the mesh
  40311. * @param url defines the url to the height map
  40312. * @param options defines the options used to create the mesh
  40313. * @param scene defines the hosting scene
  40314. * @returns the ground mesh
  40315. * @see https://doc.babylonjs.com/babylon101/height_map
  40316. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40317. */
  40318. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40319. width?: number;
  40320. height?: number;
  40321. subdivisions?: number;
  40322. minHeight?: number;
  40323. maxHeight?: number;
  40324. colorFilter?: Color3;
  40325. alphaFilter?: number;
  40326. updatable?: boolean;
  40327. onReady?: (mesh: GroundMesh) => void;
  40328. }, scene?: Nullable<Scene>): GroundMesh;
  40329. }
  40330. }
  40331. declare module BABYLON {
  40332. /**
  40333. * Class containing static functions to help procedurally build meshes
  40334. */
  40335. export class TorusBuilder {
  40336. /**
  40337. * Creates a torus mesh
  40338. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40339. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40340. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40342. * * 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
  40343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40344. * @param name defines the name of the mesh
  40345. * @param options defines the options used to create the mesh
  40346. * @param scene defines the hosting scene
  40347. * @returns the torus mesh
  40348. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40349. */
  40350. static CreateTorus(name: string, options: {
  40351. diameter?: number;
  40352. thickness?: number;
  40353. tessellation?: number;
  40354. updatable?: boolean;
  40355. sideOrientation?: number;
  40356. frontUVs?: Vector4;
  40357. backUVs?: Vector4;
  40358. }, scene: any): Mesh;
  40359. }
  40360. }
  40361. declare module BABYLON {
  40362. /**
  40363. * Class containing static functions to help procedurally build meshes
  40364. */
  40365. export class CylinderBuilder {
  40366. /**
  40367. * Creates a cylinder or a cone mesh
  40368. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40369. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40370. * * 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.
  40371. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40372. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40373. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40374. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40375. * * 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).
  40376. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40377. * * 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).
  40378. * * 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
  40379. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40380. * * 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
  40381. * * 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.
  40382. * * If `enclose` is false, a ring surface is one element.
  40383. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40384. * * 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
  40385. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40386. * * 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
  40387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40388. * @param name defines the name of the mesh
  40389. * @param options defines the options used to create the mesh
  40390. * @param scene defines the hosting scene
  40391. * @returns the cylinder mesh
  40392. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40393. */
  40394. static CreateCylinder(name: string, options: {
  40395. height?: number;
  40396. diameterTop?: number;
  40397. diameterBottom?: number;
  40398. diameter?: number;
  40399. tessellation?: number;
  40400. subdivisions?: number;
  40401. arc?: number;
  40402. faceColors?: Color4[];
  40403. faceUV?: Vector4[];
  40404. updatable?: boolean;
  40405. hasRings?: boolean;
  40406. enclose?: boolean;
  40407. cap?: number;
  40408. sideOrientation?: number;
  40409. frontUVs?: Vector4;
  40410. backUVs?: Vector4;
  40411. }, scene: any): Mesh;
  40412. }
  40413. }
  40414. declare module BABYLON {
  40415. /**
  40416. * Options to modify the vr teleportation behavior.
  40417. */
  40418. export interface VRTeleportationOptions {
  40419. /**
  40420. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40421. */
  40422. floorMeshName?: string;
  40423. /**
  40424. * A list of meshes to be used as the teleportation floor. (default: empty)
  40425. */
  40426. floorMeshes?: Mesh[];
  40427. }
  40428. /**
  40429. * Options to modify the vr experience helper's behavior.
  40430. */
  40431. export interface VRExperienceHelperOptions extends WebVROptions {
  40432. /**
  40433. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40434. */
  40435. createDeviceOrientationCamera?: boolean;
  40436. /**
  40437. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40438. */
  40439. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40440. /**
  40441. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40442. */
  40443. laserToggle?: boolean;
  40444. /**
  40445. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40446. */
  40447. floorMeshes?: Mesh[];
  40448. /**
  40449. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40450. */
  40451. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40452. }
  40453. /**
  40454. * Event containing information after VR has been entered
  40455. */
  40456. export class OnAfterEnteringVRObservableEvent {
  40457. /**
  40458. * If entering vr was successful
  40459. */
  40460. success: boolean;
  40461. }
  40462. /**
  40463. * Helps to quickly add VR support to an existing scene.
  40464. * See http://doc.babylonjs.com/how_to/webvr_helper
  40465. */
  40466. export class VRExperienceHelper {
  40467. /** Options to modify the vr experience helper's behavior. */
  40468. webVROptions: VRExperienceHelperOptions;
  40469. private _scene;
  40470. private _position;
  40471. private _btnVR;
  40472. private _btnVRDisplayed;
  40473. private _webVRsupported;
  40474. private _webVRready;
  40475. private _webVRrequesting;
  40476. private _webVRpresenting;
  40477. private _hasEnteredVR;
  40478. private _fullscreenVRpresenting;
  40479. private _canvas;
  40480. private _webVRCamera;
  40481. private _vrDeviceOrientationCamera;
  40482. private _deviceOrientationCamera;
  40483. private _existingCamera;
  40484. private _onKeyDown;
  40485. private _onVrDisplayPresentChange;
  40486. private _onVRDisplayChanged;
  40487. private _onVRRequestPresentStart;
  40488. private _onVRRequestPresentComplete;
  40489. /**
  40490. * 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)
  40491. */
  40492. enableGazeEvenWhenNoPointerLock: boolean;
  40493. /**
  40494. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40495. */
  40496. exitVROnDoubleTap: boolean;
  40497. /**
  40498. * Observable raised right before entering VR.
  40499. */
  40500. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40501. /**
  40502. * Observable raised when entering VR has completed.
  40503. */
  40504. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40505. /**
  40506. * Observable raised when exiting VR.
  40507. */
  40508. onExitingVRObservable: Observable<VRExperienceHelper>;
  40509. /**
  40510. * Observable raised when controller mesh is loaded.
  40511. */
  40512. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40513. /** Return this.onEnteringVRObservable
  40514. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40515. */
  40516. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40517. /** Return this.onExitingVRObservable
  40518. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40519. */
  40520. readonly onExitingVR: Observable<VRExperienceHelper>;
  40521. /** Return this.onControllerMeshLoadedObservable
  40522. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40523. */
  40524. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40525. private _rayLength;
  40526. private _useCustomVRButton;
  40527. private _teleportationRequested;
  40528. private _teleportActive;
  40529. private _floorMeshName;
  40530. private _floorMeshesCollection;
  40531. private _rotationAllowed;
  40532. private _teleportBackwardsVector;
  40533. private _teleportationTarget;
  40534. private _isDefaultTeleportationTarget;
  40535. private _postProcessMove;
  40536. private _teleportationFillColor;
  40537. private _teleportationBorderColor;
  40538. private _rotationAngle;
  40539. private _haloCenter;
  40540. private _cameraGazer;
  40541. private _padSensibilityUp;
  40542. private _padSensibilityDown;
  40543. private _leftController;
  40544. private _rightController;
  40545. /**
  40546. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40547. */
  40548. onNewMeshSelected: Observable<AbstractMesh>;
  40549. /**
  40550. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40551. */
  40552. onNewMeshPicked: Observable<PickingInfo>;
  40553. private _circleEase;
  40554. /**
  40555. * Observable raised before camera teleportation
  40556. */
  40557. onBeforeCameraTeleport: Observable<Vector3>;
  40558. /**
  40559. * Observable raised after camera teleportation
  40560. */
  40561. onAfterCameraTeleport: Observable<Vector3>;
  40562. /**
  40563. * Observable raised when current selected mesh gets unselected
  40564. */
  40565. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40566. private _raySelectionPredicate;
  40567. /**
  40568. * To be optionaly changed by user to define custom ray selection
  40569. */
  40570. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40571. /**
  40572. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40573. */
  40574. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40575. /**
  40576. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40577. */
  40578. teleportationEnabled: boolean;
  40579. private _defaultHeight;
  40580. private _teleportationInitialized;
  40581. private _interactionsEnabled;
  40582. private _interactionsRequested;
  40583. private _displayGaze;
  40584. private _displayLaserPointer;
  40585. /**
  40586. * The mesh used to display where the user is going to teleport.
  40587. */
  40588. /**
  40589. * Sets the mesh to be used to display where the user is going to teleport.
  40590. */
  40591. teleportationTarget: Mesh;
  40592. /**
  40593. * 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
  40594. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40595. * See http://doc.babylonjs.com/resources/baking_transformations
  40596. */
  40597. gazeTrackerMesh: Mesh;
  40598. /**
  40599. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40600. */
  40601. updateGazeTrackerScale: boolean;
  40602. /**
  40603. * If the gaze trackers color should be updated when selecting meshes
  40604. */
  40605. updateGazeTrackerColor: boolean;
  40606. /**
  40607. * The gaze tracking mesh corresponding to the left controller
  40608. */
  40609. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40610. /**
  40611. * The gaze tracking mesh corresponding to the right controller
  40612. */
  40613. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40614. /**
  40615. * If the ray of the gaze should be displayed.
  40616. */
  40617. /**
  40618. * Sets if the ray of the gaze should be displayed.
  40619. */
  40620. displayGaze: boolean;
  40621. /**
  40622. * If the ray of the LaserPointer should be displayed.
  40623. */
  40624. /**
  40625. * Sets if the ray of the LaserPointer should be displayed.
  40626. */
  40627. displayLaserPointer: boolean;
  40628. /**
  40629. * The deviceOrientationCamera used as the camera when not in VR.
  40630. */
  40631. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40632. /**
  40633. * Based on the current WebVR support, returns the current VR camera used.
  40634. */
  40635. readonly currentVRCamera: Nullable<Camera>;
  40636. /**
  40637. * The webVRCamera which is used when in VR.
  40638. */
  40639. readonly webVRCamera: WebVRFreeCamera;
  40640. /**
  40641. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40642. */
  40643. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40644. /**
  40645. * The html button that is used to trigger entering into VR.
  40646. */
  40647. readonly vrButton: Nullable<HTMLButtonElement>;
  40648. private readonly _teleportationRequestInitiated;
  40649. /**
  40650. * Defines wether or not Pointer lock should be requested when switching to
  40651. * full screen.
  40652. */
  40653. requestPointerLockOnFullScreen: boolean;
  40654. /**
  40655. * Instantiates a VRExperienceHelper.
  40656. * Helps to quickly add VR support to an existing scene.
  40657. * @param scene The scene the VRExperienceHelper belongs to.
  40658. * @param webVROptions Options to modify the vr experience helper's behavior.
  40659. */
  40660. constructor(scene: Scene,
  40661. /** Options to modify the vr experience helper's behavior. */
  40662. webVROptions?: VRExperienceHelperOptions);
  40663. private _onDefaultMeshLoaded;
  40664. private _onResize;
  40665. private _onFullscreenChange;
  40666. /**
  40667. * Gets a value indicating if we are currently in VR mode.
  40668. */
  40669. readonly isInVRMode: boolean;
  40670. private onVrDisplayPresentChange;
  40671. private onVRDisplayChanged;
  40672. private moveButtonToBottomRight;
  40673. private displayVRButton;
  40674. private updateButtonVisibility;
  40675. private _cachedAngularSensibility;
  40676. /**
  40677. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40678. * Otherwise, will use the fullscreen API.
  40679. */
  40680. enterVR(): void;
  40681. /**
  40682. * Attempt to exit VR, or fullscreen.
  40683. */
  40684. exitVR(): void;
  40685. /**
  40686. * The position of the vr experience helper.
  40687. */
  40688. /**
  40689. * Sets the position of the vr experience helper.
  40690. */
  40691. position: Vector3;
  40692. /**
  40693. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40694. */
  40695. enableInteractions(): void;
  40696. private readonly _noControllerIsActive;
  40697. private beforeRender;
  40698. private _isTeleportationFloor;
  40699. /**
  40700. * Adds a floor mesh to be used for teleportation.
  40701. * @param floorMesh the mesh to be used for teleportation.
  40702. */
  40703. addFloorMesh(floorMesh: Mesh): void;
  40704. /**
  40705. * Removes a floor mesh from being used for teleportation.
  40706. * @param floorMesh the mesh to be removed.
  40707. */
  40708. removeFloorMesh(floorMesh: Mesh): void;
  40709. /**
  40710. * Enables interactions and teleportation using the VR controllers and gaze.
  40711. * @param vrTeleportationOptions options to modify teleportation behavior.
  40712. */
  40713. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40714. private _onNewGamepadConnected;
  40715. private _tryEnableInteractionOnController;
  40716. private _onNewGamepadDisconnected;
  40717. private _enableInteractionOnController;
  40718. private _checkTeleportWithRay;
  40719. private _checkRotate;
  40720. private _checkTeleportBackwards;
  40721. private _enableTeleportationOnController;
  40722. private _createTeleportationCircles;
  40723. private _displayTeleportationTarget;
  40724. private _hideTeleportationTarget;
  40725. private _rotateCamera;
  40726. private _moveTeleportationSelectorTo;
  40727. private _workingVector;
  40728. private _workingQuaternion;
  40729. private _workingMatrix;
  40730. /**
  40731. * Teleports the users feet to the desired location
  40732. * @param location The location where the user's feet should be placed
  40733. */
  40734. teleportCamera(location: Vector3): void;
  40735. private _convertNormalToDirectionOfRay;
  40736. private _castRayAndSelectObject;
  40737. private _notifySelectedMeshUnselected;
  40738. /**
  40739. * Sets the color of the laser ray from the vr controllers.
  40740. * @param color new color for the ray.
  40741. */
  40742. changeLaserColor(color: Color3): void;
  40743. /**
  40744. * Sets the color of the ray from the vr headsets gaze.
  40745. * @param color new color for the ray.
  40746. */
  40747. changeGazeColor(color: Color3): void;
  40748. /**
  40749. * Exits VR and disposes of the vr experience helper
  40750. */
  40751. dispose(): void;
  40752. /**
  40753. * Gets the name of the VRExperienceHelper class
  40754. * @returns "VRExperienceHelper"
  40755. */
  40756. getClassName(): string;
  40757. }
  40758. }
  40759. declare module BABYLON {
  40760. /**
  40761. * Manages an XRSession to work with Babylon's engine
  40762. * @see https://doc.babylonjs.com/how_to/webxr
  40763. */
  40764. export class WebXRSessionManager implements IDisposable {
  40765. private scene;
  40766. /**
  40767. * Fires every time a new xrFrame arrives which can be used to update the camera
  40768. */
  40769. onXRFrameObservable: Observable<any>;
  40770. /**
  40771. * Fires when the xr session is ended either by the device or manually done
  40772. */
  40773. onXRSessionEnded: Observable<any>;
  40774. /**
  40775. * Underlying xr session
  40776. */
  40777. session: XRSession;
  40778. /**
  40779. * Type of reference space used when creating the session
  40780. */
  40781. referenceSpace: XRReferenceSpace;
  40782. /** @hidden */
  40783. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40784. /**
  40785. * Current XR frame
  40786. */
  40787. currentFrame: Nullable<XRFrame>;
  40788. private _xrNavigator;
  40789. private baseLayer;
  40790. /**
  40791. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40792. * @param scene The scene which the session should be created for
  40793. */
  40794. constructor(scene: Scene);
  40795. /**
  40796. * Initializes the manager
  40797. * After initialization enterXR can be called to start an XR session
  40798. * @returns Promise which resolves after it is initialized
  40799. */
  40800. initializeAsync(): Promise<void>;
  40801. /**
  40802. * Initializes an xr session
  40803. * @param xrSessionMode mode to initialize
  40804. * @returns a promise which will resolve once the session has been initialized
  40805. */
  40806. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  40807. /**
  40808. * Sets the reference space on the xr session
  40809. * @param referenceSpace space to set
  40810. * @returns a promise that will resolve once the reference space has been set
  40811. */
  40812. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  40813. /**
  40814. * Updates the render state of the session
  40815. * @param state state to set
  40816. * @returns a promise that resolves once the render state has been updated
  40817. */
  40818. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  40819. /**
  40820. * Starts rendering to the xr layer
  40821. * @returns a promise that will resolve once rendering has started
  40822. */
  40823. startRenderingToXRAsync(): Promise<void>;
  40824. /**
  40825. * Stops the xrSession and restores the renderloop
  40826. * @returns Promise which resolves after it exits XR
  40827. */
  40828. exitXRAsync(): Promise<unknown>;
  40829. /**
  40830. * Checks if a session would be supported for the creation options specified
  40831. * @param sessionMode session mode to check if supported eg. immersive-vr
  40832. * @returns true if supported
  40833. */
  40834. supportsSessionAsync(sessionMode: XRSessionMode): any;
  40835. /**
  40836. * @hidden
  40837. * Converts the render layer of xrSession to a render target
  40838. * @param session session to create render target for
  40839. * @param scene scene the new render target should be created for
  40840. */
  40841. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  40842. /**
  40843. * Disposes of the session manager
  40844. */
  40845. dispose(): void;
  40846. }
  40847. }
  40848. declare module BABYLON {
  40849. /**
  40850. * WebXR Camera which holds the views for the xrSession
  40851. * @see https://doc.babylonjs.com/how_to/webxr
  40852. */
  40853. export class WebXRCamera extends FreeCamera {
  40854. private static _TmpMatrix;
  40855. /**
  40856. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40857. * @param name the name of the camera
  40858. * @param scene the scene to add the camera to
  40859. */
  40860. constructor(name: string, scene: Scene);
  40861. private _updateNumberOfRigCameras;
  40862. /** @hidden */
  40863. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40864. /**
  40865. * Updates the cameras position from the current pose information of the XR session
  40866. * @param xrSessionManager the session containing pose information
  40867. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40868. */
  40869. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40870. }
  40871. }
  40872. declare module BABYLON {
  40873. /**
  40874. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40875. */
  40876. export class WebXRManagedOutputCanvas implements IDisposable {
  40877. private helper;
  40878. private _canvas;
  40879. /**
  40880. * xrpresent context of the canvas which can be used to display/mirror xr content
  40881. */
  40882. canvasContext: WebGLRenderingContext;
  40883. /**
  40884. * xr layer for the canvas
  40885. */
  40886. xrLayer: Nullable<XRWebGLLayer>;
  40887. /**
  40888. * Initializes the xr layer for the session
  40889. * @param xrSession xr session
  40890. * @returns a promise that will resolve once the XR Layer has been created
  40891. */
  40892. initializeXRLayerAsync(xrSession: any): any;
  40893. /**
  40894. * Initializes the canvas to be added/removed upon entering/exiting xr
  40895. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40896. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40897. */
  40898. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40899. /**
  40900. * Disposes of the object
  40901. */
  40902. dispose(): void;
  40903. private _setManagedOutputCanvas;
  40904. private _addCanvas;
  40905. private _removeCanvas;
  40906. }
  40907. }
  40908. declare module BABYLON {
  40909. /**
  40910. * States of the webXR experience
  40911. */
  40912. export enum WebXRState {
  40913. /**
  40914. * Transitioning to being in XR mode
  40915. */
  40916. ENTERING_XR = 0,
  40917. /**
  40918. * Transitioning to non XR mode
  40919. */
  40920. EXITING_XR = 1,
  40921. /**
  40922. * In XR mode and presenting
  40923. */
  40924. IN_XR = 2,
  40925. /**
  40926. * Not entered XR mode
  40927. */
  40928. NOT_IN_XR = 3
  40929. }
  40930. /**
  40931. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  40932. * @see https://doc.babylonjs.com/how_to/webxr
  40933. */
  40934. export class WebXRExperienceHelper implements IDisposable {
  40935. private scene;
  40936. /**
  40937. * 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
  40938. */
  40939. container: AbstractMesh;
  40940. /**
  40941. * Camera used to render xr content
  40942. */
  40943. camera: WebXRCamera;
  40944. /**
  40945. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40946. */
  40947. state: WebXRState;
  40948. private _setState;
  40949. private static _TmpVector;
  40950. /**
  40951. * Fires when the state of the experience helper has changed
  40952. */
  40953. onStateChangedObservable: Observable<WebXRState>;
  40954. /** Session manager used to keep track of xr session */
  40955. sessionManager: WebXRSessionManager;
  40956. private _nonVRCamera;
  40957. private _originalSceneAutoClear;
  40958. private _supported;
  40959. /**
  40960. * Creates the experience helper
  40961. * @param scene the scene to attach the experience helper to
  40962. * @returns a promise for the experience helper
  40963. */
  40964. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40965. /**
  40966. * Creates a WebXRExperienceHelper
  40967. * @param scene The scene the helper should be created in
  40968. */
  40969. private constructor();
  40970. /**
  40971. * Exits XR mode and returns the scene to its original state
  40972. * @returns promise that resolves after xr mode has exited
  40973. */
  40974. exitXRAsync(): Promise<unknown>;
  40975. /**
  40976. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40977. * @param sessionCreationOptions options for the XR session
  40978. * @param referenceSpaceType frame of reference of the XR session
  40979. * @param outputCanvas the output canvas that will be used to enter XR mode
  40980. * @returns promise that resolves after xr mode has entered
  40981. */
  40982. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  40983. /**
  40984. * Updates the global position of the camera by moving the camera's container
  40985. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40986. * @param position The desired global position of the camera
  40987. */
  40988. setPositionOfCameraUsingContainer(position: Vector3): void;
  40989. /**
  40990. * Rotates the xr camera by rotating the camera's container around the camera's position
  40991. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40992. * @param rotation the desired quaternion rotation to apply to the camera
  40993. */
  40994. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40995. /**
  40996. * Disposes of the experience helper
  40997. */
  40998. dispose(): void;
  40999. }
  41000. }
  41001. declare module BABYLON {
  41002. /**
  41003. * Button which can be used to enter a different mode of XR
  41004. */
  41005. export class WebXREnterExitUIButton {
  41006. /** button element */
  41007. element: HTMLElement;
  41008. /** XR initialization options for the button */
  41009. sessionMode: XRSessionMode;
  41010. /** Reference space type */
  41011. referenceSpaceType: XRReferenceSpaceType;
  41012. /**
  41013. * Creates a WebXREnterExitUIButton
  41014. * @param element button element
  41015. * @param sessionMode XR initialization session mode
  41016. * @param referenceSpaceType the type of reference space to be used
  41017. */
  41018. constructor(
  41019. /** button element */
  41020. element: HTMLElement,
  41021. /** XR initialization options for the button */
  41022. sessionMode: XRSessionMode,
  41023. /** Reference space type */
  41024. referenceSpaceType: XRReferenceSpaceType);
  41025. /**
  41026. * Overwritable function which can be used to update the button's visuals when the state changes
  41027. * @param activeButton the current active button in the UI
  41028. */
  41029. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41030. }
  41031. /**
  41032. * Options to create the webXR UI
  41033. */
  41034. export class WebXREnterExitUIOptions {
  41035. /**
  41036. * Context to enter xr with
  41037. */
  41038. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41039. /**
  41040. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41041. */
  41042. customButtons?: Array<WebXREnterExitUIButton>;
  41043. }
  41044. /**
  41045. * UI to allow the user to enter/exit XR mode
  41046. */
  41047. export class WebXREnterExitUI implements IDisposable {
  41048. private scene;
  41049. private _overlay;
  41050. private _buttons;
  41051. private _activeButton;
  41052. /**
  41053. * Fired every time the active button is changed.
  41054. *
  41055. * When xr is entered via a button that launches xr that button will be the callback parameter
  41056. *
  41057. * When exiting xr the callback parameter will be null)
  41058. */
  41059. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41060. /**
  41061. * Creates UI to allow the user to enter/exit XR mode
  41062. * @param scene the scene to add the ui to
  41063. * @param helper the xr experience helper to enter/exit xr with
  41064. * @param options options to configure the UI
  41065. * @returns the created ui
  41066. */
  41067. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41068. private constructor();
  41069. private _updateButtons;
  41070. /**
  41071. * Disposes of the object
  41072. */
  41073. dispose(): void;
  41074. }
  41075. }
  41076. declare module BABYLON {
  41077. /**
  41078. * Represents an XR input
  41079. */
  41080. export class WebXRController {
  41081. private scene;
  41082. /** The underlying input source for the controller */
  41083. inputSource: XRInputSource;
  41084. private parentContainer;
  41085. /**
  41086. * 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
  41087. */
  41088. grip?: AbstractMesh;
  41089. /**
  41090. * Pointer which can be used to select objects or attach a visible laser to
  41091. */
  41092. pointer: AbstractMesh;
  41093. /**
  41094. * Event that fires when the controller is removed/disposed
  41095. */
  41096. onDisposeObservable: Observable<{}>;
  41097. private _tmpMatrix;
  41098. private _tmpQuaternion;
  41099. private _tmpVector;
  41100. /**
  41101. * Creates the controller
  41102. * @see https://doc.babylonjs.com/how_to/webxr
  41103. * @param scene the scene which the controller should be associated to
  41104. * @param inputSource the underlying input source for the controller
  41105. * @param parentContainer parent that the controller meshes should be children of
  41106. */
  41107. constructor(scene: Scene,
  41108. /** The underlying input source for the controller */
  41109. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41110. /**
  41111. * Updates the controller pose based on the given XRFrame
  41112. * @param xrFrame xr frame to update the pose with
  41113. * @param referenceSpace reference space to use
  41114. */
  41115. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41116. /**
  41117. * Gets a world space ray coming from the controller
  41118. * @param result the resulting ray
  41119. */
  41120. getWorldPointerRayToRef(result: Ray): void;
  41121. /**
  41122. * Disposes of the object
  41123. */
  41124. dispose(): void;
  41125. }
  41126. }
  41127. declare module BABYLON {
  41128. /**
  41129. * XR input used to track XR inputs such as controllers/rays
  41130. */
  41131. export class WebXRInput implements IDisposable {
  41132. /**
  41133. * Base experience the input listens to
  41134. */
  41135. baseExperience: WebXRExperienceHelper;
  41136. /**
  41137. * XR controllers being tracked
  41138. */
  41139. controllers: Array<WebXRController>;
  41140. private _frameObserver;
  41141. private _stateObserver;
  41142. /**
  41143. * Event when a controller has been connected/added
  41144. */
  41145. onControllerAddedObservable: Observable<WebXRController>;
  41146. /**
  41147. * Event when a controller has been removed/disconnected
  41148. */
  41149. onControllerRemovedObservable: Observable<WebXRController>;
  41150. /**
  41151. * Initializes the WebXRInput
  41152. * @param baseExperience experience helper which the input should be created for
  41153. */
  41154. constructor(
  41155. /**
  41156. * Base experience the input listens to
  41157. */
  41158. baseExperience: WebXRExperienceHelper);
  41159. private _onInputSourcesChange;
  41160. private _addAndRemoveControllers;
  41161. /**
  41162. * Disposes of the object
  41163. */
  41164. dispose(): void;
  41165. }
  41166. }
  41167. declare module BABYLON {
  41168. /**
  41169. * Enables teleportation
  41170. */
  41171. export class WebXRControllerTeleportation {
  41172. private _teleportationFillColor;
  41173. private _teleportationBorderColor;
  41174. private _tmpRay;
  41175. private _tmpVector;
  41176. /**
  41177. * Creates a WebXRControllerTeleportation
  41178. * @param input input manager to add teleportation to
  41179. * @param floorMeshes floormeshes which can be teleported to
  41180. */
  41181. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41182. }
  41183. }
  41184. declare module BABYLON {
  41185. /**
  41186. * Handles pointer input automatically for the pointer of XR controllers
  41187. */
  41188. export class WebXRControllerPointerSelection {
  41189. private static _idCounter;
  41190. private _tmpRay;
  41191. /**
  41192. * Creates a WebXRControllerPointerSelection
  41193. * @param input input manager to setup pointer selection
  41194. */
  41195. constructor(input: WebXRInput);
  41196. private _convertNormalToDirectionOfRay;
  41197. private _updatePointerDistance;
  41198. }
  41199. }
  41200. declare module BABYLON {
  41201. /**
  41202. * Class used to represent data loading progression
  41203. */
  41204. export class SceneLoaderProgressEvent {
  41205. /** defines if data length to load can be evaluated */
  41206. readonly lengthComputable: boolean;
  41207. /** defines the loaded data length */
  41208. readonly loaded: number;
  41209. /** defines the data length to load */
  41210. readonly total: number;
  41211. /**
  41212. * Create a new progress event
  41213. * @param lengthComputable defines if data length to load can be evaluated
  41214. * @param loaded defines the loaded data length
  41215. * @param total defines the data length to load
  41216. */
  41217. constructor(
  41218. /** defines if data length to load can be evaluated */
  41219. lengthComputable: boolean,
  41220. /** defines the loaded data length */
  41221. loaded: number,
  41222. /** defines the data length to load */
  41223. total: number);
  41224. /**
  41225. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41226. * @param event defines the source event
  41227. * @returns a new SceneLoaderProgressEvent
  41228. */
  41229. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41230. }
  41231. /**
  41232. * Interface used by SceneLoader plugins to define supported file extensions
  41233. */
  41234. export interface ISceneLoaderPluginExtensions {
  41235. /**
  41236. * Defines the list of supported extensions
  41237. */
  41238. [extension: string]: {
  41239. isBinary: boolean;
  41240. };
  41241. }
  41242. /**
  41243. * Interface used by SceneLoader plugin factory
  41244. */
  41245. export interface ISceneLoaderPluginFactory {
  41246. /**
  41247. * Defines the name of the factory
  41248. */
  41249. name: string;
  41250. /**
  41251. * Function called to create a new plugin
  41252. * @return the new plugin
  41253. */
  41254. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41255. /**
  41256. * Boolean indicating if the plugin can direct load specific data
  41257. */
  41258. canDirectLoad?: (data: string) => boolean;
  41259. }
  41260. /**
  41261. * Interface used to define a SceneLoader plugin
  41262. */
  41263. export interface ISceneLoaderPlugin {
  41264. /**
  41265. * The friendly name of this plugin.
  41266. */
  41267. name: string;
  41268. /**
  41269. * The file extensions supported by this plugin.
  41270. */
  41271. extensions: string | ISceneLoaderPluginExtensions;
  41272. /**
  41273. * Import meshes into a scene.
  41274. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41275. * @param scene The scene to import into
  41276. * @param data The data to import
  41277. * @param rootUrl The root url for scene and resources
  41278. * @param meshes The meshes array to import into
  41279. * @param particleSystems The particle systems array to import into
  41280. * @param skeletons The skeletons array to import into
  41281. * @param onError The callback when import fails
  41282. * @returns True if successful or false otherwise
  41283. */
  41284. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41285. /**
  41286. * Load into a scene.
  41287. * @param scene The scene to load into
  41288. * @param data The data to import
  41289. * @param rootUrl The root url for scene and resources
  41290. * @param onError The callback when import fails
  41291. * @returns true if successful or false otherwise
  41292. */
  41293. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41294. /**
  41295. * The callback that returns true if the data can be directly loaded.
  41296. */
  41297. canDirectLoad?: (data: string) => boolean;
  41298. /**
  41299. * The callback that allows custom handling of the root url based on the response url.
  41300. */
  41301. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41302. /**
  41303. * Load into an asset container.
  41304. * @param scene The scene to load into
  41305. * @param data The data to import
  41306. * @param rootUrl The root url for scene and resources
  41307. * @param onError The callback when import fails
  41308. * @returns The loaded asset container
  41309. */
  41310. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41311. }
  41312. /**
  41313. * Interface used to define an async SceneLoader plugin
  41314. */
  41315. export interface ISceneLoaderPluginAsync {
  41316. /**
  41317. * The friendly name of this plugin.
  41318. */
  41319. name: string;
  41320. /**
  41321. * The file extensions supported by this plugin.
  41322. */
  41323. extensions: string | ISceneLoaderPluginExtensions;
  41324. /**
  41325. * Import meshes into a scene.
  41326. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41327. * @param scene The scene to import into
  41328. * @param data The data to import
  41329. * @param rootUrl The root url for scene and resources
  41330. * @param onProgress The callback when the load progresses
  41331. * @param fileName Defines the name of the file to load
  41332. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41333. */
  41334. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41335. meshes: AbstractMesh[];
  41336. particleSystems: IParticleSystem[];
  41337. skeletons: Skeleton[];
  41338. animationGroups: AnimationGroup[];
  41339. }>;
  41340. /**
  41341. * Load into a scene.
  41342. * @param scene The scene to load into
  41343. * @param data The data to import
  41344. * @param rootUrl The root url for scene and resources
  41345. * @param onProgress The callback when the load progresses
  41346. * @param fileName Defines the name of the file to load
  41347. * @returns Nothing
  41348. */
  41349. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41350. /**
  41351. * The callback that returns true if the data can be directly loaded.
  41352. */
  41353. canDirectLoad?: (data: string) => boolean;
  41354. /**
  41355. * The callback that allows custom handling of the root url based on the response url.
  41356. */
  41357. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41358. /**
  41359. * Load into an asset container.
  41360. * @param scene The scene to load into
  41361. * @param data The data to import
  41362. * @param rootUrl The root url for scene and resources
  41363. * @param onProgress The callback when the load progresses
  41364. * @param fileName Defines the name of the file to load
  41365. * @returns The loaded asset container
  41366. */
  41367. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41368. }
  41369. /**
  41370. * Class used to load scene from various file formats using registered plugins
  41371. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41372. */
  41373. export class SceneLoader {
  41374. /**
  41375. * No logging while loading
  41376. */
  41377. static readonly NO_LOGGING: number;
  41378. /**
  41379. * Minimal logging while loading
  41380. */
  41381. static readonly MINIMAL_LOGGING: number;
  41382. /**
  41383. * Summary logging while loading
  41384. */
  41385. static readonly SUMMARY_LOGGING: number;
  41386. /**
  41387. * Detailled logging while loading
  41388. */
  41389. static readonly DETAILED_LOGGING: number;
  41390. /**
  41391. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41392. */
  41393. static ForceFullSceneLoadingForIncremental: boolean;
  41394. /**
  41395. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41396. */
  41397. static ShowLoadingScreen: boolean;
  41398. /**
  41399. * Defines the current logging level (while loading the scene)
  41400. * @ignorenaming
  41401. */
  41402. static loggingLevel: number;
  41403. /**
  41404. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41405. */
  41406. static CleanBoneMatrixWeights: boolean;
  41407. /**
  41408. * Event raised when a plugin is used to load a scene
  41409. */
  41410. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41411. private static _registeredPlugins;
  41412. private static _getDefaultPlugin;
  41413. private static _getPluginForExtension;
  41414. private static _getPluginForDirectLoad;
  41415. private static _getPluginForFilename;
  41416. private static _getDirectLoad;
  41417. private static _loadData;
  41418. private static _getFileInfo;
  41419. /**
  41420. * Gets a plugin that can load the given extension
  41421. * @param extension defines the extension to load
  41422. * @returns a plugin or null if none works
  41423. */
  41424. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41425. /**
  41426. * Gets a boolean indicating that the given extension can be loaded
  41427. * @param extension defines the extension to load
  41428. * @returns true if the extension is supported
  41429. */
  41430. static IsPluginForExtensionAvailable(extension: string): boolean;
  41431. /**
  41432. * Adds a new plugin to the list of registered plugins
  41433. * @param plugin defines the plugin to add
  41434. */
  41435. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41436. /**
  41437. * Import meshes into a scene
  41438. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41439. * @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)
  41440. * @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)
  41441. * @param scene the instance of BABYLON.Scene to append to
  41442. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41443. * @param onProgress a callback with a progress event for each file being loaded
  41444. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41445. * @param pluginExtension the extension used to determine the plugin
  41446. * @returns The loaded plugin
  41447. */
  41448. 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>;
  41449. /**
  41450. * Import meshes into a scene
  41451. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41452. * @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)
  41453. * @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)
  41454. * @param scene the instance of BABYLON.Scene to append to
  41455. * @param onProgress a callback with a progress event for each file being loaded
  41456. * @param pluginExtension the extension used to determine the plugin
  41457. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41458. */
  41459. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41460. meshes: AbstractMesh[];
  41461. particleSystems: IParticleSystem[];
  41462. skeletons: Skeleton[];
  41463. animationGroups: AnimationGroup[];
  41464. }>;
  41465. /**
  41466. * Load a scene
  41467. * @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)
  41468. * @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)
  41469. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41470. * @param onSuccess a callback with the scene when import succeeds
  41471. * @param onProgress a callback with a progress event for each file being loaded
  41472. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41473. * @param pluginExtension the extension used to determine the plugin
  41474. * @returns The loaded plugin
  41475. */
  41476. 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>;
  41477. /**
  41478. * Load a scene
  41479. * @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)
  41480. * @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)
  41481. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41482. * @param onProgress a callback with a progress event for each file being loaded
  41483. * @param pluginExtension the extension used to determine the plugin
  41484. * @returns The loaded scene
  41485. */
  41486. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41487. /**
  41488. * Append a scene
  41489. * @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)
  41490. * @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)
  41491. * @param scene is the instance of BABYLON.Scene to append to
  41492. * @param onSuccess a callback with the scene when import succeeds
  41493. * @param onProgress a callback with a progress event for each file being loaded
  41494. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41495. * @param pluginExtension the extension used to determine the plugin
  41496. * @returns The loaded plugin
  41497. */
  41498. 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>;
  41499. /**
  41500. * Append a scene
  41501. * @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)
  41502. * @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)
  41503. * @param scene is the instance of BABYLON.Scene to append to
  41504. * @param onProgress a callback with a progress event for each file being loaded
  41505. * @param pluginExtension the extension used to determine the plugin
  41506. * @returns The given scene
  41507. */
  41508. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41509. /**
  41510. * Load a scene into an asset container
  41511. * @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)
  41512. * @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)
  41513. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41514. * @param onSuccess a callback with the scene when import succeeds
  41515. * @param onProgress a callback with a progress event for each file being loaded
  41516. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41517. * @param pluginExtension the extension used to determine the plugin
  41518. * @returns The loaded plugin
  41519. */
  41520. 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>;
  41521. /**
  41522. * Load a scene into an asset container
  41523. * @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)
  41524. * @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)
  41525. * @param scene is the instance of Scene to append to
  41526. * @param onProgress a callback with a progress event for each file being loaded
  41527. * @param pluginExtension the extension used to determine the plugin
  41528. * @returns The loaded asset container
  41529. */
  41530. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41531. }
  41532. }
  41533. declare module BABYLON {
  41534. /**
  41535. * Generic Controller
  41536. */
  41537. export class GenericController extends WebVRController {
  41538. /**
  41539. * Base Url for the controller model.
  41540. */
  41541. static readonly MODEL_BASE_URL: string;
  41542. /**
  41543. * File name for the controller model.
  41544. */
  41545. static readonly MODEL_FILENAME: string;
  41546. /**
  41547. * Creates a new GenericController from a gamepad
  41548. * @param vrGamepad the gamepad that the controller should be created from
  41549. */
  41550. constructor(vrGamepad: any);
  41551. /**
  41552. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41553. * @param scene scene in which to add meshes
  41554. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41555. */
  41556. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41557. /**
  41558. * Called once for each button that changed state since the last frame
  41559. * @param buttonIdx Which button index changed
  41560. * @param state New state of the button
  41561. * @param changes Which properties on the state changed since last frame
  41562. */
  41563. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41564. }
  41565. }
  41566. declare module BABYLON {
  41567. /**
  41568. * Defines the WindowsMotionController object that the state of the windows motion controller
  41569. */
  41570. export class WindowsMotionController extends WebVRController {
  41571. /**
  41572. * The base url used to load the left and right controller models
  41573. */
  41574. static MODEL_BASE_URL: string;
  41575. /**
  41576. * The name of the left controller model file
  41577. */
  41578. static MODEL_LEFT_FILENAME: string;
  41579. /**
  41580. * The name of the right controller model file
  41581. */
  41582. static MODEL_RIGHT_FILENAME: string;
  41583. /**
  41584. * The controller name prefix for this controller type
  41585. */
  41586. static readonly GAMEPAD_ID_PREFIX: string;
  41587. /**
  41588. * The controller id pattern for this controller type
  41589. */
  41590. private static readonly GAMEPAD_ID_PATTERN;
  41591. private _loadedMeshInfo;
  41592. private readonly _mapping;
  41593. /**
  41594. * Fired when the trackpad on this controller is clicked
  41595. */
  41596. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41597. /**
  41598. * Fired when the trackpad on this controller is modified
  41599. */
  41600. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41601. /**
  41602. * The current x and y values of this controller's trackpad
  41603. */
  41604. trackpad: StickValues;
  41605. /**
  41606. * Creates a new WindowsMotionController from a gamepad
  41607. * @param vrGamepad the gamepad that the controller should be created from
  41608. */
  41609. constructor(vrGamepad: any);
  41610. /**
  41611. * Fired when the trigger on this controller is modified
  41612. */
  41613. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41614. /**
  41615. * Fired when the menu button on this controller is modified
  41616. */
  41617. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41618. /**
  41619. * Fired when the grip button on this controller is modified
  41620. */
  41621. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41622. /**
  41623. * Fired when the thumbstick button on this controller is modified
  41624. */
  41625. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41626. /**
  41627. * Fired when the touchpad button on this controller is modified
  41628. */
  41629. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41630. /**
  41631. * Fired when the touchpad values on this controller are modified
  41632. */
  41633. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41634. private _updateTrackpad;
  41635. /**
  41636. * Called once per frame by the engine.
  41637. */
  41638. update(): void;
  41639. /**
  41640. * Called once for each button that changed state since the last frame
  41641. * @param buttonIdx Which button index changed
  41642. * @param state New state of the button
  41643. * @param changes Which properties on the state changed since last frame
  41644. */
  41645. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41646. /**
  41647. * Moves the buttons on the controller mesh based on their current state
  41648. * @param buttonName the name of the button to move
  41649. * @param buttonValue the value of the button which determines the buttons new position
  41650. */
  41651. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41652. /**
  41653. * Moves the axis on the controller mesh based on its current state
  41654. * @param axis the index of the axis
  41655. * @param axisValue the value of the axis which determines the meshes new position
  41656. * @hidden
  41657. */
  41658. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41659. /**
  41660. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41661. * @param scene scene in which to add meshes
  41662. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41663. */
  41664. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41665. /**
  41666. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41667. * can be transformed by button presses and axes values, based on this._mapping.
  41668. *
  41669. * @param scene scene in which the meshes exist
  41670. * @param meshes list of meshes that make up the controller model to process
  41671. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41672. */
  41673. private processModel;
  41674. private createMeshInfo;
  41675. /**
  41676. * Gets the ray of the controller in the direction the controller is pointing
  41677. * @param length the length the resulting ray should be
  41678. * @returns a ray in the direction the controller is pointing
  41679. */
  41680. getForwardRay(length?: number): Ray;
  41681. /**
  41682. * Disposes of the controller
  41683. */
  41684. dispose(): void;
  41685. }
  41686. }
  41687. declare module BABYLON {
  41688. /**
  41689. * Oculus Touch Controller
  41690. */
  41691. export class OculusTouchController extends WebVRController {
  41692. /**
  41693. * Base Url for the controller model.
  41694. */
  41695. static MODEL_BASE_URL: string;
  41696. /**
  41697. * File name for the left controller model.
  41698. */
  41699. static MODEL_LEFT_FILENAME: string;
  41700. /**
  41701. * File name for the right controller model.
  41702. */
  41703. static MODEL_RIGHT_FILENAME: string;
  41704. /**
  41705. * Base Url for the Quest controller model.
  41706. */
  41707. static QUEST_MODEL_BASE_URL: string;
  41708. /**
  41709. * @hidden
  41710. * If the controllers are running on a device that needs the updated Quest controller models
  41711. */
  41712. static _IsQuest: boolean;
  41713. /**
  41714. * Fired when the secondary trigger on this controller is modified
  41715. */
  41716. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41717. /**
  41718. * Fired when the thumb rest on this controller is modified
  41719. */
  41720. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41721. /**
  41722. * Creates a new OculusTouchController from a gamepad
  41723. * @param vrGamepad the gamepad that the controller should be created from
  41724. */
  41725. constructor(vrGamepad: any);
  41726. /**
  41727. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41728. * @param scene scene in which to add meshes
  41729. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41730. */
  41731. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41732. /**
  41733. * Fired when the A button on this controller is modified
  41734. */
  41735. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41736. /**
  41737. * Fired when the B button on this controller is modified
  41738. */
  41739. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41740. /**
  41741. * Fired when the X button on this controller is modified
  41742. */
  41743. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41744. /**
  41745. * Fired when the Y button on this controller is modified
  41746. */
  41747. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41748. /**
  41749. * Called once for each button that changed state since the last frame
  41750. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41751. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41752. * 2) secondary trigger (same)
  41753. * 3) A (right) X (left), touch, pressed = value
  41754. * 4) B / Y
  41755. * 5) thumb rest
  41756. * @param buttonIdx Which button index changed
  41757. * @param state New state of the button
  41758. * @param changes Which properties on the state changed since last frame
  41759. */
  41760. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41761. }
  41762. }
  41763. declare module BABYLON {
  41764. /**
  41765. * Vive Controller
  41766. */
  41767. export class ViveController extends WebVRController {
  41768. /**
  41769. * Base Url for the controller model.
  41770. */
  41771. static MODEL_BASE_URL: string;
  41772. /**
  41773. * File name for the controller model.
  41774. */
  41775. static MODEL_FILENAME: string;
  41776. /**
  41777. * Creates a new ViveController from a gamepad
  41778. * @param vrGamepad the gamepad that the controller should be created from
  41779. */
  41780. constructor(vrGamepad: any);
  41781. /**
  41782. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41783. * @param scene scene in which to add meshes
  41784. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41785. */
  41786. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41787. /**
  41788. * Fired when the left button on this controller is modified
  41789. */
  41790. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41791. /**
  41792. * Fired when the right button on this controller is modified
  41793. */
  41794. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41795. /**
  41796. * Fired when the menu button on this controller is modified
  41797. */
  41798. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41799. /**
  41800. * Called once for each button that changed state since the last frame
  41801. * Vive mapping:
  41802. * 0: touchpad
  41803. * 1: trigger
  41804. * 2: left AND right buttons
  41805. * 3: menu button
  41806. * @param buttonIdx Which button index changed
  41807. * @param state New state of the button
  41808. * @param changes Which properties on the state changed since last frame
  41809. */
  41810. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41811. }
  41812. }
  41813. declare module BABYLON {
  41814. /**
  41815. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  41816. */
  41817. export class WebXRControllerModelLoader {
  41818. /**
  41819. * Creates the WebXRControllerModelLoader
  41820. * @param input xr input that creates the controllers
  41821. */
  41822. constructor(input: WebXRInput);
  41823. }
  41824. }
  41825. declare module BABYLON {
  41826. /**
  41827. * Contains an array of blocks representing the octree
  41828. */
  41829. export interface IOctreeContainer<T> {
  41830. /**
  41831. * Blocks within the octree
  41832. */
  41833. blocks: Array<OctreeBlock<T>>;
  41834. }
  41835. /**
  41836. * Class used to store a cell in an octree
  41837. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41838. */
  41839. export class OctreeBlock<T> {
  41840. /**
  41841. * Gets the content of the current block
  41842. */
  41843. entries: T[];
  41844. /**
  41845. * Gets the list of block children
  41846. */
  41847. blocks: Array<OctreeBlock<T>>;
  41848. private _depth;
  41849. private _maxDepth;
  41850. private _capacity;
  41851. private _minPoint;
  41852. private _maxPoint;
  41853. private _boundingVectors;
  41854. private _creationFunc;
  41855. /**
  41856. * Creates a new block
  41857. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41858. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41859. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41860. * @param depth defines the current depth of this block in the octree
  41861. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41862. * @param creationFunc defines a callback to call when an element is added to the block
  41863. */
  41864. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41865. /**
  41866. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41867. */
  41868. readonly capacity: number;
  41869. /**
  41870. * Gets the minimum vector (in world space) of the block's bounding box
  41871. */
  41872. readonly minPoint: Vector3;
  41873. /**
  41874. * Gets the maximum vector (in world space) of the block's bounding box
  41875. */
  41876. readonly maxPoint: Vector3;
  41877. /**
  41878. * Add a new element to this block
  41879. * @param entry defines the element to add
  41880. */
  41881. addEntry(entry: T): void;
  41882. /**
  41883. * Remove an element from this block
  41884. * @param entry defines the element to remove
  41885. */
  41886. removeEntry(entry: T): void;
  41887. /**
  41888. * Add an array of elements to this block
  41889. * @param entries defines the array of elements to add
  41890. */
  41891. addEntries(entries: T[]): void;
  41892. /**
  41893. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41894. * @param frustumPlanes defines the frustum planes to test
  41895. * @param selection defines the array to store current content if selection is positive
  41896. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41897. */
  41898. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41899. /**
  41900. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41901. * @param sphereCenter defines the bounding sphere center
  41902. * @param sphereRadius defines the bounding sphere radius
  41903. * @param selection defines the array to store current content if selection is positive
  41904. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41905. */
  41906. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41907. /**
  41908. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41909. * @param ray defines the ray to test with
  41910. * @param selection defines the array to store current content if selection is positive
  41911. */
  41912. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41913. /**
  41914. * Subdivide the content into child blocks (this block will then be empty)
  41915. */
  41916. createInnerBlocks(): void;
  41917. /**
  41918. * @hidden
  41919. */
  41920. 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;
  41921. }
  41922. }
  41923. declare module BABYLON {
  41924. /**
  41925. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41926. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41927. */
  41928. export class Octree<T> {
  41929. /** 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.) */
  41930. maxDepth: number;
  41931. /**
  41932. * Blocks within the octree containing objects
  41933. */
  41934. blocks: Array<OctreeBlock<T>>;
  41935. /**
  41936. * Content stored in the octree
  41937. */
  41938. dynamicContent: T[];
  41939. private _maxBlockCapacity;
  41940. private _selectionContent;
  41941. private _creationFunc;
  41942. /**
  41943. * Creates a octree
  41944. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41945. * @param creationFunc function to be used to instatiate the octree
  41946. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41947. * @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.)
  41948. */
  41949. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41950. /** 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.) */
  41951. maxDepth?: number);
  41952. /**
  41953. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41954. * @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);
  41955. * @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);
  41956. * @param entries meshes to be added to the octree blocks
  41957. */
  41958. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41959. /**
  41960. * Adds a mesh to the octree
  41961. * @param entry Mesh to add to the octree
  41962. */
  41963. addMesh(entry: T): void;
  41964. /**
  41965. * Remove an element from the octree
  41966. * @param entry defines the element to remove
  41967. */
  41968. removeMesh(entry: T): void;
  41969. /**
  41970. * Selects an array of meshes within the frustum
  41971. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41972. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41973. * @returns array of meshes within the frustum
  41974. */
  41975. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41976. /**
  41977. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41978. * @param sphereCenter defines the bounding sphere center
  41979. * @param sphereRadius defines the bounding sphere radius
  41980. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41981. * @returns an array of objects that intersect the sphere
  41982. */
  41983. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41984. /**
  41985. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41986. * @param ray defines the ray to test with
  41987. * @returns array of intersected objects
  41988. */
  41989. intersectsRay(ray: Ray): SmartArray<T>;
  41990. /**
  41991. * Adds a mesh into the octree block if it intersects the block
  41992. */
  41993. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41994. /**
  41995. * Adds a submesh into the octree block if it intersects the block
  41996. */
  41997. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41998. }
  41999. }
  42000. declare module BABYLON {
  42001. interface Scene {
  42002. /**
  42003. * @hidden
  42004. * Backing Filed
  42005. */
  42006. _selectionOctree: Octree<AbstractMesh>;
  42007. /**
  42008. * Gets the octree used to boost mesh selection (picking)
  42009. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42010. */
  42011. selectionOctree: Octree<AbstractMesh>;
  42012. /**
  42013. * Creates or updates the octree used to boost selection (picking)
  42014. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42015. * @param maxCapacity defines the maximum capacity per leaf
  42016. * @param maxDepth defines the maximum depth of the octree
  42017. * @returns an octree of AbstractMesh
  42018. */
  42019. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42020. }
  42021. interface AbstractMesh {
  42022. /**
  42023. * @hidden
  42024. * Backing Field
  42025. */
  42026. _submeshesOctree: Octree<SubMesh>;
  42027. /**
  42028. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42029. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42030. * @param maxCapacity defines the maximum size of each block (64 by default)
  42031. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42032. * @returns the new octree
  42033. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42034. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42035. */
  42036. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42037. }
  42038. /**
  42039. * Defines the octree scene component responsible to manage any octrees
  42040. * in a given scene.
  42041. */
  42042. export class OctreeSceneComponent {
  42043. /**
  42044. * The component name help to identify the component in the list of scene components.
  42045. */
  42046. readonly name: string;
  42047. /**
  42048. * The scene the component belongs to.
  42049. */
  42050. scene: Scene;
  42051. /**
  42052. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42053. */
  42054. readonly checksIsEnabled: boolean;
  42055. /**
  42056. * Creates a new instance of the component for the given scene
  42057. * @param scene Defines the scene to register the component in
  42058. */
  42059. constructor(scene: Scene);
  42060. /**
  42061. * Registers the component in a given scene
  42062. */
  42063. register(): void;
  42064. /**
  42065. * Return the list of active meshes
  42066. * @returns the list of active meshes
  42067. */
  42068. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42069. /**
  42070. * Return the list of active sub meshes
  42071. * @param mesh The mesh to get the candidates sub meshes from
  42072. * @returns the list of active sub meshes
  42073. */
  42074. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42075. private _tempRay;
  42076. /**
  42077. * Return the list of sub meshes intersecting with a given local ray
  42078. * @param mesh defines the mesh to find the submesh for
  42079. * @param localRay defines the ray in local space
  42080. * @returns the list of intersecting sub meshes
  42081. */
  42082. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42083. /**
  42084. * Return the list of sub meshes colliding with a collider
  42085. * @param mesh defines the mesh to find the submesh for
  42086. * @param collider defines the collider to evaluate the collision against
  42087. * @returns the list of colliding sub meshes
  42088. */
  42089. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42090. /**
  42091. * Rebuilds the elements related to this component in case of
  42092. * context lost for instance.
  42093. */
  42094. rebuild(): void;
  42095. /**
  42096. * Disposes the component and the associated ressources.
  42097. */
  42098. dispose(): void;
  42099. }
  42100. }
  42101. declare module BABYLON {
  42102. /**
  42103. * Renders a layer on top of an existing scene
  42104. */
  42105. export class UtilityLayerRenderer implements IDisposable {
  42106. /** the original scene that will be rendered on top of */
  42107. originalScene: Scene;
  42108. private _pointerCaptures;
  42109. private _lastPointerEvents;
  42110. private static _DefaultUtilityLayer;
  42111. private static _DefaultKeepDepthUtilityLayer;
  42112. private _sharedGizmoLight;
  42113. private _renderCamera;
  42114. /**
  42115. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42116. * @returns the camera that is used when rendering the utility layer
  42117. */
  42118. getRenderCamera(): Nullable<Camera>;
  42119. /**
  42120. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42121. * @param cam the camera that should be used when rendering the utility layer
  42122. */
  42123. setRenderCamera(cam: Nullable<Camera>): void;
  42124. /**
  42125. * @hidden
  42126. * Light which used by gizmos to get light shading
  42127. */
  42128. _getSharedGizmoLight(): HemisphericLight;
  42129. /**
  42130. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42131. */
  42132. pickUtilitySceneFirst: boolean;
  42133. /**
  42134. * 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)
  42135. */
  42136. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42137. /**
  42138. * 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)
  42139. */
  42140. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42141. /**
  42142. * The scene that is rendered on top of the original scene
  42143. */
  42144. utilityLayerScene: Scene;
  42145. /**
  42146. * If the utility layer should automatically be rendered on top of existing scene
  42147. */
  42148. shouldRender: boolean;
  42149. /**
  42150. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42151. */
  42152. onlyCheckPointerDownEvents: boolean;
  42153. /**
  42154. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42155. */
  42156. processAllEvents: boolean;
  42157. /**
  42158. * Observable raised when the pointer move from the utility layer scene to the main scene
  42159. */
  42160. onPointerOutObservable: Observable<number>;
  42161. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42162. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42163. private _afterRenderObserver;
  42164. private _sceneDisposeObserver;
  42165. private _originalPointerObserver;
  42166. /**
  42167. * Instantiates a UtilityLayerRenderer
  42168. * @param originalScene the original scene that will be rendered on top of
  42169. * @param handleEvents boolean indicating if the utility layer should handle events
  42170. */
  42171. constructor(
  42172. /** the original scene that will be rendered on top of */
  42173. originalScene: Scene, handleEvents?: boolean);
  42174. private _notifyObservers;
  42175. /**
  42176. * Renders the utility layers scene on top of the original scene
  42177. */
  42178. render(): void;
  42179. /**
  42180. * Disposes of the renderer
  42181. */
  42182. dispose(): void;
  42183. private _updateCamera;
  42184. }
  42185. }
  42186. declare module BABYLON {
  42187. /**
  42188. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42189. */
  42190. export class Gizmo implements IDisposable {
  42191. /** The utility layer the gizmo will be added to */
  42192. gizmoLayer: UtilityLayerRenderer;
  42193. /**
  42194. * The root mesh of the gizmo
  42195. */
  42196. _rootMesh: Mesh;
  42197. private _attachedMesh;
  42198. /**
  42199. * Ratio for the scale of the gizmo (Default: 1)
  42200. */
  42201. scaleRatio: number;
  42202. /**
  42203. * If a custom mesh has been set (Default: false)
  42204. */
  42205. protected _customMeshSet: boolean;
  42206. /**
  42207. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42208. * * When set, interactions will be enabled
  42209. */
  42210. attachedMesh: Nullable<AbstractMesh>;
  42211. /**
  42212. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42213. * @param mesh The mesh to replace the default mesh of the gizmo
  42214. */
  42215. setCustomMesh(mesh: Mesh): void;
  42216. /**
  42217. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42218. */
  42219. updateGizmoRotationToMatchAttachedMesh: boolean;
  42220. /**
  42221. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42222. */
  42223. updateGizmoPositionToMatchAttachedMesh: boolean;
  42224. /**
  42225. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42226. */
  42227. updateScale: boolean;
  42228. protected _interactionsEnabled: boolean;
  42229. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42230. private _beforeRenderObserver;
  42231. private _tempVector;
  42232. /**
  42233. * Creates a gizmo
  42234. * @param gizmoLayer The utility layer the gizmo will be added to
  42235. */
  42236. constructor(
  42237. /** The utility layer the gizmo will be added to */
  42238. gizmoLayer?: UtilityLayerRenderer);
  42239. /**
  42240. * Updates the gizmo to match the attached mesh's position/rotation
  42241. */
  42242. protected _update(): void;
  42243. /**
  42244. * Disposes of the gizmo
  42245. */
  42246. dispose(): void;
  42247. }
  42248. }
  42249. declare module BABYLON {
  42250. /**
  42251. * Single plane drag gizmo
  42252. */
  42253. export class PlaneDragGizmo extends Gizmo {
  42254. /**
  42255. * Drag behavior responsible for the gizmos dragging interactions
  42256. */
  42257. dragBehavior: PointerDragBehavior;
  42258. private _pointerObserver;
  42259. /**
  42260. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42261. */
  42262. snapDistance: number;
  42263. /**
  42264. * Event that fires each time the gizmo snaps to a new location.
  42265. * * snapDistance is the the change in distance
  42266. */
  42267. onSnapObservable: Observable<{
  42268. snapDistance: number;
  42269. }>;
  42270. private _plane;
  42271. private _coloredMaterial;
  42272. private _hoverMaterial;
  42273. private _isEnabled;
  42274. private _parent;
  42275. /** @hidden */
  42276. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42277. /** @hidden */
  42278. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42279. /**
  42280. * Creates a PlaneDragGizmo
  42281. * @param gizmoLayer The utility layer the gizmo will be added to
  42282. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42283. * @param color The color of the gizmo
  42284. */
  42285. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42286. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42287. /**
  42288. * If the gizmo is enabled
  42289. */
  42290. isEnabled: boolean;
  42291. /**
  42292. * Disposes of the gizmo
  42293. */
  42294. dispose(): void;
  42295. }
  42296. }
  42297. declare module BABYLON {
  42298. /**
  42299. * Gizmo that enables dragging a mesh along 3 axis
  42300. */
  42301. export class PositionGizmo extends Gizmo {
  42302. /**
  42303. * Internal gizmo used for interactions on the x axis
  42304. */
  42305. xGizmo: AxisDragGizmo;
  42306. /**
  42307. * Internal gizmo used for interactions on the y axis
  42308. */
  42309. yGizmo: AxisDragGizmo;
  42310. /**
  42311. * Internal gizmo used for interactions on the z axis
  42312. */
  42313. zGizmo: AxisDragGizmo;
  42314. /**
  42315. * Internal gizmo used for interactions on the yz plane
  42316. */
  42317. xPlaneGizmo: PlaneDragGizmo;
  42318. /**
  42319. * Internal gizmo used for interactions on the xz plane
  42320. */
  42321. yPlaneGizmo: PlaneDragGizmo;
  42322. /**
  42323. * Internal gizmo used for interactions on the xy plane
  42324. */
  42325. zPlaneGizmo: PlaneDragGizmo;
  42326. /**
  42327. * private variables
  42328. */
  42329. private _meshAttached;
  42330. private _updateGizmoRotationToMatchAttachedMesh;
  42331. private _snapDistance;
  42332. private _scaleRatio;
  42333. /** Fires an event when any of it's sub gizmos are dragged */
  42334. onDragStartObservable: Observable<unknown>;
  42335. /** Fires an event when any of it's sub gizmos are released from dragging */
  42336. onDragEndObservable: Observable<unknown>;
  42337. /**
  42338. * If set to true, planar drag is enabled
  42339. */
  42340. private _planarGizmoEnabled;
  42341. attachedMesh: Nullable<AbstractMesh>;
  42342. /**
  42343. * Creates a PositionGizmo
  42344. * @param gizmoLayer The utility layer the gizmo will be added to
  42345. */
  42346. constructor(gizmoLayer?: UtilityLayerRenderer);
  42347. /**
  42348. * If the planar drag gizmo is enabled
  42349. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42350. */
  42351. planarGizmoEnabled: boolean;
  42352. updateGizmoRotationToMatchAttachedMesh: boolean;
  42353. /**
  42354. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42355. */
  42356. snapDistance: number;
  42357. /**
  42358. * Ratio for the scale of the gizmo (Default: 1)
  42359. */
  42360. scaleRatio: number;
  42361. /**
  42362. * Disposes of the gizmo
  42363. */
  42364. dispose(): void;
  42365. /**
  42366. * CustomMeshes are not supported by this gizmo
  42367. * @param mesh The mesh to replace the default mesh of the gizmo
  42368. */
  42369. setCustomMesh(mesh: Mesh): void;
  42370. }
  42371. }
  42372. declare module BABYLON {
  42373. /**
  42374. * Single axis drag gizmo
  42375. */
  42376. export class AxisDragGizmo extends Gizmo {
  42377. /**
  42378. * Drag behavior responsible for the gizmos dragging interactions
  42379. */
  42380. dragBehavior: PointerDragBehavior;
  42381. private _pointerObserver;
  42382. /**
  42383. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42384. */
  42385. snapDistance: number;
  42386. /**
  42387. * Event that fires each time the gizmo snaps to a new location.
  42388. * * snapDistance is the the change in distance
  42389. */
  42390. onSnapObservable: Observable<{
  42391. snapDistance: number;
  42392. }>;
  42393. private _isEnabled;
  42394. private _parent;
  42395. private _arrow;
  42396. private _coloredMaterial;
  42397. private _hoverMaterial;
  42398. /** @hidden */
  42399. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42400. /** @hidden */
  42401. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42402. /**
  42403. * Creates an AxisDragGizmo
  42404. * @param gizmoLayer The utility layer the gizmo will be added to
  42405. * @param dragAxis The axis which the gizmo will be able to drag on
  42406. * @param color The color of the gizmo
  42407. */
  42408. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42409. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42410. /**
  42411. * If the gizmo is enabled
  42412. */
  42413. isEnabled: boolean;
  42414. /**
  42415. * Disposes of the gizmo
  42416. */
  42417. dispose(): void;
  42418. }
  42419. }
  42420. declare module BABYLON.Debug {
  42421. /**
  42422. * The Axes viewer will show 3 axes in a specific point in space
  42423. */
  42424. export class AxesViewer {
  42425. private _xAxis;
  42426. private _yAxis;
  42427. private _zAxis;
  42428. private _scaleLinesFactor;
  42429. private _instanced;
  42430. /**
  42431. * Gets the hosting scene
  42432. */
  42433. scene: Scene;
  42434. /**
  42435. * Gets or sets a number used to scale line length
  42436. */
  42437. scaleLines: number;
  42438. /** Gets the node hierarchy used to render x-axis */
  42439. readonly xAxis: TransformNode;
  42440. /** Gets the node hierarchy used to render y-axis */
  42441. readonly yAxis: TransformNode;
  42442. /** Gets the node hierarchy used to render z-axis */
  42443. readonly zAxis: TransformNode;
  42444. /**
  42445. * Creates a new AxesViewer
  42446. * @param scene defines the hosting scene
  42447. * @param scaleLines defines a number used to scale line length (1 by default)
  42448. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42449. * @param xAxis defines the node hierarchy used to render the x-axis
  42450. * @param yAxis defines the node hierarchy used to render the y-axis
  42451. * @param zAxis defines the node hierarchy used to render the z-axis
  42452. */
  42453. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42454. /**
  42455. * Force the viewer to update
  42456. * @param position defines the position of the viewer
  42457. * @param xaxis defines the x axis of the viewer
  42458. * @param yaxis defines the y axis of the viewer
  42459. * @param zaxis defines the z axis of the viewer
  42460. */
  42461. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42462. /**
  42463. * Creates an instance of this axes viewer.
  42464. * @returns a new axes viewer with instanced meshes
  42465. */
  42466. createInstance(): AxesViewer;
  42467. /** Releases resources */
  42468. dispose(): void;
  42469. private static _SetRenderingGroupId;
  42470. }
  42471. }
  42472. declare module BABYLON.Debug {
  42473. /**
  42474. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42475. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42476. */
  42477. export class BoneAxesViewer extends AxesViewer {
  42478. /**
  42479. * Gets or sets the target mesh where to display the axes viewer
  42480. */
  42481. mesh: Nullable<Mesh>;
  42482. /**
  42483. * Gets or sets the target bone where to display the axes viewer
  42484. */
  42485. bone: Nullable<Bone>;
  42486. /** Gets current position */
  42487. pos: Vector3;
  42488. /** Gets direction of X axis */
  42489. xaxis: Vector3;
  42490. /** Gets direction of Y axis */
  42491. yaxis: Vector3;
  42492. /** Gets direction of Z axis */
  42493. zaxis: Vector3;
  42494. /**
  42495. * Creates a new BoneAxesViewer
  42496. * @param scene defines the hosting scene
  42497. * @param bone defines the target bone
  42498. * @param mesh defines the target mesh
  42499. * @param scaleLines defines a scaling factor for line length (1 by default)
  42500. */
  42501. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42502. /**
  42503. * Force the viewer to update
  42504. */
  42505. update(): void;
  42506. /** Releases resources */
  42507. dispose(): void;
  42508. }
  42509. }
  42510. declare module BABYLON {
  42511. /**
  42512. * Interface used to define scene explorer extensibility option
  42513. */
  42514. export interface IExplorerExtensibilityOption {
  42515. /**
  42516. * Define the option label
  42517. */
  42518. label: string;
  42519. /**
  42520. * Defines the action to execute on click
  42521. */
  42522. action: (entity: any) => void;
  42523. }
  42524. /**
  42525. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42526. */
  42527. export interface IExplorerExtensibilityGroup {
  42528. /**
  42529. * Defines a predicate to test if a given type mut be extended
  42530. */
  42531. predicate: (entity: any) => boolean;
  42532. /**
  42533. * Gets the list of options added to a type
  42534. */
  42535. entries: IExplorerExtensibilityOption[];
  42536. }
  42537. /**
  42538. * Interface used to define the options to use to create the Inspector
  42539. */
  42540. export interface IInspectorOptions {
  42541. /**
  42542. * Display in overlay mode (default: false)
  42543. */
  42544. overlay?: boolean;
  42545. /**
  42546. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42547. */
  42548. globalRoot?: HTMLElement;
  42549. /**
  42550. * Display the Scene explorer
  42551. */
  42552. showExplorer?: boolean;
  42553. /**
  42554. * Display the property inspector
  42555. */
  42556. showInspector?: boolean;
  42557. /**
  42558. * Display in embed mode (both panes on the right)
  42559. */
  42560. embedMode?: boolean;
  42561. /**
  42562. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42563. */
  42564. handleResize?: boolean;
  42565. /**
  42566. * Allow the panes to popup (default: true)
  42567. */
  42568. enablePopup?: boolean;
  42569. /**
  42570. * Allow the panes to be closed by users (default: true)
  42571. */
  42572. enableClose?: boolean;
  42573. /**
  42574. * Optional list of extensibility entries
  42575. */
  42576. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42577. /**
  42578. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42579. */
  42580. inspectorURL?: string;
  42581. }
  42582. interface Scene {
  42583. /**
  42584. * @hidden
  42585. * Backing field
  42586. */
  42587. _debugLayer: DebugLayer;
  42588. /**
  42589. * Gets the debug layer (aka Inspector) associated with the scene
  42590. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42591. */
  42592. debugLayer: DebugLayer;
  42593. }
  42594. /**
  42595. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42596. * what is happening in your scene
  42597. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42598. */
  42599. export class DebugLayer {
  42600. /**
  42601. * Define the url to get the inspector script from.
  42602. * By default it uses the babylonjs CDN.
  42603. * @ignoreNaming
  42604. */
  42605. static InspectorURL: string;
  42606. private _scene;
  42607. private BJSINSPECTOR;
  42608. private _onPropertyChangedObservable?;
  42609. /**
  42610. * Observable triggered when a property is changed through the inspector.
  42611. */
  42612. readonly onPropertyChangedObservable: any;
  42613. /**
  42614. * Instantiates a new debug layer.
  42615. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42616. * what is happening in your scene
  42617. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42618. * @param scene Defines the scene to inspect
  42619. */
  42620. constructor(scene: Scene);
  42621. /** Creates the inspector window. */
  42622. private _createInspector;
  42623. /**
  42624. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42625. * @param entity defines the entity to select
  42626. * @param lineContainerTitle defines the specific block to highlight
  42627. */
  42628. select(entity: any, lineContainerTitle?: string): void;
  42629. /** Get the inspector from bundle or global */
  42630. private _getGlobalInspector;
  42631. /**
  42632. * Get if the inspector is visible or not.
  42633. * @returns true if visible otherwise, false
  42634. */
  42635. isVisible(): boolean;
  42636. /**
  42637. * Hide the inspector and close its window.
  42638. */
  42639. hide(): void;
  42640. /**
  42641. * Launch the debugLayer.
  42642. * @param config Define the configuration of the inspector
  42643. * @return a promise fulfilled when the debug layer is visible
  42644. */
  42645. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42646. }
  42647. }
  42648. declare module BABYLON {
  42649. /**
  42650. * Class containing static functions to help procedurally build meshes
  42651. */
  42652. export class BoxBuilder {
  42653. /**
  42654. * Creates a box mesh
  42655. * * The parameter `size` sets the size (float) of each box side (default 1)
  42656. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42657. * * 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)
  42658. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42660. * * 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
  42661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42662. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42663. * @param name defines the name of the mesh
  42664. * @param options defines the options used to create the mesh
  42665. * @param scene defines the hosting scene
  42666. * @returns the box mesh
  42667. */
  42668. static CreateBox(name: string, options: {
  42669. size?: number;
  42670. width?: number;
  42671. height?: number;
  42672. depth?: number;
  42673. faceUV?: Vector4[];
  42674. faceColors?: Color4[];
  42675. sideOrientation?: number;
  42676. frontUVs?: Vector4;
  42677. backUVs?: Vector4;
  42678. wrap?: boolean;
  42679. topBaseAt?: number;
  42680. bottomBaseAt?: number;
  42681. updatable?: boolean;
  42682. }, scene?: Nullable<Scene>): Mesh;
  42683. }
  42684. }
  42685. declare module BABYLON {
  42686. /**
  42687. * Class containing static functions to help procedurally build meshes
  42688. */
  42689. export class SphereBuilder {
  42690. /**
  42691. * Creates a sphere mesh
  42692. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42693. * * 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`)
  42694. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42695. * * 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
  42696. * * 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)
  42697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42698. * * 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
  42699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42700. * @param name defines the name of the mesh
  42701. * @param options defines the options used to create the mesh
  42702. * @param scene defines the hosting scene
  42703. * @returns the sphere mesh
  42704. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42705. */
  42706. static CreateSphere(name: string, options: {
  42707. segments?: number;
  42708. diameter?: number;
  42709. diameterX?: number;
  42710. diameterY?: number;
  42711. diameterZ?: number;
  42712. arc?: number;
  42713. slice?: number;
  42714. sideOrientation?: number;
  42715. frontUVs?: Vector4;
  42716. backUVs?: Vector4;
  42717. updatable?: boolean;
  42718. }, scene: any): Mesh;
  42719. }
  42720. }
  42721. declare module BABYLON.Debug {
  42722. /**
  42723. * Used to show the physics impostor around the specific mesh
  42724. */
  42725. export class PhysicsViewer {
  42726. /** @hidden */
  42727. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42728. /** @hidden */
  42729. protected _meshes: Array<Nullable<AbstractMesh>>;
  42730. /** @hidden */
  42731. protected _scene: Nullable<Scene>;
  42732. /** @hidden */
  42733. protected _numMeshes: number;
  42734. /** @hidden */
  42735. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42736. private _renderFunction;
  42737. private _utilityLayer;
  42738. private _debugBoxMesh;
  42739. private _debugSphereMesh;
  42740. private _debugCylinderMesh;
  42741. private _debugMaterial;
  42742. private _debugMeshMeshes;
  42743. /**
  42744. * Creates a new PhysicsViewer
  42745. * @param scene defines the hosting scene
  42746. */
  42747. constructor(scene: Scene);
  42748. /** @hidden */
  42749. protected _updateDebugMeshes(): void;
  42750. /**
  42751. * Renders a specified physic impostor
  42752. * @param impostor defines the impostor to render
  42753. * @param targetMesh defines the mesh represented by the impostor
  42754. * @returns the new debug mesh used to render the impostor
  42755. */
  42756. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42757. /**
  42758. * Hides a specified physic impostor
  42759. * @param impostor defines the impostor to hide
  42760. */
  42761. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42762. private _getDebugMaterial;
  42763. private _getDebugBoxMesh;
  42764. private _getDebugSphereMesh;
  42765. private _getDebugCylinderMesh;
  42766. private _getDebugMeshMesh;
  42767. private _getDebugMesh;
  42768. /** Releases all resources */
  42769. dispose(): void;
  42770. }
  42771. }
  42772. declare module BABYLON {
  42773. /**
  42774. * Class containing static functions to help procedurally build meshes
  42775. */
  42776. export class LinesBuilder {
  42777. /**
  42778. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42779. * * 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
  42780. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42781. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42782. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42783. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42784. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42785. * * 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
  42786. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42788. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42789. * @param name defines the name of the new line system
  42790. * @param options defines the options used to create the line system
  42791. * @param scene defines the hosting scene
  42792. * @returns a new line system mesh
  42793. */
  42794. static CreateLineSystem(name: string, options: {
  42795. lines: Vector3[][];
  42796. updatable?: boolean;
  42797. instance?: Nullable<LinesMesh>;
  42798. colors?: Nullable<Color4[][]>;
  42799. useVertexAlpha?: boolean;
  42800. }, scene: Nullable<Scene>): LinesMesh;
  42801. /**
  42802. * Creates a line mesh
  42803. * 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
  42804. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42805. * * The parameter `points` is an array successive Vector3
  42806. * * 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
  42807. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42808. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42809. * * When updating an instance, remember that only point positions can change, not the number of points
  42810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42811. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42812. * @param name defines the name of the new line system
  42813. * @param options defines the options used to create the line system
  42814. * @param scene defines the hosting scene
  42815. * @returns a new line mesh
  42816. */
  42817. static CreateLines(name: string, options: {
  42818. points: Vector3[];
  42819. updatable?: boolean;
  42820. instance?: Nullable<LinesMesh>;
  42821. colors?: Color4[];
  42822. useVertexAlpha?: boolean;
  42823. }, scene?: Nullable<Scene>): LinesMesh;
  42824. /**
  42825. * Creates a dashed line mesh
  42826. * * 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
  42827. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42828. * * The parameter `points` is an array successive Vector3
  42829. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42830. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42831. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42832. * * 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
  42833. * * When updating an instance, remember that only point positions can change, not the number of points
  42834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42835. * @param name defines the name of the mesh
  42836. * @param options defines the options used to create the mesh
  42837. * @param scene defines the hosting scene
  42838. * @returns the dashed line mesh
  42839. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42840. */
  42841. static CreateDashedLines(name: string, options: {
  42842. points: Vector3[];
  42843. dashSize?: number;
  42844. gapSize?: number;
  42845. dashNb?: number;
  42846. updatable?: boolean;
  42847. instance?: LinesMesh;
  42848. }, scene?: Nullable<Scene>): LinesMesh;
  42849. }
  42850. }
  42851. declare module BABYLON {
  42852. /**
  42853. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42854. * in order to better appreciate the issue one might have.
  42855. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42856. */
  42857. export class RayHelper {
  42858. /**
  42859. * Defines the ray we are currently tryin to visualize.
  42860. */
  42861. ray: Nullable<Ray>;
  42862. private _renderPoints;
  42863. private _renderLine;
  42864. private _renderFunction;
  42865. private _scene;
  42866. private _updateToMeshFunction;
  42867. private _attachedToMesh;
  42868. private _meshSpaceDirection;
  42869. private _meshSpaceOrigin;
  42870. /**
  42871. * Helper function to create a colored helper in a scene in one line.
  42872. * @param ray Defines the ray we are currently tryin to visualize
  42873. * @param scene Defines the scene the ray is used in
  42874. * @param color Defines the color we want to see the ray in
  42875. * @returns The newly created ray helper.
  42876. */
  42877. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42878. /**
  42879. * Instantiate a new ray helper.
  42880. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42881. * in order to better appreciate the issue one might have.
  42882. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42883. * @param ray Defines the ray we are currently tryin to visualize
  42884. */
  42885. constructor(ray: Ray);
  42886. /**
  42887. * Shows the ray we are willing to debug.
  42888. * @param scene Defines the scene the ray needs to be rendered in
  42889. * @param color Defines the color the ray needs to be rendered in
  42890. */
  42891. show(scene: Scene, color?: Color3): void;
  42892. /**
  42893. * Hides the ray we are debugging.
  42894. */
  42895. hide(): void;
  42896. private _render;
  42897. /**
  42898. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42899. * @param mesh Defines the mesh we want the helper attached to
  42900. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42901. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42902. * @param length Defines the length of the ray
  42903. */
  42904. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42905. /**
  42906. * Detach the ray helper from the mesh it has previously been attached to.
  42907. */
  42908. detachFromMesh(): void;
  42909. private _updateToMesh;
  42910. /**
  42911. * Dispose the helper and release its associated resources.
  42912. */
  42913. dispose(): void;
  42914. }
  42915. }
  42916. declare module BABYLON.Debug {
  42917. /**
  42918. * Class used to render a debug view of a given skeleton
  42919. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42920. */
  42921. export class SkeletonViewer {
  42922. /** defines the skeleton to render */
  42923. skeleton: Skeleton;
  42924. /** defines the mesh attached to the skeleton */
  42925. mesh: AbstractMesh;
  42926. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42927. autoUpdateBonesMatrices: boolean;
  42928. /** defines the rendering group id to use with the viewer */
  42929. renderingGroupId: number;
  42930. /** Gets or sets the color used to render the skeleton */
  42931. color: Color3;
  42932. private _scene;
  42933. private _debugLines;
  42934. private _debugMesh;
  42935. private _isEnabled;
  42936. private _renderFunction;
  42937. private _utilityLayer;
  42938. /**
  42939. * Returns the mesh used to render the bones
  42940. */
  42941. readonly debugMesh: Nullable<LinesMesh>;
  42942. /**
  42943. * Creates a new SkeletonViewer
  42944. * @param skeleton defines the skeleton to render
  42945. * @param mesh defines the mesh attached to the skeleton
  42946. * @param scene defines the hosting scene
  42947. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42948. * @param renderingGroupId defines the rendering group id to use with the viewer
  42949. */
  42950. constructor(
  42951. /** defines the skeleton to render */
  42952. skeleton: Skeleton,
  42953. /** defines the mesh attached to the skeleton */
  42954. mesh: AbstractMesh, scene: Scene,
  42955. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42956. autoUpdateBonesMatrices?: boolean,
  42957. /** defines the rendering group id to use with the viewer */
  42958. renderingGroupId?: number);
  42959. /** Gets or sets a boolean indicating if the viewer is enabled */
  42960. isEnabled: boolean;
  42961. private _getBonePosition;
  42962. private _getLinesForBonesWithLength;
  42963. private _getLinesForBonesNoLength;
  42964. /** Update the viewer to sync with current skeleton state */
  42965. update(): void;
  42966. /** Release associated resources */
  42967. dispose(): void;
  42968. }
  42969. }
  42970. declare module BABYLON {
  42971. /**
  42972. * Options to create the null engine
  42973. */
  42974. export class NullEngineOptions {
  42975. /**
  42976. * Render width (Default: 512)
  42977. */
  42978. renderWidth: number;
  42979. /**
  42980. * Render height (Default: 256)
  42981. */
  42982. renderHeight: number;
  42983. /**
  42984. * Texture size (Default: 512)
  42985. */
  42986. textureSize: number;
  42987. /**
  42988. * If delta time between frames should be constant
  42989. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42990. */
  42991. deterministicLockstep: boolean;
  42992. /**
  42993. * Maximum about of steps between frames (Default: 4)
  42994. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42995. */
  42996. lockstepMaxSteps: number;
  42997. }
  42998. /**
  42999. * The null engine class provides support for headless version of babylon.js.
  43000. * This can be used in server side scenario or for testing purposes
  43001. */
  43002. export class NullEngine extends Engine {
  43003. private _options;
  43004. /**
  43005. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43006. */
  43007. isDeterministicLockStep(): boolean;
  43008. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43009. getLockstepMaxSteps(): number;
  43010. /**
  43011. * Sets hardware scaling, used to save performance if needed
  43012. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43013. */
  43014. getHardwareScalingLevel(): number;
  43015. constructor(options?: NullEngineOptions);
  43016. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43017. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43018. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43019. getRenderWidth(useScreen?: boolean): number;
  43020. getRenderHeight(useScreen?: boolean): number;
  43021. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43022. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43023. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43024. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43025. bindSamplers(effect: Effect): void;
  43026. enableEffect(effect: Effect): void;
  43027. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43028. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43029. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43030. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43031. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43032. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43033. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43034. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43035. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43036. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43037. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43038. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43039. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43040. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43041. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43042. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43043. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43044. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43045. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43046. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43047. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43048. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43049. bindBuffers(vertexBuffers: {
  43050. [key: string]: VertexBuffer;
  43051. }, indexBuffer: DataBuffer, effect: Effect): void;
  43052. wipeCaches(bruteForce?: boolean): void;
  43053. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43054. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43055. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43056. /** @hidden */
  43057. _createTexture(): WebGLTexture;
  43058. /** @hidden */
  43059. _releaseTexture(texture: InternalTexture): void;
  43060. 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;
  43061. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43062. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43063. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43064. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43065. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43066. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43067. areAllEffectsReady(): boolean;
  43068. /**
  43069. * @hidden
  43070. * Get the current error code of the webGL context
  43071. * @returns the error code
  43072. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43073. */
  43074. getError(): number;
  43075. /** @hidden */
  43076. _getUnpackAlignement(): number;
  43077. /** @hidden */
  43078. _unpackFlipY(value: boolean): void;
  43079. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43080. /**
  43081. * Updates a dynamic vertex buffer.
  43082. * @param vertexBuffer the vertex buffer to update
  43083. * @param data the data used to update the vertex buffer
  43084. * @param byteOffset the byte offset of the data (optional)
  43085. * @param byteLength the byte length of the data (optional)
  43086. */
  43087. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43088. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43089. /** @hidden */
  43090. _bindTexture(channel: number, texture: InternalTexture): void;
  43091. /** @hidden */
  43092. _releaseBuffer(buffer: DataBuffer): boolean;
  43093. releaseEffects(): void;
  43094. displayLoadingUI(): void;
  43095. hideLoadingUI(): void;
  43096. /** @hidden */
  43097. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43098. /** @hidden */
  43099. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43100. /** @hidden */
  43101. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43102. /** @hidden */
  43103. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43104. }
  43105. }
  43106. declare module BABYLON {
  43107. /** @hidden */
  43108. export class _OcclusionDataStorage {
  43109. /** @hidden */
  43110. occlusionInternalRetryCounter: number;
  43111. /** @hidden */
  43112. isOcclusionQueryInProgress: boolean;
  43113. /** @hidden */
  43114. isOccluded: boolean;
  43115. /** @hidden */
  43116. occlusionRetryCount: number;
  43117. /** @hidden */
  43118. occlusionType: number;
  43119. /** @hidden */
  43120. occlusionQueryAlgorithmType: number;
  43121. }
  43122. interface Engine {
  43123. /**
  43124. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43125. * @return the new query
  43126. */
  43127. createQuery(): WebGLQuery;
  43128. /**
  43129. * Delete and release a webGL query
  43130. * @param query defines the query to delete
  43131. * @return the current engine
  43132. */
  43133. deleteQuery(query: WebGLQuery): Engine;
  43134. /**
  43135. * Check if a given query has resolved and got its value
  43136. * @param query defines the query to check
  43137. * @returns true if the query got its value
  43138. */
  43139. isQueryResultAvailable(query: WebGLQuery): boolean;
  43140. /**
  43141. * Gets the value of a given query
  43142. * @param query defines the query to check
  43143. * @returns the value of the query
  43144. */
  43145. getQueryResult(query: WebGLQuery): number;
  43146. /**
  43147. * Initiates an occlusion query
  43148. * @param algorithmType defines the algorithm to use
  43149. * @param query defines the query to use
  43150. * @returns the current engine
  43151. * @see http://doc.babylonjs.com/features/occlusionquery
  43152. */
  43153. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43154. /**
  43155. * Ends an occlusion query
  43156. * @see http://doc.babylonjs.com/features/occlusionquery
  43157. * @param algorithmType defines the algorithm to use
  43158. * @returns the current engine
  43159. */
  43160. endOcclusionQuery(algorithmType: number): Engine;
  43161. /**
  43162. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43163. * Please note that only one query can be issued at a time
  43164. * @returns a time token used to track the time span
  43165. */
  43166. startTimeQuery(): Nullable<_TimeToken>;
  43167. /**
  43168. * Ends a time query
  43169. * @param token defines the token used to measure the time span
  43170. * @returns the time spent (in ns)
  43171. */
  43172. endTimeQuery(token: _TimeToken): int;
  43173. /** @hidden */
  43174. _currentNonTimestampToken: Nullable<_TimeToken>;
  43175. /** @hidden */
  43176. _createTimeQuery(): WebGLQuery;
  43177. /** @hidden */
  43178. _deleteTimeQuery(query: WebGLQuery): void;
  43179. /** @hidden */
  43180. _getGlAlgorithmType(algorithmType: number): number;
  43181. /** @hidden */
  43182. _getTimeQueryResult(query: WebGLQuery): any;
  43183. /** @hidden */
  43184. _getTimeQueryAvailability(query: WebGLQuery): any;
  43185. }
  43186. interface AbstractMesh {
  43187. /**
  43188. * Backing filed
  43189. * @hidden
  43190. */
  43191. __occlusionDataStorage: _OcclusionDataStorage;
  43192. /**
  43193. * Access property
  43194. * @hidden
  43195. */
  43196. _occlusionDataStorage: _OcclusionDataStorage;
  43197. /**
  43198. * 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.
  43199. * The default value is -1 which means don't break the query and wait till the result
  43200. * @see http://doc.babylonjs.com/features/occlusionquery
  43201. */
  43202. occlusionRetryCount: number;
  43203. /**
  43204. * 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:
  43205. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43206. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43207. * * 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.
  43208. * @see http://doc.babylonjs.com/features/occlusionquery
  43209. */
  43210. occlusionType: number;
  43211. /**
  43212. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43213. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43214. * * 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.
  43215. * @see http://doc.babylonjs.com/features/occlusionquery
  43216. */
  43217. occlusionQueryAlgorithmType: number;
  43218. /**
  43219. * 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
  43220. * @see http://doc.babylonjs.com/features/occlusionquery
  43221. */
  43222. isOccluded: boolean;
  43223. /**
  43224. * Flag to check the progress status of the query
  43225. * @see http://doc.babylonjs.com/features/occlusionquery
  43226. */
  43227. isOcclusionQueryInProgress: boolean;
  43228. }
  43229. }
  43230. declare module BABYLON {
  43231. /** @hidden */
  43232. export var _forceTransformFeedbackToBundle: boolean;
  43233. interface Engine {
  43234. /**
  43235. * Creates a webGL transform feedback object
  43236. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43237. * @returns the webGL transform feedback object
  43238. */
  43239. createTransformFeedback(): WebGLTransformFeedback;
  43240. /**
  43241. * Delete a webGL transform feedback object
  43242. * @param value defines the webGL transform feedback object to delete
  43243. */
  43244. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43245. /**
  43246. * Bind a webGL transform feedback object to the webgl context
  43247. * @param value defines the webGL transform feedback object to bind
  43248. */
  43249. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43250. /**
  43251. * Begins a transform feedback operation
  43252. * @param usePoints defines if points or triangles must be used
  43253. */
  43254. beginTransformFeedback(usePoints: boolean): void;
  43255. /**
  43256. * Ends a transform feedback operation
  43257. */
  43258. endTransformFeedback(): void;
  43259. /**
  43260. * Specify the varyings to use with transform feedback
  43261. * @param program defines the associated webGL program
  43262. * @param value defines the list of strings representing the varying names
  43263. */
  43264. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43265. /**
  43266. * Bind a webGL buffer for a transform feedback operation
  43267. * @param value defines the webGL buffer to bind
  43268. */
  43269. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43270. }
  43271. }
  43272. declare module BABYLON {
  43273. /**
  43274. * Creation options of the multi render target texture.
  43275. */
  43276. export interface IMultiRenderTargetOptions {
  43277. /**
  43278. * Define if the texture needs to create mip maps after render.
  43279. */
  43280. generateMipMaps?: boolean;
  43281. /**
  43282. * Define the types of all the draw buffers we want to create
  43283. */
  43284. types?: number[];
  43285. /**
  43286. * Define the sampling modes of all the draw buffers we want to create
  43287. */
  43288. samplingModes?: number[];
  43289. /**
  43290. * Define if a depth buffer is required
  43291. */
  43292. generateDepthBuffer?: boolean;
  43293. /**
  43294. * Define if a stencil buffer is required
  43295. */
  43296. generateStencilBuffer?: boolean;
  43297. /**
  43298. * Define if a depth texture is required instead of a depth buffer
  43299. */
  43300. generateDepthTexture?: boolean;
  43301. /**
  43302. * Define the number of desired draw buffers
  43303. */
  43304. textureCount?: number;
  43305. /**
  43306. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43307. */
  43308. doNotChangeAspectRatio?: boolean;
  43309. /**
  43310. * Define the default type of the buffers we are creating
  43311. */
  43312. defaultType?: number;
  43313. }
  43314. /**
  43315. * A multi render target, like a render target provides the ability to render to a texture.
  43316. * Unlike the render target, it can render to several draw buffers in one draw.
  43317. * This is specially interesting in deferred rendering or for any effects requiring more than
  43318. * just one color from a single pass.
  43319. */
  43320. export class MultiRenderTarget extends RenderTargetTexture {
  43321. private _internalTextures;
  43322. private _textures;
  43323. private _multiRenderTargetOptions;
  43324. /**
  43325. * Get if draw buffers are currently supported by the used hardware and browser.
  43326. */
  43327. readonly isSupported: boolean;
  43328. /**
  43329. * Get the list of textures generated by the multi render target.
  43330. */
  43331. readonly textures: Texture[];
  43332. /**
  43333. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43334. */
  43335. readonly depthTexture: Texture;
  43336. /**
  43337. * Set the wrapping mode on U of all the textures we are rendering to.
  43338. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43339. */
  43340. wrapU: number;
  43341. /**
  43342. * Set the wrapping mode on V of all the textures we are rendering to.
  43343. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43344. */
  43345. wrapV: number;
  43346. /**
  43347. * Instantiate a new multi render target texture.
  43348. * A multi render target, like a render target provides the ability to render to a texture.
  43349. * Unlike the render target, it can render to several draw buffers in one draw.
  43350. * This is specially interesting in deferred rendering or for any effects requiring more than
  43351. * just one color from a single pass.
  43352. * @param name Define the name of the texture
  43353. * @param size Define the size of the buffers to render to
  43354. * @param count Define the number of target we are rendering into
  43355. * @param scene Define the scene the texture belongs to
  43356. * @param options Define the options used to create the multi render target
  43357. */
  43358. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43359. /** @hidden */
  43360. _rebuild(): void;
  43361. private _createInternalTextures;
  43362. private _createTextures;
  43363. /**
  43364. * Define the number of samples used if MSAA is enabled.
  43365. */
  43366. samples: number;
  43367. /**
  43368. * Resize all the textures in the multi render target.
  43369. * Be carrefull as it will recreate all the data in the new texture.
  43370. * @param size Define the new size
  43371. */
  43372. resize(size: any): void;
  43373. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43374. /**
  43375. * Dispose the render targets and their associated resources
  43376. */
  43377. dispose(): void;
  43378. /**
  43379. * Release all the underlying texture used as draw buffers.
  43380. */
  43381. releaseInternalTextures(): void;
  43382. }
  43383. }
  43384. declare module BABYLON {
  43385. interface Engine {
  43386. /**
  43387. * Unbind a list of render target textures from the webGL context
  43388. * This is used only when drawBuffer extension or webGL2 are active
  43389. * @param textures defines the render target textures to unbind
  43390. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43391. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43392. */
  43393. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43394. /**
  43395. * Create a multi render target texture
  43396. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43397. * @param size defines the size of the texture
  43398. * @param options defines the creation options
  43399. * @returns the cube texture as an InternalTexture
  43400. */
  43401. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43402. /**
  43403. * Update the sample count for a given multiple render target texture
  43404. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43405. * @param textures defines the textures to update
  43406. * @param samples defines the sample count to set
  43407. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43408. */
  43409. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43410. }
  43411. }
  43412. declare module BABYLON {
  43413. /**
  43414. * Gather the list of clipboard event types as constants.
  43415. */
  43416. export class ClipboardEventTypes {
  43417. /**
  43418. * The clipboard event is fired when a copy command is active (pressed).
  43419. */
  43420. static readonly COPY: number;
  43421. /**
  43422. * The clipboard event is fired when a cut command is active (pressed).
  43423. */
  43424. static readonly CUT: number;
  43425. /**
  43426. * The clipboard event is fired when a paste command is active (pressed).
  43427. */
  43428. static readonly PASTE: number;
  43429. }
  43430. /**
  43431. * This class is used to store clipboard related info for the onClipboardObservable event.
  43432. */
  43433. export class ClipboardInfo {
  43434. /**
  43435. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43436. */
  43437. type: number;
  43438. /**
  43439. * Defines the related dom event
  43440. */
  43441. event: ClipboardEvent;
  43442. /**
  43443. *Creates an instance of ClipboardInfo.
  43444. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43445. * @param event Defines the related dom event
  43446. */
  43447. constructor(
  43448. /**
  43449. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43450. */
  43451. type: number,
  43452. /**
  43453. * Defines the related dom event
  43454. */
  43455. event: ClipboardEvent);
  43456. /**
  43457. * Get the clipboard event's type from the keycode.
  43458. * @param keyCode Defines the keyCode for the current keyboard event.
  43459. * @return {number}
  43460. */
  43461. static GetTypeFromCharacter(keyCode: number): number;
  43462. }
  43463. }
  43464. declare module BABYLON {
  43465. /**
  43466. * Google Daydream controller
  43467. */
  43468. export class DaydreamController extends WebVRController {
  43469. /**
  43470. * Base Url for the controller model.
  43471. */
  43472. static MODEL_BASE_URL: string;
  43473. /**
  43474. * File name for the controller model.
  43475. */
  43476. static MODEL_FILENAME: string;
  43477. /**
  43478. * Gamepad Id prefix used to identify Daydream Controller.
  43479. */
  43480. static readonly GAMEPAD_ID_PREFIX: string;
  43481. /**
  43482. * Creates a new DaydreamController from a gamepad
  43483. * @param vrGamepad the gamepad that the controller should be created from
  43484. */
  43485. constructor(vrGamepad: any);
  43486. /**
  43487. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43488. * @param scene scene in which to add meshes
  43489. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43490. */
  43491. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43492. /**
  43493. * Called once for each button that changed state since the last frame
  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. * Gear VR Controller
  43504. */
  43505. export class GearVRController extends WebVRController {
  43506. /**
  43507. * Base Url for the controller model.
  43508. */
  43509. static MODEL_BASE_URL: string;
  43510. /**
  43511. * File name for the controller model.
  43512. */
  43513. static MODEL_FILENAME: string;
  43514. /**
  43515. * Gamepad Id prefix used to identify this controller.
  43516. */
  43517. static readonly GAMEPAD_ID_PREFIX: string;
  43518. private readonly _buttonIndexToObservableNameMap;
  43519. /**
  43520. * Creates a new GearVRController from a gamepad
  43521. * @param vrGamepad the gamepad that the controller should be created from
  43522. */
  43523. constructor(vrGamepad: any);
  43524. /**
  43525. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43526. * @param scene scene in which to add meshes
  43527. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43528. */
  43529. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43530. /**
  43531. * Called once for each button that changed state since the last frame
  43532. * @param buttonIdx Which button index changed
  43533. * @param state New state of the button
  43534. * @param changes Which properties on the state changed since last frame
  43535. */
  43536. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43537. }
  43538. }
  43539. declare module BABYLON {
  43540. /**
  43541. * Class containing static functions to help procedurally build meshes
  43542. */
  43543. export class PolyhedronBuilder {
  43544. /**
  43545. * Creates a polyhedron mesh
  43546. * * 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
  43547. * * The parameter `size` (positive float, default 1) sets the polygon size
  43548. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43549. * * 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`
  43550. * * 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
  43551. * * 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)`)
  43552. * * 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
  43553. * * 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
  43554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43555. * * 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
  43556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43557. * @param name defines the name of the mesh
  43558. * @param options defines the options used to create the mesh
  43559. * @param scene defines the hosting scene
  43560. * @returns the polyhedron mesh
  43561. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43562. */
  43563. static CreatePolyhedron(name: string, options: {
  43564. type?: number;
  43565. size?: number;
  43566. sizeX?: number;
  43567. sizeY?: number;
  43568. sizeZ?: number;
  43569. custom?: any;
  43570. faceUV?: Vector4[];
  43571. faceColors?: Color4[];
  43572. flat?: boolean;
  43573. updatable?: boolean;
  43574. sideOrientation?: number;
  43575. frontUVs?: Vector4;
  43576. backUVs?: Vector4;
  43577. }, scene?: Nullable<Scene>): Mesh;
  43578. }
  43579. }
  43580. declare module BABYLON {
  43581. /**
  43582. * Gizmo that enables scaling a mesh along 3 axis
  43583. */
  43584. export class ScaleGizmo extends Gizmo {
  43585. /**
  43586. * Internal gizmo used for interactions on the x axis
  43587. */
  43588. xGizmo: AxisScaleGizmo;
  43589. /**
  43590. * Internal gizmo used for interactions on the y axis
  43591. */
  43592. yGizmo: AxisScaleGizmo;
  43593. /**
  43594. * Internal gizmo used for interactions on the z axis
  43595. */
  43596. zGizmo: AxisScaleGizmo;
  43597. /**
  43598. * Internal gizmo used to scale all axis equally
  43599. */
  43600. uniformScaleGizmo: AxisScaleGizmo;
  43601. private _meshAttached;
  43602. private _updateGizmoRotationToMatchAttachedMesh;
  43603. private _snapDistance;
  43604. private _scaleRatio;
  43605. private _uniformScalingMesh;
  43606. private _octahedron;
  43607. /** Fires an event when any of it's sub gizmos are dragged */
  43608. onDragStartObservable: Observable<unknown>;
  43609. /** Fires an event when any of it's sub gizmos are released from dragging */
  43610. onDragEndObservable: Observable<unknown>;
  43611. attachedMesh: Nullable<AbstractMesh>;
  43612. /**
  43613. * Creates a ScaleGizmo
  43614. * @param gizmoLayer The utility layer the gizmo will be added to
  43615. */
  43616. constructor(gizmoLayer?: UtilityLayerRenderer);
  43617. updateGizmoRotationToMatchAttachedMesh: boolean;
  43618. /**
  43619. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43620. */
  43621. snapDistance: number;
  43622. /**
  43623. * Ratio for the scale of the gizmo (Default: 1)
  43624. */
  43625. scaleRatio: number;
  43626. /**
  43627. * Disposes of the gizmo
  43628. */
  43629. dispose(): void;
  43630. }
  43631. }
  43632. declare module BABYLON {
  43633. /**
  43634. * Single axis scale gizmo
  43635. */
  43636. export class AxisScaleGizmo extends Gizmo {
  43637. /**
  43638. * Drag behavior responsible for the gizmos dragging interactions
  43639. */
  43640. dragBehavior: PointerDragBehavior;
  43641. private _pointerObserver;
  43642. /**
  43643. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43644. */
  43645. snapDistance: number;
  43646. /**
  43647. * Event that fires each time the gizmo snaps to a new location.
  43648. * * snapDistance is the the change in distance
  43649. */
  43650. onSnapObservable: Observable<{
  43651. snapDistance: number;
  43652. }>;
  43653. /**
  43654. * If the scaling operation should be done on all axis (default: false)
  43655. */
  43656. uniformScaling: boolean;
  43657. private _isEnabled;
  43658. private _parent;
  43659. private _arrow;
  43660. private _coloredMaterial;
  43661. private _hoverMaterial;
  43662. /**
  43663. * Creates an AxisScaleGizmo
  43664. * @param gizmoLayer The utility layer the gizmo will be added to
  43665. * @param dragAxis The axis which the gizmo will be able to scale on
  43666. * @param color The color of the gizmo
  43667. */
  43668. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  43669. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43670. /**
  43671. * If the gizmo is enabled
  43672. */
  43673. isEnabled: boolean;
  43674. /**
  43675. * Disposes of the gizmo
  43676. */
  43677. dispose(): void;
  43678. /**
  43679. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43680. * @param mesh The mesh to replace the default mesh of the gizmo
  43681. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43682. */
  43683. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43684. }
  43685. }
  43686. declare module BABYLON {
  43687. /**
  43688. * Bounding box gizmo
  43689. */
  43690. export class BoundingBoxGizmo extends Gizmo {
  43691. private _lineBoundingBox;
  43692. private _rotateSpheresParent;
  43693. private _scaleBoxesParent;
  43694. private _boundingDimensions;
  43695. private _renderObserver;
  43696. private _pointerObserver;
  43697. private _scaleDragSpeed;
  43698. private _tmpQuaternion;
  43699. private _tmpVector;
  43700. private _tmpRotationMatrix;
  43701. /**
  43702. * 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)
  43703. */
  43704. ignoreChildren: boolean;
  43705. /**
  43706. * 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)
  43707. */
  43708. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43709. /**
  43710. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43711. */
  43712. rotationSphereSize: number;
  43713. /**
  43714. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43715. */
  43716. scaleBoxSize: number;
  43717. /**
  43718. * 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)
  43719. */
  43720. fixedDragMeshScreenSize: boolean;
  43721. /**
  43722. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43723. */
  43724. fixedDragMeshScreenSizeDistanceFactor: number;
  43725. /**
  43726. * Fired when a rotation sphere or scale box is dragged
  43727. */
  43728. onDragStartObservable: Observable<{}>;
  43729. /**
  43730. * Fired when a scale box is dragged
  43731. */
  43732. onScaleBoxDragObservable: Observable<{}>;
  43733. /**
  43734. * Fired when a scale box drag is ended
  43735. */
  43736. onScaleBoxDragEndObservable: Observable<{}>;
  43737. /**
  43738. * Fired when a rotation sphere is dragged
  43739. */
  43740. onRotationSphereDragObservable: Observable<{}>;
  43741. /**
  43742. * Fired when a rotation sphere drag is ended
  43743. */
  43744. onRotationSphereDragEndObservable: Observable<{}>;
  43745. /**
  43746. * 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)
  43747. */
  43748. scalePivot: Nullable<Vector3>;
  43749. /**
  43750. * Mesh used as a pivot to rotate the attached mesh
  43751. */
  43752. private _anchorMesh;
  43753. private _existingMeshScale;
  43754. private _dragMesh;
  43755. private pointerDragBehavior;
  43756. private coloredMaterial;
  43757. private hoverColoredMaterial;
  43758. /**
  43759. * Sets the color of the bounding box gizmo
  43760. * @param color the color to set
  43761. */
  43762. setColor(color: Color3): void;
  43763. /**
  43764. * Creates an BoundingBoxGizmo
  43765. * @param gizmoLayer The utility layer the gizmo will be added to
  43766. * @param color The color of the gizmo
  43767. */
  43768. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43769. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43770. private _selectNode;
  43771. /**
  43772. * Updates the bounding box information for the Gizmo
  43773. */
  43774. updateBoundingBox(): void;
  43775. private _updateRotationSpheres;
  43776. private _updateScaleBoxes;
  43777. /**
  43778. * Enables rotation on the specified axis and disables rotation on the others
  43779. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43780. */
  43781. setEnabledRotationAxis(axis: string): void;
  43782. /**
  43783. * Enables/disables scaling
  43784. * @param enable if scaling should be enabled
  43785. */
  43786. setEnabledScaling(enable: boolean): void;
  43787. private _updateDummy;
  43788. /**
  43789. * Enables a pointer drag behavior on the bounding box of the gizmo
  43790. */
  43791. enableDragBehavior(): void;
  43792. /**
  43793. * Disposes of the gizmo
  43794. */
  43795. dispose(): void;
  43796. /**
  43797. * 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)
  43798. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43799. * @returns the bounding box mesh with the passed in mesh as a child
  43800. */
  43801. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43802. /**
  43803. * CustomMeshes are not supported by this gizmo
  43804. * @param mesh The mesh to replace the default mesh of the gizmo
  43805. */
  43806. setCustomMesh(mesh: Mesh): void;
  43807. }
  43808. }
  43809. declare module BABYLON {
  43810. /**
  43811. * Single plane rotation gizmo
  43812. */
  43813. export class PlaneRotationGizmo extends Gizmo {
  43814. /**
  43815. * Drag behavior responsible for the gizmos dragging interactions
  43816. */
  43817. dragBehavior: PointerDragBehavior;
  43818. private _pointerObserver;
  43819. /**
  43820. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43821. */
  43822. snapDistance: number;
  43823. /**
  43824. * Event that fires each time the gizmo snaps to a new location.
  43825. * * snapDistance is the the change in distance
  43826. */
  43827. onSnapObservable: Observable<{
  43828. snapDistance: number;
  43829. }>;
  43830. private _isEnabled;
  43831. private _parent;
  43832. /**
  43833. * Creates a PlaneRotationGizmo
  43834. * @param gizmoLayer The utility layer the gizmo will be added to
  43835. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43836. * @param color The color of the gizmo
  43837. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43838. */
  43839. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  43840. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43841. /**
  43842. * If the gizmo is enabled
  43843. */
  43844. isEnabled: boolean;
  43845. /**
  43846. * Disposes of the gizmo
  43847. */
  43848. dispose(): void;
  43849. }
  43850. }
  43851. declare module BABYLON {
  43852. /**
  43853. * Gizmo that enables rotating a mesh along 3 axis
  43854. */
  43855. export class RotationGizmo extends Gizmo {
  43856. /**
  43857. * Internal gizmo used for interactions on the x axis
  43858. */
  43859. xGizmo: PlaneRotationGizmo;
  43860. /**
  43861. * Internal gizmo used for interactions on the y axis
  43862. */
  43863. yGizmo: PlaneRotationGizmo;
  43864. /**
  43865. * Internal gizmo used for interactions on the z axis
  43866. */
  43867. zGizmo: PlaneRotationGizmo;
  43868. /** Fires an event when any of it's sub gizmos are dragged */
  43869. onDragStartObservable: Observable<unknown>;
  43870. /** Fires an event when any of it's sub gizmos are released from dragging */
  43871. onDragEndObservable: Observable<unknown>;
  43872. private _meshAttached;
  43873. attachedMesh: Nullable<AbstractMesh>;
  43874. /**
  43875. * Creates a RotationGizmo
  43876. * @param gizmoLayer The utility layer the gizmo will be added to
  43877. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43878. */
  43879. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43880. updateGizmoRotationToMatchAttachedMesh: boolean;
  43881. /**
  43882. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43883. */
  43884. snapDistance: number;
  43885. /**
  43886. * Ratio for the scale of the gizmo (Default: 1)
  43887. */
  43888. scaleRatio: number;
  43889. /**
  43890. * Disposes of the gizmo
  43891. */
  43892. dispose(): void;
  43893. /**
  43894. * CustomMeshes are not supported by this gizmo
  43895. * @param mesh The mesh to replace the default mesh of the gizmo
  43896. */
  43897. setCustomMesh(mesh: Mesh): void;
  43898. }
  43899. }
  43900. declare module BABYLON {
  43901. /**
  43902. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43903. */
  43904. export class GizmoManager implements IDisposable {
  43905. private scene;
  43906. /**
  43907. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43908. */
  43909. gizmos: {
  43910. positionGizmo: Nullable<PositionGizmo>;
  43911. rotationGizmo: Nullable<RotationGizmo>;
  43912. scaleGizmo: Nullable<ScaleGizmo>;
  43913. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43914. };
  43915. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43916. clearGizmoOnEmptyPointerEvent: boolean;
  43917. /** Fires an event when the manager is attached to a mesh */
  43918. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43919. private _gizmosEnabled;
  43920. private _pointerObserver;
  43921. private _attachedMesh;
  43922. private _boundingBoxColor;
  43923. private _defaultUtilityLayer;
  43924. private _defaultKeepDepthUtilityLayer;
  43925. /**
  43926. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43927. */
  43928. boundingBoxDragBehavior: SixDofDragBehavior;
  43929. /**
  43930. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43931. */
  43932. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43933. /**
  43934. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43935. */
  43936. usePointerToAttachGizmos: boolean;
  43937. /**
  43938. * Utility layer that the bounding box gizmo belongs to
  43939. */
  43940. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  43941. /**
  43942. * Utility layer that all gizmos besides bounding box belong to
  43943. */
  43944. readonly utilityLayer: UtilityLayerRenderer;
  43945. /**
  43946. * Instatiates a gizmo manager
  43947. * @param scene the scene to overlay the gizmos on top of
  43948. */
  43949. constructor(scene: Scene);
  43950. /**
  43951. * Attaches a set of gizmos to the specified mesh
  43952. * @param mesh The mesh the gizmo's should be attached to
  43953. */
  43954. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43955. /**
  43956. * If the position gizmo is enabled
  43957. */
  43958. positionGizmoEnabled: boolean;
  43959. /**
  43960. * If the rotation gizmo is enabled
  43961. */
  43962. rotationGizmoEnabled: boolean;
  43963. /**
  43964. * If the scale gizmo is enabled
  43965. */
  43966. scaleGizmoEnabled: boolean;
  43967. /**
  43968. * If the boundingBox gizmo is enabled
  43969. */
  43970. boundingBoxGizmoEnabled: boolean;
  43971. /**
  43972. * Disposes of the gizmo manager
  43973. */
  43974. dispose(): void;
  43975. }
  43976. }
  43977. declare module BABYLON {
  43978. /**
  43979. * A directional light is defined by a direction (what a surprise!).
  43980. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  43981. * 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.
  43982. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43983. */
  43984. export class DirectionalLight extends ShadowLight {
  43985. private _shadowFrustumSize;
  43986. /**
  43987. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  43988. */
  43989. /**
  43990. * Specifies a fix frustum size for the shadow generation.
  43991. */
  43992. shadowFrustumSize: number;
  43993. private _shadowOrthoScale;
  43994. /**
  43995. * Gets the shadow projection scale against the optimal computed one.
  43996. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43997. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43998. */
  43999. /**
  44000. * Sets the shadow projection scale against the optimal computed one.
  44001. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44002. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44003. */
  44004. shadowOrthoScale: number;
  44005. /**
  44006. * Automatically compute the projection matrix to best fit (including all the casters)
  44007. * on each frame.
  44008. */
  44009. autoUpdateExtends: boolean;
  44010. private _orthoLeft;
  44011. private _orthoRight;
  44012. private _orthoTop;
  44013. private _orthoBottom;
  44014. /**
  44015. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44016. * The directional light is emitted from everywhere in the given direction.
  44017. * It can cast shadows.
  44018. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44019. * @param name The friendly name of the light
  44020. * @param direction The direction of the light
  44021. * @param scene The scene the light belongs to
  44022. */
  44023. constructor(name: string, direction: Vector3, scene: Scene);
  44024. /**
  44025. * Returns the string "DirectionalLight".
  44026. * @return The class name
  44027. */
  44028. getClassName(): string;
  44029. /**
  44030. * Returns the integer 1.
  44031. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44032. */
  44033. getTypeID(): number;
  44034. /**
  44035. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44036. * Returns the DirectionalLight Shadow projection matrix.
  44037. */
  44038. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44039. /**
  44040. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44041. * Returns the DirectionalLight Shadow projection matrix.
  44042. */
  44043. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44044. /**
  44045. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44046. * Returns the DirectionalLight Shadow projection matrix.
  44047. */
  44048. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44049. protected _buildUniformLayout(): void;
  44050. /**
  44051. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44052. * @param effect The effect to update
  44053. * @param lightIndex The index of the light in the effect to update
  44054. * @returns The directional light
  44055. */
  44056. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44057. /**
  44058. * Gets the minZ used for shadow according to both the scene and the light.
  44059. *
  44060. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44061. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44062. * @param activeCamera The camera we are returning the min for
  44063. * @returns the depth min z
  44064. */
  44065. getDepthMinZ(activeCamera: Camera): number;
  44066. /**
  44067. * Gets the maxZ used for shadow according to both the scene and the light.
  44068. *
  44069. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44070. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44071. * @param activeCamera The camera we are returning the max for
  44072. * @returns the depth max z
  44073. */
  44074. getDepthMaxZ(activeCamera: Camera): number;
  44075. /**
  44076. * Prepares the list of defines specific to the light type.
  44077. * @param defines the list of defines
  44078. * @param lightIndex defines the index of the light for the effect
  44079. */
  44080. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44081. }
  44082. }
  44083. declare module BABYLON {
  44084. /**
  44085. * Class containing static functions to help procedurally build meshes
  44086. */
  44087. export class HemisphereBuilder {
  44088. /**
  44089. * Creates a hemisphere mesh
  44090. * @param name defines the name of the mesh
  44091. * @param options defines the options used to create the mesh
  44092. * @param scene defines the hosting scene
  44093. * @returns the hemisphere mesh
  44094. */
  44095. static CreateHemisphere(name: string, options: {
  44096. segments?: number;
  44097. diameter?: number;
  44098. sideOrientation?: number;
  44099. }, scene: any): Mesh;
  44100. }
  44101. }
  44102. declare module BABYLON {
  44103. /**
  44104. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44105. * These values define a cone of light starting from the position, emitting toward the direction.
  44106. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44107. * and the exponent defines the speed of the decay of the light with distance (reach).
  44108. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44109. */
  44110. export class SpotLight extends ShadowLight {
  44111. private _angle;
  44112. private _innerAngle;
  44113. private _cosHalfAngle;
  44114. private _lightAngleScale;
  44115. private _lightAngleOffset;
  44116. /**
  44117. * Gets the cone angle of the spot light in Radians.
  44118. */
  44119. /**
  44120. * Sets the cone angle of the spot light in Radians.
  44121. */
  44122. angle: number;
  44123. /**
  44124. * Only used in gltf falloff mode, this defines the angle where
  44125. * the directional falloff will start before cutting at angle which could be seen
  44126. * as outer angle.
  44127. */
  44128. /**
  44129. * Only used in gltf falloff mode, this defines the angle where
  44130. * the directional falloff will start before cutting at angle which could be seen
  44131. * as outer angle.
  44132. */
  44133. innerAngle: number;
  44134. private _shadowAngleScale;
  44135. /**
  44136. * Allows scaling the angle of the light for shadow generation only.
  44137. */
  44138. /**
  44139. * Allows scaling the angle of the light for shadow generation only.
  44140. */
  44141. shadowAngleScale: number;
  44142. /**
  44143. * The light decay speed with the distance from the emission spot.
  44144. */
  44145. exponent: number;
  44146. private _projectionTextureMatrix;
  44147. /**
  44148. * Allows reading the projecton texture
  44149. */
  44150. readonly projectionTextureMatrix: Matrix;
  44151. protected _projectionTextureLightNear: number;
  44152. /**
  44153. * Gets the near clip of the Spotlight for texture projection.
  44154. */
  44155. /**
  44156. * Sets the near clip of the Spotlight for texture projection.
  44157. */
  44158. projectionTextureLightNear: number;
  44159. protected _projectionTextureLightFar: number;
  44160. /**
  44161. * Gets the far clip of the Spotlight for texture projection.
  44162. */
  44163. /**
  44164. * Sets the far clip of the Spotlight for texture projection.
  44165. */
  44166. projectionTextureLightFar: number;
  44167. protected _projectionTextureUpDirection: Vector3;
  44168. /**
  44169. * Gets the Up vector of the Spotlight for texture projection.
  44170. */
  44171. /**
  44172. * Sets the Up vector of the Spotlight for texture projection.
  44173. */
  44174. projectionTextureUpDirection: Vector3;
  44175. private _projectionTexture;
  44176. /**
  44177. * Gets the projection texture of the light.
  44178. */
  44179. /**
  44180. * Sets the projection texture of the light.
  44181. */
  44182. projectionTexture: Nullable<BaseTexture>;
  44183. private _projectionTextureViewLightDirty;
  44184. private _projectionTextureProjectionLightDirty;
  44185. private _projectionTextureDirty;
  44186. private _projectionTextureViewTargetVector;
  44187. private _projectionTextureViewLightMatrix;
  44188. private _projectionTextureProjectionLightMatrix;
  44189. private _projectionTextureScalingMatrix;
  44190. /**
  44191. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44192. * It can cast shadows.
  44193. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44194. * @param name The light friendly name
  44195. * @param position The position of the spot light in the scene
  44196. * @param direction The direction of the light in the scene
  44197. * @param angle The cone angle of the light in Radians
  44198. * @param exponent The light decay speed with the distance from the emission spot
  44199. * @param scene The scene the lights belongs to
  44200. */
  44201. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44202. /**
  44203. * Returns the string "SpotLight".
  44204. * @returns the class name
  44205. */
  44206. getClassName(): string;
  44207. /**
  44208. * Returns the integer 2.
  44209. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44210. */
  44211. getTypeID(): number;
  44212. /**
  44213. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44214. */
  44215. protected _setDirection(value: Vector3): void;
  44216. /**
  44217. * Overrides the position setter to recompute the projection texture view light Matrix.
  44218. */
  44219. protected _setPosition(value: Vector3): void;
  44220. /**
  44221. * 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.
  44222. * Returns the SpotLight.
  44223. */
  44224. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44225. protected _computeProjectionTextureViewLightMatrix(): void;
  44226. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44227. /**
  44228. * Main function for light texture projection matrix computing.
  44229. */
  44230. protected _computeProjectionTextureMatrix(): void;
  44231. protected _buildUniformLayout(): void;
  44232. private _computeAngleValues;
  44233. /**
  44234. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44235. * @param effect The effect to update
  44236. * @param lightIndex The index of the light in the effect to update
  44237. * @returns The spot light
  44238. */
  44239. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44240. /**
  44241. * Disposes the light and the associated resources.
  44242. */
  44243. dispose(): void;
  44244. /**
  44245. * Prepares the list of defines specific to the light type.
  44246. * @param defines the list of defines
  44247. * @param lightIndex defines the index of the light for the effect
  44248. */
  44249. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44250. }
  44251. }
  44252. declare module BABYLON {
  44253. /**
  44254. * Gizmo that enables viewing a light
  44255. */
  44256. export class LightGizmo extends Gizmo {
  44257. private _lightMesh;
  44258. private _material;
  44259. private cachedPosition;
  44260. private cachedForward;
  44261. /**
  44262. * Creates a LightGizmo
  44263. * @param gizmoLayer The utility layer the gizmo will be added to
  44264. */
  44265. constructor(gizmoLayer?: UtilityLayerRenderer);
  44266. private _light;
  44267. /**
  44268. * The light that the gizmo is attached to
  44269. */
  44270. light: Nullable<Light>;
  44271. /**
  44272. * @hidden
  44273. * Updates the gizmo to match the attached mesh's position/rotation
  44274. */
  44275. protected _update(): void;
  44276. private static _Scale;
  44277. /**
  44278. * Creates the lines for a light mesh
  44279. */
  44280. private static _createLightLines;
  44281. /**
  44282. * Disposes of the light gizmo
  44283. */
  44284. dispose(): void;
  44285. private static _CreateHemisphericLightMesh;
  44286. private static _CreatePointLightMesh;
  44287. private static _CreateSpotLightMesh;
  44288. private static _CreateDirectionalLightMesh;
  44289. }
  44290. }
  44291. declare module BABYLON {
  44292. /** @hidden */
  44293. export var backgroundFragmentDeclaration: {
  44294. name: string;
  44295. shader: string;
  44296. };
  44297. }
  44298. declare module BABYLON {
  44299. /** @hidden */
  44300. export var backgroundUboDeclaration: {
  44301. name: string;
  44302. shader: string;
  44303. };
  44304. }
  44305. declare module BABYLON {
  44306. /** @hidden */
  44307. export var backgroundPixelShader: {
  44308. name: string;
  44309. shader: string;
  44310. };
  44311. }
  44312. declare module BABYLON {
  44313. /** @hidden */
  44314. export var backgroundVertexDeclaration: {
  44315. name: string;
  44316. shader: string;
  44317. };
  44318. }
  44319. declare module BABYLON {
  44320. /** @hidden */
  44321. export var backgroundVertexShader: {
  44322. name: string;
  44323. shader: string;
  44324. };
  44325. }
  44326. declare module BABYLON {
  44327. /**
  44328. * Background material used to create an efficient environement around your scene.
  44329. */
  44330. export class BackgroundMaterial extends PushMaterial {
  44331. /**
  44332. * Standard reflectance value at parallel view angle.
  44333. */
  44334. static StandardReflectance0: number;
  44335. /**
  44336. * Standard reflectance value at grazing angle.
  44337. */
  44338. static StandardReflectance90: number;
  44339. protected _primaryColor: Color3;
  44340. /**
  44341. * Key light Color (multiply against the environement texture)
  44342. */
  44343. primaryColor: Color3;
  44344. protected __perceptualColor: Nullable<Color3>;
  44345. /**
  44346. * Experimental Internal Use Only.
  44347. *
  44348. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44349. * This acts as a helper to set the primary color to a more "human friendly" value.
  44350. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44351. * output color as close as possible from the chosen value.
  44352. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44353. * part of lighting setup.)
  44354. */
  44355. _perceptualColor: Nullable<Color3>;
  44356. protected _primaryColorShadowLevel: float;
  44357. /**
  44358. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44359. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44360. */
  44361. primaryColorShadowLevel: float;
  44362. protected _primaryColorHighlightLevel: float;
  44363. /**
  44364. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44365. * The primary color is used at the level chosen to define what the white area would look.
  44366. */
  44367. primaryColorHighlightLevel: float;
  44368. protected _reflectionTexture: Nullable<BaseTexture>;
  44369. /**
  44370. * Reflection Texture used in the material.
  44371. * Should be author in a specific way for the best result (refer to the documentation).
  44372. */
  44373. reflectionTexture: Nullable<BaseTexture>;
  44374. protected _reflectionBlur: float;
  44375. /**
  44376. * Reflection Texture level of blur.
  44377. *
  44378. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44379. * texture twice.
  44380. */
  44381. reflectionBlur: float;
  44382. protected _diffuseTexture: Nullable<BaseTexture>;
  44383. /**
  44384. * Diffuse Texture used in the material.
  44385. * Should be author in a specific way for the best result (refer to the documentation).
  44386. */
  44387. diffuseTexture: Nullable<BaseTexture>;
  44388. protected _shadowLights: Nullable<IShadowLight[]>;
  44389. /**
  44390. * Specify the list of lights casting shadow on the material.
  44391. * All scene shadow lights will be included if null.
  44392. */
  44393. shadowLights: Nullable<IShadowLight[]>;
  44394. protected _shadowLevel: float;
  44395. /**
  44396. * Helps adjusting the shadow to a softer level if required.
  44397. * 0 means black shadows and 1 means no shadows.
  44398. */
  44399. shadowLevel: float;
  44400. protected _sceneCenter: Vector3;
  44401. /**
  44402. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44403. * It is usually zero but might be interesting to modify according to your setup.
  44404. */
  44405. sceneCenter: Vector3;
  44406. protected _opacityFresnel: boolean;
  44407. /**
  44408. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44409. * This helps ensuring a nice transition when the camera goes under the ground.
  44410. */
  44411. opacityFresnel: boolean;
  44412. protected _reflectionFresnel: boolean;
  44413. /**
  44414. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44415. * This helps adding a mirror texture on the ground.
  44416. */
  44417. reflectionFresnel: boolean;
  44418. protected _reflectionFalloffDistance: number;
  44419. /**
  44420. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44421. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44422. */
  44423. reflectionFalloffDistance: number;
  44424. protected _reflectionAmount: number;
  44425. /**
  44426. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44427. */
  44428. reflectionAmount: number;
  44429. protected _reflectionReflectance0: number;
  44430. /**
  44431. * This specifies the weight of the reflection at grazing angle.
  44432. */
  44433. reflectionReflectance0: number;
  44434. protected _reflectionReflectance90: number;
  44435. /**
  44436. * This specifies the weight of the reflection at a perpendicular point of view.
  44437. */
  44438. reflectionReflectance90: number;
  44439. /**
  44440. * Sets the reflection reflectance fresnel values according to the default standard
  44441. * empirically know to work well :-)
  44442. */
  44443. reflectionStandardFresnelWeight: number;
  44444. protected _useRGBColor: boolean;
  44445. /**
  44446. * Helps to directly use the maps channels instead of their level.
  44447. */
  44448. useRGBColor: boolean;
  44449. protected _enableNoise: boolean;
  44450. /**
  44451. * This helps reducing the banding effect that could occur on the background.
  44452. */
  44453. enableNoise: boolean;
  44454. /**
  44455. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44456. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44457. * Recommended to be keep at 1.0 except for special cases.
  44458. */
  44459. fovMultiplier: number;
  44460. private _fovMultiplier;
  44461. /**
  44462. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44463. */
  44464. useEquirectangularFOV: boolean;
  44465. private _maxSimultaneousLights;
  44466. /**
  44467. * Number of Simultaneous lights allowed on the material.
  44468. */
  44469. maxSimultaneousLights: int;
  44470. /**
  44471. * Default configuration related to image processing available in the Background Material.
  44472. */
  44473. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44474. /**
  44475. * Keep track of the image processing observer to allow dispose and replace.
  44476. */
  44477. private _imageProcessingObserver;
  44478. /**
  44479. * Attaches a new image processing configuration to the PBR Material.
  44480. * @param configuration (if null the scene configuration will be use)
  44481. */
  44482. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44483. /**
  44484. * Gets the image processing configuration used either in this material.
  44485. */
  44486. /**
  44487. * Sets the Default image processing configuration used either in the this material.
  44488. *
  44489. * If sets to null, the scene one is in use.
  44490. */
  44491. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44492. /**
  44493. * Gets wether the color curves effect is enabled.
  44494. */
  44495. /**
  44496. * Sets wether the color curves effect is enabled.
  44497. */
  44498. cameraColorCurvesEnabled: boolean;
  44499. /**
  44500. * Gets wether the color grading effect is enabled.
  44501. */
  44502. /**
  44503. * Gets wether the color grading effect is enabled.
  44504. */
  44505. cameraColorGradingEnabled: boolean;
  44506. /**
  44507. * Gets wether tonemapping is enabled or not.
  44508. */
  44509. /**
  44510. * Sets wether tonemapping is enabled or not
  44511. */
  44512. cameraToneMappingEnabled: boolean;
  44513. /**
  44514. * The camera exposure used on this material.
  44515. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44516. * This corresponds to a photographic exposure.
  44517. */
  44518. /**
  44519. * The camera exposure used on this material.
  44520. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44521. * This corresponds to a photographic exposure.
  44522. */
  44523. cameraExposure: float;
  44524. /**
  44525. * Gets The camera contrast used on this material.
  44526. */
  44527. /**
  44528. * Sets The camera contrast used on this material.
  44529. */
  44530. cameraContrast: float;
  44531. /**
  44532. * Gets the Color Grading 2D Lookup Texture.
  44533. */
  44534. /**
  44535. * Sets the Color Grading 2D Lookup Texture.
  44536. */
  44537. cameraColorGradingTexture: Nullable<BaseTexture>;
  44538. /**
  44539. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44540. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44541. * 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;
  44542. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44543. */
  44544. /**
  44545. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44546. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44547. * 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;
  44548. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44549. */
  44550. cameraColorCurves: Nullable<ColorCurves>;
  44551. /**
  44552. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44553. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44554. */
  44555. switchToBGR: boolean;
  44556. private _renderTargets;
  44557. private _reflectionControls;
  44558. private _white;
  44559. private _primaryShadowColor;
  44560. private _primaryHighlightColor;
  44561. /**
  44562. * Instantiates a Background Material in the given scene
  44563. * @param name The friendly name of the material
  44564. * @param scene The scene to add the material to
  44565. */
  44566. constructor(name: string, scene: Scene);
  44567. /**
  44568. * Gets a boolean indicating that current material needs to register RTT
  44569. */
  44570. readonly hasRenderTargetTextures: boolean;
  44571. /**
  44572. * The entire material has been created in order to prevent overdraw.
  44573. * @returns false
  44574. */
  44575. needAlphaTesting(): boolean;
  44576. /**
  44577. * The entire material has been created in order to prevent overdraw.
  44578. * @returns true if blending is enable
  44579. */
  44580. needAlphaBlending(): boolean;
  44581. /**
  44582. * Checks wether the material is ready to be rendered for a given mesh.
  44583. * @param mesh The mesh to render
  44584. * @param subMesh The submesh to check against
  44585. * @param useInstances Specify wether or not the material is used with instances
  44586. * @returns true if all the dependencies are ready (Textures, Effects...)
  44587. */
  44588. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44589. /**
  44590. * Compute the primary color according to the chosen perceptual color.
  44591. */
  44592. private _computePrimaryColorFromPerceptualColor;
  44593. /**
  44594. * Compute the highlights and shadow colors according to their chosen levels.
  44595. */
  44596. private _computePrimaryColors;
  44597. /**
  44598. * Build the uniform buffer used in the material.
  44599. */
  44600. buildUniformLayout(): void;
  44601. /**
  44602. * Unbind the material.
  44603. */
  44604. unbind(): void;
  44605. /**
  44606. * Bind only the world matrix to the material.
  44607. * @param world The world matrix to bind.
  44608. */
  44609. bindOnlyWorldMatrix(world: Matrix): void;
  44610. /**
  44611. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44612. * @param world The world matrix to bind.
  44613. * @param subMesh The submesh to bind for.
  44614. */
  44615. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44616. /**
  44617. * Dispose the material.
  44618. * @param forceDisposeEffect Force disposal of the associated effect.
  44619. * @param forceDisposeTextures Force disposal of the associated textures.
  44620. */
  44621. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44622. /**
  44623. * Clones the material.
  44624. * @param name The cloned name.
  44625. * @returns The cloned material.
  44626. */
  44627. clone(name: string): BackgroundMaterial;
  44628. /**
  44629. * Serializes the current material to its JSON representation.
  44630. * @returns The JSON representation.
  44631. */
  44632. serialize(): any;
  44633. /**
  44634. * Gets the class name of the material
  44635. * @returns "BackgroundMaterial"
  44636. */
  44637. getClassName(): string;
  44638. /**
  44639. * Parse a JSON input to create back a background material.
  44640. * @param source The JSON data to parse
  44641. * @param scene The scene to create the parsed material in
  44642. * @param rootUrl The root url of the assets the material depends upon
  44643. * @returns the instantiated BackgroundMaterial.
  44644. */
  44645. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44646. }
  44647. }
  44648. declare module BABYLON {
  44649. /**
  44650. * Represents the different options available during the creation of
  44651. * a Environment helper.
  44652. *
  44653. * This can control the default ground, skybox and image processing setup of your scene.
  44654. */
  44655. export interface IEnvironmentHelperOptions {
  44656. /**
  44657. * Specifies wether or not to create a ground.
  44658. * True by default.
  44659. */
  44660. createGround: boolean;
  44661. /**
  44662. * Specifies the ground size.
  44663. * 15 by default.
  44664. */
  44665. groundSize: number;
  44666. /**
  44667. * The texture used on the ground for the main color.
  44668. * Comes from the BabylonJS CDN by default.
  44669. *
  44670. * Remarks: Can be either a texture or a url.
  44671. */
  44672. groundTexture: string | BaseTexture;
  44673. /**
  44674. * The color mixed in the ground texture by default.
  44675. * BabylonJS clearColor by default.
  44676. */
  44677. groundColor: Color3;
  44678. /**
  44679. * Specifies the ground opacity.
  44680. * 1 by default.
  44681. */
  44682. groundOpacity: number;
  44683. /**
  44684. * Enables the ground to receive shadows.
  44685. * True by default.
  44686. */
  44687. enableGroundShadow: boolean;
  44688. /**
  44689. * Helps preventing the shadow to be fully black on the ground.
  44690. * 0.5 by default.
  44691. */
  44692. groundShadowLevel: number;
  44693. /**
  44694. * Creates a mirror texture attach to the ground.
  44695. * false by default.
  44696. */
  44697. enableGroundMirror: boolean;
  44698. /**
  44699. * Specifies the ground mirror size ratio.
  44700. * 0.3 by default as the default kernel is 64.
  44701. */
  44702. groundMirrorSizeRatio: number;
  44703. /**
  44704. * Specifies the ground mirror blur kernel size.
  44705. * 64 by default.
  44706. */
  44707. groundMirrorBlurKernel: number;
  44708. /**
  44709. * Specifies the ground mirror visibility amount.
  44710. * 1 by default
  44711. */
  44712. groundMirrorAmount: number;
  44713. /**
  44714. * Specifies the ground mirror reflectance weight.
  44715. * This uses the standard weight of the background material to setup the fresnel effect
  44716. * of the mirror.
  44717. * 1 by default.
  44718. */
  44719. groundMirrorFresnelWeight: number;
  44720. /**
  44721. * Specifies the ground mirror Falloff distance.
  44722. * This can helps reducing the size of the reflection.
  44723. * 0 by Default.
  44724. */
  44725. groundMirrorFallOffDistance: number;
  44726. /**
  44727. * Specifies the ground mirror texture type.
  44728. * Unsigned Int by Default.
  44729. */
  44730. groundMirrorTextureType: number;
  44731. /**
  44732. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44733. * the shown objects.
  44734. */
  44735. groundYBias: number;
  44736. /**
  44737. * Specifies wether or not to create a skybox.
  44738. * True by default.
  44739. */
  44740. createSkybox: boolean;
  44741. /**
  44742. * Specifies the skybox size.
  44743. * 20 by default.
  44744. */
  44745. skyboxSize: number;
  44746. /**
  44747. * The texture used on the skybox for the main color.
  44748. * Comes from the BabylonJS CDN by default.
  44749. *
  44750. * Remarks: Can be either a texture or a url.
  44751. */
  44752. skyboxTexture: string | BaseTexture;
  44753. /**
  44754. * The color mixed in the skybox texture by default.
  44755. * BabylonJS clearColor by default.
  44756. */
  44757. skyboxColor: Color3;
  44758. /**
  44759. * The background rotation around the Y axis of the scene.
  44760. * This helps aligning the key lights of your scene with the background.
  44761. * 0 by default.
  44762. */
  44763. backgroundYRotation: number;
  44764. /**
  44765. * Compute automatically the size of the elements to best fit with the scene.
  44766. */
  44767. sizeAuto: boolean;
  44768. /**
  44769. * Default position of the rootMesh if autoSize is not true.
  44770. */
  44771. rootPosition: Vector3;
  44772. /**
  44773. * Sets up the image processing in the scene.
  44774. * true by default.
  44775. */
  44776. setupImageProcessing: boolean;
  44777. /**
  44778. * The texture used as your environment texture in the scene.
  44779. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44780. *
  44781. * Remarks: Can be either a texture or a url.
  44782. */
  44783. environmentTexture: string | BaseTexture;
  44784. /**
  44785. * The value of the exposure to apply to the scene.
  44786. * 0.6 by default if setupImageProcessing is true.
  44787. */
  44788. cameraExposure: number;
  44789. /**
  44790. * The value of the contrast to apply to the scene.
  44791. * 1.6 by default if setupImageProcessing is true.
  44792. */
  44793. cameraContrast: number;
  44794. /**
  44795. * Specifies wether or not tonemapping should be enabled in the scene.
  44796. * true by default if setupImageProcessing is true.
  44797. */
  44798. toneMappingEnabled: boolean;
  44799. }
  44800. /**
  44801. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44802. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44803. * It also helps with the default setup of your imageProcessing configuration.
  44804. */
  44805. export class EnvironmentHelper {
  44806. /**
  44807. * Default ground texture URL.
  44808. */
  44809. private static _groundTextureCDNUrl;
  44810. /**
  44811. * Default skybox texture URL.
  44812. */
  44813. private static _skyboxTextureCDNUrl;
  44814. /**
  44815. * Default environment texture URL.
  44816. */
  44817. private static _environmentTextureCDNUrl;
  44818. /**
  44819. * Creates the default options for the helper.
  44820. */
  44821. private static _getDefaultOptions;
  44822. private _rootMesh;
  44823. /**
  44824. * Gets the root mesh created by the helper.
  44825. */
  44826. readonly rootMesh: Mesh;
  44827. private _skybox;
  44828. /**
  44829. * Gets the skybox created by the helper.
  44830. */
  44831. readonly skybox: Nullable<Mesh>;
  44832. private _skyboxTexture;
  44833. /**
  44834. * Gets the skybox texture created by the helper.
  44835. */
  44836. readonly skyboxTexture: Nullable<BaseTexture>;
  44837. private _skyboxMaterial;
  44838. /**
  44839. * Gets the skybox material created by the helper.
  44840. */
  44841. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44842. private _ground;
  44843. /**
  44844. * Gets the ground mesh created by the helper.
  44845. */
  44846. readonly ground: Nullable<Mesh>;
  44847. private _groundTexture;
  44848. /**
  44849. * Gets the ground texture created by the helper.
  44850. */
  44851. readonly groundTexture: Nullable<BaseTexture>;
  44852. private _groundMirror;
  44853. /**
  44854. * Gets the ground mirror created by the helper.
  44855. */
  44856. readonly groundMirror: Nullable<MirrorTexture>;
  44857. /**
  44858. * Gets the ground mirror render list to helps pushing the meshes
  44859. * you wish in the ground reflection.
  44860. */
  44861. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44862. private _groundMaterial;
  44863. /**
  44864. * Gets the ground material created by the helper.
  44865. */
  44866. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44867. /**
  44868. * Stores the creation options.
  44869. */
  44870. private readonly _scene;
  44871. private _options;
  44872. /**
  44873. * This observable will be notified with any error during the creation of the environment,
  44874. * mainly texture creation errors.
  44875. */
  44876. onErrorObservable: Observable<{
  44877. message?: string;
  44878. exception?: any;
  44879. }>;
  44880. /**
  44881. * constructor
  44882. * @param options Defines the options we want to customize the helper
  44883. * @param scene The scene to add the material to
  44884. */
  44885. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44886. /**
  44887. * Updates the background according to the new options
  44888. * @param options
  44889. */
  44890. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44891. /**
  44892. * Sets the primary color of all the available elements.
  44893. * @param color the main color to affect to the ground and the background
  44894. */
  44895. setMainColor(color: Color3): void;
  44896. /**
  44897. * Setup the image processing according to the specified options.
  44898. */
  44899. private _setupImageProcessing;
  44900. /**
  44901. * Setup the environment texture according to the specified options.
  44902. */
  44903. private _setupEnvironmentTexture;
  44904. /**
  44905. * Setup the background according to the specified options.
  44906. */
  44907. private _setupBackground;
  44908. /**
  44909. * Get the scene sizes according to the setup.
  44910. */
  44911. private _getSceneSize;
  44912. /**
  44913. * Setup the ground according to the specified options.
  44914. */
  44915. private _setupGround;
  44916. /**
  44917. * Setup the ground material according to the specified options.
  44918. */
  44919. private _setupGroundMaterial;
  44920. /**
  44921. * Setup the ground diffuse texture according to the specified options.
  44922. */
  44923. private _setupGroundDiffuseTexture;
  44924. /**
  44925. * Setup the ground mirror texture according to the specified options.
  44926. */
  44927. private _setupGroundMirrorTexture;
  44928. /**
  44929. * Setup the ground to receive the mirror texture.
  44930. */
  44931. private _setupMirrorInGroundMaterial;
  44932. /**
  44933. * Setup the skybox according to the specified options.
  44934. */
  44935. private _setupSkybox;
  44936. /**
  44937. * Setup the skybox material according to the specified options.
  44938. */
  44939. private _setupSkyboxMaterial;
  44940. /**
  44941. * Setup the skybox reflection texture according to the specified options.
  44942. */
  44943. private _setupSkyboxReflectionTexture;
  44944. private _errorHandler;
  44945. /**
  44946. * Dispose all the elements created by the Helper.
  44947. */
  44948. dispose(): void;
  44949. }
  44950. }
  44951. declare module BABYLON {
  44952. /**
  44953. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44954. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44955. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44956. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44957. */
  44958. export class PhotoDome extends TransformNode {
  44959. /**
  44960. * Define the image as a Monoscopic panoramic 360 image.
  44961. */
  44962. static readonly MODE_MONOSCOPIC: number;
  44963. /**
  44964. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44965. */
  44966. static readonly MODE_TOPBOTTOM: number;
  44967. /**
  44968. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44969. */
  44970. static readonly MODE_SIDEBYSIDE: number;
  44971. private _useDirectMapping;
  44972. /**
  44973. * The texture being displayed on the sphere
  44974. */
  44975. protected _photoTexture: Texture;
  44976. /**
  44977. * Gets or sets the texture being displayed on the sphere
  44978. */
  44979. photoTexture: Texture;
  44980. /**
  44981. * Observable raised when an error occured while loading the 360 image
  44982. */
  44983. onLoadErrorObservable: Observable<string>;
  44984. /**
  44985. * The skybox material
  44986. */
  44987. protected _material: BackgroundMaterial;
  44988. /**
  44989. * The surface used for the skybox
  44990. */
  44991. protected _mesh: Mesh;
  44992. /**
  44993. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44994. * Also see the options.resolution property.
  44995. */
  44996. fovMultiplier: number;
  44997. private _imageMode;
  44998. /**
  44999. * Gets or set the current video mode for the video. It can be:
  45000. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45001. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45002. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45003. */
  45004. imageMode: number;
  45005. /**
  45006. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45007. * @param name Element's name, child elements will append suffixes for their own names.
  45008. * @param urlsOfPhoto defines the url of the photo to display
  45009. * @param options defines an object containing optional or exposed sub element properties
  45010. * @param onError defines a callback called when an error occured while loading the texture
  45011. */
  45012. constructor(name: string, urlOfPhoto: string, options: {
  45013. resolution?: number;
  45014. size?: number;
  45015. useDirectMapping?: boolean;
  45016. faceForward?: boolean;
  45017. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45018. private _onBeforeCameraRenderObserver;
  45019. private _changeImageMode;
  45020. /**
  45021. * Releases resources associated with this node.
  45022. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45023. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45024. */
  45025. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45026. }
  45027. }
  45028. declare module BABYLON {
  45029. /** @hidden */
  45030. export var rgbdDecodePixelShader: {
  45031. name: string;
  45032. shader: string;
  45033. };
  45034. }
  45035. declare module BABYLON {
  45036. /**
  45037. * Class used to host texture specific utilities
  45038. */
  45039. export class BRDFTextureTools {
  45040. /**
  45041. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45042. * @param texture the texture to expand.
  45043. */
  45044. private static _ExpandDefaultBRDFTexture;
  45045. /**
  45046. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45047. * @param scene defines the hosting scene
  45048. * @returns the environment BRDF texture
  45049. */
  45050. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45051. private static _environmentBRDFBase64Texture;
  45052. }
  45053. }
  45054. declare module BABYLON {
  45055. /**
  45056. * @hidden
  45057. */
  45058. export interface IMaterialClearCoatDefines {
  45059. CLEARCOAT: boolean;
  45060. CLEARCOAT_DEFAULTIOR: boolean;
  45061. CLEARCOAT_TEXTURE: boolean;
  45062. CLEARCOAT_TEXTUREDIRECTUV: number;
  45063. CLEARCOAT_BUMP: boolean;
  45064. CLEARCOAT_BUMPDIRECTUV: number;
  45065. CLEARCOAT_TINT: boolean;
  45066. CLEARCOAT_TINT_TEXTURE: boolean;
  45067. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45068. /** @hidden */
  45069. _areTexturesDirty: boolean;
  45070. }
  45071. /**
  45072. * Define the code related to the clear coat parameters of the pbr material.
  45073. */
  45074. export class PBRClearCoatConfiguration {
  45075. /**
  45076. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45077. * The default fits with a polyurethane material.
  45078. */
  45079. private static readonly _DefaultIndexOfRefraction;
  45080. private _isEnabled;
  45081. /**
  45082. * Defines if the clear coat is enabled in the material.
  45083. */
  45084. isEnabled: boolean;
  45085. /**
  45086. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45087. */
  45088. intensity: number;
  45089. /**
  45090. * Defines the clear coat layer roughness.
  45091. */
  45092. roughness: number;
  45093. private _indexOfRefraction;
  45094. /**
  45095. * Defines the index of refraction of the clear coat.
  45096. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45097. * The default fits with a polyurethane material.
  45098. * Changing the default value is more performance intensive.
  45099. */
  45100. indexOfRefraction: number;
  45101. private _texture;
  45102. /**
  45103. * Stores the clear coat values in a texture.
  45104. */
  45105. texture: Nullable<BaseTexture>;
  45106. private _bumpTexture;
  45107. /**
  45108. * Define the clear coat specific bump texture.
  45109. */
  45110. bumpTexture: Nullable<BaseTexture>;
  45111. private _isTintEnabled;
  45112. /**
  45113. * Defines if the clear coat tint is enabled in the material.
  45114. */
  45115. isTintEnabled: boolean;
  45116. /**
  45117. * Defines the clear coat tint of the material.
  45118. * This is only use if tint is enabled
  45119. */
  45120. tintColor: Color3;
  45121. /**
  45122. * Defines the distance at which the tint color should be found in the
  45123. * clear coat media.
  45124. * This is only use if tint is enabled
  45125. */
  45126. tintColorAtDistance: number;
  45127. /**
  45128. * Defines the clear coat layer thickness.
  45129. * This is only use if tint is enabled
  45130. */
  45131. tintThickness: number;
  45132. private _tintTexture;
  45133. /**
  45134. * Stores the clear tint values in a texture.
  45135. * rgb is tint
  45136. * a is a thickness factor
  45137. */
  45138. tintTexture: Nullable<BaseTexture>;
  45139. /** @hidden */
  45140. private _internalMarkAllSubMeshesAsTexturesDirty;
  45141. /** @hidden */
  45142. _markAllSubMeshesAsTexturesDirty(): void;
  45143. /**
  45144. * Instantiate a new istance of clear coat configuration.
  45145. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45146. */
  45147. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45148. /**
  45149. * Gets wehter the submesh is ready to be used or not.
  45150. * @param defines the list of "defines" to update.
  45151. * @param scene defines the scene the material belongs to.
  45152. * @param engine defines the engine the material belongs to.
  45153. * @param disableBumpMap defines wether the material disables bump or not.
  45154. * @returns - boolean indicating that the submesh is ready or not.
  45155. */
  45156. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45157. /**
  45158. * Checks to see if a texture is used in the material.
  45159. * @param defines the list of "defines" to update.
  45160. * @param scene defines the scene to the material belongs to.
  45161. */
  45162. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45163. /**
  45164. * Binds the material data.
  45165. * @param uniformBuffer defines the Uniform buffer to fill in.
  45166. * @param scene defines the scene the material belongs to.
  45167. * @param engine defines the engine the material belongs to.
  45168. * @param disableBumpMap defines wether the material disables bump or not.
  45169. * @param isFrozen defines wether the material is frozen or not.
  45170. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45171. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45172. */
  45173. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45174. /**
  45175. * Checks to see if a texture is used in the material.
  45176. * @param texture - Base texture to use.
  45177. * @returns - Boolean specifying if a texture is used in the material.
  45178. */
  45179. hasTexture(texture: BaseTexture): boolean;
  45180. /**
  45181. * Returns an array of the actively used textures.
  45182. * @param activeTextures Array of BaseTextures
  45183. */
  45184. getActiveTextures(activeTextures: BaseTexture[]): void;
  45185. /**
  45186. * Returns the animatable textures.
  45187. * @param animatables Array of animatable textures.
  45188. */
  45189. getAnimatables(animatables: IAnimatable[]): void;
  45190. /**
  45191. * Disposes the resources of the material.
  45192. * @param forceDisposeTextures - Forces the disposal of all textures.
  45193. */
  45194. dispose(forceDisposeTextures?: boolean): void;
  45195. /**
  45196. * Get the current class name of the texture useful for serialization or dynamic coding.
  45197. * @returns "PBRClearCoatConfiguration"
  45198. */
  45199. getClassName(): string;
  45200. /**
  45201. * Add fallbacks to the effect fallbacks list.
  45202. * @param defines defines the Base texture to use.
  45203. * @param fallbacks defines the current fallback list.
  45204. * @param currentRank defines the current fallback rank.
  45205. * @returns the new fallback rank.
  45206. */
  45207. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45208. /**
  45209. * Add the required uniforms to the current list.
  45210. * @param uniforms defines the current uniform list.
  45211. */
  45212. static AddUniforms(uniforms: string[]): void;
  45213. /**
  45214. * Add the required samplers to the current list.
  45215. * @param samplers defines the current sampler list.
  45216. */
  45217. static AddSamplers(samplers: string[]): void;
  45218. /**
  45219. * Add the required uniforms to the current buffer.
  45220. * @param uniformBuffer defines the current uniform buffer.
  45221. */
  45222. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45223. /**
  45224. * Makes a duplicate of the current configuration into another one.
  45225. * @param clearCoatConfiguration define the config where to copy the info
  45226. */
  45227. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45228. /**
  45229. * Serializes this clear coat configuration.
  45230. * @returns - An object with the serialized config.
  45231. */
  45232. serialize(): any;
  45233. /**
  45234. * Parses a anisotropy Configuration from a serialized object.
  45235. * @param source - Serialized object.
  45236. * @param scene Defines the scene we are parsing for
  45237. * @param rootUrl Defines the rootUrl to load from
  45238. */
  45239. parse(source: any, scene: Scene, rootUrl: string): void;
  45240. }
  45241. }
  45242. declare module BABYLON {
  45243. /**
  45244. * @hidden
  45245. */
  45246. export interface IMaterialAnisotropicDefines {
  45247. ANISOTROPIC: boolean;
  45248. ANISOTROPIC_TEXTURE: boolean;
  45249. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45250. MAINUV1: boolean;
  45251. _areTexturesDirty: boolean;
  45252. _needUVs: boolean;
  45253. }
  45254. /**
  45255. * Define the code related to the anisotropic parameters of the pbr material.
  45256. */
  45257. export class PBRAnisotropicConfiguration {
  45258. private _isEnabled;
  45259. /**
  45260. * Defines if the anisotropy is enabled in the material.
  45261. */
  45262. isEnabled: boolean;
  45263. /**
  45264. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45265. */
  45266. intensity: number;
  45267. /**
  45268. * Defines if the effect is along the tangents, bitangents or in between.
  45269. * By default, the effect is "strectching" the highlights along the tangents.
  45270. */
  45271. direction: Vector2;
  45272. private _texture;
  45273. /**
  45274. * Stores the anisotropy values in a texture.
  45275. * rg is direction (like normal from -1 to 1)
  45276. * b is a intensity
  45277. */
  45278. texture: Nullable<BaseTexture>;
  45279. /** @hidden */
  45280. private _internalMarkAllSubMeshesAsTexturesDirty;
  45281. /** @hidden */
  45282. _markAllSubMeshesAsTexturesDirty(): void;
  45283. /**
  45284. * Instantiate a new istance of anisotropy configuration.
  45285. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45286. */
  45287. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45288. /**
  45289. * Specifies that the submesh is ready to be used.
  45290. * @param defines the list of "defines" to update.
  45291. * @param scene defines the scene the material belongs to.
  45292. * @returns - boolean indicating that the submesh is ready or not.
  45293. */
  45294. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45295. /**
  45296. * Checks to see if a texture is used in the material.
  45297. * @param defines the list of "defines" to update.
  45298. * @param mesh the mesh we are preparing the defines for.
  45299. * @param scene defines the scene the material belongs to.
  45300. */
  45301. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45302. /**
  45303. * Binds the material data.
  45304. * @param uniformBuffer defines the Uniform buffer to fill in.
  45305. * @param scene defines the scene the material belongs to.
  45306. * @param isFrozen defines wether the material is frozen or not.
  45307. */
  45308. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45309. /**
  45310. * Checks to see if a texture is used in the material.
  45311. * @param texture - Base texture to use.
  45312. * @returns - Boolean specifying if a texture is used in the material.
  45313. */
  45314. hasTexture(texture: BaseTexture): boolean;
  45315. /**
  45316. * Returns an array of the actively used textures.
  45317. * @param activeTextures Array of BaseTextures
  45318. */
  45319. getActiveTextures(activeTextures: BaseTexture[]): void;
  45320. /**
  45321. * Returns the animatable textures.
  45322. * @param animatables Array of animatable textures.
  45323. */
  45324. getAnimatables(animatables: IAnimatable[]): void;
  45325. /**
  45326. * Disposes the resources of the material.
  45327. * @param forceDisposeTextures - Forces the disposal of all textures.
  45328. */
  45329. dispose(forceDisposeTextures?: boolean): void;
  45330. /**
  45331. * Get the current class name of the texture useful for serialization or dynamic coding.
  45332. * @returns "PBRAnisotropicConfiguration"
  45333. */
  45334. getClassName(): string;
  45335. /**
  45336. * Add fallbacks to the effect fallbacks list.
  45337. * @param defines defines the Base texture to use.
  45338. * @param fallbacks defines the current fallback list.
  45339. * @param currentRank defines the current fallback rank.
  45340. * @returns the new fallback rank.
  45341. */
  45342. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45343. /**
  45344. * Add the required uniforms to the current list.
  45345. * @param uniforms defines the current uniform list.
  45346. */
  45347. static AddUniforms(uniforms: string[]): void;
  45348. /**
  45349. * Add the required uniforms to the current buffer.
  45350. * @param uniformBuffer defines the current uniform buffer.
  45351. */
  45352. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45353. /**
  45354. * Add the required samplers to the current list.
  45355. * @param samplers defines the current sampler list.
  45356. */
  45357. static AddSamplers(samplers: string[]): void;
  45358. /**
  45359. * Makes a duplicate of the current configuration into another one.
  45360. * @param anisotropicConfiguration define the config where to copy the info
  45361. */
  45362. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45363. /**
  45364. * Serializes this anisotropy configuration.
  45365. * @returns - An object with the serialized config.
  45366. */
  45367. serialize(): any;
  45368. /**
  45369. * Parses a anisotropy Configuration from a serialized object.
  45370. * @param source - Serialized object.
  45371. * @param scene Defines the scene we are parsing for
  45372. * @param rootUrl Defines the rootUrl to load from
  45373. */
  45374. parse(source: any, scene: Scene, rootUrl: string): void;
  45375. }
  45376. }
  45377. declare module BABYLON {
  45378. /**
  45379. * @hidden
  45380. */
  45381. export interface IMaterialBRDFDefines {
  45382. BRDF_V_HEIGHT_CORRELATED: boolean;
  45383. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45384. SPHERICAL_HARMONICS: boolean;
  45385. /** @hidden */
  45386. _areMiscDirty: boolean;
  45387. }
  45388. /**
  45389. * Define the code related to the BRDF parameters of the pbr material.
  45390. */
  45391. export class PBRBRDFConfiguration {
  45392. /**
  45393. * Default value used for the energy conservation.
  45394. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45395. */
  45396. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45397. /**
  45398. * Default value used for the Smith Visibility Height Correlated mode.
  45399. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45400. */
  45401. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45402. /**
  45403. * Default value used for the IBL diffuse part.
  45404. * This can help switching back to the polynomials mode globally which is a tiny bit
  45405. * less GPU intensive at the drawback of a lower quality.
  45406. */
  45407. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  45408. private _useEnergyConservation;
  45409. /**
  45410. * Defines if the material uses energy conservation.
  45411. */
  45412. useEnergyConservation: boolean;
  45413. private _useSmithVisibilityHeightCorrelated;
  45414. /**
  45415. * LEGACY Mode set to false
  45416. * Defines if the material uses height smith correlated visibility term.
  45417. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45418. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45419. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45420. * Not relying on height correlated will also disable energy conservation.
  45421. */
  45422. useSmithVisibilityHeightCorrelated: boolean;
  45423. private _useSphericalHarmonics;
  45424. /**
  45425. * LEGACY Mode set to false
  45426. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  45427. * diffuse part of the IBL.
  45428. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  45429. * to the ground truth.
  45430. */
  45431. useSphericalHarmonics: boolean;
  45432. /** @hidden */
  45433. private _internalMarkAllSubMeshesAsMiscDirty;
  45434. /** @hidden */
  45435. _markAllSubMeshesAsMiscDirty(): void;
  45436. /**
  45437. * Instantiate a new istance of clear coat configuration.
  45438. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45439. */
  45440. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45441. /**
  45442. * Checks to see if a texture is used in the material.
  45443. * @param defines the list of "defines" to update.
  45444. */
  45445. prepareDefines(defines: IMaterialBRDFDefines): void;
  45446. /**
  45447. * Get the current class name of the texture useful for serialization or dynamic coding.
  45448. * @returns "PBRClearCoatConfiguration"
  45449. */
  45450. getClassName(): string;
  45451. /**
  45452. * Makes a duplicate of the current configuration into another one.
  45453. * @param brdfConfiguration define the config where to copy the info
  45454. */
  45455. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45456. /**
  45457. * Serializes this BRDF configuration.
  45458. * @returns - An object with the serialized config.
  45459. */
  45460. serialize(): any;
  45461. /**
  45462. * Parses a anisotropy Configuration from a serialized object.
  45463. * @param source - Serialized object.
  45464. * @param scene Defines the scene we are parsing for
  45465. * @param rootUrl Defines the rootUrl to load from
  45466. */
  45467. parse(source: any, scene: Scene, rootUrl: string): void;
  45468. }
  45469. }
  45470. declare module BABYLON {
  45471. /**
  45472. * @hidden
  45473. */
  45474. export interface IMaterialSheenDefines {
  45475. SHEEN: boolean;
  45476. SHEEN_TEXTURE: boolean;
  45477. SHEEN_TEXTUREDIRECTUV: number;
  45478. SHEEN_LINKWITHALBEDO: boolean;
  45479. /** @hidden */
  45480. _areTexturesDirty: boolean;
  45481. }
  45482. /**
  45483. * Define the code related to the Sheen parameters of the pbr material.
  45484. */
  45485. export class PBRSheenConfiguration {
  45486. private _isEnabled;
  45487. /**
  45488. * Defines if the material uses sheen.
  45489. */
  45490. isEnabled: boolean;
  45491. private _linkSheenWithAlbedo;
  45492. /**
  45493. * Defines if the sheen is linked to the sheen color.
  45494. */
  45495. linkSheenWithAlbedo: boolean;
  45496. /**
  45497. * Defines the sheen intensity.
  45498. */
  45499. intensity: number;
  45500. /**
  45501. * Defines the sheen color.
  45502. */
  45503. color: Color3;
  45504. private _texture;
  45505. /**
  45506. * Stores the sheen tint values in a texture.
  45507. * rgb is tint
  45508. * a is a intensity
  45509. */
  45510. texture: Nullable<BaseTexture>;
  45511. /** @hidden */
  45512. private _internalMarkAllSubMeshesAsTexturesDirty;
  45513. /** @hidden */
  45514. _markAllSubMeshesAsTexturesDirty(): void;
  45515. /**
  45516. * Instantiate a new istance of clear coat configuration.
  45517. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45518. */
  45519. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45520. /**
  45521. * Specifies that the submesh is ready to be used.
  45522. * @param defines the list of "defines" to update.
  45523. * @param scene defines the scene the material belongs to.
  45524. * @returns - boolean indicating that the submesh is ready or not.
  45525. */
  45526. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45527. /**
  45528. * Checks to see if a texture is used in the material.
  45529. * @param defines the list of "defines" to update.
  45530. * @param scene defines the scene the material belongs to.
  45531. */
  45532. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45533. /**
  45534. * Binds the material data.
  45535. * @param uniformBuffer defines the Uniform buffer to fill in.
  45536. * @param scene defines the scene the material belongs to.
  45537. * @param isFrozen defines wether the material is frozen or not.
  45538. */
  45539. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45540. /**
  45541. * Checks to see if a texture is used in the material.
  45542. * @param texture - Base texture to use.
  45543. * @returns - Boolean specifying if a texture is used in the material.
  45544. */
  45545. hasTexture(texture: BaseTexture): boolean;
  45546. /**
  45547. * Returns an array of the actively used textures.
  45548. * @param activeTextures Array of BaseTextures
  45549. */
  45550. getActiveTextures(activeTextures: BaseTexture[]): void;
  45551. /**
  45552. * Returns the animatable textures.
  45553. * @param animatables Array of animatable textures.
  45554. */
  45555. getAnimatables(animatables: IAnimatable[]): void;
  45556. /**
  45557. * Disposes the resources of the material.
  45558. * @param forceDisposeTextures - Forces the disposal of all textures.
  45559. */
  45560. dispose(forceDisposeTextures?: boolean): void;
  45561. /**
  45562. * Get the current class name of the texture useful for serialization or dynamic coding.
  45563. * @returns "PBRSheenConfiguration"
  45564. */
  45565. getClassName(): string;
  45566. /**
  45567. * Add fallbacks to the effect fallbacks list.
  45568. * @param defines defines the Base texture to use.
  45569. * @param fallbacks defines the current fallback list.
  45570. * @param currentRank defines the current fallback rank.
  45571. * @returns the new fallback rank.
  45572. */
  45573. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45574. /**
  45575. * Add the required uniforms to the current list.
  45576. * @param uniforms defines the current uniform list.
  45577. */
  45578. static AddUniforms(uniforms: string[]): void;
  45579. /**
  45580. * Add the required uniforms to the current buffer.
  45581. * @param uniformBuffer defines the current uniform buffer.
  45582. */
  45583. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45584. /**
  45585. * Add the required samplers to the current list.
  45586. * @param samplers defines the current sampler list.
  45587. */
  45588. static AddSamplers(samplers: string[]): void;
  45589. /**
  45590. * Makes a duplicate of the current configuration into another one.
  45591. * @param sheenConfiguration define the config where to copy the info
  45592. */
  45593. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45594. /**
  45595. * Serializes this BRDF configuration.
  45596. * @returns - An object with the serialized config.
  45597. */
  45598. serialize(): any;
  45599. /**
  45600. * Parses a anisotropy Configuration from a serialized object.
  45601. * @param source - Serialized object.
  45602. * @param scene Defines the scene we are parsing for
  45603. * @param rootUrl Defines the rootUrl to load from
  45604. */
  45605. parse(source: any, scene: Scene, rootUrl: string): void;
  45606. }
  45607. }
  45608. declare module BABYLON {
  45609. /**
  45610. * @hidden
  45611. */
  45612. export interface IMaterialSubSurfaceDefines {
  45613. SUBSURFACE: boolean;
  45614. SS_REFRACTION: boolean;
  45615. SS_TRANSLUCENCY: boolean;
  45616. SS_SCATERRING: boolean;
  45617. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45618. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45619. SS_REFRACTIONMAP_3D: boolean;
  45620. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45621. SS_LODINREFRACTIONALPHA: boolean;
  45622. SS_GAMMAREFRACTION: boolean;
  45623. SS_RGBDREFRACTION: boolean;
  45624. SS_LINEARSPECULARREFRACTION: boolean;
  45625. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45626. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45627. /** @hidden */
  45628. _areTexturesDirty: boolean;
  45629. }
  45630. /**
  45631. * Define the code related to the sub surface parameters of the pbr material.
  45632. */
  45633. export class PBRSubSurfaceConfiguration {
  45634. private _isRefractionEnabled;
  45635. /**
  45636. * Defines if the refraction is enabled in the material.
  45637. */
  45638. isRefractionEnabled: boolean;
  45639. private _isTranslucencyEnabled;
  45640. /**
  45641. * Defines if the translucency is enabled in the material.
  45642. */
  45643. isTranslucencyEnabled: boolean;
  45644. private _isScatteringEnabled;
  45645. /**
  45646. * Defines the refraction intensity of the material.
  45647. * The refraction when enabled replaces the Diffuse part of the material.
  45648. * The intensity helps transitionning between diffuse and refraction.
  45649. */
  45650. refractionIntensity: number;
  45651. /**
  45652. * Defines the translucency intensity of the material.
  45653. * When translucency has been enabled, this defines how much of the "translucency"
  45654. * is addded to the diffuse part of the material.
  45655. */
  45656. translucencyIntensity: number;
  45657. /**
  45658. * Defines the scattering intensity of the material.
  45659. * When scattering has been enabled, this defines how much of the "scattered light"
  45660. * is addded to the diffuse part of the material.
  45661. */
  45662. scatteringIntensity: number;
  45663. private _thicknessTexture;
  45664. /**
  45665. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45666. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45667. * 0 would mean minimumThickness
  45668. * 1 would mean maximumThickness
  45669. * The other channels might be use as a mask to vary the different effects intensity.
  45670. */
  45671. thicknessTexture: Nullable<BaseTexture>;
  45672. private _refractionTexture;
  45673. /**
  45674. * Defines the texture to use for refraction.
  45675. */
  45676. refractionTexture: Nullable<BaseTexture>;
  45677. private _indexOfRefraction;
  45678. /**
  45679. * Defines the index of refraction used in the material.
  45680. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45681. */
  45682. indexOfRefraction: number;
  45683. private _invertRefractionY;
  45684. /**
  45685. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45686. */
  45687. invertRefractionY: boolean;
  45688. private _linkRefractionWithTransparency;
  45689. /**
  45690. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45691. * Materials half opaque for instance using refraction could benefit from this control.
  45692. */
  45693. linkRefractionWithTransparency: boolean;
  45694. /**
  45695. * Defines the minimum thickness stored in the thickness map.
  45696. * If no thickness map is defined, this value will be used to simulate thickness.
  45697. */
  45698. minimumThickness: number;
  45699. /**
  45700. * Defines the maximum thickness stored in the thickness map.
  45701. */
  45702. maximumThickness: number;
  45703. /**
  45704. * Defines the volume tint of the material.
  45705. * This is used for both translucency and scattering.
  45706. */
  45707. tintColor: Color3;
  45708. /**
  45709. * Defines the distance at which the tint color should be found in the media.
  45710. * This is used for refraction only.
  45711. */
  45712. tintColorAtDistance: number;
  45713. /**
  45714. * Defines how far each channel transmit through the media.
  45715. * It is defined as a color to simplify it selection.
  45716. */
  45717. diffusionDistance: Color3;
  45718. private _useMaskFromThicknessTexture;
  45719. /**
  45720. * Stores the intensity of the different subsurface effects in the thickness texture.
  45721. * * the green channel is the translucency intensity.
  45722. * * the blue channel is the scattering intensity.
  45723. * * the alpha channel is the refraction intensity.
  45724. */
  45725. useMaskFromThicknessTexture: boolean;
  45726. /** @hidden */
  45727. private _internalMarkAllSubMeshesAsTexturesDirty;
  45728. /** @hidden */
  45729. _markAllSubMeshesAsTexturesDirty(): void;
  45730. /**
  45731. * Instantiate a new istance of sub surface configuration.
  45732. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45733. */
  45734. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45735. /**
  45736. * Gets wehter the submesh is ready to be used or not.
  45737. * @param defines the list of "defines" to update.
  45738. * @param scene defines the scene the material belongs to.
  45739. * @returns - boolean indicating that the submesh is ready or not.
  45740. */
  45741. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  45742. /**
  45743. * Checks to see if a texture is used in the material.
  45744. * @param defines the list of "defines" to update.
  45745. * @param scene defines the scene to the material belongs to.
  45746. */
  45747. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  45748. /**
  45749. * Binds the material data.
  45750. * @param uniformBuffer defines the Uniform buffer to fill in.
  45751. * @param scene defines the scene the material belongs to.
  45752. * @param engine defines the engine the material belongs to.
  45753. * @param isFrozen defines wether the material is frozen or not.
  45754. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  45755. */
  45756. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  45757. /**
  45758. * Unbinds the material from the mesh.
  45759. * @param activeEffect defines the effect that should be unbound from.
  45760. * @returns true if unbound, otherwise false
  45761. */
  45762. unbind(activeEffect: Effect): boolean;
  45763. /**
  45764. * Returns the texture used for refraction or null if none is used.
  45765. * @param scene defines the scene the material belongs to.
  45766. * @returns - Refraction texture if present. If no refraction texture and refraction
  45767. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45768. */
  45769. private _getRefractionTexture;
  45770. /**
  45771. * Returns true if alpha blending should be disabled.
  45772. */
  45773. readonly disableAlphaBlending: boolean;
  45774. /**
  45775. * Fills the list of render target textures.
  45776. * @param renderTargets the list of render targets to update
  45777. */
  45778. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  45779. /**
  45780. * Checks to see if a texture is used in the material.
  45781. * @param texture - Base texture to use.
  45782. * @returns - Boolean specifying if a texture is used in the material.
  45783. */
  45784. hasTexture(texture: BaseTexture): boolean;
  45785. /**
  45786. * Gets a boolean indicating that current material needs to register RTT
  45787. * @returns true if this uses a render target otherwise false.
  45788. */
  45789. hasRenderTargetTextures(): boolean;
  45790. /**
  45791. * Returns an array of the actively used textures.
  45792. * @param activeTextures Array of BaseTextures
  45793. */
  45794. getActiveTextures(activeTextures: BaseTexture[]): void;
  45795. /**
  45796. * Returns the animatable textures.
  45797. * @param animatables Array of animatable textures.
  45798. */
  45799. getAnimatables(animatables: IAnimatable[]): void;
  45800. /**
  45801. * Disposes the resources of the material.
  45802. * @param forceDisposeTextures - Forces the disposal of all textures.
  45803. */
  45804. dispose(forceDisposeTextures?: boolean): void;
  45805. /**
  45806. * Get the current class name of the texture useful for serialization or dynamic coding.
  45807. * @returns "PBRSubSurfaceConfiguration"
  45808. */
  45809. getClassName(): string;
  45810. /**
  45811. * Add fallbacks to the effect fallbacks list.
  45812. * @param defines defines the Base texture to use.
  45813. * @param fallbacks defines the current fallback list.
  45814. * @param currentRank defines the current fallback rank.
  45815. * @returns the new fallback rank.
  45816. */
  45817. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45818. /**
  45819. * Add the required uniforms to the current list.
  45820. * @param uniforms defines the current uniform list.
  45821. */
  45822. static AddUniforms(uniforms: string[]): void;
  45823. /**
  45824. * Add the required samplers to the current list.
  45825. * @param samplers defines the current sampler list.
  45826. */
  45827. static AddSamplers(samplers: string[]): void;
  45828. /**
  45829. * Add the required uniforms to the current buffer.
  45830. * @param uniformBuffer defines the current uniform buffer.
  45831. */
  45832. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45833. /**
  45834. * Makes a duplicate of the current configuration into another one.
  45835. * @param configuration define the config where to copy the info
  45836. */
  45837. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  45838. /**
  45839. * Serializes this Sub Surface configuration.
  45840. * @returns - An object with the serialized config.
  45841. */
  45842. serialize(): any;
  45843. /**
  45844. * Parses a anisotropy Configuration from a serialized object.
  45845. * @param source - Serialized object.
  45846. * @param scene Defines the scene we are parsing for
  45847. * @param rootUrl Defines the rootUrl to load from
  45848. */
  45849. parse(source: any, scene: Scene, rootUrl: string): void;
  45850. }
  45851. }
  45852. declare module BABYLON {
  45853. /** @hidden */
  45854. export var pbrFragmentDeclaration: {
  45855. name: string;
  45856. shader: string;
  45857. };
  45858. }
  45859. declare module BABYLON {
  45860. /** @hidden */
  45861. export var pbrUboDeclaration: {
  45862. name: string;
  45863. shader: string;
  45864. };
  45865. }
  45866. declare module BABYLON {
  45867. /** @hidden */
  45868. export var pbrFragmentExtraDeclaration: {
  45869. name: string;
  45870. shader: string;
  45871. };
  45872. }
  45873. declare module BABYLON {
  45874. /** @hidden */
  45875. export var pbrFragmentSamplersDeclaration: {
  45876. name: string;
  45877. shader: string;
  45878. };
  45879. }
  45880. declare module BABYLON {
  45881. /** @hidden */
  45882. export var pbrHelperFunctions: {
  45883. name: string;
  45884. shader: string;
  45885. };
  45886. }
  45887. declare module BABYLON {
  45888. /** @hidden */
  45889. export var harmonicsFunctions: {
  45890. name: string;
  45891. shader: string;
  45892. };
  45893. }
  45894. declare module BABYLON {
  45895. /** @hidden */
  45896. export var pbrDirectLightingSetupFunctions: {
  45897. name: string;
  45898. shader: string;
  45899. };
  45900. }
  45901. declare module BABYLON {
  45902. /** @hidden */
  45903. export var pbrDirectLightingFalloffFunctions: {
  45904. name: string;
  45905. shader: string;
  45906. };
  45907. }
  45908. declare module BABYLON {
  45909. /** @hidden */
  45910. export var pbrBRDFFunctions: {
  45911. name: string;
  45912. shader: string;
  45913. };
  45914. }
  45915. declare module BABYLON {
  45916. /** @hidden */
  45917. export var pbrDirectLightingFunctions: {
  45918. name: string;
  45919. shader: string;
  45920. };
  45921. }
  45922. declare module BABYLON {
  45923. /** @hidden */
  45924. export var pbrIBLFunctions: {
  45925. name: string;
  45926. shader: string;
  45927. };
  45928. }
  45929. declare module BABYLON {
  45930. /** @hidden */
  45931. export var pbrDebug: {
  45932. name: string;
  45933. shader: string;
  45934. };
  45935. }
  45936. declare module BABYLON {
  45937. /** @hidden */
  45938. export var pbrPixelShader: {
  45939. name: string;
  45940. shader: string;
  45941. };
  45942. }
  45943. declare module BABYLON {
  45944. /** @hidden */
  45945. export var pbrVertexDeclaration: {
  45946. name: string;
  45947. shader: string;
  45948. };
  45949. }
  45950. declare module BABYLON {
  45951. /** @hidden */
  45952. export var pbrVertexShader: {
  45953. name: string;
  45954. shader: string;
  45955. };
  45956. }
  45957. declare module BABYLON {
  45958. /**
  45959. * Manages the defines for the PBR Material.
  45960. * @hidden
  45961. */
  45962. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  45963. PBR: boolean;
  45964. MAINUV1: boolean;
  45965. MAINUV2: boolean;
  45966. UV1: boolean;
  45967. UV2: boolean;
  45968. ALBEDO: boolean;
  45969. ALBEDODIRECTUV: number;
  45970. VERTEXCOLOR: boolean;
  45971. AMBIENT: boolean;
  45972. AMBIENTDIRECTUV: number;
  45973. AMBIENTINGRAYSCALE: boolean;
  45974. OPACITY: boolean;
  45975. VERTEXALPHA: boolean;
  45976. OPACITYDIRECTUV: number;
  45977. OPACITYRGB: boolean;
  45978. ALPHATEST: boolean;
  45979. DEPTHPREPASS: boolean;
  45980. ALPHABLEND: boolean;
  45981. ALPHAFROMALBEDO: boolean;
  45982. ALPHATESTVALUE: string;
  45983. SPECULAROVERALPHA: boolean;
  45984. RADIANCEOVERALPHA: boolean;
  45985. ALPHAFRESNEL: boolean;
  45986. LINEARALPHAFRESNEL: boolean;
  45987. PREMULTIPLYALPHA: boolean;
  45988. EMISSIVE: boolean;
  45989. EMISSIVEDIRECTUV: number;
  45990. REFLECTIVITY: boolean;
  45991. REFLECTIVITYDIRECTUV: number;
  45992. SPECULARTERM: boolean;
  45993. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  45994. MICROSURFACEAUTOMATIC: boolean;
  45995. LODBASEDMICROSFURACE: boolean;
  45996. MICROSURFACEMAP: boolean;
  45997. MICROSURFACEMAPDIRECTUV: number;
  45998. METALLICWORKFLOW: boolean;
  45999. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46000. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46001. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46002. AOSTOREINMETALMAPRED: boolean;
  46003. ENVIRONMENTBRDF: boolean;
  46004. ENVIRONMENTBRDF_RGBD: boolean;
  46005. NORMAL: boolean;
  46006. TANGENT: boolean;
  46007. BUMP: boolean;
  46008. BUMPDIRECTUV: number;
  46009. OBJECTSPACE_NORMALMAP: boolean;
  46010. PARALLAX: boolean;
  46011. PARALLAXOCCLUSION: boolean;
  46012. NORMALXYSCALE: boolean;
  46013. LIGHTMAP: boolean;
  46014. LIGHTMAPDIRECTUV: number;
  46015. USELIGHTMAPASSHADOWMAP: boolean;
  46016. GAMMALIGHTMAP: boolean;
  46017. REFLECTION: boolean;
  46018. REFLECTIONMAP_3D: boolean;
  46019. REFLECTIONMAP_SPHERICAL: boolean;
  46020. REFLECTIONMAP_PLANAR: boolean;
  46021. REFLECTIONMAP_CUBIC: boolean;
  46022. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46023. REFLECTIONMAP_PROJECTION: boolean;
  46024. REFLECTIONMAP_SKYBOX: boolean;
  46025. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46026. REFLECTIONMAP_EXPLICIT: boolean;
  46027. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46028. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46029. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46030. INVERTCUBICMAP: boolean;
  46031. USESPHERICALFROMREFLECTIONMAP: boolean;
  46032. USEIRRADIANCEMAP: boolean;
  46033. SPHERICAL_HARMONICS: boolean;
  46034. USESPHERICALINVERTEX: boolean;
  46035. REFLECTIONMAP_OPPOSITEZ: boolean;
  46036. LODINREFLECTIONALPHA: boolean;
  46037. GAMMAREFLECTION: boolean;
  46038. RGBDREFLECTION: boolean;
  46039. LINEARSPECULARREFLECTION: boolean;
  46040. RADIANCEOCCLUSION: boolean;
  46041. HORIZONOCCLUSION: boolean;
  46042. INSTANCES: boolean;
  46043. NUM_BONE_INFLUENCERS: number;
  46044. BonesPerMesh: number;
  46045. BONETEXTURE: boolean;
  46046. NONUNIFORMSCALING: boolean;
  46047. MORPHTARGETS: boolean;
  46048. MORPHTARGETS_NORMAL: boolean;
  46049. MORPHTARGETS_TANGENT: boolean;
  46050. MORPHTARGETS_UV: boolean;
  46051. NUM_MORPH_INFLUENCERS: number;
  46052. IMAGEPROCESSING: boolean;
  46053. VIGNETTE: boolean;
  46054. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46055. VIGNETTEBLENDMODEOPAQUE: boolean;
  46056. TONEMAPPING: boolean;
  46057. TONEMAPPING_ACES: boolean;
  46058. CONTRAST: boolean;
  46059. COLORCURVES: boolean;
  46060. COLORGRADING: boolean;
  46061. COLORGRADING3D: boolean;
  46062. SAMPLER3DGREENDEPTH: boolean;
  46063. SAMPLER3DBGRMAP: boolean;
  46064. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46065. EXPOSURE: boolean;
  46066. MULTIVIEW: boolean;
  46067. USEPHYSICALLIGHTFALLOFF: boolean;
  46068. USEGLTFLIGHTFALLOFF: boolean;
  46069. TWOSIDEDLIGHTING: boolean;
  46070. SHADOWFLOAT: boolean;
  46071. CLIPPLANE: boolean;
  46072. CLIPPLANE2: boolean;
  46073. CLIPPLANE3: boolean;
  46074. CLIPPLANE4: boolean;
  46075. POINTSIZE: boolean;
  46076. FOG: boolean;
  46077. LOGARITHMICDEPTH: boolean;
  46078. FORCENORMALFORWARD: boolean;
  46079. SPECULARAA: boolean;
  46080. CLEARCOAT: boolean;
  46081. CLEARCOAT_DEFAULTIOR: boolean;
  46082. CLEARCOAT_TEXTURE: boolean;
  46083. CLEARCOAT_TEXTUREDIRECTUV: number;
  46084. CLEARCOAT_BUMP: boolean;
  46085. CLEARCOAT_BUMPDIRECTUV: number;
  46086. CLEARCOAT_TINT: boolean;
  46087. CLEARCOAT_TINT_TEXTURE: boolean;
  46088. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46089. ANISOTROPIC: boolean;
  46090. ANISOTROPIC_TEXTURE: boolean;
  46091. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46092. BRDF_V_HEIGHT_CORRELATED: boolean;
  46093. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46094. SHEEN: boolean;
  46095. SHEEN_TEXTURE: boolean;
  46096. SHEEN_TEXTUREDIRECTUV: number;
  46097. SHEEN_LINKWITHALBEDO: boolean;
  46098. SUBSURFACE: boolean;
  46099. SS_REFRACTION: boolean;
  46100. SS_TRANSLUCENCY: boolean;
  46101. SS_SCATERRING: boolean;
  46102. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46103. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46104. SS_REFRACTIONMAP_3D: boolean;
  46105. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46106. SS_LODINREFRACTIONALPHA: boolean;
  46107. SS_GAMMAREFRACTION: boolean;
  46108. SS_RGBDREFRACTION: boolean;
  46109. SS_LINEARSPECULARREFRACTION: boolean;
  46110. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46111. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46112. UNLIT: boolean;
  46113. DEBUGMODE: number;
  46114. /**
  46115. * Initializes the PBR Material defines.
  46116. */
  46117. constructor();
  46118. /**
  46119. * Resets the PBR Material defines.
  46120. */
  46121. reset(): void;
  46122. }
  46123. /**
  46124. * The Physically based material base class of BJS.
  46125. *
  46126. * This offers the main features of a standard PBR material.
  46127. * For more information, please refer to the documentation :
  46128. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46129. */
  46130. export abstract class PBRBaseMaterial extends PushMaterial {
  46131. /**
  46132. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46133. */
  46134. static readonly PBRMATERIAL_OPAQUE: number;
  46135. /**
  46136. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46137. */
  46138. static readonly PBRMATERIAL_ALPHATEST: number;
  46139. /**
  46140. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46141. */
  46142. static readonly PBRMATERIAL_ALPHABLEND: number;
  46143. /**
  46144. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46145. * They are also discarded below the alpha cutoff threshold to improve performances.
  46146. */
  46147. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46148. /**
  46149. * Defines the default value of how much AO map is occluding the analytical lights
  46150. * (point spot...).
  46151. */
  46152. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46153. /**
  46154. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46155. */
  46156. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46157. /**
  46158. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46159. * to enhance interoperability with other engines.
  46160. */
  46161. static readonly LIGHTFALLOFF_GLTF: number;
  46162. /**
  46163. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46164. * to enhance interoperability with other materials.
  46165. */
  46166. static readonly LIGHTFALLOFF_STANDARD: number;
  46167. /**
  46168. * Intensity of the direct lights e.g. the four lights available in your scene.
  46169. * This impacts both the direct diffuse and specular highlights.
  46170. */
  46171. protected _directIntensity: number;
  46172. /**
  46173. * Intensity of the emissive part of the material.
  46174. * This helps controlling the emissive effect without modifying the emissive color.
  46175. */
  46176. protected _emissiveIntensity: number;
  46177. /**
  46178. * Intensity of the environment e.g. how much the environment will light the object
  46179. * either through harmonics for rough material or through the refelction for shiny ones.
  46180. */
  46181. protected _environmentIntensity: number;
  46182. /**
  46183. * This is a special control allowing the reduction of the specular highlights coming from the
  46184. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46185. */
  46186. protected _specularIntensity: number;
  46187. /**
  46188. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46189. */
  46190. private _lightingInfos;
  46191. /**
  46192. * Debug Control allowing disabling the bump map on this material.
  46193. */
  46194. protected _disableBumpMap: boolean;
  46195. /**
  46196. * AKA Diffuse Texture in standard nomenclature.
  46197. */
  46198. protected _albedoTexture: Nullable<BaseTexture>;
  46199. /**
  46200. * AKA Occlusion Texture in other nomenclature.
  46201. */
  46202. protected _ambientTexture: Nullable<BaseTexture>;
  46203. /**
  46204. * AKA Occlusion Texture Intensity in other nomenclature.
  46205. */
  46206. protected _ambientTextureStrength: number;
  46207. /**
  46208. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46209. * 1 means it completely occludes it
  46210. * 0 mean it has no impact
  46211. */
  46212. protected _ambientTextureImpactOnAnalyticalLights: number;
  46213. /**
  46214. * Stores the alpha values in a texture.
  46215. */
  46216. protected _opacityTexture: Nullable<BaseTexture>;
  46217. /**
  46218. * Stores the reflection values in a texture.
  46219. */
  46220. protected _reflectionTexture: Nullable<BaseTexture>;
  46221. /**
  46222. * Stores the emissive values in a texture.
  46223. */
  46224. protected _emissiveTexture: Nullable<BaseTexture>;
  46225. /**
  46226. * AKA Specular texture in other nomenclature.
  46227. */
  46228. protected _reflectivityTexture: Nullable<BaseTexture>;
  46229. /**
  46230. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46231. */
  46232. protected _metallicTexture: Nullable<BaseTexture>;
  46233. /**
  46234. * Specifies the metallic scalar of the metallic/roughness workflow.
  46235. * Can also be used to scale the metalness values of the metallic texture.
  46236. */
  46237. protected _metallic: Nullable<number>;
  46238. /**
  46239. * Specifies the roughness scalar of the metallic/roughness workflow.
  46240. * Can also be used to scale the roughness values of the metallic texture.
  46241. */
  46242. protected _roughness: Nullable<number>;
  46243. /**
  46244. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46245. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46246. */
  46247. protected _microSurfaceTexture: Nullable<BaseTexture>;
  46248. /**
  46249. * Stores surface normal data used to displace a mesh in a texture.
  46250. */
  46251. protected _bumpTexture: Nullable<BaseTexture>;
  46252. /**
  46253. * Stores the pre-calculated light information of a mesh in a texture.
  46254. */
  46255. protected _lightmapTexture: Nullable<BaseTexture>;
  46256. /**
  46257. * The color of a material in ambient lighting.
  46258. */
  46259. protected _ambientColor: Color3;
  46260. /**
  46261. * AKA Diffuse Color in other nomenclature.
  46262. */
  46263. protected _albedoColor: Color3;
  46264. /**
  46265. * AKA Specular Color in other nomenclature.
  46266. */
  46267. protected _reflectivityColor: Color3;
  46268. /**
  46269. * The color applied when light is reflected from a material.
  46270. */
  46271. protected _reflectionColor: Color3;
  46272. /**
  46273. * The color applied when light is emitted from a material.
  46274. */
  46275. protected _emissiveColor: Color3;
  46276. /**
  46277. * AKA Glossiness in other nomenclature.
  46278. */
  46279. protected _microSurface: number;
  46280. /**
  46281. * Specifies that the material will use the light map as a show map.
  46282. */
  46283. protected _useLightmapAsShadowmap: boolean;
  46284. /**
  46285. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46286. * makes the reflect vector face the model (under horizon).
  46287. */
  46288. protected _useHorizonOcclusion: boolean;
  46289. /**
  46290. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46291. * too much the area relying on ambient texture to define their ambient occlusion.
  46292. */
  46293. protected _useRadianceOcclusion: boolean;
  46294. /**
  46295. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46296. */
  46297. protected _useAlphaFromAlbedoTexture: boolean;
  46298. /**
  46299. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46300. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46301. */
  46302. protected _useSpecularOverAlpha: boolean;
  46303. /**
  46304. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46305. */
  46306. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46307. /**
  46308. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46309. */
  46310. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46311. /**
  46312. * Specifies if the metallic texture contains the roughness information in its green channel.
  46313. */
  46314. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46315. /**
  46316. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46317. */
  46318. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46319. /**
  46320. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46321. */
  46322. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46323. /**
  46324. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46325. */
  46326. protected _useAmbientInGrayScale: boolean;
  46327. /**
  46328. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46329. * The material will try to infer what glossiness each pixel should be.
  46330. */
  46331. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46332. /**
  46333. * Defines the falloff type used in this material.
  46334. * It by default is Physical.
  46335. */
  46336. protected _lightFalloff: number;
  46337. /**
  46338. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46339. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46340. */
  46341. protected _useRadianceOverAlpha: boolean;
  46342. /**
  46343. * Allows using an object space normal map (instead of tangent space).
  46344. */
  46345. protected _useObjectSpaceNormalMap: boolean;
  46346. /**
  46347. * Allows using the bump map in parallax mode.
  46348. */
  46349. protected _useParallax: boolean;
  46350. /**
  46351. * Allows using the bump map in parallax occlusion mode.
  46352. */
  46353. protected _useParallaxOcclusion: boolean;
  46354. /**
  46355. * Controls the scale bias of the parallax mode.
  46356. */
  46357. protected _parallaxScaleBias: number;
  46358. /**
  46359. * If sets to true, disables all the lights affecting the material.
  46360. */
  46361. protected _disableLighting: boolean;
  46362. /**
  46363. * Number of Simultaneous lights allowed on the material.
  46364. */
  46365. protected _maxSimultaneousLights: number;
  46366. /**
  46367. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46368. */
  46369. protected _invertNormalMapX: boolean;
  46370. /**
  46371. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46372. */
  46373. protected _invertNormalMapY: boolean;
  46374. /**
  46375. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46376. */
  46377. protected _twoSidedLighting: boolean;
  46378. /**
  46379. * Defines the alpha limits in alpha test mode.
  46380. */
  46381. protected _alphaCutOff: number;
  46382. /**
  46383. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46384. */
  46385. protected _forceAlphaTest: boolean;
  46386. /**
  46387. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46388. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46389. */
  46390. protected _useAlphaFresnel: boolean;
  46391. /**
  46392. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46393. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46394. */
  46395. protected _useLinearAlphaFresnel: boolean;
  46396. /**
  46397. * The transparency mode of the material.
  46398. */
  46399. protected _transparencyMode: Nullable<number>;
  46400. /**
  46401. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46402. * from cos thetav and roughness:
  46403. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46404. */
  46405. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46406. /**
  46407. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46408. */
  46409. protected _forceIrradianceInFragment: boolean;
  46410. /**
  46411. * Force normal to face away from face.
  46412. */
  46413. protected _forceNormalForward: boolean;
  46414. /**
  46415. * Enables specular anti aliasing in the PBR shader.
  46416. * It will both interacts on the Geometry for analytical and IBL lighting.
  46417. * It also prefilter the roughness map based on the bump values.
  46418. */
  46419. protected _enableSpecularAntiAliasing: boolean;
  46420. /**
  46421. * Default configuration related to image processing available in the PBR Material.
  46422. */
  46423. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46424. /**
  46425. * Keep track of the image processing observer to allow dispose and replace.
  46426. */
  46427. private _imageProcessingObserver;
  46428. /**
  46429. * Attaches a new image processing configuration to the PBR Material.
  46430. * @param configuration
  46431. */
  46432. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46433. /**
  46434. * Stores the available render targets.
  46435. */
  46436. private _renderTargets;
  46437. /**
  46438. * Sets the global ambient color for the material used in lighting calculations.
  46439. */
  46440. private _globalAmbientColor;
  46441. /**
  46442. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46443. */
  46444. private _useLogarithmicDepth;
  46445. /**
  46446. * If set to true, no lighting calculations will be applied.
  46447. */
  46448. private _unlit;
  46449. private _debugMode;
  46450. /**
  46451. * @hidden
  46452. * This is reserved for the inspector.
  46453. * Defines the material debug mode.
  46454. * It helps seeing only some components of the material while troubleshooting.
  46455. */
  46456. debugMode: number;
  46457. /**
  46458. * @hidden
  46459. * This is reserved for the inspector.
  46460. * Specify from where on screen the debug mode should start.
  46461. * The value goes from -1 (full screen) to 1 (not visible)
  46462. * It helps with side by side comparison against the final render
  46463. * This defaults to -1
  46464. */
  46465. private debugLimit;
  46466. /**
  46467. * @hidden
  46468. * This is reserved for the inspector.
  46469. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46470. * You can use the factor to better multiply the final value.
  46471. */
  46472. private debugFactor;
  46473. /**
  46474. * Defines the clear coat layer parameters for the material.
  46475. */
  46476. readonly clearCoat: PBRClearCoatConfiguration;
  46477. /**
  46478. * Defines the anisotropic parameters for the material.
  46479. */
  46480. readonly anisotropy: PBRAnisotropicConfiguration;
  46481. /**
  46482. * Defines the BRDF parameters for the material.
  46483. */
  46484. readonly brdf: PBRBRDFConfiguration;
  46485. /**
  46486. * Defines the Sheen parameters for the material.
  46487. */
  46488. readonly sheen: PBRSheenConfiguration;
  46489. /**
  46490. * Defines the SubSurface parameters for the material.
  46491. */
  46492. readonly subSurface: PBRSubSurfaceConfiguration;
  46493. /**
  46494. * Custom callback helping to override the default shader used in the material.
  46495. */
  46496. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46497. /**
  46498. * Instantiates a new PBRMaterial instance.
  46499. *
  46500. * @param name The material name
  46501. * @param scene The scene the material will be use in.
  46502. */
  46503. constructor(name: string, scene: Scene);
  46504. /**
  46505. * Gets a boolean indicating that current material needs to register RTT
  46506. */
  46507. readonly hasRenderTargetTextures: boolean;
  46508. /**
  46509. * Gets the name of the material class.
  46510. */
  46511. getClassName(): string;
  46512. /**
  46513. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46514. */
  46515. /**
  46516. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46517. */
  46518. useLogarithmicDepth: boolean;
  46519. /**
  46520. * Gets the current transparency mode.
  46521. */
  46522. /**
  46523. * Sets the transparency mode of the material.
  46524. *
  46525. * | Value | Type | Description |
  46526. * | ----- | ----------------------------------- | ----------- |
  46527. * | 0 | OPAQUE | |
  46528. * | 1 | ALPHATEST | |
  46529. * | 2 | ALPHABLEND | |
  46530. * | 3 | ALPHATESTANDBLEND | |
  46531. *
  46532. */
  46533. transparencyMode: Nullable<number>;
  46534. /**
  46535. * Returns true if alpha blending should be disabled.
  46536. */
  46537. private readonly _disableAlphaBlending;
  46538. /**
  46539. * Specifies whether or not this material should be rendered in alpha blend mode.
  46540. */
  46541. needAlphaBlending(): boolean;
  46542. /**
  46543. * Specifies if the mesh will require alpha blending.
  46544. * @param mesh - BJS mesh.
  46545. */
  46546. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46547. /**
  46548. * Specifies whether or not this material should be rendered in alpha test mode.
  46549. */
  46550. needAlphaTesting(): boolean;
  46551. /**
  46552. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46553. */
  46554. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46555. /**
  46556. * Gets the texture used for the alpha test.
  46557. */
  46558. getAlphaTestTexture(): Nullable<BaseTexture>;
  46559. /**
  46560. * Specifies that the submesh is ready to be used.
  46561. * @param mesh - BJS mesh.
  46562. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46563. * @param useInstances - Specifies that instances should be used.
  46564. * @returns - boolean indicating that the submesh is ready or not.
  46565. */
  46566. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46567. /**
  46568. * Specifies if the material uses metallic roughness workflow.
  46569. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46570. */
  46571. isMetallicWorkflow(): boolean;
  46572. private _prepareEffect;
  46573. private _prepareDefines;
  46574. /**
  46575. * Force shader compilation
  46576. */
  46577. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46578. clipPlane: boolean;
  46579. }>): void;
  46580. /**
  46581. * Initializes the uniform buffer layout for the shader.
  46582. */
  46583. buildUniformLayout(): void;
  46584. /**
  46585. * Unbinds the material from the mesh
  46586. */
  46587. unbind(): void;
  46588. /**
  46589. * Binds the submesh data.
  46590. * @param world - The world matrix.
  46591. * @param mesh - The BJS mesh.
  46592. * @param subMesh - A submesh of the BJS mesh.
  46593. */
  46594. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46595. /**
  46596. * Returns the animatable textures.
  46597. * @returns - Array of animatable textures.
  46598. */
  46599. getAnimatables(): IAnimatable[];
  46600. /**
  46601. * Returns the texture used for reflections.
  46602. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46603. */
  46604. private _getReflectionTexture;
  46605. /**
  46606. * Returns an array of the actively used textures.
  46607. * @returns - Array of BaseTextures
  46608. */
  46609. getActiveTextures(): BaseTexture[];
  46610. /**
  46611. * Checks to see if a texture is used in the material.
  46612. * @param texture - Base texture to use.
  46613. * @returns - Boolean specifying if a texture is used in the material.
  46614. */
  46615. hasTexture(texture: BaseTexture): boolean;
  46616. /**
  46617. * Disposes the resources of the material.
  46618. * @param forceDisposeEffect - Forces the disposal of effects.
  46619. * @param forceDisposeTextures - Forces the disposal of all textures.
  46620. */
  46621. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46622. }
  46623. }
  46624. declare module BABYLON {
  46625. /**
  46626. * The Physically based material of BJS.
  46627. *
  46628. * This offers the main features of a standard PBR material.
  46629. * For more information, please refer to the documentation :
  46630. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46631. */
  46632. export class PBRMaterial extends PBRBaseMaterial {
  46633. /**
  46634. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46635. */
  46636. static readonly PBRMATERIAL_OPAQUE: number;
  46637. /**
  46638. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46639. */
  46640. static readonly PBRMATERIAL_ALPHATEST: number;
  46641. /**
  46642. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46643. */
  46644. static readonly PBRMATERIAL_ALPHABLEND: number;
  46645. /**
  46646. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46647. * They are also discarded below the alpha cutoff threshold to improve performances.
  46648. */
  46649. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46650. /**
  46651. * Defines the default value of how much AO map is occluding the analytical lights
  46652. * (point spot...).
  46653. */
  46654. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46655. /**
  46656. * Intensity of the direct lights e.g. the four lights available in your scene.
  46657. * This impacts both the direct diffuse and specular highlights.
  46658. */
  46659. directIntensity: number;
  46660. /**
  46661. * Intensity of the emissive part of the material.
  46662. * This helps controlling the emissive effect without modifying the emissive color.
  46663. */
  46664. emissiveIntensity: number;
  46665. /**
  46666. * Intensity of the environment e.g. how much the environment will light the object
  46667. * either through harmonics for rough material or through the refelction for shiny ones.
  46668. */
  46669. environmentIntensity: number;
  46670. /**
  46671. * This is a special control allowing the reduction of the specular highlights coming from the
  46672. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46673. */
  46674. specularIntensity: number;
  46675. /**
  46676. * Debug Control allowing disabling the bump map on this material.
  46677. */
  46678. disableBumpMap: boolean;
  46679. /**
  46680. * AKA Diffuse Texture in standard nomenclature.
  46681. */
  46682. albedoTexture: BaseTexture;
  46683. /**
  46684. * AKA Occlusion Texture in other nomenclature.
  46685. */
  46686. ambientTexture: BaseTexture;
  46687. /**
  46688. * AKA Occlusion Texture Intensity in other nomenclature.
  46689. */
  46690. ambientTextureStrength: number;
  46691. /**
  46692. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46693. * 1 means it completely occludes it
  46694. * 0 mean it has no impact
  46695. */
  46696. ambientTextureImpactOnAnalyticalLights: number;
  46697. /**
  46698. * Stores the alpha values in a texture.
  46699. */
  46700. opacityTexture: BaseTexture;
  46701. /**
  46702. * Stores the reflection values in a texture.
  46703. */
  46704. reflectionTexture: Nullable<BaseTexture>;
  46705. /**
  46706. * Stores the emissive values in a texture.
  46707. */
  46708. emissiveTexture: BaseTexture;
  46709. /**
  46710. * AKA Specular texture in other nomenclature.
  46711. */
  46712. reflectivityTexture: BaseTexture;
  46713. /**
  46714. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46715. */
  46716. metallicTexture: BaseTexture;
  46717. /**
  46718. * Specifies the metallic scalar of the metallic/roughness workflow.
  46719. * Can also be used to scale the metalness values of the metallic texture.
  46720. */
  46721. metallic: Nullable<number>;
  46722. /**
  46723. * Specifies the roughness scalar of the metallic/roughness workflow.
  46724. * Can also be used to scale the roughness values of the metallic texture.
  46725. */
  46726. roughness: Nullable<number>;
  46727. /**
  46728. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46729. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46730. */
  46731. microSurfaceTexture: BaseTexture;
  46732. /**
  46733. * Stores surface normal data used to displace a mesh in a texture.
  46734. */
  46735. bumpTexture: BaseTexture;
  46736. /**
  46737. * Stores the pre-calculated light information of a mesh in a texture.
  46738. */
  46739. lightmapTexture: BaseTexture;
  46740. /**
  46741. * Stores the refracted light information in a texture.
  46742. */
  46743. refractionTexture: Nullable<BaseTexture>;
  46744. /**
  46745. * The color of a material in ambient lighting.
  46746. */
  46747. ambientColor: Color3;
  46748. /**
  46749. * AKA Diffuse Color in other nomenclature.
  46750. */
  46751. albedoColor: Color3;
  46752. /**
  46753. * AKA Specular Color in other nomenclature.
  46754. */
  46755. reflectivityColor: Color3;
  46756. /**
  46757. * The color reflected from the material.
  46758. */
  46759. reflectionColor: Color3;
  46760. /**
  46761. * The color emitted from the material.
  46762. */
  46763. emissiveColor: Color3;
  46764. /**
  46765. * AKA Glossiness in other nomenclature.
  46766. */
  46767. microSurface: number;
  46768. /**
  46769. * source material index of refraction (IOR)' / 'destination material IOR.
  46770. */
  46771. indexOfRefraction: number;
  46772. /**
  46773. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46774. */
  46775. invertRefractionY: boolean;
  46776. /**
  46777. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46778. * Materials half opaque for instance using refraction could benefit from this control.
  46779. */
  46780. linkRefractionWithTransparency: boolean;
  46781. /**
  46782. * If true, the light map contains occlusion information instead of lighting info.
  46783. */
  46784. useLightmapAsShadowmap: boolean;
  46785. /**
  46786. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46787. */
  46788. useAlphaFromAlbedoTexture: boolean;
  46789. /**
  46790. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46791. */
  46792. forceAlphaTest: boolean;
  46793. /**
  46794. * Defines the alpha limits in alpha test mode.
  46795. */
  46796. alphaCutOff: number;
  46797. /**
  46798. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46799. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46800. */
  46801. useSpecularOverAlpha: boolean;
  46802. /**
  46803. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46804. */
  46805. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46806. /**
  46807. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46808. */
  46809. useRoughnessFromMetallicTextureAlpha: boolean;
  46810. /**
  46811. * Specifies if the metallic texture contains the roughness information in its green channel.
  46812. */
  46813. useRoughnessFromMetallicTextureGreen: boolean;
  46814. /**
  46815. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46816. */
  46817. useMetallnessFromMetallicTextureBlue: boolean;
  46818. /**
  46819. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46820. */
  46821. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46822. /**
  46823. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46824. */
  46825. useAmbientInGrayScale: boolean;
  46826. /**
  46827. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46828. * The material will try to infer what glossiness each pixel should be.
  46829. */
  46830. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46831. /**
  46832. * BJS is using an harcoded light falloff based on a manually sets up range.
  46833. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46834. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46835. */
  46836. /**
  46837. * BJS is using an harcoded light falloff based on a manually sets up range.
  46838. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46839. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46840. */
  46841. usePhysicalLightFalloff: boolean;
  46842. /**
  46843. * In order to support the falloff compatibility with gltf, a special mode has been added
  46844. * to reproduce the gltf light falloff.
  46845. */
  46846. /**
  46847. * In order to support the falloff compatibility with gltf, a special mode has been added
  46848. * to reproduce the gltf light falloff.
  46849. */
  46850. useGLTFLightFalloff: boolean;
  46851. /**
  46852. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46853. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46854. */
  46855. useRadianceOverAlpha: boolean;
  46856. /**
  46857. * Allows using an object space normal map (instead of tangent space).
  46858. */
  46859. useObjectSpaceNormalMap: boolean;
  46860. /**
  46861. * Allows using the bump map in parallax mode.
  46862. */
  46863. useParallax: boolean;
  46864. /**
  46865. * Allows using the bump map in parallax occlusion mode.
  46866. */
  46867. useParallaxOcclusion: boolean;
  46868. /**
  46869. * Controls the scale bias of the parallax mode.
  46870. */
  46871. parallaxScaleBias: number;
  46872. /**
  46873. * If sets to true, disables all the lights affecting the material.
  46874. */
  46875. disableLighting: boolean;
  46876. /**
  46877. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46878. */
  46879. forceIrradianceInFragment: boolean;
  46880. /**
  46881. * Number of Simultaneous lights allowed on the material.
  46882. */
  46883. maxSimultaneousLights: number;
  46884. /**
  46885. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46886. */
  46887. invertNormalMapX: boolean;
  46888. /**
  46889. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46890. */
  46891. invertNormalMapY: boolean;
  46892. /**
  46893. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46894. */
  46895. twoSidedLighting: boolean;
  46896. /**
  46897. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46898. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46899. */
  46900. useAlphaFresnel: boolean;
  46901. /**
  46902. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46903. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46904. */
  46905. useLinearAlphaFresnel: boolean;
  46906. /**
  46907. * Let user defines the brdf lookup texture used for IBL.
  46908. * A default 8bit version is embedded but you could point at :
  46909. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  46910. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46911. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  46912. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46913. */
  46914. environmentBRDFTexture: Nullable<BaseTexture>;
  46915. /**
  46916. * Force normal to face away from face.
  46917. */
  46918. forceNormalForward: boolean;
  46919. /**
  46920. * Enables specular anti aliasing in the PBR shader.
  46921. * It will both interacts on the Geometry for analytical and IBL lighting.
  46922. * It also prefilter the roughness map based on the bump values.
  46923. */
  46924. enableSpecularAntiAliasing: boolean;
  46925. /**
  46926. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46927. * makes the reflect vector face the model (under horizon).
  46928. */
  46929. useHorizonOcclusion: boolean;
  46930. /**
  46931. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46932. * too much the area relying on ambient texture to define their ambient occlusion.
  46933. */
  46934. useRadianceOcclusion: boolean;
  46935. /**
  46936. * If set to true, no lighting calculations will be applied.
  46937. */
  46938. unlit: boolean;
  46939. /**
  46940. * Gets the image processing configuration used either in this material.
  46941. */
  46942. /**
  46943. * Sets the Default image processing configuration used either in the this material.
  46944. *
  46945. * If sets to null, the scene one is in use.
  46946. */
  46947. imageProcessingConfiguration: ImageProcessingConfiguration;
  46948. /**
  46949. * Gets wether the color curves effect is enabled.
  46950. */
  46951. /**
  46952. * Sets wether the color curves effect is enabled.
  46953. */
  46954. cameraColorCurvesEnabled: boolean;
  46955. /**
  46956. * Gets wether the color grading effect is enabled.
  46957. */
  46958. /**
  46959. * Gets wether the color grading effect is enabled.
  46960. */
  46961. cameraColorGradingEnabled: boolean;
  46962. /**
  46963. * Gets wether tonemapping is enabled or not.
  46964. */
  46965. /**
  46966. * Sets wether tonemapping is enabled or not
  46967. */
  46968. cameraToneMappingEnabled: boolean;
  46969. /**
  46970. * The camera exposure used on this material.
  46971. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46972. * This corresponds to a photographic exposure.
  46973. */
  46974. /**
  46975. * The camera exposure used on this material.
  46976. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46977. * This corresponds to a photographic exposure.
  46978. */
  46979. cameraExposure: number;
  46980. /**
  46981. * Gets The camera contrast used on this material.
  46982. */
  46983. /**
  46984. * Sets The camera contrast used on this material.
  46985. */
  46986. cameraContrast: number;
  46987. /**
  46988. * Gets the Color Grading 2D Lookup Texture.
  46989. */
  46990. /**
  46991. * Sets the Color Grading 2D Lookup Texture.
  46992. */
  46993. cameraColorGradingTexture: Nullable<BaseTexture>;
  46994. /**
  46995. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46996. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46997. * 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;
  46998. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46999. */
  47000. /**
  47001. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47002. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47003. * 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;
  47004. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47005. */
  47006. cameraColorCurves: Nullable<ColorCurves>;
  47007. /**
  47008. * Instantiates a new PBRMaterial instance.
  47009. *
  47010. * @param name The material name
  47011. * @param scene The scene the material will be use in.
  47012. */
  47013. constructor(name: string, scene: Scene);
  47014. /**
  47015. * Returns the name of this material class.
  47016. */
  47017. getClassName(): string;
  47018. /**
  47019. * Makes a duplicate of the current material.
  47020. * @param name - name to use for the new material.
  47021. */
  47022. clone(name: string): PBRMaterial;
  47023. /**
  47024. * Serializes this PBR Material.
  47025. * @returns - An object with the serialized material.
  47026. */
  47027. serialize(): any;
  47028. /**
  47029. * Parses a PBR Material from a serialized object.
  47030. * @param source - Serialized object.
  47031. * @param scene - BJS scene instance.
  47032. * @param rootUrl - url for the scene object
  47033. * @returns - PBRMaterial
  47034. */
  47035. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47036. }
  47037. }
  47038. declare module BABYLON {
  47039. /**
  47040. * Direct draw surface info
  47041. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47042. */
  47043. export interface DDSInfo {
  47044. /**
  47045. * Width of the texture
  47046. */
  47047. width: number;
  47048. /**
  47049. * Width of the texture
  47050. */
  47051. height: number;
  47052. /**
  47053. * Number of Mipmaps for the texture
  47054. * @see https://en.wikipedia.org/wiki/Mipmap
  47055. */
  47056. mipmapCount: number;
  47057. /**
  47058. * If the textures format is a known fourCC format
  47059. * @see https://www.fourcc.org/
  47060. */
  47061. isFourCC: boolean;
  47062. /**
  47063. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47064. */
  47065. isRGB: boolean;
  47066. /**
  47067. * If the texture is a lumincance format
  47068. */
  47069. isLuminance: boolean;
  47070. /**
  47071. * If this is a cube texture
  47072. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47073. */
  47074. isCube: boolean;
  47075. /**
  47076. * If the texture is a compressed format eg. FOURCC_DXT1
  47077. */
  47078. isCompressed: boolean;
  47079. /**
  47080. * The dxgiFormat of the texture
  47081. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47082. */
  47083. dxgiFormat: number;
  47084. /**
  47085. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47086. */
  47087. textureType: number;
  47088. /**
  47089. * Sphericle polynomial created for the dds texture
  47090. */
  47091. sphericalPolynomial?: SphericalPolynomial;
  47092. }
  47093. /**
  47094. * Class used to provide DDS decompression tools
  47095. */
  47096. export class DDSTools {
  47097. /**
  47098. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47099. */
  47100. static StoreLODInAlphaChannel: boolean;
  47101. /**
  47102. * Gets DDS information from an array buffer
  47103. * @param arrayBuffer defines the array buffer to read data from
  47104. * @returns the DDS information
  47105. */
  47106. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47107. private static _FloatView;
  47108. private static _Int32View;
  47109. private static _ToHalfFloat;
  47110. private static _FromHalfFloat;
  47111. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47112. private static _GetHalfFloatRGBAArrayBuffer;
  47113. private static _GetFloatRGBAArrayBuffer;
  47114. private static _GetFloatAsUIntRGBAArrayBuffer;
  47115. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47116. private static _GetRGBAArrayBuffer;
  47117. private static _ExtractLongWordOrder;
  47118. private static _GetRGBArrayBuffer;
  47119. private static _GetLuminanceArrayBuffer;
  47120. /**
  47121. * Uploads DDS Levels to a Babylon Texture
  47122. * @hidden
  47123. */
  47124. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47125. }
  47126. interface Engine {
  47127. /**
  47128. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47129. * @param rootUrl defines the url where the file to load is located
  47130. * @param scene defines the current scene
  47131. * @param lodScale defines scale to apply to the mip map selection
  47132. * @param lodOffset defines offset to apply to the mip map selection
  47133. * @param onLoad defines an optional callback raised when the texture is loaded
  47134. * @param onError defines an optional callback raised if there is an issue to load the texture
  47135. * @param format defines the format of the data
  47136. * @param forcedExtension defines the extension to use to pick the right loader
  47137. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47138. * @returns the cube texture as an InternalTexture
  47139. */
  47140. 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;
  47141. }
  47142. }
  47143. declare module BABYLON {
  47144. /**
  47145. * Implementation of the DDS Texture Loader.
  47146. * @hidden
  47147. */
  47148. export class _DDSTextureLoader implements IInternalTextureLoader {
  47149. /**
  47150. * Defines wether the loader supports cascade loading the different faces.
  47151. */
  47152. readonly supportCascades: boolean;
  47153. /**
  47154. * This returns if the loader support the current file information.
  47155. * @param extension defines the file extension of the file being loaded
  47156. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47157. * @param fallback defines the fallback internal texture if any
  47158. * @param isBase64 defines whether the texture is encoded as a base64
  47159. * @param isBuffer defines whether the texture data are stored as a buffer
  47160. * @returns true if the loader can load the specified file
  47161. */
  47162. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47163. /**
  47164. * Transform the url before loading if required.
  47165. * @param rootUrl the url of the texture
  47166. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47167. * @returns the transformed texture
  47168. */
  47169. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47170. /**
  47171. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47172. * @param rootUrl the url of the texture
  47173. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47174. * @returns the fallback texture
  47175. */
  47176. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47177. /**
  47178. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47179. * @param data contains the texture data
  47180. * @param texture defines the BabylonJS internal texture
  47181. * @param createPolynomials will be true if polynomials have been requested
  47182. * @param onLoad defines the callback to trigger once the texture is ready
  47183. * @param onError defines the callback to trigger in case of error
  47184. */
  47185. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47186. /**
  47187. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47188. * @param data contains the texture data
  47189. * @param texture defines the BabylonJS internal texture
  47190. * @param callback defines the method to call once ready to upload
  47191. */
  47192. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47193. }
  47194. }
  47195. declare module BABYLON {
  47196. /** @hidden */
  47197. export var rgbdEncodePixelShader: {
  47198. name: string;
  47199. shader: string;
  47200. };
  47201. }
  47202. declare module BABYLON {
  47203. /**
  47204. * Raw texture data and descriptor sufficient for WebGL texture upload
  47205. */
  47206. export interface EnvironmentTextureInfo {
  47207. /**
  47208. * Version of the environment map
  47209. */
  47210. version: number;
  47211. /**
  47212. * Width of image
  47213. */
  47214. width: number;
  47215. /**
  47216. * Irradiance information stored in the file.
  47217. */
  47218. irradiance: any;
  47219. /**
  47220. * Specular information stored in the file.
  47221. */
  47222. specular: any;
  47223. }
  47224. /**
  47225. * Sets of helpers addressing the serialization and deserialization of environment texture
  47226. * stored in a BabylonJS env file.
  47227. * Those files are usually stored as .env files.
  47228. */
  47229. export class EnvironmentTextureTools {
  47230. /**
  47231. * Magic number identifying the env file.
  47232. */
  47233. private static _MagicBytes;
  47234. /**
  47235. * Gets the environment info from an env file.
  47236. * @param data The array buffer containing the .env bytes.
  47237. * @returns the environment file info (the json header) if successfully parsed.
  47238. */
  47239. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47240. /**
  47241. * Creates an environment texture from a loaded cube texture.
  47242. * @param texture defines the cube texture to convert in env file
  47243. * @return a promise containing the environment data if succesfull.
  47244. */
  47245. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47246. /**
  47247. * Creates a JSON representation of the spherical data.
  47248. * @param texture defines the texture containing the polynomials
  47249. * @return the JSON representation of the spherical info
  47250. */
  47251. private static _CreateEnvTextureIrradiance;
  47252. /**
  47253. * Uploads the texture info contained in the env file to the GPU.
  47254. * @param texture defines the internal texture to upload to
  47255. * @param arrayBuffer defines the buffer cotaining the data to load
  47256. * @param info defines the texture info retrieved through the GetEnvInfo method
  47257. * @returns a promise
  47258. */
  47259. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47260. /**
  47261. * Uploads the levels of image data to the GPU.
  47262. * @param texture defines the internal texture to upload to
  47263. * @param imageData defines the array buffer views of image data [mipmap][face]
  47264. * @returns a promise
  47265. */
  47266. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47267. /**
  47268. * Uploads spherical polynomials information to the texture.
  47269. * @param texture defines the texture we are trying to upload the information to
  47270. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47271. */
  47272. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47273. /** @hidden */
  47274. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47275. }
  47276. }
  47277. declare module BABYLON {
  47278. /**
  47279. * Implementation of the ENV Texture Loader.
  47280. * @hidden
  47281. */
  47282. export class _ENVTextureLoader implements IInternalTextureLoader {
  47283. /**
  47284. * Defines wether the loader supports cascade loading the different faces.
  47285. */
  47286. readonly supportCascades: boolean;
  47287. /**
  47288. * This returns if the loader support the current file information.
  47289. * @param extension defines the file extension of the file being loaded
  47290. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47291. * @param fallback defines the fallback internal texture if any
  47292. * @param isBase64 defines whether the texture is encoded as a base64
  47293. * @param isBuffer defines whether the texture data are stored as a buffer
  47294. * @returns true if the loader can load the specified file
  47295. */
  47296. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47297. /**
  47298. * Transform the url before loading if required.
  47299. * @param rootUrl the url of the texture
  47300. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47301. * @returns the transformed texture
  47302. */
  47303. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47304. /**
  47305. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47306. * @param rootUrl the url of the texture
  47307. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47308. * @returns the fallback texture
  47309. */
  47310. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47311. /**
  47312. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47313. * @param data contains the texture data
  47314. * @param texture defines the BabylonJS internal texture
  47315. * @param createPolynomials will be true if polynomials have been requested
  47316. * @param onLoad defines the callback to trigger once the texture is ready
  47317. * @param onError defines the callback to trigger in case of error
  47318. */
  47319. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47320. /**
  47321. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47322. * @param data contains the texture data
  47323. * @param texture defines the BabylonJS internal texture
  47324. * @param callback defines the method to call once ready to upload
  47325. */
  47326. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47327. }
  47328. }
  47329. declare module BABYLON {
  47330. /**
  47331. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47332. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47333. */
  47334. export class KhronosTextureContainer {
  47335. /** contents of the KTX container file */
  47336. arrayBuffer: any;
  47337. private static HEADER_LEN;
  47338. private static COMPRESSED_2D;
  47339. private static COMPRESSED_3D;
  47340. private static TEX_2D;
  47341. private static TEX_3D;
  47342. /**
  47343. * Gets the openGL type
  47344. */
  47345. glType: number;
  47346. /**
  47347. * Gets the openGL type size
  47348. */
  47349. glTypeSize: number;
  47350. /**
  47351. * Gets the openGL format
  47352. */
  47353. glFormat: number;
  47354. /**
  47355. * Gets the openGL internal format
  47356. */
  47357. glInternalFormat: number;
  47358. /**
  47359. * Gets the base internal format
  47360. */
  47361. glBaseInternalFormat: number;
  47362. /**
  47363. * Gets image width in pixel
  47364. */
  47365. pixelWidth: number;
  47366. /**
  47367. * Gets image height in pixel
  47368. */
  47369. pixelHeight: number;
  47370. /**
  47371. * Gets image depth in pixels
  47372. */
  47373. pixelDepth: number;
  47374. /**
  47375. * Gets the number of array elements
  47376. */
  47377. numberOfArrayElements: number;
  47378. /**
  47379. * Gets the number of faces
  47380. */
  47381. numberOfFaces: number;
  47382. /**
  47383. * Gets the number of mipmap levels
  47384. */
  47385. numberOfMipmapLevels: number;
  47386. /**
  47387. * Gets the bytes of key value data
  47388. */
  47389. bytesOfKeyValueData: number;
  47390. /**
  47391. * Gets the load type
  47392. */
  47393. loadType: number;
  47394. /**
  47395. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47396. */
  47397. isInvalid: boolean;
  47398. /**
  47399. * Creates a new KhronosTextureContainer
  47400. * @param arrayBuffer contents of the KTX container file
  47401. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47402. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47403. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47404. */
  47405. constructor(
  47406. /** contents of the KTX container file */
  47407. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47408. /**
  47409. * Uploads KTX content to a Babylon Texture.
  47410. * It is assumed that the texture has already been created & is currently bound
  47411. * @hidden
  47412. */
  47413. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47414. private _upload2DCompressedLevels;
  47415. }
  47416. }
  47417. declare module BABYLON {
  47418. /**
  47419. * Implementation of the KTX Texture Loader.
  47420. * @hidden
  47421. */
  47422. export class _KTXTextureLoader implements IInternalTextureLoader {
  47423. /**
  47424. * Defines wether the loader supports cascade loading the different faces.
  47425. */
  47426. readonly supportCascades: boolean;
  47427. /**
  47428. * This returns if the loader support the current file information.
  47429. * @param extension defines the file extension of the file being loaded
  47430. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47431. * @param fallback defines the fallback internal texture if any
  47432. * @param isBase64 defines whether the texture is encoded as a base64
  47433. * @param isBuffer defines whether the texture data are stored as a buffer
  47434. * @returns true if the loader can load the specified file
  47435. */
  47436. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47437. /**
  47438. * Transform the url before loading if required.
  47439. * @param rootUrl the url of the texture
  47440. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47441. * @returns the transformed texture
  47442. */
  47443. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47444. /**
  47445. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47446. * @param rootUrl the url of the texture
  47447. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47448. * @returns the fallback texture
  47449. */
  47450. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47451. /**
  47452. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47453. * @param data contains the texture data
  47454. * @param texture defines the BabylonJS internal texture
  47455. * @param createPolynomials will be true if polynomials have been requested
  47456. * @param onLoad defines the callback to trigger once the texture is ready
  47457. * @param onError defines the callback to trigger in case of error
  47458. */
  47459. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47460. /**
  47461. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47462. * @param data contains the texture data
  47463. * @param texture defines the BabylonJS internal texture
  47464. * @param callback defines the method to call once ready to upload
  47465. */
  47466. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47467. }
  47468. }
  47469. declare module BABYLON {
  47470. /**
  47471. * Options for the default xr helper
  47472. */
  47473. export class WebXRDefaultExperienceOptions {
  47474. /**
  47475. * Floor meshes that should be used for teleporting
  47476. */
  47477. floorMeshes: Array<AbstractMesh>;
  47478. }
  47479. /**
  47480. * Default experience which provides a similar setup to the previous webVRExperience
  47481. */
  47482. export class WebXRDefaultExperience {
  47483. /**
  47484. * Base experience
  47485. */
  47486. baseExperience: WebXRExperienceHelper;
  47487. /**
  47488. * Input experience extension
  47489. */
  47490. input: WebXRInput;
  47491. /**
  47492. * Loads the controller models
  47493. */
  47494. controllerModelLoader: WebXRControllerModelLoader;
  47495. /**
  47496. * Enables laser pointer and selection
  47497. */
  47498. pointerSelection: WebXRControllerPointerSelection;
  47499. /**
  47500. * Enables teleportation
  47501. */
  47502. teleportation: WebXRControllerTeleportation;
  47503. /**
  47504. * Enables ui for enetering/exiting xr
  47505. */
  47506. enterExitUI: WebXREnterExitUI;
  47507. /**
  47508. * Default output canvas xr should render to
  47509. */
  47510. outputCanvas: WebXRManagedOutputCanvas;
  47511. /**
  47512. * Creates the default xr experience
  47513. * @param scene scene
  47514. * @param options options for basic configuration
  47515. * @returns resulting WebXRDefaultExperience
  47516. */
  47517. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47518. private constructor();
  47519. /**
  47520. * DIsposes of the experience helper
  47521. */
  47522. dispose(): void;
  47523. }
  47524. }
  47525. declare module BABYLON {
  47526. /** @hidden */
  47527. export var _forceSceneHelpersToBundle: boolean;
  47528. interface Scene {
  47529. /**
  47530. * Creates a default light for the scene.
  47531. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47532. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47533. */
  47534. createDefaultLight(replace?: boolean): void;
  47535. /**
  47536. * Creates a default camera for the scene.
  47537. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47538. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47539. * @param replace has default false, when true replaces the active camera in the scene
  47540. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47541. */
  47542. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47543. /**
  47544. * Creates a default camera and a default light.
  47545. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47546. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47547. * @param replace has the default false, when true replaces the active camera/light in the scene
  47548. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47549. */
  47550. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47551. /**
  47552. * Creates a new sky box
  47553. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47554. * @param environmentTexture defines the texture to use as environment texture
  47555. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47556. * @param scale defines the overall scale of the skybox
  47557. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47558. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47559. * @returns a new mesh holding the sky box
  47560. */
  47561. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47562. /**
  47563. * Creates a new environment
  47564. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47565. * @param options defines the options you can use to configure the environment
  47566. * @returns the new EnvironmentHelper
  47567. */
  47568. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47569. /**
  47570. * Creates a new VREXperienceHelper
  47571. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47572. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47573. * @returns a new VREXperienceHelper
  47574. */
  47575. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47576. /**
  47577. * Creates a new WebXRDefaultExperience
  47578. * @see http://doc.babylonjs.com/how_to/webxr
  47579. * @param options experience options
  47580. * @returns a promise for a new WebXRDefaultExperience
  47581. */
  47582. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47583. }
  47584. }
  47585. declare module BABYLON {
  47586. /**
  47587. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47588. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47589. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47590. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47591. */
  47592. export class VideoDome extends TransformNode {
  47593. /**
  47594. * Define the video source as a Monoscopic panoramic 360 video.
  47595. */
  47596. static readonly MODE_MONOSCOPIC: number;
  47597. /**
  47598. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47599. */
  47600. static readonly MODE_TOPBOTTOM: number;
  47601. /**
  47602. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47603. */
  47604. static readonly MODE_SIDEBYSIDE: number;
  47605. private _useDirectMapping;
  47606. /**
  47607. * The video texture being displayed on the sphere
  47608. */
  47609. protected _videoTexture: VideoTexture;
  47610. /**
  47611. * Gets the video texture being displayed on the sphere
  47612. */
  47613. readonly videoTexture: VideoTexture;
  47614. /**
  47615. * The skybox material
  47616. */
  47617. protected _material: BackgroundMaterial;
  47618. /**
  47619. * The surface used for the skybox
  47620. */
  47621. protected _mesh: Mesh;
  47622. /**
  47623. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47624. * Also see the options.resolution property.
  47625. */
  47626. fovMultiplier: number;
  47627. private _videoMode;
  47628. /**
  47629. * Gets or set the current video mode for the video. It can be:
  47630. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47631. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47632. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47633. */
  47634. videoMode: number;
  47635. /**
  47636. * Oberserver used in Stereoscopic VR Mode.
  47637. */
  47638. private _onBeforeCameraRenderObserver;
  47639. /**
  47640. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47641. * @param name Element's name, child elements will append suffixes for their own names.
  47642. * @param urlsOrVideo defines the url(s) or the video element to use
  47643. * @param options An object containing optional or exposed sub element properties
  47644. */
  47645. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47646. resolution?: number;
  47647. clickToPlay?: boolean;
  47648. autoPlay?: boolean;
  47649. loop?: boolean;
  47650. size?: number;
  47651. poster?: string;
  47652. faceForward?: boolean;
  47653. useDirectMapping?: boolean;
  47654. }, scene: Scene);
  47655. private _changeVideoMode;
  47656. /**
  47657. * Releases resources associated with this node.
  47658. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47659. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47660. */
  47661. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47662. }
  47663. }
  47664. declare module BABYLON {
  47665. /**
  47666. * This class can be used to get instrumentation data from a Babylon engine
  47667. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47668. */
  47669. export class EngineInstrumentation implements IDisposable {
  47670. /**
  47671. * Define the instrumented engine.
  47672. */
  47673. engine: Engine;
  47674. private _captureGPUFrameTime;
  47675. private _gpuFrameTimeToken;
  47676. private _gpuFrameTime;
  47677. private _captureShaderCompilationTime;
  47678. private _shaderCompilationTime;
  47679. private _onBeginFrameObserver;
  47680. private _onEndFrameObserver;
  47681. private _onBeforeShaderCompilationObserver;
  47682. private _onAfterShaderCompilationObserver;
  47683. /**
  47684. * Gets the perf counter used for GPU frame time
  47685. */
  47686. readonly gpuFrameTimeCounter: PerfCounter;
  47687. /**
  47688. * Gets the GPU frame time capture status
  47689. */
  47690. /**
  47691. * Enable or disable the GPU frame time capture
  47692. */
  47693. captureGPUFrameTime: boolean;
  47694. /**
  47695. * Gets the perf counter used for shader compilation time
  47696. */
  47697. readonly shaderCompilationTimeCounter: PerfCounter;
  47698. /**
  47699. * Gets the shader compilation time capture status
  47700. */
  47701. /**
  47702. * Enable or disable the shader compilation time capture
  47703. */
  47704. captureShaderCompilationTime: boolean;
  47705. /**
  47706. * Instantiates a new engine instrumentation.
  47707. * This class can be used to get instrumentation data from a Babylon engine
  47708. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47709. * @param engine Defines the engine to instrument
  47710. */
  47711. constructor(
  47712. /**
  47713. * Define the instrumented engine.
  47714. */
  47715. engine: Engine);
  47716. /**
  47717. * Dispose and release associated resources.
  47718. */
  47719. dispose(): void;
  47720. }
  47721. }
  47722. declare module BABYLON {
  47723. /**
  47724. * This class can be used to get instrumentation data from a Babylon engine
  47725. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47726. */
  47727. export class SceneInstrumentation implements IDisposable {
  47728. /**
  47729. * Defines the scene to instrument
  47730. */
  47731. scene: Scene;
  47732. private _captureActiveMeshesEvaluationTime;
  47733. private _activeMeshesEvaluationTime;
  47734. private _captureRenderTargetsRenderTime;
  47735. private _renderTargetsRenderTime;
  47736. private _captureFrameTime;
  47737. private _frameTime;
  47738. private _captureRenderTime;
  47739. private _renderTime;
  47740. private _captureInterFrameTime;
  47741. private _interFrameTime;
  47742. private _captureParticlesRenderTime;
  47743. private _particlesRenderTime;
  47744. private _captureSpritesRenderTime;
  47745. private _spritesRenderTime;
  47746. private _capturePhysicsTime;
  47747. private _physicsTime;
  47748. private _captureAnimationsTime;
  47749. private _animationsTime;
  47750. private _captureCameraRenderTime;
  47751. private _cameraRenderTime;
  47752. private _onBeforeActiveMeshesEvaluationObserver;
  47753. private _onAfterActiveMeshesEvaluationObserver;
  47754. private _onBeforeRenderTargetsRenderObserver;
  47755. private _onAfterRenderTargetsRenderObserver;
  47756. private _onAfterRenderObserver;
  47757. private _onBeforeDrawPhaseObserver;
  47758. private _onAfterDrawPhaseObserver;
  47759. private _onBeforeAnimationsObserver;
  47760. private _onBeforeParticlesRenderingObserver;
  47761. private _onAfterParticlesRenderingObserver;
  47762. private _onBeforeSpritesRenderingObserver;
  47763. private _onAfterSpritesRenderingObserver;
  47764. private _onBeforePhysicsObserver;
  47765. private _onAfterPhysicsObserver;
  47766. private _onAfterAnimationsObserver;
  47767. private _onBeforeCameraRenderObserver;
  47768. private _onAfterCameraRenderObserver;
  47769. /**
  47770. * Gets the perf counter used for active meshes evaluation time
  47771. */
  47772. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47773. /**
  47774. * Gets the active meshes evaluation time capture status
  47775. */
  47776. /**
  47777. * Enable or disable the active meshes evaluation time capture
  47778. */
  47779. captureActiveMeshesEvaluationTime: boolean;
  47780. /**
  47781. * Gets the perf counter used for render targets render time
  47782. */
  47783. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47784. /**
  47785. * Gets the render targets render time capture status
  47786. */
  47787. /**
  47788. * Enable or disable the render targets render time capture
  47789. */
  47790. captureRenderTargetsRenderTime: boolean;
  47791. /**
  47792. * Gets the perf counter used for particles render time
  47793. */
  47794. readonly particlesRenderTimeCounter: PerfCounter;
  47795. /**
  47796. * Gets the particles render time capture status
  47797. */
  47798. /**
  47799. * Enable or disable the particles render time capture
  47800. */
  47801. captureParticlesRenderTime: boolean;
  47802. /**
  47803. * Gets the perf counter used for sprites render time
  47804. */
  47805. readonly spritesRenderTimeCounter: PerfCounter;
  47806. /**
  47807. * Gets the sprites render time capture status
  47808. */
  47809. /**
  47810. * Enable or disable the sprites render time capture
  47811. */
  47812. captureSpritesRenderTime: boolean;
  47813. /**
  47814. * Gets the perf counter used for physics time
  47815. */
  47816. readonly physicsTimeCounter: PerfCounter;
  47817. /**
  47818. * Gets the physics time capture status
  47819. */
  47820. /**
  47821. * Enable or disable the physics time capture
  47822. */
  47823. capturePhysicsTime: boolean;
  47824. /**
  47825. * Gets the perf counter used for animations time
  47826. */
  47827. readonly animationsTimeCounter: PerfCounter;
  47828. /**
  47829. * Gets the animations time capture status
  47830. */
  47831. /**
  47832. * Enable or disable the animations time capture
  47833. */
  47834. captureAnimationsTime: boolean;
  47835. /**
  47836. * Gets the perf counter used for frame time capture
  47837. */
  47838. readonly frameTimeCounter: PerfCounter;
  47839. /**
  47840. * Gets the frame time capture status
  47841. */
  47842. /**
  47843. * Enable or disable the frame time capture
  47844. */
  47845. captureFrameTime: boolean;
  47846. /**
  47847. * Gets the perf counter used for inter-frames time capture
  47848. */
  47849. readonly interFrameTimeCounter: PerfCounter;
  47850. /**
  47851. * Gets the inter-frames time capture status
  47852. */
  47853. /**
  47854. * Enable or disable the inter-frames time capture
  47855. */
  47856. captureInterFrameTime: boolean;
  47857. /**
  47858. * Gets the perf counter used for render time capture
  47859. */
  47860. readonly renderTimeCounter: PerfCounter;
  47861. /**
  47862. * Gets the render time capture status
  47863. */
  47864. /**
  47865. * Enable or disable the render time capture
  47866. */
  47867. captureRenderTime: boolean;
  47868. /**
  47869. * Gets the perf counter used for camera render time capture
  47870. */
  47871. readonly cameraRenderTimeCounter: PerfCounter;
  47872. /**
  47873. * Gets the camera render time capture status
  47874. */
  47875. /**
  47876. * Enable or disable the camera render time capture
  47877. */
  47878. captureCameraRenderTime: boolean;
  47879. /**
  47880. * Gets the perf counter used for draw calls
  47881. */
  47882. readonly drawCallsCounter: PerfCounter;
  47883. /**
  47884. * Instantiates a new scene instrumentation.
  47885. * This class can be used to get instrumentation data from a Babylon engine
  47886. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47887. * @param scene Defines the scene to instrument
  47888. */
  47889. constructor(
  47890. /**
  47891. * Defines the scene to instrument
  47892. */
  47893. scene: Scene);
  47894. /**
  47895. * Dispose and release associated resources.
  47896. */
  47897. dispose(): void;
  47898. }
  47899. }
  47900. declare module BABYLON {
  47901. /** @hidden */
  47902. export var glowMapGenerationPixelShader: {
  47903. name: string;
  47904. shader: string;
  47905. };
  47906. }
  47907. declare module BABYLON {
  47908. /** @hidden */
  47909. export var glowMapGenerationVertexShader: {
  47910. name: string;
  47911. shader: string;
  47912. };
  47913. }
  47914. declare module BABYLON {
  47915. /**
  47916. * Effect layer options. This helps customizing the behaviour
  47917. * of the effect layer.
  47918. */
  47919. export interface IEffectLayerOptions {
  47920. /**
  47921. * Multiplication factor apply to the canvas size to compute the render target size
  47922. * used to generated the objects (the smaller the faster).
  47923. */
  47924. mainTextureRatio: number;
  47925. /**
  47926. * Enforces a fixed size texture to ensure effect stability across devices.
  47927. */
  47928. mainTextureFixedSize?: number;
  47929. /**
  47930. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47931. */
  47932. alphaBlendingMode: number;
  47933. /**
  47934. * The camera attached to the layer.
  47935. */
  47936. camera: Nullable<Camera>;
  47937. /**
  47938. * The rendering group to draw the layer in.
  47939. */
  47940. renderingGroupId: number;
  47941. }
  47942. /**
  47943. * The effect layer Helps adding post process effect blended with the main pass.
  47944. *
  47945. * This can be for instance use to generate glow or higlight effects on the scene.
  47946. *
  47947. * The effect layer class can not be used directly and is intented to inherited from to be
  47948. * customized per effects.
  47949. */
  47950. export abstract class EffectLayer {
  47951. private _vertexBuffers;
  47952. private _indexBuffer;
  47953. private _cachedDefines;
  47954. private _effectLayerMapGenerationEffect;
  47955. private _effectLayerOptions;
  47956. private _mergeEffect;
  47957. protected _scene: Scene;
  47958. protected _engine: Engine;
  47959. protected _maxSize: number;
  47960. protected _mainTextureDesiredSize: ISize;
  47961. protected _mainTexture: RenderTargetTexture;
  47962. protected _shouldRender: boolean;
  47963. protected _postProcesses: PostProcess[];
  47964. protected _textures: BaseTexture[];
  47965. protected _emissiveTextureAndColor: {
  47966. texture: Nullable<BaseTexture>;
  47967. color: Color4;
  47968. };
  47969. /**
  47970. * The name of the layer
  47971. */
  47972. name: string;
  47973. /**
  47974. * The clear color of the texture used to generate the glow map.
  47975. */
  47976. neutralColor: Color4;
  47977. /**
  47978. * Specifies wether the highlight layer is enabled or not.
  47979. */
  47980. isEnabled: boolean;
  47981. /**
  47982. * Gets the camera attached to the layer.
  47983. */
  47984. readonly camera: Nullable<Camera>;
  47985. /**
  47986. * Gets the rendering group id the layer should render in.
  47987. */
  47988. renderingGroupId: number;
  47989. /**
  47990. * An event triggered when the effect layer has been disposed.
  47991. */
  47992. onDisposeObservable: Observable<EffectLayer>;
  47993. /**
  47994. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47995. */
  47996. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47997. /**
  47998. * An event triggered when the generated texture is being merged in the scene.
  47999. */
  48000. onBeforeComposeObservable: Observable<EffectLayer>;
  48001. /**
  48002. * An event triggered when the generated texture has been merged in the scene.
  48003. */
  48004. onAfterComposeObservable: Observable<EffectLayer>;
  48005. /**
  48006. * An event triggered when the efffect layer changes its size.
  48007. */
  48008. onSizeChangedObservable: Observable<EffectLayer>;
  48009. /** @hidden */
  48010. static _SceneComponentInitialization: (scene: Scene) => void;
  48011. /**
  48012. * Instantiates a new effect Layer and references it in the scene.
  48013. * @param name The name of the layer
  48014. * @param scene The scene to use the layer in
  48015. */
  48016. constructor(
  48017. /** The Friendly of the effect in the scene */
  48018. name: string, scene: Scene);
  48019. /**
  48020. * Get the effect name of the layer.
  48021. * @return The effect name
  48022. */
  48023. abstract getEffectName(): string;
  48024. /**
  48025. * Checks for the readiness of the element composing the layer.
  48026. * @param subMesh the mesh to check for
  48027. * @param useInstances specify wether or not to use instances to render the mesh
  48028. * @return true if ready otherwise, false
  48029. */
  48030. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48031. /**
  48032. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48033. * @returns true if the effect requires stencil during the main canvas render pass.
  48034. */
  48035. abstract needStencil(): boolean;
  48036. /**
  48037. * Create the merge effect. This is the shader use to blit the information back
  48038. * to the main canvas at the end of the scene rendering.
  48039. * @returns The effect containing the shader used to merge the effect on the main canvas
  48040. */
  48041. protected abstract _createMergeEffect(): Effect;
  48042. /**
  48043. * Creates the render target textures and post processes used in the effect layer.
  48044. */
  48045. protected abstract _createTextureAndPostProcesses(): void;
  48046. /**
  48047. * Implementation specific of rendering the generating effect on the main canvas.
  48048. * @param effect The effect used to render through
  48049. */
  48050. protected abstract _internalRender(effect: Effect): void;
  48051. /**
  48052. * Sets the required values for both the emissive texture and and the main color.
  48053. */
  48054. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48055. /**
  48056. * Free any resources and references associated to a mesh.
  48057. * Internal use
  48058. * @param mesh The mesh to free.
  48059. */
  48060. abstract _disposeMesh(mesh: Mesh): void;
  48061. /**
  48062. * Serializes this layer (Glow or Highlight for example)
  48063. * @returns a serialized layer object
  48064. */
  48065. abstract serialize?(): any;
  48066. /**
  48067. * Initializes the effect layer with the required options.
  48068. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48069. */
  48070. protected _init(options: Partial<IEffectLayerOptions>): void;
  48071. /**
  48072. * Generates the index buffer of the full screen quad blending to the main canvas.
  48073. */
  48074. private _generateIndexBuffer;
  48075. /**
  48076. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48077. */
  48078. private _generateVertexBuffer;
  48079. /**
  48080. * Sets the main texture desired size which is the closest power of two
  48081. * of the engine canvas size.
  48082. */
  48083. private _setMainTextureSize;
  48084. /**
  48085. * Creates the main texture for the effect layer.
  48086. */
  48087. protected _createMainTexture(): void;
  48088. /**
  48089. * Adds specific effects defines.
  48090. * @param defines The defines to add specifics to.
  48091. */
  48092. protected _addCustomEffectDefines(defines: string[]): void;
  48093. /**
  48094. * Checks for the readiness of the element composing the layer.
  48095. * @param subMesh the mesh to check for
  48096. * @param useInstances specify wether or not to use instances to render the mesh
  48097. * @param emissiveTexture the associated emissive texture used to generate the glow
  48098. * @return true if ready otherwise, false
  48099. */
  48100. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48101. /**
  48102. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48103. */
  48104. render(): void;
  48105. /**
  48106. * Determine if a given mesh will be used in the current effect.
  48107. * @param mesh mesh to test
  48108. * @returns true if the mesh will be used
  48109. */
  48110. hasMesh(mesh: AbstractMesh): boolean;
  48111. /**
  48112. * Returns true if the layer contains information to display, otherwise false.
  48113. * @returns true if the glow layer should be rendered
  48114. */
  48115. shouldRender(): boolean;
  48116. /**
  48117. * Returns true if the mesh should render, otherwise false.
  48118. * @param mesh The mesh to render
  48119. * @returns true if it should render otherwise false
  48120. */
  48121. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48122. /**
  48123. * Returns true if the mesh can be rendered, otherwise false.
  48124. * @param mesh The mesh to render
  48125. * @param material The material used on the mesh
  48126. * @returns true if it can be rendered otherwise false
  48127. */
  48128. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48129. /**
  48130. * Returns true if the mesh should render, otherwise false.
  48131. * @param mesh The mesh to render
  48132. * @returns true if it should render otherwise false
  48133. */
  48134. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48135. /**
  48136. * Renders the submesh passed in parameter to the generation map.
  48137. */
  48138. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48139. /**
  48140. * Rebuild the required buffers.
  48141. * @hidden Internal use only.
  48142. */
  48143. _rebuild(): void;
  48144. /**
  48145. * Dispose only the render target textures and post process.
  48146. */
  48147. private _disposeTextureAndPostProcesses;
  48148. /**
  48149. * Dispose the highlight layer and free resources.
  48150. */
  48151. dispose(): void;
  48152. /**
  48153. * Gets the class name of the effect layer
  48154. * @returns the string with the class name of the effect layer
  48155. */
  48156. getClassName(): string;
  48157. /**
  48158. * Creates an effect layer from parsed effect layer data
  48159. * @param parsedEffectLayer defines effect layer data
  48160. * @param scene defines the current scene
  48161. * @param rootUrl defines the root URL containing the effect layer information
  48162. * @returns a parsed effect Layer
  48163. */
  48164. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48165. }
  48166. }
  48167. declare module BABYLON {
  48168. interface AbstractScene {
  48169. /**
  48170. * The list of effect layers (highlights/glow) added to the scene
  48171. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48172. * @see http://doc.babylonjs.com/how_to/glow_layer
  48173. */
  48174. effectLayers: Array<EffectLayer>;
  48175. /**
  48176. * Removes the given effect layer from this scene.
  48177. * @param toRemove defines the effect layer to remove
  48178. * @returns the index of the removed effect layer
  48179. */
  48180. removeEffectLayer(toRemove: EffectLayer): number;
  48181. /**
  48182. * Adds the given effect layer to this scene
  48183. * @param newEffectLayer defines the effect layer to add
  48184. */
  48185. addEffectLayer(newEffectLayer: EffectLayer): void;
  48186. }
  48187. /**
  48188. * Defines the layer scene component responsible to manage any effect layers
  48189. * in a given scene.
  48190. */
  48191. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48192. /**
  48193. * The component name helpfull to identify the component in the list of scene components.
  48194. */
  48195. readonly name: string;
  48196. /**
  48197. * The scene the component belongs to.
  48198. */
  48199. scene: Scene;
  48200. private _engine;
  48201. private _renderEffects;
  48202. private _needStencil;
  48203. private _previousStencilState;
  48204. /**
  48205. * Creates a new instance of the component for the given scene
  48206. * @param scene Defines the scene to register the component in
  48207. */
  48208. constructor(scene: Scene);
  48209. /**
  48210. * Registers the component in a given scene
  48211. */
  48212. register(): void;
  48213. /**
  48214. * Rebuilds the elements related to this component in case of
  48215. * context lost for instance.
  48216. */
  48217. rebuild(): void;
  48218. /**
  48219. * Serializes the component data to the specified json object
  48220. * @param serializationObject The object to serialize to
  48221. */
  48222. serialize(serializationObject: any): void;
  48223. /**
  48224. * Adds all the elements from the container to the scene
  48225. * @param container the container holding the elements
  48226. */
  48227. addFromContainer(container: AbstractScene): void;
  48228. /**
  48229. * Removes all the elements in the container from the scene
  48230. * @param container contains the elements to remove
  48231. * @param dispose if the removed element should be disposed (default: false)
  48232. */
  48233. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48234. /**
  48235. * Disposes the component and the associated ressources.
  48236. */
  48237. dispose(): void;
  48238. private _isReadyForMesh;
  48239. private _renderMainTexture;
  48240. private _setStencil;
  48241. private _setStencilBack;
  48242. private _draw;
  48243. private _drawCamera;
  48244. private _drawRenderingGroup;
  48245. }
  48246. }
  48247. declare module BABYLON {
  48248. /** @hidden */
  48249. export var glowMapMergePixelShader: {
  48250. name: string;
  48251. shader: string;
  48252. };
  48253. }
  48254. declare module BABYLON {
  48255. /** @hidden */
  48256. export var glowMapMergeVertexShader: {
  48257. name: string;
  48258. shader: string;
  48259. };
  48260. }
  48261. declare module BABYLON {
  48262. interface AbstractScene {
  48263. /**
  48264. * Return a the first highlight layer of the scene with a given name.
  48265. * @param name The name of the highlight layer to look for.
  48266. * @return The highlight layer if found otherwise null.
  48267. */
  48268. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48269. }
  48270. /**
  48271. * Glow layer options. This helps customizing the behaviour
  48272. * of the glow layer.
  48273. */
  48274. export interface IGlowLayerOptions {
  48275. /**
  48276. * Multiplication factor apply to the canvas size to compute the render target size
  48277. * used to generated the glowing objects (the smaller the faster).
  48278. */
  48279. mainTextureRatio: number;
  48280. /**
  48281. * Enforces a fixed size texture to ensure resize independant blur.
  48282. */
  48283. mainTextureFixedSize?: number;
  48284. /**
  48285. * How big is the kernel of the blur texture.
  48286. */
  48287. blurKernelSize: number;
  48288. /**
  48289. * The camera attached to the layer.
  48290. */
  48291. camera: Nullable<Camera>;
  48292. /**
  48293. * Enable MSAA by chosing the number of samples.
  48294. */
  48295. mainTextureSamples?: number;
  48296. /**
  48297. * The rendering group to draw the layer in.
  48298. */
  48299. renderingGroupId: number;
  48300. }
  48301. /**
  48302. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48303. *
  48304. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48305. * glowy meshes to your scene.
  48306. *
  48307. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48308. */
  48309. export class GlowLayer extends EffectLayer {
  48310. /**
  48311. * Effect Name of the layer.
  48312. */
  48313. static readonly EffectName: string;
  48314. /**
  48315. * The default blur kernel size used for the glow.
  48316. */
  48317. static DefaultBlurKernelSize: number;
  48318. /**
  48319. * The default texture size ratio used for the glow.
  48320. */
  48321. static DefaultTextureRatio: number;
  48322. /**
  48323. * Sets the kernel size of the blur.
  48324. */
  48325. /**
  48326. * Gets the kernel size of the blur.
  48327. */
  48328. blurKernelSize: number;
  48329. /**
  48330. * Sets the glow intensity.
  48331. */
  48332. /**
  48333. * Gets the glow intensity.
  48334. */
  48335. intensity: number;
  48336. private _options;
  48337. private _intensity;
  48338. private _horizontalBlurPostprocess1;
  48339. private _verticalBlurPostprocess1;
  48340. private _horizontalBlurPostprocess2;
  48341. private _verticalBlurPostprocess2;
  48342. private _blurTexture1;
  48343. private _blurTexture2;
  48344. private _postProcesses1;
  48345. private _postProcesses2;
  48346. private _includedOnlyMeshes;
  48347. private _excludedMeshes;
  48348. /**
  48349. * Callback used to let the user override the color selection on a per mesh basis
  48350. */
  48351. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48352. /**
  48353. * Callback used to let the user override the texture selection on a per mesh basis
  48354. */
  48355. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48356. /**
  48357. * Instantiates a new glow Layer and references it to the scene.
  48358. * @param name The name of the layer
  48359. * @param scene The scene to use the layer in
  48360. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48361. */
  48362. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48363. /**
  48364. * Get the effect name of the layer.
  48365. * @return The effect name
  48366. */
  48367. getEffectName(): string;
  48368. /**
  48369. * Create the merge effect. This is the shader use to blit the information back
  48370. * to the main canvas at the end of the scene rendering.
  48371. */
  48372. protected _createMergeEffect(): Effect;
  48373. /**
  48374. * Creates the render target textures and post processes used in the glow layer.
  48375. */
  48376. protected _createTextureAndPostProcesses(): void;
  48377. /**
  48378. * Checks for the readiness of the element composing the layer.
  48379. * @param subMesh the mesh to check for
  48380. * @param useInstances specify wether or not to use instances to render the mesh
  48381. * @param emissiveTexture the associated emissive texture used to generate the glow
  48382. * @return true if ready otherwise, false
  48383. */
  48384. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48385. /**
  48386. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48387. */
  48388. needStencil(): boolean;
  48389. /**
  48390. * Returns true if the mesh can be rendered, otherwise false.
  48391. * @param mesh The mesh to render
  48392. * @param material The material used on the mesh
  48393. * @returns true if it can be rendered otherwise false
  48394. */
  48395. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48396. /**
  48397. * Implementation specific of rendering the generating effect on the main canvas.
  48398. * @param effect The effect used to render through
  48399. */
  48400. protected _internalRender(effect: Effect): void;
  48401. /**
  48402. * Sets the required values for both the emissive texture and and the main color.
  48403. */
  48404. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48405. /**
  48406. * Returns true if the mesh should render, otherwise false.
  48407. * @param mesh The mesh to render
  48408. * @returns true if it should render otherwise false
  48409. */
  48410. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48411. /**
  48412. * Adds specific effects defines.
  48413. * @param defines The defines to add specifics to.
  48414. */
  48415. protected _addCustomEffectDefines(defines: string[]): void;
  48416. /**
  48417. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48418. * @param mesh The mesh to exclude from the glow layer
  48419. */
  48420. addExcludedMesh(mesh: Mesh): void;
  48421. /**
  48422. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48423. * @param mesh The mesh to remove
  48424. */
  48425. removeExcludedMesh(mesh: Mesh): void;
  48426. /**
  48427. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48428. * @param mesh The mesh to include in the glow layer
  48429. */
  48430. addIncludedOnlyMesh(mesh: Mesh): void;
  48431. /**
  48432. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48433. * @param mesh The mesh to remove
  48434. */
  48435. removeIncludedOnlyMesh(mesh: Mesh): void;
  48436. /**
  48437. * Determine if a given mesh will be used in the glow layer
  48438. * @param mesh The mesh to test
  48439. * @returns true if the mesh will be highlighted by the current glow layer
  48440. */
  48441. hasMesh(mesh: AbstractMesh): boolean;
  48442. /**
  48443. * Free any resources and references associated to a mesh.
  48444. * Internal use
  48445. * @param mesh The mesh to free.
  48446. * @hidden
  48447. */
  48448. _disposeMesh(mesh: Mesh): void;
  48449. /**
  48450. * Gets the class name of the effect layer
  48451. * @returns the string with the class name of the effect layer
  48452. */
  48453. getClassName(): string;
  48454. /**
  48455. * Serializes this glow layer
  48456. * @returns a serialized glow layer object
  48457. */
  48458. serialize(): any;
  48459. /**
  48460. * Creates a Glow Layer from parsed glow layer data
  48461. * @param parsedGlowLayer defines glow layer data
  48462. * @param scene defines the current scene
  48463. * @param rootUrl defines the root URL containing the glow layer information
  48464. * @returns a parsed Glow Layer
  48465. */
  48466. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48467. }
  48468. }
  48469. declare module BABYLON {
  48470. /** @hidden */
  48471. export var glowBlurPostProcessPixelShader: {
  48472. name: string;
  48473. shader: string;
  48474. };
  48475. }
  48476. declare module BABYLON {
  48477. interface AbstractScene {
  48478. /**
  48479. * Return a the first highlight layer of the scene with a given name.
  48480. * @param name The name of the highlight layer to look for.
  48481. * @return The highlight layer if found otherwise null.
  48482. */
  48483. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48484. }
  48485. /**
  48486. * Highlight layer options. This helps customizing the behaviour
  48487. * of the highlight layer.
  48488. */
  48489. export interface IHighlightLayerOptions {
  48490. /**
  48491. * Multiplication factor apply to the canvas size to compute the render target size
  48492. * used to generated the glowing objects (the smaller the faster).
  48493. */
  48494. mainTextureRatio: number;
  48495. /**
  48496. * Enforces a fixed size texture to ensure resize independant blur.
  48497. */
  48498. mainTextureFixedSize?: number;
  48499. /**
  48500. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48501. * of the picture to blur (the smaller the faster).
  48502. */
  48503. blurTextureSizeRatio: number;
  48504. /**
  48505. * How big in texel of the blur texture is the vertical blur.
  48506. */
  48507. blurVerticalSize: number;
  48508. /**
  48509. * How big in texel of the blur texture is the horizontal blur.
  48510. */
  48511. blurHorizontalSize: number;
  48512. /**
  48513. * Alpha blending mode used to apply the blur. Default is combine.
  48514. */
  48515. alphaBlendingMode: number;
  48516. /**
  48517. * The camera attached to the layer.
  48518. */
  48519. camera: Nullable<Camera>;
  48520. /**
  48521. * Should we display highlight as a solid stroke?
  48522. */
  48523. isStroke?: boolean;
  48524. /**
  48525. * The rendering group to draw the layer in.
  48526. */
  48527. renderingGroupId: number;
  48528. }
  48529. /**
  48530. * The highlight layer Helps adding a glow effect around a mesh.
  48531. *
  48532. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48533. * glowy meshes to your scene.
  48534. *
  48535. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48536. */
  48537. export class HighlightLayer extends EffectLayer {
  48538. name: string;
  48539. /**
  48540. * Effect Name of the highlight layer.
  48541. */
  48542. static readonly EffectName: string;
  48543. /**
  48544. * The neutral color used during the preparation of the glow effect.
  48545. * This is black by default as the blend operation is a blend operation.
  48546. */
  48547. static NeutralColor: Color4;
  48548. /**
  48549. * Stencil value used for glowing meshes.
  48550. */
  48551. static GlowingMeshStencilReference: number;
  48552. /**
  48553. * Stencil value used for the other meshes in the scene.
  48554. */
  48555. static NormalMeshStencilReference: number;
  48556. /**
  48557. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48558. */
  48559. innerGlow: boolean;
  48560. /**
  48561. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48562. */
  48563. outerGlow: boolean;
  48564. /**
  48565. * Specifies the horizontal size of the blur.
  48566. */
  48567. /**
  48568. * Gets the horizontal size of the blur.
  48569. */
  48570. blurHorizontalSize: number;
  48571. /**
  48572. * Specifies the vertical size of the blur.
  48573. */
  48574. /**
  48575. * Gets the vertical size of the blur.
  48576. */
  48577. blurVerticalSize: number;
  48578. /**
  48579. * An event triggered when the highlight layer is being blurred.
  48580. */
  48581. onBeforeBlurObservable: Observable<HighlightLayer>;
  48582. /**
  48583. * An event triggered when the highlight layer has been blurred.
  48584. */
  48585. onAfterBlurObservable: Observable<HighlightLayer>;
  48586. private _instanceGlowingMeshStencilReference;
  48587. private _options;
  48588. private _downSamplePostprocess;
  48589. private _horizontalBlurPostprocess;
  48590. private _verticalBlurPostprocess;
  48591. private _blurTexture;
  48592. private _meshes;
  48593. private _excludedMeshes;
  48594. /**
  48595. * Instantiates a new highlight Layer and references it to the scene..
  48596. * @param name The name of the layer
  48597. * @param scene The scene to use the layer in
  48598. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48599. */
  48600. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48601. /**
  48602. * Get the effect name of the layer.
  48603. * @return The effect name
  48604. */
  48605. getEffectName(): string;
  48606. /**
  48607. * Create the merge effect. This is the shader use to blit the information back
  48608. * to the main canvas at the end of the scene rendering.
  48609. */
  48610. protected _createMergeEffect(): Effect;
  48611. /**
  48612. * Creates the render target textures and post processes used in the highlight layer.
  48613. */
  48614. protected _createTextureAndPostProcesses(): void;
  48615. /**
  48616. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48617. */
  48618. needStencil(): boolean;
  48619. /**
  48620. * Checks for the readiness of the element composing the layer.
  48621. * @param subMesh the mesh to check for
  48622. * @param useInstances specify wether or not to use instances to render the mesh
  48623. * @param emissiveTexture the associated emissive texture used to generate the glow
  48624. * @return true if ready otherwise, false
  48625. */
  48626. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48627. /**
  48628. * Implementation specific of rendering the generating effect on the main canvas.
  48629. * @param effect The effect used to render through
  48630. */
  48631. protected _internalRender(effect: Effect): void;
  48632. /**
  48633. * Returns true if the layer contains information to display, otherwise false.
  48634. */
  48635. shouldRender(): boolean;
  48636. /**
  48637. * Returns true if the mesh should render, otherwise false.
  48638. * @param mesh The mesh to render
  48639. * @returns true if it should render otherwise false
  48640. */
  48641. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48642. /**
  48643. * Sets the required values for both the emissive texture and and the main color.
  48644. */
  48645. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48646. /**
  48647. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48648. * @param mesh The mesh to exclude from the highlight layer
  48649. */
  48650. addExcludedMesh(mesh: Mesh): void;
  48651. /**
  48652. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48653. * @param mesh The mesh to highlight
  48654. */
  48655. removeExcludedMesh(mesh: Mesh): void;
  48656. /**
  48657. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48658. * @param mesh mesh to test
  48659. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48660. */
  48661. hasMesh(mesh: AbstractMesh): boolean;
  48662. /**
  48663. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48664. * @param mesh The mesh to highlight
  48665. * @param color The color of the highlight
  48666. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48667. */
  48668. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48669. /**
  48670. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48671. * @param mesh The mesh to highlight
  48672. */
  48673. removeMesh(mesh: Mesh): void;
  48674. /**
  48675. * Force the stencil to the normal expected value for none glowing parts
  48676. */
  48677. private _defaultStencilReference;
  48678. /**
  48679. * Free any resources and references associated to a mesh.
  48680. * Internal use
  48681. * @param mesh The mesh to free.
  48682. * @hidden
  48683. */
  48684. _disposeMesh(mesh: Mesh): void;
  48685. /**
  48686. * Dispose the highlight layer and free resources.
  48687. */
  48688. dispose(): void;
  48689. /**
  48690. * Gets the class name of the effect layer
  48691. * @returns the string with the class name of the effect layer
  48692. */
  48693. getClassName(): string;
  48694. /**
  48695. * Serializes this Highlight layer
  48696. * @returns a serialized Highlight layer object
  48697. */
  48698. serialize(): any;
  48699. /**
  48700. * Creates a Highlight layer from parsed Highlight layer data
  48701. * @param parsedHightlightLayer defines the Highlight layer data
  48702. * @param scene defines the current scene
  48703. * @param rootUrl defines the root URL containing the Highlight layer information
  48704. * @returns a parsed Highlight layer
  48705. */
  48706. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48707. }
  48708. }
  48709. declare module BABYLON {
  48710. interface AbstractScene {
  48711. /**
  48712. * The list of layers (background and foreground) of the scene
  48713. */
  48714. layers: Array<Layer>;
  48715. }
  48716. /**
  48717. * Defines the layer scene component responsible to manage any layers
  48718. * in a given scene.
  48719. */
  48720. export class LayerSceneComponent implements ISceneComponent {
  48721. /**
  48722. * The component name helpfull to identify the component in the list of scene components.
  48723. */
  48724. readonly name: string;
  48725. /**
  48726. * The scene the component belongs to.
  48727. */
  48728. scene: Scene;
  48729. private _engine;
  48730. /**
  48731. * Creates a new instance of the component for the given scene
  48732. * @param scene Defines the scene to register the component in
  48733. */
  48734. constructor(scene: Scene);
  48735. /**
  48736. * Registers the component in a given scene
  48737. */
  48738. register(): void;
  48739. /**
  48740. * Rebuilds the elements related to this component in case of
  48741. * context lost for instance.
  48742. */
  48743. rebuild(): void;
  48744. /**
  48745. * Disposes the component and the associated ressources.
  48746. */
  48747. dispose(): void;
  48748. private _draw;
  48749. private _drawCameraPredicate;
  48750. private _drawCameraBackground;
  48751. private _drawCameraForeground;
  48752. private _drawRenderTargetPredicate;
  48753. private _drawRenderTargetBackground;
  48754. private _drawRenderTargetForeground;
  48755. /**
  48756. * Adds all the elements from the container to the scene
  48757. * @param container the container holding the elements
  48758. */
  48759. addFromContainer(container: AbstractScene): void;
  48760. /**
  48761. * Removes all the elements in the container from the scene
  48762. * @param container contains the elements to remove
  48763. * @param dispose if the removed element should be disposed (default: false)
  48764. */
  48765. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48766. }
  48767. }
  48768. declare module BABYLON {
  48769. /** @hidden */
  48770. export var layerPixelShader: {
  48771. name: string;
  48772. shader: string;
  48773. };
  48774. }
  48775. declare module BABYLON {
  48776. /** @hidden */
  48777. export var layerVertexShader: {
  48778. name: string;
  48779. shader: string;
  48780. };
  48781. }
  48782. declare module BABYLON {
  48783. /**
  48784. * This represents a full screen 2d layer.
  48785. * This can be useful to display a picture in the background of your scene for instance.
  48786. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48787. */
  48788. export class Layer {
  48789. /**
  48790. * Define the name of the layer.
  48791. */
  48792. name: string;
  48793. /**
  48794. * Define the texture the layer should display.
  48795. */
  48796. texture: Nullable<Texture>;
  48797. /**
  48798. * Is the layer in background or foreground.
  48799. */
  48800. isBackground: boolean;
  48801. /**
  48802. * Define the color of the layer (instead of texture).
  48803. */
  48804. color: Color4;
  48805. /**
  48806. * Define the scale of the layer in order to zoom in out of the texture.
  48807. */
  48808. scale: Vector2;
  48809. /**
  48810. * Define an offset for the layer in order to shift the texture.
  48811. */
  48812. offset: Vector2;
  48813. /**
  48814. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  48815. */
  48816. alphaBlendingMode: number;
  48817. /**
  48818. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  48819. * Alpha test will not mix with the background color in case of transparency.
  48820. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  48821. */
  48822. alphaTest: boolean;
  48823. /**
  48824. * Define a mask to restrict the layer to only some of the scene cameras.
  48825. */
  48826. layerMask: number;
  48827. /**
  48828. * Define the list of render target the layer is visible into.
  48829. */
  48830. renderTargetTextures: RenderTargetTexture[];
  48831. /**
  48832. * Define if the layer is only used in renderTarget or if it also
  48833. * renders in the main frame buffer of the canvas.
  48834. */
  48835. renderOnlyInRenderTargetTextures: boolean;
  48836. private _scene;
  48837. private _vertexBuffers;
  48838. private _indexBuffer;
  48839. private _effect;
  48840. private _alphaTestEffect;
  48841. /**
  48842. * An event triggered when the layer is disposed.
  48843. */
  48844. onDisposeObservable: Observable<Layer>;
  48845. private _onDisposeObserver;
  48846. /**
  48847. * Back compatibility with callback before the onDisposeObservable existed.
  48848. * The set callback will be triggered when the layer has been disposed.
  48849. */
  48850. onDispose: () => void;
  48851. /**
  48852. * An event triggered before rendering the scene
  48853. */
  48854. onBeforeRenderObservable: Observable<Layer>;
  48855. private _onBeforeRenderObserver;
  48856. /**
  48857. * Back compatibility with callback before the onBeforeRenderObservable existed.
  48858. * The set callback will be triggered just before rendering the layer.
  48859. */
  48860. onBeforeRender: () => void;
  48861. /**
  48862. * An event triggered after rendering the scene
  48863. */
  48864. onAfterRenderObservable: Observable<Layer>;
  48865. private _onAfterRenderObserver;
  48866. /**
  48867. * Back compatibility with callback before the onAfterRenderObservable existed.
  48868. * The set callback will be triggered just after rendering the layer.
  48869. */
  48870. onAfterRender: () => void;
  48871. /**
  48872. * Instantiates a new layer.
  48873. * This represents a full screen 2d layer.
  48874. * This can be useful to display a picture in the background of your scene for instance.
  48875. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48876. * @param name Define the name of the layer in the scene
  48877. * @param imgUrl Define the url of the texture to display in the layer
  48878. * @param scene Define the scene the layer belongs to
  48879. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  48880. * @param color Defines a color for the layer
  48881. */
  48882. constructor(
  48883. /**
  48884. * Define the name of the layer.
  48885. */
  48886. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  48887. private _createIndexBuffer;
  48888. /** @hidden */
  48889. _rebuild(): void;
  48890. /**
  48891. * Renders the layer in the scene.
  48892. */
  48893. render(): void;
  48894. /**
  48895. * Disposes and releases the associated ressources.
  48896. */
  48897. dispose(): void;
  48898. }
  48899. }
  48900. declare module BABYLON {
  48901. /** @hidden */
  48902. export var lensFlarePixelShader: {
  48903. name: string;
  48904. shader: string;
  48905. };
  48906. }
  48907. declare module BABYLON {
  48908. /** @hidden */
  48909. export var lensFlareVertexShader: {
  48910. name: string;
  48911. shader: string;
  48912. };
  48913. }
  48914. declare module BABYLON {
  48915. /**
  48916. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48917. * It is usually composed of several `lensFlare`.
  48918. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48919. */
  48920. export class LensFlareSystem {
  48921. /**
  48922. * Define the name of the lens flare system
  48923. */
  48924. name: string;
  48925. /**
  48926. * List of lens flares used in this system.
  48927. */
  48928. lensFlares: LensFlare[];
  48929. /**
  48930. * Define a limit from the border the lens flare can be visible.
  48931. */
  48932. borderLimit: number;
  48933. /**
  48934. * Define a viewport border we do not want to see the lens flare in.
  48935. */
  48936. viewportBorder: number;
  48937. /**
  48938. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48939. */
  48940. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48941. /**
  48942. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48943. */
  48944. layerMask: number;
  48945. /**
  48946. * Define the id of the lens flare system in the scene.
  48947. * (equal to name by default)
  48948. */
  48949. id: string;
  48950. private _scene;
  48951. private _emitter;
  48952. private _vertexBuffers;
  48953. private _indexBuffer;
  48954. private _effect;
  48955. private _positionX;
  48956. private _positionY;
  48957. private _isEnabled;
  48958. /** @hidden */
  48959. static _SceneComponentInitialization: (scene: Scene) => void;
  48960. /**
  48961. * Instantiates a lens flare system.
  48962. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48963. * It is usually composed of several `lensFlare`.
  48964. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48965. * @param name Define the name of the lens flare system in the scene
  48966. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48967. * @param scene Define the scene the lens flare system belongs to
  48968. */
  48969. constructor(
  48970. /**
  48971. * Define the name of the lens flare system
  48972. */
  48973. name: string, emitter: any, scene: Scene);
  48974. /**
  48975. * Define if the lens flare system is enabled.
  48976. */
  48977. isEnabled: boolean;
  48978. /**
  48979. * Get the scene the effects belongs to.
  48980. * @returns the scene holding the lens flare system
  48981. */
  48982. getScene(): Scene;
  48983. /**
  48984. * Get the emitter of the lens flare system.
  48985. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48986. * @returns the emitter of the lens flare system
  48987. */
  48988. getEmitter(): any;
  48989. /**
  48990. * Set the emitter of the lens flare system.
  48991. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48992. * @param newEmitter Define the new emitter of the system
  48993. */
  48994. setEmitter(newEmitter: any): void;
  48995. /**
  48996. * Get the lens flare system emitter position.
  48997. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48998. * @returns the position
  48999. */
  49000. getEmitterPosition(): Vector3;
  49001. /**
  49002. * @hidden
  49003. */
  49004. computeEffectivePosition(globalViewport: Viewport): boolean;
  49005. /** @hidden */
  49006. _isVisible(): boolean;
  49007. /**
  49008. * @hidden
  49009. */
  49010. render(): boolean;
  49011. /**
  49012. * Dispose and release the lens flare with its associated resources.
  49013. */
  49014. dispose(): void;
  49015. /**
  49016. * Parse a lens flare system from a JSON repressentation
  49017. * @param parsedLensFlareSystem Define the JSON to parse
  49018. * @param scene Define the scene the parsed system should be instantiated in
  49019. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49020. * @returns the parsed system
  49021. */
  49022. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49023. /**
  49024. * Serialize the current Lens Flare System into a JSON representation.
  49025. * @returns the serialized JSON
  49026. */
  49027. serialize(): any;
  49028. }
  49029. }
  49030. declare module BABYLON {
  49031. /**
  49032. * This represents one of the lens effect in a `lensFlareSystem`.
  49033. * It controls one of the indiviual texture used in the effect.
  49034. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49035. */
  49036. export class LensFlare {
  49037. /**
  49038. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49039. */
  49040. size: number;
  49041. /**
  49042. * 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.
  49043. */
  49044. position: number;
  49045. /**
  49046. * Define the lens color.
  49047. */
  49048. color: Color3;
  49049. /**
  49050. * Define the lens texture.
  49051. */
  49052. texture: Nullable<Texture>;
  49053. /**
  49054. * Define the alpha mode to render this particular lens.
  49055. */
  49056. alphaMode: number;
  49057. private _system;
  49058. /**
  49059. * Creates a new Lens Flare.
  49060. * This represents one of the lens effect in a `lensFlareSystem`.
  49061. * It controls one of the indiviual texture used in the effect.
  49062. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49063. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49064. * @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.
  49065. * @param color Define the lens color
  49066. * @param imgUrl Define the lens texture url
  49067. * @param system Define the `lensFlareSystem` this flare is part of
  49068. * @returns The newly created Lens Flare
  49069. */
  49070. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49071. /**
  49072. * Instantiates a new Lens Flare.
  49073. * This represents one of the lens effect in a `lensFlareSystem`.
  49074. * It controls one of the indiviual texture used in the effect.
  49075. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49076. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49077. * @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.
  49078. * @param color Define the lens color
  49079. * @param imgUrl Define the lens texture url
  49080. * @param system Define the `lensFlareSystem` this flare is part of
  49081. */
  49082. constructor(
  49083. /**
  49084. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49085. */
  49086. size: number,
  49087. /**
  49088. * 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.
  49089. */
  49090. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49091. /**
  49092. * Dispose and release the lens flare with its associated resources.
  49093. */
  49094. dispose(): void;
  49095. }
  49096. }
  49097. declare module BABYLON {
  49098. interface AbstractScene {
  49099. /**
  49100. * The list of lens flare system added to the scene
  49101. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49102. */
  49103. lensFlareSystems: Array<LensFlareSystem>;
  49104. /**
  49105. * Removes the given lens flare system from this scene.
  49106. * @param toRemove The lens flare system to remove
  49107. * @returns The index of the removed lens flare system
  49108. */
  49109. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49110. /**
  49111. * Adds the given lens flare system to this scene
  49112. * @param newLensFlareSystem The lens flare system to add
  49113. */
  49114. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49115. /**
  49116. * Gets a lens flare system using its name
  49117. * @param name defines the name to look for
  49118. * @returns the lens flare system or null if not found
  49119. */
  49120. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49121. /**
  49122. * Gets a lens flare system using its id
  49123. * @param id defines the id to look for
  49124. * @returns the lens flare system or null if not found
  49125. */
  49126. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49127. }
  49128. /**
  49129. * Defines the lens flare scene component responsible to manage any lens flares
  49130. * in a given scene.
  49131. */
  49132. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49133. /**
  49134. * The component name helpfull to identify the component in the list of scene components.
  49135. */
  49136. readonly name: string;
  49137. /**
  49138. * The scene the component belongs to.
  49139. */
  49140. scene: Scene;
  49141. /**
  49142. * Creates a new instance of the component for the given scene
  49143. * @param scene Defines the scene to register the component in
  49144. */
  49145. constructor(scene: Scene);
  49146. /**
  49147. * Registers the component in a given scene
  49148. */
  49149. register(): void;
  49150. /**
  49151. * Rebuilds the elements related to this component in case of
  49152. * context lost for instance.
  49153. */
  49154. rebuild(): void;
  49155. /**
  49156. * Adds all the elements from the container to the scene
  49157. * @param container the container holding the elements
  49158. */
  49159. addFromContainer(container: AbstractScene): void;
  49160. /**
  49161. * Removes all the elements in the container from the scene
  49162. * @param container contains the elements to remove
  49163. * @param dispose if the removed element should be disposed (default: false)
  49164. */
  49165. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49166. /**
  49167. * Serializes the component data to the specified json object
  49168. * @param serializationObject The object to serialize to
  49169. */
  49170. serialize(serializationObject: any): void;
  49171. /**
  49172. * Disposes the component and the associated ressources.
  49173. */
  49174. dispose(): void;
  49175. private _draw;
  49176. }
  49177. }
  49178. declare module BABYLON {
  49179. /**
  49180. * Defines the shadow generator component responsible to manage any shadow generators
  49181. * in a given scene.
  49182. */
  49183. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49184. /**
  49185. * The component name helpfull to identify the component in the list of scene components.
  49186. */
  49187. readonly name: string;
  49188. /**
  49189. * The scene the component belongs to.
  49190. */
  49191. scene: Scene;
  49192. /**
  49193. * Creates a new instance of the component for the given scene
  49194. * @param scene Defines the scene to register the component in
  49195. */
  49196. constructor(scene: Scene);
  49197. /**
  49198. * Registers the component in a given scene
  49199. */
  49200. register(): void;
  49201. /**
  49202. * Rebuilds the elements related to this component in case of
  49203. * context lost for instance.
  49204. */
  49205. rebuild(): void;
  49206. /**
  49207. * Serializes the component data to the specified json object
  49208. * @param serializationObject The object to serialize to
  49209. */
  49210. serialize(serializationObject: any): void;
  49211. /**
  49212. * Adds all the elements from the container to the scene
  49213. * @param container the container holding the elements
  49214. */
  49215. addFromContainer(container: AbstractScene): void;
  49216. /**
  49217. * Removes all the elements in the container from the scene
  49218. * @param container contains the elements to remove
  49219. * @param dispose if the removed element should be disposed (default: false)
  49220. */
  49221. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49222. /**
  49223. * Rebuilds the elements related to this component in case of
  49224. * context lost for instance.
  49225. */
  49226. dispose(): void;
  49227. private _gatherRenderTargets;
  49228. }
  49229. }
  49230. declare module BABYLON {
  49231. /**
  49232. * A point light is a light defined by an unique point in world space.
  49233. * The light is emitted in every direction from this point.
  49234. * A good example of a point light is a standard light bulb.
  49235. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49236. */
  49237. export class PointLight extends ShadowLight {
  49238. private _shadowAngle;
  49239. /**
  49240. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49241. * This specifies what angle the shadow will use to be created.
  49242. *
  49243. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49244. */
  49245. /**
  49246. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49247. * This specifies what angle the shadow will use to be created.
  49248. *
  49249. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49250. */
  49251. shadowAngle: number;
  49252. /**
  49253. * Gets the direction if it has been set.
  49254. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49255. */
  49256. /**
  49257. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49258. */
  49259. direction: Vector3;
  49260. /**
  49261. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49262. * A PointLight emits the light in every direction.
  49263. * It can cast shadows.
  49264. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49265. * ```javascript
  49266. * var pointLight = new PointLight("pl", camera.position, scene);
  49267. * ```
  49268. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49269. * @param name The light friendly name
  49270. * @param position The position of the point light in the scene
  49271. * @param scene The scene the lights belongs to
  49272. */
  49273. constructor(name: string, position: Vector3, scene: Scene);
  49274. /**
  49275. * Returns the string "PointLight"
  49276. * @returns the class name
  49277. */
  49278. getClassName(): string;
  49279. /**
  49280. * Returns the integer 0.
  49281. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49282. */
  49283. getTypeID(): number;
  49284. /**
  49285. * Specifies wether or not the shadowmap should be a cube texture.
  49286. * @returns true if the shadowmap needs to be a cube texture.
  49287. */
  49288. needCube(): boolean;
  49289. /**
  49290. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49291. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49292. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49293. */
  49294. getShadowDirection(faceIndex?: number): Vector3;
  49295. /**
  49296. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49297. * - fov = PI / 2
  49298. * - aspect ratio : 1.0
  49299. * - z-near and far equal to the active camera minZ and maxZ.
  49300. * Returns the PointLight.
  49301. */
  49302. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49303. protected _buildUniformLayout(): void;
  49304. /**
  49305. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49306. * @param effect The effect to update
  49307. * @param lightIndex The index of the light in the effect to update
  49308. * @returns The point light
  49309. */
  49310. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49311. /**
  49312. * Prepares the list of defines specific to the light type.
  49313. * @param defines the list of defines
  49314. * @param lightIndex defines the index of the light for the effect
  49315. */
  49316. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49317. }
  49318. }
  49319. declare module BABYLON {
  49320. /**
  49321. * Header information of HDR texture files.
  49322. */
  49323. export interface HDRInfo {
  49324. /**
  49325. * The height of the texture in pixels.
  49326. */
  49327. height: number;
  49328. /**
  49329. * The width of the texture in pixels.
  49330. */
  49331. width: number;
  49332. /**
  49333. * The index of the beginning of the data in the binary file.
  49334. */
  49335. dataPosition: number;
  49336. }
  49337. /**
  49338. * This groups tools to convert HDR texture to native colors array.
  49339. */
  49340. export class HDRTools {
  49341. private static Ldexp;
  49342. private static Rgbe2float;
  49343. private static readStringLine;
  49344. /**
  49345. * Reads header information from an RGBE texture stored in a native array.
  49346. * More information on this format are available here:
  49347. * https://en.wikipedia.org/wiki/RGBE_image_format
  49348. *
  49349. * @param uint8array The binary file stored in native array.
  49350. * @return The header information.
  49351. */
  49352. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49353. /**
  49354. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49355. * This RGBE texture needs to store the information as a panorama.
  49356. *
  49357. * More information on this format are available here:
  49358. * https://en.wikipedia.org/wiki/RGBE_image_format
  49359. *
  49360. * @param buffer The binary file stored in an array buffer.
  49361. * @param size The expected size of the extracted cubemap.
  49362. * @return The Cube Map information.
  49363. */
  49364. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49365. /**
  49366. * Returns the pixels data extracted from an RGBE texture.
  49367. * This pixels will be stored left to right up to down in the R G B order in one array.
  49368. *
  49369. * More information on this format are available here:
  49370. * https://en.wikipedia.org/wiki/RGBE_image_format
  49371. *
  49372. * @param uint8array The binary file stored in an array buffer.
  49373. * @param hdrInfo The header information of the file.
  49374. * @return The pixels data in RGB right to left up to down order.
  49375. */
  49376. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49377. private static RGBE_ReadPixels_RLE;
  49378. }
  49379. }
  49380. declare module BABYLON {
  49381. /**
  49382. * This represents a texture coming from an HDR input.
  49383. *
  49384. * The only supported format is currently panorama picture stored in RGBE format.
  49385. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49386. */
  49387. export class HDRCubeTexture extends BaseTexture {
  49388. private static _facesMapping;
  49389. private _generateHarmonics;
  49390. private _noMipmap;
  49391. private _textureMatrix;
  49392. private _size;
  49393. private _onLoad;
  49394. private _onError;
  49395. /**
  49396. * The texture URL.
  49397. */
  49398. url: string;
  49399. /**
  49400. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49401. */
  49402. coordinatesMode: number;
  49403. protected _isBlocking: boolean;
  49404. /**
  49405. * Sets wether or not the texture is blocking during loading.
  49406. */
  49407. /**
  49408. * Gets wether or not the texture is blocking during loading.
  49409. */
  49410. isBlocking: boolean;
  49411. protected _rotationY: number;
  49412. /**
  49413. * Sets texture matrix rotation angle around Y axis in radians.
  49414. */
  49415. /**
  49416. * Gets texture matrix rotation angle around Y axis radians.
  49417. */
  49418. rotationY: number;
  49419. /**
  49420. * Gets or sets the center of the bounding box associated with the cube texture
  49421. * It must define where the camera used to render the texture was set
  49422. */
  49423. boundingBoxPosition: Vector3;
  49424. private _boundingBoxSize;
  49425. /**
  49426. * Gets or sets the size of the bounding box associated with the cube texture
  49427. * When defined, the cubemap will switch to local mode
  49428. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49429. * @example https://www.babylonjs-playground.com/#RNASML
  49430. */
  49431. boundingBoxSize: Vector3;
  49432. /**
  49433. * Instantiates an HDRTexture from the following parameters.
  49434. *
  49435. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49436. * @param scene The scene the texture will be used in
  49437. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49438. * @param noMipmap Forces to not generate the mipmap if true
  49439. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49440. * @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)
  49441. * @param reserved Reserved flag for internal use.
  49442. */
  49443. 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>);
  49444. /**
  49445. * Get the current class name of the texture useful for serialization or dynamic coding.
  49446. * @returns "HDRCubeTexture"
  49447. */
  49448. getClassName(): string;
  49449. /**
  49450. * Occurs when the file is raw .hdr file.
  49451. */
  49452. private loadTexture;
  49453. clone(): HDRCubeTexture;
  49454. delayLoad(): void;
  49455. /**
  49456. * Get the texture reflection matrix used to rotate/transform the reflection.
  49457. * @returns the reflection matrix
  49458. */
  49459. getReflectionTextureMatrix(): Matrix;
  49460. /**
  49461. * Set the texture reflection matrix used to rotate/transform the reflection.
  49462. * @param value Define the reflection matrix to set
  49463. */
  49464. setReflectionTextureMatrix(value: Matrix): void;
  49465. /**
  49466. * Parses a JSON representation of an HDR Texture in order to create the texture
  49467. * @param parsedTexture Define the JSON representation
  49468. * @param scene Define the scene the texture should be created in
  49469. * @param rootUrl Define the root url in case we need to load relative dependencies
  49470. * @returns the newly created texture after parsing
  49471. */
  49472. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49473. serialize(): any;
  49474. }
  49475. }
  49476. declare module BABYLON {
  49477. /**
  49478. * Class used to control physics engine
  49479. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49480. */
  49481. export class PhysicsEngine implements IPhysicsEngine {
  49482. private _physicsPlugin;
  49483. /**
  49484. * Global value used to control the smallest number supported by the simulation
  49485. */
  49486. static Epsilon: number;
  49487. private _impostors;
  49488. private _joints;
  49489. /**
  49490. * Gets the gravity vector used by the simulation
  49491. */
  49492. gravity: Vector3;
  49493. /**
  49494. * Factory used to create the default physics plugin.
  49495. * @returns The default physics plugin
  49496. */
  49497. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49498. /**
  49499. * Creates a new Physics Engine
  49500. * @param gravity defines the gravity vector used by the simulation
  49501. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49502. */
  49503. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49504. /**
  49505. * Sets the gravity vector used by the simulation
  49506. * @param gravity defines the gravity vector to use
  49507. */
  49508. setGravity(gravity: Vector3): void;
  49509. /**
  49510. * Set the time step of the physics engine.
  49511. * Default is 1/60.
  49512. * To slow it down, enter 1/600 for example.
  49513. * To speed it up, 1/30
  49514. * @param newTimeStep defines the new timestep to apply to this world.
  49515. */
  49516. setTimeStep(newTimeStep?: number): void;
  49517. /**
  49518. * Get the time step of the physics engine.
  49519. * @returns the current time step
  49520. */
  49521. getTimeStep(): number;
  49522. /**
  49523. * Release all resources
  49524. */
  49525. dispose(): void;
  49526. /**
  49527. * Gets the name of the current physics plugin
  49528. * @returns the name of the plugin
  49529. */
  49530. getPhysicsPluginName(): string;
  49531. /**
  49532. * Adding a new impostor for the impostor tracking.
  49533. * This will be done by the impostor itself.
  49534. * @param impostor the impostor to add
  49535. */
  49536. addImpostor(impostor: PhysicsImpostor): void;
  49537. /**
  49538. * Remove an impostor from the engine.
  49539. * This impostor and its mesh will not longer be updated by the physics engine.
  49540. * @param impostor the impostor to remove
  49541. */
  49542. removeImpostor(impostor: PhysicsImpostor): void;
  49543. /**
  49544. * Add a joint to the physics engine
  49545. * @param mainImpostor defines the main impostor to which the joint is added.
  49546. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49547. * @param joint defines the joint that will connect both impostors.
  49548. */
  49549. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49550. /**
  49551. * Removes a joint from the simulation
  49552. * @param mainImpostor defines the impostor used with the joint
  49553. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49554. * @param joint defines the joint to remove
  49555. */
  49556. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49557. /**
  49558. * Called by the scene. No need to call it.
  49559. * @param delta defines the timespam between frames
  49560. */
  49561. _step(delta: number): void;
  49562. /**
  49563. * Gets the current plugin used to run the simulation
  49564. * @returns current plugin
  49565. */
  49566. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49567. /**
  49568. * Gets the list of physic impostors
  49569. * @returns an array of PhysicsImpostor
  49570. */
  49571. getImpostors(): Array<PhysicsImpostor>;
  49572. /**
  49573. * Gets the impostor for a physics enabled object
  49574. * @param object defines the object impersonated by the impostor
  49575. * @returns the PhysicsImpostor or null if not found
  49576. */
  49577. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49578. /**
  49579. * Gets the impostor for a physics body object
  49580. * @param body defines physics body used by the impostor
  49581. * @returns the PhysicsImpostor or null if not found
  49582. */
  49583. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49584. /**
  49585. * Does a raycast in the physics world
  49586. * @param from when should the ray start?
  49587. * @param to when should the ray end?
  49588. * @returns PhysicsRaycastResult
  49589. */
  49590. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49591. }
  49592. }
  49593. declare module BABYLON {
  49594. /** @hidden */
  49595. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49596. private _useDeltaForWorldStep;
  49597. world: any;
  49598. name: string;
  49599. private _physicsMaterials;
  49600. private _fixedTimeStep;
  49601. private _cannonRaycastResult;
  49602. private _raycastResult;
  49603. private _physicsBodysToRemoveAfterStep;
  49604. BJSCANNON: any;
  49605. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49606. setGravity(gravity: Vector3): void;
  49607. setTimeStep(timeStep: number): void;
  49608. getTimeStep(): number;
  49609. executeStep(delta: number): void;
  49610. private _removeMarkedPhysicsBodiesFromWorld;
  49611. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49612. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49613. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49614. private _processChildMeshes;
  49615. removePhysicsBody(impostor: PhysicsImpostor): void;
  49616. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49617. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49618. private _addMaterial;
  49619. private _checkWithEpsilon;
  49620. private _createShape;
  49621. private _createHeightmap;
  49622. private _minus90X;
  49623. private _plus90X;
  49624. private _tmpPosition;
  49625. private _tmpDeltaPosition;
  49626. private _tmpUnityRotation;
  49627. private _updatePhysicsBodyTransformation;
  49628. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49629. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49630. isSupported(): boolean;
  49631. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49632. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49633. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49634. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49635. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49636. getBodyMass(impostor: PhysicsImpostor): number;
  49637. getBodyFriction(impostor: PhysicsImpostor): number;
  49638. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49639. getBodyRestitution(impostor: PhysicsImpostor): number;
  49640. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49641. sleepBody(impostor: PhysicsImpostor): void;
  49642. wakeUpBody(impostor: PhysicsImpostor): void;
  49643. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49644. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49645. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49646. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49647. getRadius(impostor: PhysicsImpostor): number;
  49648. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49649. dispose(): void;
  49650. private _extendNamespace;
  49651. /**
  49652. * Does a raycast in the physics world
  49653. * @param from when should the ray start?
  49654. * @param to when should the ray end?
  49655. * @returns PhysicsRaycastResult
  49656. */
  49657. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49658. }
  49659. }
  49660. declare module BABYLON {
  49661. /** @hidden */
  49662. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49663. world: any;
  49664. name: string;
  49665. BJSOIMO: any;
  49666. private _raycastResult;
  49667. constructor(iterations?: number, oimoInjection?: any);
  49668. setGravity(gravity: Vector3): void;
  49669. setTimeStep(timeStep: number): void;
  49670. getTimeStep(): number;
  49671. private _tmpImpostorsArray;
  49672. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49673. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49674. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49675. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49676. private _tmpPositionVector;
  49677. removePhysicsBody(impostor: PhysicsImpostor): void;
  49678. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49679. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49680. isSupported(): boolean;
  49681. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49682. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49683. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49684. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49685. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49686. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49687. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49688. getBodyMass(impostor: PhysicsImpostor): number;
  49689. getBodyFriction(impostor: PhysicsImpostor): number;
  49690. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49691. getBodyRestitution(impostor: PhysicsImpostor): number;
  49692. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49693. sleepBody(impostor: PhysicsImpostor): void;
  49694. wakeUpBody(impostor: PhysicsImpostor): void;
  49695. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49696. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49697. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49698. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49699. getRadius(impostor: PhysicsImpostor): number;
  49700. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49701. dispose(): void;
  49702. /**
  49703. * Does a raycast in the physics world
  49704. * @param from when should the ray start?
  49705. * @param to when should the ray end?
  49706. * @returns PhysicsRaycastResult
  49707. */
  49708. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49709. }
  49710. }
  49711. declare module BABYLON {
  49712. /**
  49713. * Class containing static functions to help procedurally build meshes
  49714. */
  49715. export class RibbonBuilder {
  49716. /**
  49717. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49718. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49719. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49720. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49721. * * 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
  49722. * * 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
  49723. * * 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
  49724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49725. * * 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
  49726. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49727. * * 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
  49728. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49729. * * 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
  49730. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49732. * @param name defines the name of the mesh
  49733. * @param options defines the options used to create the mesh
  49734. * @param scene defines the hosting scene
  49735. * @returns the ribbon mesh
  49736. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49737. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49738. */
  49739. static CreateRibbon(name: string, options: {
  49740. pathArray: Vector3[][];
  49741. closeArray?: boolean;
  49742. closePath?: boolean;
  49743. offset?: number;
  49744. updatable?: boolean;
  49745. sideOrientation?: number;
  49746. frontUVs?: Vector4;
  49747. backUVs?: Vector4;
  49748. instance?: Mesh;
  49749. invertUV?: boolean;
  49750. uvs?: Vector2[];
  49751. colors?: Color4[];
  49752. }, scene?: Nullable<Scene>): Mesh;
  49753. }
  49754. }
  49755. declare module BABYLON {
  49756. /**
  49757. * Class containing static functions to help procedurally build meshes
  49758. */
  49759. export class ShapeBuilder {
  49760. /**
  49761. * 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.
  49762. * * 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.
  49763. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49764. * * 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.
  49765. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49766. * * 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
  49767. * * 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
  49768. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49770. * * 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
  49771. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49773. * @param name defines the name of the mesh
  49774. * @param options defines the options used to create the mesh
  49775. * @param scene defines the hosting scene
  49776. * @returns the extruded shape mesh
  49777. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49778. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49779. */
  49780. static ExtrudeShape(name: string, options: {
  49781. shape: Vector3[];
  49782. path: Vector3[];
  49783. scale?: number;
  49784. rotation?: number;
  49785. cap?: number;
  49786. updatable?: boolean;
  49787. sideOrientation?: number;
  49788. frontUVs?: Vector4;
  49789. backUVs?: Vector4;
  49790. instance?: Mesh;
  49791. invertUV?: boolean;
  49792. }, scene?: Nullable<Scene>): Mesh;
  49793. /**
  49794. * Creates an custom extruded shape mesh.
  49795. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49796. * * 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.
  49797. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49798. * * 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
  49799. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49800. * * 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
  49801. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49802. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49803. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49804. * * 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
  49805. * * 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
  49806. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49807. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49808. * * 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
  49809. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49811. * @param name defines the name of the mesh
  49812. * @param options defines the options used to create the mesh
  49813. * @param scene defines the hosting scene
  49814. * @returns the custom extruded shape mesh
  49815. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49816. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49817. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49818. */
  49819. static ExtrudeShapeCustom(name: string, options: {
  49820. shape: Vector3[];
  49821. path: Vector3[];
  49822. scaleFunction?: any;
  49823. rotationFunction?: any;
  49824. ribbonCloseArray?: boolean;
  49825. ribbonClosePath?: boolean;
  49826. cap?: number;
  49827. updatable?: boolean;
  49828. sideOrientation?: number;
  49829. frontUVs?: Vector4;
  49830. backUVs?: Vector4;
  49831. instance?: Mesh;
  49832. invertUV?: boolean;
  49833. }, scene?: Nullable<Scene>): Mesh;
  49834. private static _ExtrudeShapeGeneric;
  49835. }
  49836. }
  49837. declare module BABYLON {
  49838. /**
  49839. * AmmoJS Physics plugin
  49840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49841. * @see https://github.com/kripken/ammo.js/
  49842. */
  49843. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49844. private _useDeltaForWorldStep;
  49845. /**
  49846. * Reference to the Ammo library
  49847. */
  49848. bjsAMMO: any;
  49849. /**
  49850. * Created ammoJS world which physics bodies are added to
  49851. */
  49852. world: any;
  49853. /**
  49854. * Name of the plugin
  49855. */
  49856. name: string;
  49857. private _timeStep;
  49858. private _fixedTimeStep;
  49859. private _maxSteps;
  49860. private _tmpQuaternion;
  49861. private _tmpAmmoTransform;
  49862. private _tmpAmmoQuaternion;
  49863. private _tmpAmmoConcreteContactResultCallback;
  49864. private _collisionConfiguration;
  49865. private _dispatcher;
  49866. private _overlappingPairCache;
  49867. private _solver;
  49868. private _softBodySolver;
  49869. private _tmpAmmoVectorA;
  49870. private _tmpAmmoVectorB;
  49871. private _tmpAmmoVectorC;
  49872. private _tmpAmmoVectorD;
  49873. private _tmpContactCallbackResult;
  49874. private _tmpAmmoVectorRCA;
  49875. private _tmpAmmoVectorRCB;
  49876. private _raycastResult;
  49877. private static readonly DISABLE_COLLISION_FLAG;
  49878. private static readonly KINEMATIC_FLAG;
  49879. private static readonly DISABLE_DEACTIVATION_FLAG;
  49880. /**
  49881. * Initializes the ammoJS plugin
  49882. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49883. * @param ammoInjection can be used to inject your own ammo reference
  49884. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  49885. */
  49886. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  49887. /**
  49888. * Sets the gravity of the physics world (m/(s^2))
  49889. * @param gravity Gravity to set
  49890. */
  49891. setGravity(gravity: Vector3): void;
  49892. /**
  49893. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49894. * @param timeStep timestep to use in seconds
  49895. */
  49896. setTimeStep(timeStep: number): void;
  49897. /**
  49898. * 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)
  49899. * @param fixedTimeStep fixedTimeStep to use in seconds
  49900. */
  49901. setFixedTimeStep(fixedTimeStep: number): void;
  49902. /**
  49903. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49904. * @param maxSteps the maximum number of steps by the physics engine per frame
  49905. */
  49906. setMaxSteps(maxSteps: number): void;
  49907. /**
  49908. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49909. * @returns the current timestep in seconds
  49910. */
  49911. getTimeStep(): number;
  49912. private _isImpostorInContact;
  49913. private _isImpostorPairInContact;
  49914. private _stepSimulation;
  49915. /**
  49916. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49917. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49918. * After the step the babylon meshes are set to the position of the physics imposters
  49919. * @param delta amount of time to step forward
  49920. * @param impostors array of imposters to update before/after the step
  49921. */
  49922. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49923. /**
  49924. * Update babylon mesh to match physics world object
  49925. * @param impostor imposter to match
  49926. */
  49927. private _afterSoftStep;
  49928. /**
  49929. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49930. * @param impostor imposter to match
  49931. */
  49932. private _ropeStep;
  49933. /**
  49934. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49935. * @param impostor imposter to match
  49936. */
  49937. private _softbodyOrClothStep;
  49938. private _tmpVector;
  49939. private _tmpMatrix;
  49940. /**
  49941. * Applies an impulse on the imposter
  49942. * @param impostor imposter to apply impulse to
  49943. * @param force amount of force to be applied to the imposter
  49944. * @param contactPoint the location to apply the impulse on the imposter
  49945. */
  49946. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49947. /**
  49948. * Applies a force on the imposter
  49949. * @param impostor imposter to apply force
  49950. * @param force amount of force to be applied to the imposter
  49951. * @param contactPoint the location to apply the force on the imposter
  49952. */
  49953. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49954. /**
  49955. * Creates a physics body using the plugin
  49956. * @param impostor the imposter to create the physics body on
  49957. */
  49958. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49959. /**
  49960. * Removes the physics body from the imposter and disposes of the body's memory
  49961. * @param impostor imposter to remove the physics body from
  49962. */
  49963. removePhysicsBody(impostor: PhysicsImpostor): void;
  49964. /**
  49965. * Generates a joint
  49966. * @param impostorJoint the imposter joint to create the joint with
  49967. */
  49968. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49969. /**
  49970. * Removes a joint
  49971. * @param impostorJoint the imposter joint to remove the joint from
  49972. */
  49973. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49974. private _addMeshVerts;
  49975. /**
  49976. * Initialise the soft body vertices to match its object's (mesh) vertices
  49977. * Softbody vertices (nodes) are in world space and to match this
  49978. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  49979. * @param impostor to create the softbody for
  49980. */
  49981. private _softVertexData;
  49982. /**
  49983. * Create an impostor's soft body
  49984. * @param impostor to create the softbody for
  49985. */
  49986. private _createSoftbody;
  49987. /**
  49988. * Create cloth for an impostor
  49989. * @param impostor to create the softbody for
  49990. */
  49991. private _createCloth;
  49992. /**
  49993. * Create rope for an impostor
  49994. * @param impostor to create the softbody for
  49995. */
  49996. private _createRope;
  49997. private _addHullVerts;
  49998. private _createShape;
  49999. /**
  50000. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50001. * @param impostor imposter containing the physics body and babylon object
  50002. */
  50003. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50004. /**
  50005. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50006. * @param impostor imposter containing the physics body and babylon object
  50007. * @param newPosition new position
  50008. * @param newRotation new rotation
  50009. */
  50010. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50011. /**
  50012. * If this plugin is supported
  50013. * @returns true if its supported
  50014. */
  50015. isSupported(): boolean;
  50016. /**
  50017. * Sets the linear velocity of the physics body
  50018. * @param impostor imposter to set the velocity on
  50019. * @param velocity velocity to set
  50020. */
  50021. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50022. /**
  50023. * Sets the angular velocity of the physics body
  50024. * @param impostor imposter to set the velocity on
  50025. * @param velocity velocity to set
  50026. */
  50027. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50028. /**
  50029. * gets the linear velocity
  50030. * @param impostor imposter to get linear velocity from
  50031. * @returns linear velocity
  50032. */
  50033. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50034. /**
  50035. * gets the angular velocity
  50036. * @param impostor imposter to get angular velocity from
  50037. * @returns angular velocity
  50038. */
  50039. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50040. /**
  50041. * Sets the mass of physics body
  50042. * @param impostor imposter to set the mass on
  50043. * @param mass mass to set
  50044. */
  50045. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50046. /**
  50047. * Gets the mass of the physics body
  50048. * @param impostor imposter to get the mass from
  50049. * @returns mass
  50050. */
  50051. getBodyMass(impostor: PhysicsImpostor): number;
  50052. /**
  50053. * Gets friction of the impostor
  50054. * @param impostor impostor to get friction from
  50055. * @returns friction value
  50056. */
  50057. getBodyFriction(impostor: PhysicsImpostor): number;
  50058. /**
  50059. * Sets friction of the impostor
  50060. * @param impostor impostor to set friction on
  50061. * @param friction friction value
  50062. */
  50063. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50064. /**
  50065. * Gets restitution of the impostor
  50066. * @param impostor impostor to get restitution from
  50067. * @returns restitution value
  50068. */
  50069. getBodyRestitution(impostor: PhysicsImpostor): number;
  50070. /**
  50071. * Sets resitution of the impostor
  50072. * @param impostor impostor to set resitution on
  50073. * @param restitution resitution value
  50074. */
  50075. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50076. /**
  50077. * Gets pressure inside the impostor
  50078. * @param impostor impostor to get pressure from
  50079. * @returns pressure value
  50080. */
  50081. getBodyPressure(impostor: PhysicsImpostor): number;
  50082. /**
  50083. * Sets pressure inside a soft body impostor
  50084. * Cloth and rope must remain 0 pressure
  50085. * @param impostor impostor to set pressure on
  50086. * @param pressure pressure value
  50087. */
  50088. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50089. /**
  50090. * Gets stiffness of the impostor
  50091. * @param impostor impostor to get stiffness from
  50092. * @returns pressure value
  50093. */
  50094. getBodyStiffness(impostor: PhysicsImpostor): number;
  50095. /**
  50096. * Sets stiffness of the impostor
  50097. * @param impostor impostor to set stiffness on
  50098. * @param stiffness stiffness value from 0 to 1
  50099. */
  50100. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50101. /**
  50102. * Gets velocityIterations of the impostor
  50103. * @param impostor impostor to get velocity iterations from
  50104. * @returns velocityIterations value
  50105. */
  50106. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50107. /**
  50108. * Sets velocityIterations of the impostor
  50109. * @param impostor impostor to set velocity iterations on
  50110. * @param velocityIterations velocityIterations value
  50111. */
  50112. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50113. /**
  50114. * Gets positionIterations of the impostor
  50115. * @param impostor impostor to get position iterations from
  50116. * @returns positionIterations value
  50117. */
  50118. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50119. /**
  50120. * Sets positionIterations of the impostor
  50121. * @param impostor impostor to set position on
  50122. * @param positionIterations positionIterations value
  50123. */
  50124. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50125. /**
  50126. * Append an anchor to a cloth object
  50127. * @param impostor is the cloth impostor to add anchor to
  50128. * @param otherImpostor is the rigid impostor to anchor to
  50129. * @param width ratio across width from 0 to 1
  50130. * @param height ratio up height from 0 to 1
  50131. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50132. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50133. */
  50134. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50135. /**
  50136. * Append an hook to a rope object
  50137. * @param impostor is the rope impostor to add hook to
  50138. * @param otherImpostor is the rigid impostor to hook to
  50139. * @param length ratio along the rope from 0 to 1
  50140. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50141. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50142. */
  50143. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50144. /**
  50145. * Sleeps the physics body and stops it from being active
  50146. * @param impostor impostor to sleep
  50147. */
  50148. sleepBody(impostor: PhysicsImpostor): void;
  50149. /**
  50150. * Activates the physics body
  50151. * @param impostor impostor to activate
  50152. */
  50153. wakeUpBody(impostor: PhysicsImpostor): void;
  50154. /**
  50155. * Updates the distance parameters of the joint
  50156. * @param joint joint to update
  50157. * @param maxDistance maximum distance of the joint
  50158. * @param minDistance minimum distance of the joint
  50159. */
  50160. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50161. /**
  50162. * Sets a motor on the joint
  50163. * @param joint joint to set motor on
  50164. * @param speed speed of the motor
  50165. * @param maxForce maximum force of the motor
  50166. * @param motorIndex index of the motor
  50167. */
  50168. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50169. /**
  50170. * Sets the motors limit
  50171. * @param joint joint to set limit on
  50172. * @param upperLimit upper limit
  50173. * @param lowerLimit lower limit
  50174. */
  50175. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50176. /**
  50177. * Syncs the position and rotation of a mesh with the impostor
  50178. * @param mesh mesh to sync
  50179. * @param impostor impostor to update the mesh with
  50180. */
  50181. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50182. /**
  50183. * Gets the radius of the impostor
  50184. * @param impostor impostor to get radius from
  50185. * @returns the radius
  50186. */
  50187. getRadius(impostor: PhysicsImpostor): number;
  50188. /**
  50189. * Gets the box size of the impostor
  50190. * @param impostor impostor to get box size from
  50191. * @param result the resulting box size
  50192. */
  50193. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50194. /**
  50195. * Disposes of the impostor
  50196. */
  50197. dispose(): void;
  50198. /**
  50199. * Does a raycast in the physics world
  50200. * @param from when should the ray start?
  50201. * @param to when should the ray end?
  50202. * @returns PhysicsRaycastResult
  50203. */
  50204. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50205. }
  50206. }
  50207. declare module BABYLON {
  50208. interface AbstractScene {
  50209. /**
  50210. * The list of reflection probes added to the scene
  50211. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50212. */
  50213. reflectionProbes: Array<ReflectionProbe>;
  50214. /**
  50215. * Removes the given reflection probe from this scene.
  50216. * @param toRemove The reflection probe to remove
  50217. * @returns The index of the removed reflection probe
  50218. */
  50219. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50220. /**
  50221. * Adds the given reflection probe to this scene.
  50222. * @param newReflectionProbe The reflection probe to add
  50223. */
  50224. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50225. }
  50226. /**
  50227. * Class used to generate realtime reflection / refraction cube textures
  50228. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50229. */
  50230. export class ReflectionProbe {
  50231. /** defines the name of the probe */
  50232. name: string;
  50233. private _scene;
  50234. private _renderTargetTexture;
  50235. private _projectionMatrix;
  50236. private _viewMatrix;
  50237. private _target;
  50238. private _add;
  50239. private _attachedMesh;
  50240. private _invertYAxis;
  50241. /** Gets or sets probe position (center of the cube map) */
  50242. position: Vector3;
  50243. /**
  50244. * Creates a new reflection probe
  50245. * @param name defines the name of the probe
  50246. * @param size defines the texture resolution (for each face)
  50247. * @param scene defines the hosting scene
  50248. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50249. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50250. */
  50251. constructor(
  50252. /** defines the name of the probe */
  50253. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50254. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50255. samples: number;
  50256. /** Gets or sets the refresh rate to use (on every frame by default) */
  50257. refreshRate: number;
  50258. /**
  50259. * Gets the hosting scene
  50260. * @returns a Scene
  50261. */
  50262. getScene(): Scene;
  50263. /** Gets the internal CubeTexture used to render to */
  50264. readonly cubeTexture: RenderTargetTexture;
  50265. /** Gets the list of meshes to render */
  50266. readonly renderList: Nullable<AbstractMesh[]>;
  50267. /**
  50268. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50269. * @param mesh defines the mesh to attach to
  50270. */
  50271. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50272. /**
  50273. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50274. * @param renderingGroupId The rendering group id corresponding to its index
  50275. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50276. */
  50277. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50278. /**
  50279. * Clean all associated resources
  50280. */
  50281. dispose(): void;
  50282. /**
  50283. * Converts the reflection probe information to a readable string for debug purpose.
  50284. * @param fullDetails Supports for multiple levels of logging within scene loading
  50285. * @returns the human readable reflection probe info
  50286. */
  50287. toString(fullDetails?: boolean): string;
  50288. /**
  50289. * Get the class name of the relfection probe.
  50290. * @returns "ReflectionProbe"
  50291. */
  50292. getClassName(): string;
  50293. /**
  50294. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50295. * @returns The JSON representation of the texture
  50296. */
  50297. serialize(): any;
  50298. /**
  50299. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50300. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50301. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50302. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50303. * @returns The parsed reflection probe if successful
  50304. */
  50305. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50306. }
  50307. }
  50308. declare module BABYLON {
  50309. /** @hidden */
  50310. export var _BabylonLoaderRegistered: boolean;
  50311. }
  50312. declare module BABYLON {
  50313. /**
  50314. * The Physically based simple base material of BJS.
  50315. *
  50316. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50317. * It is used as the base class for both the specGloss and metalRough conventions.
  50318. */
  50319. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50320. /**
  50321. * Number of Simultaneous lights allowed on the material.
  50322. */
  50323. maxSimultaneousLights: number;
  50324. /**
  50325. * If sets to true, disables all the lights affecting the material.
  50326. */
  50327. disableLighting: boolean;
  50328. /**
  50329. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50330. */
  50331. environmentTexture: BaseTexture;
  50332. /**
  50333. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50334. */
  50335. invertNormalMapX: boolean;
  50336. /**
  50337. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50338. */
  50339. invertNormalMapY: boolean;
  50340. /**
  50341. * Normal map used in the model.
  50342. */
  50343. normalTexture: BaseTexture;
  50344. /**
  50345. * Emissivie color used to self-illuminate the model.
  50346. */
  50347. emissiveColor: Color3;
  50348. /**
  50349. * Emissivie texture used to self-illuminate the model.
  50350. */
  50351. emissiveTexture: BaseTexture;
  50352. /**
  50353. * Occlusion Channel Strenght.
  50354. */
  50355. occlusionStrength: number;
  50356. /**
  50357. * Occlusion Texture of the material (adding extra occlusion effects).
  50358. */
  50359. occlusionTexture: BaseTexture;
  50360. /**
  50361. * Defines the alpha limits in alpha test mode.
  50362. */
  50363. alphaCutOff: number;
  50364. /**
  50365. * Gets the current double sided mode.
  50366. */
  50367. /**
  50368. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50369. */
  50370. doubleSided: boolean;
  50371. /**
  50372. * Stores the pre-calculated light information of a mesh in a texture.
  50373. */
  50374. lightmapTexture: BaseTexture;
  50375. /**
  50376. * If true, the light map contains occlusion information instead of lighting info.
  50377. */
  50378. useLightmapAsShadowmap: boolean;
  50379. /**
  50380. * Instantiates a new PBRMaterial instance.
  50381. *
  50382. * @param name The material name
  50383. * @param scene The scene the material will be use in.
  50384. */
  50385. constructor(name: string, scene: Scene);
  50386. getClassName(): string;
  50387. }
  50388. }
  50389. declare module BABYLON {
  50390. /**
  50391. * The PBR material of BJS following the metal roughness convention.
  50392. *
  50393. * This fits to the PBR convention in the GLTF definition:
  50394. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50395. */
  50396. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50397. /**
  50398. * The base color has two different interpretations depending on the value of metalness.
  50399. * When the material is a metal, the base color is the specific measured reflectance value
  50400. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50401. * of the material.
  50402. */
  50403. baseColor: Color3;
  50404. /**
  50405. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50406. * well as opacity information in the alpha channel.
  50407. */
  50408. baseTexture: BaseTexture;
  50409. /**
  50410. * Specifies the metallic scalar value of the material.
  50411. * Can also be used to scale the metalness values of the metallic texture.
  50412. */
  50413. metallic: number;
  50414. /**
  50415. * Specifies the roughness scalar value of the material.
  50416. * Can also be used to scale the roughness values of the metallic texture.
  50417. */
  50418. roughness: number;
  50419. /**
  50420. * Texture containing both the metallic value in the B channel and the
  50421. * roughness value in the G channel to keep better precision.
  50422. */
  50423. metallicRoughnessTexture: BaseTexture;
  50424. /**
  50425. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50426. *
  50427. * @param name The material name
  50428. * @param scene The scene the material will be use in.
  50429. */
  50430. constructor(name: string, scene: Scene);
  50431. /**
  50432. * Return the currrent class name of the material.
  50433. */
  50434. getClassName(): string;
  50435. /**
  50436. * Makes a duplicate of the current material.
  50437. * @param name - name to use for the new material.
  50438. */
  50439. clone(name: string): PBRMetallicRoughnessMaterial;
  50440. /**
  50441. * Serialize the material to a parsable JSON object.
  50442. */
  50443. serialize(): any;
  50444. /**
  50445. * Parses a JSON object correponding to the serialize function.
  50446. */
  50447. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50448. }
  50449. }
  50450. declare module BABYLON {
  50451. /**
  50452. * The PBR material of BJS following the specular glossiness convention.
  50453. *
  50454. * This fits to the PBR convention in the GLTF definition:
  50455. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50456. */
  50457. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50458. /**
  50459. * Specifies the diffuse color of the material.
  50460. */
  50461. diffuseColor: Color3;
  50462. /**
  50463. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50464. * channel.
  50465. */
  50466. diffuseTexture: BaseTexture;
  50467. /**
  50468. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50469. */
  50470. specularColor: Color3;
  50471. /**
  50472. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50473. */
  50474. glossiness: number;
  50475. /**
  50476. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50477. */
  50478. specularGlossinessTexture: BaseTexture;
  50479. /**
  50480. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50481. *
  50482. * @param name The material name
  50483. * @param scene The scene the material will be use in.
  50484. */
  50485. constructor(name: string, scene: Scene);
  50486. /**
  50487. * Return the currrent class name of the material.
  50488. */
  50489. getClassName(): string;
  50490. /**
  50491. * Makes a duplicate of the current material.
  50492. * @param name - name to use for the new material.
  50493. */
  50494. clone(name: string): PBRSpecularGlossinessMaterial;
  50495. /**
  50496. * Serialize the material to a parsable JSON object.
  50497. */
  50498. serialize(): any;
  50499. /**
  50500. * Parses a JSON object correponding to the serialize function.
  50501. */
  50502. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50503. }
  50504. }
  50505. declare module BABYLON {
  50506. /**
  50507. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50508. * It can help converting any input color in a desired output one. This can then be used to create effects
  50509. * from sepia, black and white to sixties or futuristic rendering...
  50510. *
  50511. * The only supported format is currently 3dl.
  50512. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50513. */
  50514. export class ColorGradingTexture extends BaseTexture {
  50515. /**
  50516. * The current texture matrix. (will always be identity in color grading texture)
  50517. */
  50518. private _textureMatrix;
  50519. /**
  50520. * The texture URL.
  50521. */
  50522. url: string;
  50523. /**
  50524. * Empty line regex stored for GC.
  50525. */
  50526. private static _noneEmptyLineRegex;
  50527. private _engine;
  50528. /**
  50529. * Instantiates a ColorGradingTexture from the following parameters.
  50530. *
  50531. * @param url The location of the color gradind data (currently only supporting 3dl)
  50532. * @param scene The scene the texture will be used in
  50533. */
  50534. constructor(url: string, scene: Scene);
  50535. /**
  50536. * Returns the texture matrix used in most of the material.
  50537. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50538. */
  50539. getTextureMatrix(): Matrix;
  50540. /**
  50541. * Occurs when the file being loaded is a .3dl LUT file.
  50542. */
  50543. private load3dlTexture;
  50544. /**
  50545. * Starts the loading process of the texture.
  50546. */
  50547. private loadTexture;
  50548. /**
  50549. * Clones the color gradind texture.
  50550. */
  50551. clone(): ColorGradingTexture;
  50552. /**
  50553. * Called during delayed load for textures.
  50554. */
  50555. delayLoad(): void;
  50556. /**
  50557. * Parses a color grading texture serialized by Babylon.
  50558. * @param parsedTexture The texture information being parsedTexture
  50559. * @param scene The scene to load the texture in
  50560. * @param rootUrl The root url of the data assets to load
  50561. * @return A color gradind texture
  50562. */
  50563. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50564. /**
  50565. * Serializes the LUT texture to json format.
  50566. */
  50567. serialize(): any;
  50568. }
  50569. }
  50570. declare module BABYLON {
  50571. /**
  50572. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50573. */
  50574. export class EquiRectangularCubeTexture extends BaseTexture {
  50575. /** The six faces of the cube. */
  50576. private static _FacesMapping;
  50577. private _noMipmap;
  50578. private _onLoad;
  50579. private _onError;
  50580. /** The size of the cubemap. */
  50581. private _size;
  50582. /** The buffer of the image. */
  50583. private _buffer;
  50584. /** The width of the input image. */
  50585. private _width;
  50586. /** The height of the input image. */
  50587. private _height;
  50588. /** The URL to the image. */
  50589. url: string;
  50590. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50591. coordinatesMode: number;
  50592. /**
  50593. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50594. * @param url The location of the image
  50595. * @param scene The scene the texture will be used in
  50596. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50597. * @param noMipmap Forces to not generate the mipmap if true
  50598. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50599. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50600. * @param onLoad — defines a callback called when texture is loaded
  50601. * @param onError — defines a callback called if there is an error
  50602. */
  50603. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50604. /**
  50605. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50606. */
  50607. private loadImage;
  50608. /**
  50609. * Convert the image buffer into a cubemap and create a CubeTexture.
  50610. */
  50611. private loadTexture;
  50612. /**
  50613. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50614. * @param buffer The ArrayBuffer that should be converted.
  50615. * @returns The buffer as Float32Array.
  50616. */
  50617. private getFloat32ArrayFromArrayBuffer;
  50618. /**
  50619. * Get the current class name of the texture useful for serialization or dynamic coding.
  50620. * @returns "EquiRectangularCubeTexture"
  50621. */
  50622. getClassName(): string;
  50623. /**
  50624. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50625. * @returns A clone of the current EquiRectangularCubeTexture.
  50626. */
  50627. clone(): EquiRectangularCubeTexture;
  50628. }
  50629. }
  50630. declare module BABYLON {
  50631. /**
  50632. * Based on jsTGALoader - Javascript loader for TGA file
  50633. * By Vincent Thibault
  50634. * @see http://blog.robrowser.com/javascript-tga-loader.html
  50635. */
  50636. export class TGATools {
  50637. private static _TYPE_INDEXED;
  50638. private static _TYPE_RGB;
  50639. private static _TYPE_GREY;
  50640. private static _TYPE_RLE_INDEXED;
  50641. private static _TYPE_RLE_RGB;
  50642. private static _TYPE_RLE_GREY;
  50643. private static _ORIGIN_MASK;
  50644. private static _ORIGIN_SHIFT;
  50645. private static _ORIGIN_BL;
  50646. private static _ORIGIN_BR;
  50647. private static _ORIGIN_UL;
  50648. private static _ORIGIN_UR;
  50649. /**
  50650. * Gets the header of a TGA file
  50651. * @param data defines the TGA data
  50652. * @returns the header
  50653. */
  50654. static GetTGAHeader(data: Uint8Array): any;
  50655. /**
  50656. * Uploads TGA content to a Babylon Texture
  50657. * @hidden
  50658. */
  50659. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  50660. /** @hidden */
  50661. 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;
  50662. /** @hidden */
  50663. 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;
  50664. /** @hidden */
  50665. 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;
  50666. /** @hidden */
  50667. 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;
  50668. /** @hidden */
  50669. 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;
  50670. /** @hidden */
  50671. 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;
  50672. }
  50673. }
  50674. declare module BABYLON {
  50675. /**
  50676. * Implementation of the TGA Texture Loader.
  50677. * @hidden
  50678. */
  50679. export class _TGATextureLoader implements IInternalTextureLoader {
  50680. /**
  50681. * Defines wether the loader supports cascade loading the different faces.
  50682. */
  50683. readonly supportCascades: boolean;
  50684. /**
  50685. * This returns if the loader support the current file information.
  50686. * @param extension defines the file extension of the file being loaded
  50687. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50688. * @param fallback defines the fallback internal texture if any
  50689. * @param isBase64 defines whether the texture is encoded as a base64
  50690. * @param isBuffer defines whether the texture data are stored as a buffer
  50691. * @returns true if the loader can load the specified file
  50692. */
  50693. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50694. /**
  50695. * Transform the url before loading if required.
  50696. * @param rootUrl the url of the texture
  50697. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50698. * @returns the transformed texture
  50699. */
  50700. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50701. /**
  50702. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50703. * @param rootUrl the url of the texture
  50704. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50705. * @returns the fallback texture
  50706. */
  50707. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50708. /**
  50709. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50710. * @param data contains the texture data
  50711. * @param texture defines the BabylonJS internal texture
  50712. * @param createPolynomials will be true if polynomials have been requested
  50713. * @param onLoad defines the callback to trigger once the texture is ready
  50714. * @param onError defines the callback to trigger in case of error
  50715. */
  50716. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50717. /**
  50718. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50719. * @param data contains the texture data
  50720. * @param texture defines the BabylonJS internal texture
  50721. * @param callback defines the method to call once ready to upload
  50722. */
  50723. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50724. }
  50725. }
  50726. declare module BABYLON {
  50727. /**
  50728. * Info about the .basis files
  50729. */
  50730. class BasisFileInfo {
  50731. /**
  50732. * If the file has alpha
  50733. */
  50734. hasAlpha: boolean;
  50735. /**
  50736. * Info about each image of the basis file
  50737. */
  50738. images: Array<{
  50739. levels: Array<{
  50740. width: number;
  50741. height: number;
  50742. transcodedPixels: ArrayBufferView;
  50743. }>;
  50744. }>;
  50745. }
  50746. /**
  50747. * Result of transcoding a basis file
  50748. */
  50749. class TranscodeResult {
  50750. /**
  50751. * Info about the .basis file
  50752. */
  50753. fileInfo: BasisFileInfo;
  50754. /**
  50755. * Format to use when loading the file
  50756. */
  50757. format: number;
  50758. }
  50759. /**
  50760. * Configuration options for the Basis transcoder
  50761. */
  50762. export class BasisTranscodeConfiguration {
  50763. /**
  50764. * Supported compression formats used to determine the supported output format of the transcoder
  50765. */
  50766. supportedCompressionFormats?: {
  50767. /**
  50768. * etc1 compression format
  50769. */
  50770. etc1?: boolean;
  50771. /**
  50772. * s3tc compression format
  50773. */
  50774. s3tc?: boolean;
  50775. /**
  50776. * pvrtc compression format
  50777. */
  50778. pvrtc?: boolean;
  50779. /**
  50780. * etc2 compression format
  50781. */
  50782. etc2?: boolean;
  50783. };
  50784. /**
  50785. * If mipmap levels should be loaded for transcoded images (Default: true)
  50786. */
  50787. loadMipmapLevels?: boolean;
  50788. /**
  50789. * Index of a single image to load (Default: all images)
  50790. */
  50791. loadSingleImage?: number;
  50792. }
  50793. /**
  50794. * Used to load .Basis files
  50795. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  50796. */
  50797. export class BasisTools {
  50798. private static _IgnoreSupportedFormats;
  50799. /**
  50800. * URL to use when loading the basis transcoder
  50801. */
  50802. static JSModuleURL: string;
  50803. /**
  50804. * URL to use when loading the wasm module for the transcoder
  50805. */
  50806. static WasmModuleURL: string;
  50807. /**
  50808. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  50809. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  50810. * @returns internal format corresponding to the Basis format
  50811. */
  50812. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  50813. private static _WorkerPromise;
  50814. private static _Worker;
  50815. private static _actionId;
  50816. private static _CreateWorkerAsync;
  50817. /**
  50818. * Transcodes a loaded image file to compressed pixel data
  50819. * @param imageData image data to transcode
  50820. * @param config configuration options for the transcoding
  50821. * @returns a promise resulting in the transcoded image
  50822. */
  50823. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  50824. /**
  50825. * Loads a texture from the transcode result
  50826. * @param texture texture load to
  50827. * @param transcodeResult the result of transcoding the basis file to load from
  50828. */
  50829. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  50830. }
  50831. }
  50832. declare module BABYLON {
  50833. /**
  50834. * Loader for .basis file format
  50835. */
  50836. export class _BasisTextureLoader implements IInternalTextureLoader {
  50837. /**
  50838. * Defines whether the loader supports cascade loading the different faces.
  50839. */
  50840. readonly supportCascades: boolean;
  50841. /**
  50842. * This returns if the loader support the current file information.
  50843. * @param extension defines the file extension of the file being loaded
  50844. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50845. * @param fallback defines the fallback internal texture if any
  50846. * @param isBase64 defines whether the texture is encoded as a base64
  50847. * @param isBuffer defines whether the texture data are stored as a buffer
  50848. * @returns true if the loader can load the specified file
  50849. */
  50850. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50851. /**
  50852. * Transform the url before loading if required.
  50853. * @param rootUrl the url of the texture
  50854. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50855. * @returns the transformed texture
  50856. */
  50857. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50858. /**
  50859. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50860. * @param rootUrl the url of the texture
  50861. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50862. * @returns the fallback texture
  50863. */
  50864. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50865. /**
  50866. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  50867. * @param data contains the texture data
  50868. * @param texture defines the BabylonJS internal texture
  50869. * @param createPolynomials will be true if polynomials have been requested
  50870. * @param onLoad defines the callback to trigger once the texture is ready
  50871. * @param onError defines the callback to trigger in case of error
  50872. */
  50873. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50874. /**
  50875. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50876. * @param data contains the texture data
  50877. * @param texture defines the BabylonJS internal texture
  50878. * @param callback defines the method to call once ready to upload
  50879. */
  50880. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50881. }
  50882. }
  50883. declare module BABYLON {
  50884. /**
  50885. * 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.
  50886. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50887. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50888. */
  50889. export class CustomProceduralTexture extends ProceduralTexture {
  50890. private _animate;
  50891. private _time;
  50892. private _config;
  50893. private _texturePath;
  50894. /**
  50895. * Instantiates a new Custom Procedural Texture.
  50896. * 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.
  50897. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50898. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50899. * @param name Define the name of the texture
  50900. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50901. * @param size Define the size of the texture to create
  50902. * @param scene Define the scene the texture belongs to
  50903. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50904. * @param generateMipMaps Define if the texture should creates mip maps or not
  50905. */
  50906. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50907. private _loadJson;
  50908. /**
  50909. * Is the texture ready to be used ? (rendered at least once)
  50910. * @returns true if ready, otherwise, false.
  50911. */
  50912. isReady(): boolean;
  50913. /**
  50914. * Render the texture to its associated render target.
  50915. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50916. */
  50917. render(useCameraPostProcess?: boolean): void;
  50918. /**
  50919. * Update the list of dependant textures samplers in the shader.
  50920. */
  50921. updateTextures(): void;
  50922. /**
  50923. * Update the uniform values of the procedural texture in the shader.
  50924. */
  50925. updateShaderUniforms(): void;
  50926. /**
  50927. * Define if the texture animates or not.
  50928. */
  50929. animate: boolean;
  50930. }
  50931. }
  50932. declare module BABYLON {
  50933. /** @hidden */
  50934. export var noisePixelShader: {
  50935. name: string;
  50936. shader: string;
  50937. };
  50938. }
  50939. declare module BABYLON {
  50940. /**
  50941. * Class used to generate noise procedural textures
  50942. */
  50943. export class NoiseProceduralTexture extends ProceduralTexture {
  50944. private _time;
  50945. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50946. brightness: number;
  50947. /** Defines the number of octaves to process */
  50948. octaves: number;
  50949. /** Defines the level of persistence (0.8 by default) */
  50950. persistence: number;
  50951. /** Gets or sets animation speed factor (default is 1) */
  50952. animationSpeedFactor: number;
  50953. /**
  50954. * Creates a new NoiseProceduralTexture
  50955. * @param name defines the name fo the texture
  50956. * @param size defines the size of the texture (default is 256)
  50957. * @param scene defines the hosting scene
  50958. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50959. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50960. */
  50961. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50962. private _updateShaderUniforms;
  50963. protected _getDefines(): string;
  50964. /** Generate the current state of the procedural texture */
  50965. render(useCameraPostProcess?: boolean): void;
  50966. /**
  50967. * Serializes this noise procedural texture
  50968. * @returns a serialized noise procedural texture object
  50969. */
  50970. serialize(): any;
  50971. /**
  50972. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50973. * @param parsedTexture defines parsed texture data
  50974. * @param scene defines the current scene
  50975. * @param rootUrl defines the root URL containing noise procedural texture information
  50976. * @returns a parsed NoiseProceduralTexture
  50977. */
  50978. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  50979. }
  50980. }
  50981. declare module BABYLON {
  50982. /**
  50983. * Raw cube texture where the raw buffers are passed in
  50984. */
  50985. export class RawCubeTexture extends CubeTexture {
  50986. /**
  50987. * Creates a cube texture where the raw buffers are passed in.
  50988. * @param scene defines the scene the texture is attached to
  50989. * @param data defines the array of data to use to create each face
  50990. * @param size defines the size of the textures
  50991. * @param format defines the format of the data
  50992. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  50993. * @param generateMipMaps defines if the engine should generate the mip levels
  50994. * @param invertY defines if data must be stored with Y axis inverted
  50995. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  50996. * @param compression defines the compression used (null by default)
  50997. */
  50998. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  50999. /**
  51000. * Updates the raw cube texture.
  51001. * @param data defines the data to store
  51002. * @param format defines the data format
  51003. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51004. * @param invertY defines if data must be stored with Y axis inverted
  51005. * @param compression defines the compression used (null by default)
  51006. * @param level defines which level of the texture to update
  51007. */
  51008. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51009. /**
  51010. * Updates a raw cube texture with RGBD encoded data.
  51011. * @param data defines the array of data [mipmap][face] to use to create each face
  51012. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51013. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51014. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51015. * @returns a promsie that resolves when the operation is complete
  51016. */
  51017. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51018. /**
  51019. * Clones the raw cube texture.
  51020. * @return a new cube texture
  51021. */
  51022. clone(): CubeTexture;
  51023. /** @hidden */
  51024. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51025. }
  51026. }
  51027. declare module BABYLON {
  51028. /**
  51029. * Class used to store 3D textures containing user data
  51030. */
  51031. export class RawTexture3D extends Texture {
  51032. /** Gets or sets the texture format to use */
  51033. format: number;
  51034. private _engine;
  51035. /**
  51036. * Create a new RawTexture3D
  51037. * @param data defines the data of the texture
  51038. * @param width defines the width of the texture
  51039. * @param height defines the height of the texture
  51040. * @param depth defines the depth of the texture
  51041. * @param format defines the texture format to use
  51042. * @param scene defines the hosting scene
  51043. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51044. * @param invertY defines if texture must be stored with Y axis inverted
  51045. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51046. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51047. */
  51048. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51049. /** Gets or sets the texture format to use */
  51050. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51051. /**
  51052. * Update the texture with new data
  51053. * @param data defines the data to store in the texture
  51054. */
  51055. update(data: ArrayBufferView): void;
  51056. }
  51057. }
  51058. declare module BABYLON {
  51059. /**
  51060. * Creates a refraction texture used by refraction channel of the standard material.
  51061. * It is like a mirror but to see through a material.
  51062. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51063. */
  51064. export class RefractionTexture extends RenderTargetTexture {
  51065. /**
  51066. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51067. * 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.
  51068. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51069. */
  51070. refractionPlane: Plane;
  51071. /**
  51072. * Define how deep under the surface we should see.
  51073. */
  51074. depth: number;
  51075. /**
  51076. * Creates a refraction texture used by refraction channel of the standard material.
  51077. * It is like a mirror but to see through a material.
  51078. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51079. * @param name Define the texture name
  51080. * @param size Define the size of the underlying texture
  51081. * @param scene Define the scene the refraction belongs to
  51082. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51083. */
  51084. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51085. /**
  51086. * Clone the refraction texture.
  51087. * @returns the cloned texture
  51088. */
  51089. clone(): RefractionTexture;
  51090. /**
  51091. * Serialize the texture to a JSON representation you could use in Parse later on
  51092. * @returns the serialized JSON representation
  51093. */
  51094. serialize(): any;
  51095. }
  51096. }
  51097. declare module BABYLON {
  51098. /**
  51099. * Defines the options related to the creation of an HtmlElementTexture
  51100. */
  51101. export interface IHtmlElementTextureOptions {
  51102. /**
  51103. * Defines wether mip maps should be created or not.
  51104. */
  51105. generateMipMaps?: boolean;
  51106. /**
  51107. * Defines the sampling mode of the texture.
  51108. */
  51109. samplingMode?: number;
  51110. /**
  51111. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51112. */
  51113. engine: Nullable<Engine>;
  51114. /**
  51115. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51116. */
  51117. scene: Nullable<Scene>;
  51118. }
  51119. /**
  51120. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51121. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51122. * is automatically managed.
  51123. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51124. * in your application.
  51125. *
  51126. * As the update is not automatic, you need to call them manually.
  51127. */
  51128. export class HtmlElementTexture extends BaseTexture {
  51129. /**
  51130. * The texture URL.
  51131. */
  51132. element: HTMLVideoElement | HTMLCanvasElement;
  51133. private static readonly DefaultOptions;
  51134. private _textureMatrix;
  51135. private _engine;
  51136. private _isVideo;
  51137. private _generateMipMaps;
  51138. private _samplingMode;
  51139. /**
  51140. * Instantiates a HtmlElementTexture from the following parameters.
  51141. *
  51142. * @param name Defines the name of the texture
  51143. * @param element Defines the video or canvas the texture is filled with
  51144. * @param options Defines the other none mandatory texture creation options
  51145. */
  51146. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51147. private _createInternalTexture;
  51148. /**
  51149. * Returns the texture matrix used in most of the material.
  51150. */
  51151. getTextureMatrix(): Matrix;
  51152. /**
  51153. * Updates the content of the texture.
  51154. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51155. */
  51156. update(invertY?: Nullable<boolean>): void;
  51157. }
  51158. }
  51159. declare module BABYLON {
  51160. /**
  51161. * Enum used to define the target of a block
  51162. */
  51163. export enum NodeMaterialBlockTargets {
  51164. /** Vertex shader */
  51165. Vertex = 1,
  51166. /** Fragment shader */
  51167. Fragment = 2,
  51168. /** Neutral */
  51169. Neutral = 4,
  51170. /** Vertex and Fragment */
  51171. VertexAndFragment = 3
  51172. }
  51173. }
  51174. declare module BABYLON {
  51175. /**
  51176. * Defines the kind of connection point for node based material
  51177. */
  51178. export enum NodeMaterialBlockConnectionPointTypes {
  51179. /** Float */
  51180. Float = 1,
  51181. /** Int */
  51182. Int = 2,
  51183. /** Vector2 */
  51184. Vector2 = 4,
  51185. /** Vector3 */
  51186. Vector3 = 8,
  51187. /** Vector4 */
  51188. Vector4 = 16,
  51189. /** Color3 */
  51190. Color3 = 32,
  51191. /** Color4 */
  51192. Color4 = 64,
  51193. /** Matrix */
  51194. Matrix = 128,
  51195. /** Vector3 or Color3 */
  51196. Vector3OrColor3 = 40,
  51197. /** Vector3 or Vector4 */
  51198. Vector3OrVector4 = 24,
  51199. /** Vector4 or Color4 */
  51200. Vector4OrColor4 = 80,
  51201. /** Color3 or Color4 */
  51202. Color3OrColor4 = 96,
  51203. /** Vector2 or Color3 or Color4 */
  51204. Vector2OrColor3OrColor4 = 100,
  51205. /** Vector3 or Color3 or Color4 or Vector4 */
  51206. Vector3OrColor3OrVector4OrColor4 = 120,
  51207. /** Vector2 or Vector3 or Color3 or Color4 or Vector4 */
  51208. Vector2OrVector3OrColor3OrVector4OrColor4 = 124,
  51209. /** Detect type based on connection */
  51210. AutoDetect = 1024,
  51211. /** Output type that will be defined by input type */
  51212. BasedOnInput = 2048
  51213. }
  51214. }
  51215. declare module BABYLON {
  51216. /**
  51217. * Root class for all node material optimizers
  51218. */
  51219. export class NodeMaterialOptimizer {
  51220. /**
  51221. * Function used to optimize a NodeMaterial graph
  51222. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  51223. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  51224. */
  51225. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  51226. }
  51227. }
  51228. declare module BABYLON {
  51229. /**
  51230. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  51231. */
  51232. export class TransformBlock extends NodeMaterialBlock {
  51233. /**
  51234. * Defines the value to use to complement W value to transform it to a Vector4
  51235. */
  51236. complementW: number;
  51237. /**
  51238. * Defines the value to use to complement z value to transform it to a Vector4
  51239. */
  51240. complementZ: number;
  51241. /**
  51242. * Creates a new TransformBlock
  51243. * @param name defines the block name
  51244. */
  51245. constructor(name: string);
  51246. /**
  51247. * Gets the current class name
  51248. * @returns the class name
  51249. */
  51250. getClassName(): string;
  51251. /**
  51252. * Gets the vector input
  51253. */
  51254. readonly vector: NodeMaterialConnectionPoint;
  51255. /**
  51256. * Gets the output component
  51257. */
  51258. readonly output: NodeMaterialConnectionPoint;
  51259. /**
  51260. * Gets the matrix transform input
  51261. */
  51262. readonly transform: NodeMaterialConnectionPoint;
  51263. protected _buildBlock(state: NodeMaterialBuildState): this;
  51264. }
  51265. }
  51266. declare module BABYLON {
  51267. /**
  51268. * Block used to output the vertex position
  51269. */
  51270. export class VertexOutputBlock extends NodeMaterialBlock {
  51271. /**
  51272. * Creates a new VertexOutputBlock
  51273. * @param name defines the block name
  51274. */
  51275. constructor(name: string);
  51276. /**
  51277. * Gets the current class name
  51278. * @returns the class name
  51279. */
  51280. getClassName(): string;
  51281. /**
  51282. * Gets the vector input component
  51283. */
  51284. readonly vector: NodeMaterialConnectionPoint;
  51285. protected _buildBlock(state: NodeMaterialBuildState): this;
  51286. }
  51287. }
  51288. declare module BABYLON {
  51289. /**
  51290. * Block used to output the final color
  51291. */
  51292. export class FragmentOutputBlock extends NodeMaterialBlock {
  51293. /**
  51294. * Create a new FragmentOutputBlock
  51295. * @param name defines the block name
  51296. */
  51297. constructor(name: string);
  51298. /**
  51299. * Gets the current class name
  51300. * @returns the class name
  51301. */
  51302. getClassName(): string;
  51303. /**
  51304. * Gets the rgba input component
  51305. */
  51306. readonly rgba: NodeMaterialConnectionPoint;
  51307. /**
  51308. * Gets the rgb input component
  51309. */
  51310. readonly rgb: NodeMaterialConnectionPoint;
  51311. /**
  51312. * Gets the a input component
  51313. */
  51314. readonly a: NodeMaterialConnectionPoint;
  51315. protected _buildBlock(state: NodeMaterialBuildState): this;
  51316. }
  51317. }
  51318. declare module BABYLON {
  51319. /**
  51320. * Interface used to configure the node material editor
  51321. */
  51322. export interface INodeMaterialEditorOptions {
  51323. /** Define the URl to load node editor script */
  51324. editorURL?: string;
  51325. }
  51326. /** @hidden */
  51327. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  51328. /** BONES */
  51329. NUM_BONE_INFLUENCERS: number;
  51330. BonesPerMesh: number;
  51331. BONETEXTURE: boolean;
  51332. /** MORPH TARGETS */
  51333. MORPHTARGETS: boolean;
  51334. MORPHTARGETS_NORMAL: boolean;
  51335. MORPHTARGETS_TANGENT: boolean;
  51336. MORPHTARGETS_UV: boolean;
  51337. NUM_MORPH_INFLUENCERS: number;
  51338. /** IMAGE PROCESSING */
  51339. IMAGEPROCESSING: boolean;
  51340. VIGNETTE: boolean;
  51341. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51342. VIGNETTEBLENDMODEOPAQUE: boolean;
  51343. TONEMAPPING: boolean;
  51344. TONEMAPPING_ACES: boolean;
  51345. CONTRAST: boolean;
  51346. EXPOSURE: boolean;
  51347. COLORCURVES: boolean;
  51348. COLORGRADING: boolean;
  51349. COLORGRADING3D: boolean;
  51350. SAMPLER3DGREENDEPTH: boolean;
  51351. SAMPLER3DBGRMAP: boolean;
  51352. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51353. constructor();
  51354. setValue(name: string, value: boolean): void;
  51355. }
  51356. /**
  51357. * Class used to configure NodeMaterial
  51358. */
  51359. export interface INodeMaterialOptions {
  51360. /**
  51361. * Defines if blocks should emit comments
  51362. */
  51363. emitComments: boolean;
  51364. }
  51365. /**
  51366. * Class used to create a node based material built by assembling shader blocks
  51367. */
  51368. export class NodeMaterial extends PushMaterial {
  51369. private _options;
  51370. private _vertexCompilationState;
  51371. private _fragmentCompilationState;
  51372. private _sharedData;
  51373. private _buildId;
  51374. private _buildWasSuccessful;
  51375. private _cachedWorldViewMatrix;
  51376. private _cachedWorldViewProjectionMatrix;
  51377. private _optimizers;
  51378. /** Define the URl to load node editor script */
  51379. static EditorURL: string;
  51380. private BJSNODEMATERIALEDITOR;
  51381. /** Get the inspector from bundle or global */
  51382. private _getGlobalNodeMaterialEditor;
  51383. /**
  51384. * 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)
  51385. */
  51386. ignoreAlpha: boolean;
  51387. /**
  51388. * Defines the maximum number of lights that can be used in the material
  51389. */
  51390. maxSimultaneousLights: number;
  51391. /**
  51392. * Observable raised when the material is built
  51393. */
  51394. onBuildObservable: Observable<NodeMaterial>;
  51395. /**
  51396. * Gets or sets the root nodes of the material vertex shader
  51397. */
  51398. _vertexOutputNodes: NodeMaterialBlock[];
  51399. /**
  51400. * Gets or sets the root nodes of the material fragment (pixel) shader
  51401. */
  51402. _fragmentOutputNodes: NodeMaterialBlock[];
  51403. /** Gets or sets options to control the node material overall behavior */
  51404. options: INodeMaterialOptions;
  51405. /**
  51406. * Default configuration related to image processing available in the standard Material.
  51407. */
  51408. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51409. /**
  51410. * Gets the image processing configuration used either in this material.
  51411. */
  51412. /**
  51413. * Sets the Default image processing configuration used either in the this material.
  51414. *
  51415. * If sets to null, the scene one is in use.
  51416. */
  51417. imageProcessingConfiguration: ImageProcessingConfiguration;
  51418. /**
  51419. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  51420. */
  51421. attachedBlocks: NodeMaterialBlock[];
  51422. /**
  51423. * Create a new node based material
  51424. * @param name defines the material name
  51425. * @param scene defines the hosting scene
  51426. * @param options defines creation option
  51427. */
  51428. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  51429. /**
  51430. * Gets the current class name of the material e.g. "NodeMaterial"
  51431. * @returns the class name
  51432. */
  51433. getClassName(): string;
  51434. /**
  51435. * Keep track of the image processing observer to allow dispose and replace.
  51436. */
  51437. private _imageProcessingObserver;
  51438. /**
  51439. * Attaches a new image processing configuration to the Standard Material.
  51440. * @param configuration
  51441. */
  51442. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51443. /**
  51444. * Adds a new optimizer to the list of optimizers
  51445. * @param optimizer defines the optimizers to add
  51446. * @returns the current material
  51447. */
  51448. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51449. /**
  51450. * Remove an optimizer from the list of optimizers
  51451. * @param optimizer defines the optimizers to remove
  51452. * @returns the current material
  51453. */
  51454. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51455. /**
  51456. * Add a new block to the list of output nodes
  51457. * @param node defines the node to add
  51458. * @returns the current material
  51459. */
  51460. addOutputNode(node: NodeMaterialBlock): this;
  51461. /**
  51462. * Remove a block from the list of root nodes
  51463. * @param node defines the node to remove
  51464. * @returns the current material
  51465. */
  51466. removeOutputNode(node: NodeMaterialBlock): this;
  51467. private _addVertexOutputNode;
  51468. private _removeVertexOutputNode;
  51469. private _addFragmentOutputNode;
  51470. private _removeFragmentOutputNode;
  51471. /**
  51472. * Specifies if the material will require alpha blending
  51473. * @returns a boolean specifying if alpha blending is needed
  51474. */
  51475. needAlphaBlending(): boolean;
  51476. /**
  51477. * Specifies if this material should be rendered in alpha test mode
  51478. * @returns a boolean specifying if an alpha test is needed.
  51479. */
  51480. needAlphaTesting(): boolean;
  51481. private _initializeBlock;
  51482. private _resetDualBlocks;
  51483. /**
  51484. * Build the material and generates the inner effect
  51485. * @param verbose defines if the build should log activity
  51486. */
  51487. build(verbose?: boolean): void;
  51488. /**
  51489. * Runs an otpimization phase to try to improve the shader code
  51490. */
  51491. optimize(): void;
  51492. private _prepareDefinesForAttributes;
  51493. /**
  51494. * Get if the submesh is ready to be used and all its information available.
  51495. * Child classes can use it to update shaders
  51496. * @param mesh defines the mesh to check
  51497. * @param subMesh defines which submesh to check
  51498. * @param useInstances specifies that instances should be used
  51499. * @returns a boolean indicating that the submesh is ready or not
  51500. */
  51501. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51502. /**
  51503. * Get a string representing the shaders built by the current node graph
  51504. */
  51505. readonly compiledShaders: string;
  51506. /**
  51507. * Binds the world matrix to the material
  51508. * @param world defines the world transformation matrix
  51509. */
  51510. bindOnlyWorldMatrix(world: Matrix): void;
  51511. /**
  51512. * Binds the submesh to this material by preparing the effect and shader to draw
  51513. * @param world defines the world transformation matrix
  51514. * @param mesh defines the mesh containing the submesh
  51515. * @param subMesh defines the submesh to bind the material to
  51516. */
  51517. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51518. /**
  51519. * Gets the active textures from the material
  51520. * @returns an array of textures
  51521. */
  51522. getActiveTextures(): BaseTexture[];
  51523. /**
  51524. * Specifies if the material uses a texture
  51525. * @param texture defines the texture to check against the material
  51526. * @returns a boolean specifying if the material uses the texture
  51527. */
  51528. hasTexture(texture: BaseTexture): boolean;
  51529. /**
  51530. * Disposes the material
  51531. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  51532. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  51533. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  51534. */
  51535. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  51536. /** Creates the node editor window. */
  51537. private _createNodeEditor;
  51538. /**
  51539. * Launch the node material editor
  51540. * @param config Define the configuration of the editor
  51541. * @return a promise fulfilled when the node editor is visible
  51542. */
  51543. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  51544. /**
  51545. * Clear the current material
  51546. */
  51547. clear(): void;
  51548. /**
  51549. * Clear the current material and set it to a default state
  51550. */
  51551. setToDefault(): void;
  51552. private _gatherBlocks;
  51553. /**
  51554. * Serializes this material in a JSON representation
  51555. * @returns the serialized material object
  51556. */
  51557. serialize(): any;
  51558. /**
  51559. * Clear the current graph and load a new one from a serialization object
  51560. * @param source defines the JSON representation of the material
  51561. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51562. */
  51563. loadFromSerialization(source: any, rootUrl?: string): void;
  51564. /**
  51565. * Creates a node material from parsed material data
  51566. * @param source defines the JSON representation of the material
  51567. * @param scene defines the hosting scene
  51568. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51569. * @returns a new node material
  51570. */
  51571. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  51572. }
  51573. }
  51574. declare module BABYLON {
  51575. /**
  51576. * Block used to read a texture from a sampler
  51577. */
  51578. export class TextureBlock extends NodeMaterialBlock {
  51579. private _defineName;
  51580. private _samplerName;
  51581. private _transformedUVName;
  51582. private _textureTransformName;
  51583. private _textureInfoName;
  51584. private _mainUVName;
  51585. private _mainUVDefineName;
  51586. /**
  51587. * Gets or sets the texture associated with the node
  51588. */
  51589. texture: Nullable<BaseTexture>;
  51590. /**
  51591. * Create a new TextureBlock
  51592. * @param name defines the block name
  51593. */
  51594. constructor(name: string);
  51595. /**
  51596. * Gets the current class name
  51597. * @returns the class name
  51598. */
  51599. getClassName(): string;
  51600. /**
  51601. * Gets the uv input component
  51602. */
  51603. readonly uv: NodeMaterialConnectionPoint;
  51604. /**
  51605. * Gets the output component
  51606. */
  51607. readonly output: NodeMaterialConnectionPoint;
  51608. autoConfigure(): void;
  51609. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51610. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51611. isReady(): boolean;
  51612. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51613. private _injectVertexCode;
  51614. private _writeOutput;
  51615. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51616. serialize(): any;
  51617. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51618. }
  51619. }
  51620. declare module BABYLON {
  51621. /**
  51622. * Class used to store shared data between 2 NodeMaterialBuildState
  51623. */
  51624. export class NodeMaterialBuildStateSharedData {
  51625. /**
  51626. * Gets the list of emitted varyings
  51627. */
  51628. varyings: string[];
  51629. /**
  51630. * Gets the varying declaration string
  51631. */
  51632. varyingDeclaration: string;
  51633. /**
  51634. * Input blocks
  51635. */
  51636. inputBlocks: InputBlock[];
  51637. /**
  51638. * Input blocks
  51639. */
  51640. textureBlocks: TextureBlock[];
  51641. /**
  51642. * Bindable blocks (Blocks that need to set data to the effect)
  51643. */
  51644. bindableBlocks: NodeMaterialBlock[];
  51645. /**
  51646. * List of blocks that can provide a compilation fallback
  51647. */
  51648. blocksWithFallbacks: NodeMaterialBlock[];
  51649. /**
  51650. * List of blocks that can provide a define update
  51651. */
  51652. blocksWithDefines: NodeMaterialBlock[];
  51653. /**
  51654. * List of blocks that can provide a repeatable content
  51655. */
  51656. repeatableContentBlocks: NodeMaterialBlock[];
  51657. /**
  51658. * List of blocks that can provide a dynamic list of uniforms
  51659. */
  51660. dynamicUniformBlocks: NodeMaterialBlock[];
  51661. /**
  51662. * List of blocks that can block the isReady function for the material
  51663. */
  51664. blockingBlocks: NodeMaterialBlock[];
  51665. /**
  51666. * Build Id used to avoid multiple recompilations
  51667. */
  51668. buildId: number;
  51669. /** List of emitted variables */
  51670. variableNames: {
  51671. [key: string]: number;
  51672. };
  51673. /** List of emitted defines */
  51674. defineNames: {
  51675. [key: string]: number;
  51676. };
  51677. /** Should emit comments? */
  51678. emitComments: boolean;
  51679. /** Emit build activity */
  51680. verbose: boolean;
  51681. /**
  51682. * Gets the compilation hints emitted at compilation time
  51683. */
  51684. hints: {
  51685. needWorldViewMatrix: boolean;
  51686. needWorldViewProjectionMatrix: boolean;
  51687. needAlphaBlending: boolean;
  51688. needAlphaTesting: boolean;
  51689. };
  51690. /**
  51691. * List of compilation checks
  51692. */
  51693. checks: {
  51694. emitVertex: boolean;
  51695. emitFragment: boolean;
  51696. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  51697. };
  51698. /** Creates a new shared data */
  51699. constructor();
  51700. /**
  51701. * Emits console errors and exceptions if there is a failing check
  51702. */
  51703. emitErrors(): void;
  51704. }
  51705. }
  51706. declare module BABYLON {
  51707. /**
  51708. * Class used to store node based material build state
  51709. */
  51710. export class NodeMaterialBuildState {
  51711. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  51712. supportUniformBuffers: boolean;
  51713. /**
  51714. * Gets the list of emitted attributes
  51715. */
  51716. attributes: string[];
  51717. /**
  51718. * Gets the list of emitted uniforms
  51719. */
  51720. uniforms: string[];
  51721. /**
  51722. * Gets the list of emitted uniform buffers
  51723. */
  51724. uniformBuffers: string[];
  51725. /**
  51726. * Gets the list of emitted samplers
  51727. */
  51728. samplers: string[];
  51729. /**
  51730. * Gets the list of emitted functions
  51731. */
  51732. functions: {
  51733. [key: string]: string;
  51734. };
  51735. /**
  51736. * Gets the target of the compilation state
  51737. */
  51738. target: NodeMaterialBlockTargets;
  51739. /**
  51740. * Gets the list of emitted counters
  51741. */
  51742. counters: {
  51743. [key: string]: number;
  51744. };
  51745. /**
  51746. * Shared data between multiple NodeMaterialBuildState instances
  51747. */
  51748. sharedData: NodeMaterialBuildStateSharedData;
  51749. /** @hidden */
  51750. _vertexState: NodeMaterialBuildState;
  51751. /** @hidden */
  51752. _attributeDeclaration: string;
  51753. /** @hidden */
  51754. _uniformDeclaration: string;
  51755. /** @hidden */
  51756. _samplerDeclaration: string;
  51757. /** @hidden */
  51758. _varyingTransfer: string;
  51759. private _repeatableContentAnchorIndex;
  51760. /** @hidden */
  51761. _builtCompilationString: string;
  51762. /**
  51763. * Gets the emitted compilation strings
  51764. */
  51765. compilationString: string;
  51766. /**
  51767. * Finalize the compilation strings
  51768. * @param state defines the current compilation state
  51769. */
  51770. finalize(state: NodeMaterialBuildState): void;
  51771. /** @hidden */
  51772. readonly _repeatableContentAnchor: string;
  51773. /** @hidden */
  51774. _getFreeVariableName(prefix: string): string;
  51775. /** @hidden */
  51776. _getFreeDefineName(prefix: string): string;
  51777. /** @hidden */
  51778. _excludeVariableName(name: string): void;
  51779. /** @hidden */
  51780. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  51781. /** @hidden */
  51782. _emitFunction(name: string, code: string, comments: string): void;
  51783. /** @hidden */
  51784. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  51785. replaceStrings?: {
  51786. search: RegExp;
  51787. replace: string;
  51788. }[];
  51789. repeatKey?: string;
  51790. }): string;
  51791. /** @hidden */
  51792. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  51793. repeatKey?: string;
  51794. removeAttributes?: boolean;
  51795. removeUniforms?: boolean;
  51796. removeVaryings?: boolean;
  51797. removeIfDef?: boolean;
  51798. replaceStrings?: {
  51799. search: RegExp;
  51800. replace: string;
  51801. }[];
  51802. }, storeKey?: string): void;
  51803. /** @hidden */
  51804. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  51805. /** @hidden */
  51806. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  51807. }
  51808. }
  51809. declare module BABYLON {
  51810. /**
  51811. * Defines a block that can be used inside a node based material
  51812. */
  51813. export class NodeMaterialBlock {
  51814. private _buildId;
  51815. private _buildTarget;
  51816. private _target;
  51817. private _isFinalMerger;
  51818. private _isInput;
  51819. /** @hidden */
  51820. _inputs: NodeMaterialConnectionPoint[];
  51821. /** @hidden */
  51822. _outputs: NodeMaterialConnectionPoint[];
  51823. /**
  51824. * Gets or sets the name of the block
  51825. */
  51826. name: string;
  51827. /**
  51828. * Gets or sets the unique id of the node
  51829. */
  51830. uniqueId: number;
  51831. /**
  51832. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  51833. */
  51834. readonly isFinalMerger: boolean;
  51835. /**
  51836. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  51837. */
  51838. readonly isInput: boolean;
  51839. /**
  51840. * Gets or sets the build Id
  51841. */
  51842. buildId: number;
  51843. /**
  51844. * Gets or sets the target of the block
  51845. */
  51846. target: NodeMaterialBlockTargets;
  51847. /**
  51848. * Gets the list of input points
  51849. */
  51850. readonly inputs: NodeMaterialConnectionPoint[];
  51851. /** Gets the list of output points */
  51852. readonly outputs: NodeMaterialConnectionPoint[];
  51853. /**
  51854. * Find an input by its name
  51855. * @param name defines the name of the input to look for
  51856. * @returns the input or null if not found
  51857. */
  51858. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51859. /**
  51860. * Find an output by its name
  51861. * @param name defines the name of the outputto look for
  51862. * @returns the output or null if not found
  51863. */
  51864. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51865. /**
  51866. * Creates a new NodeMaterialBlock
  51867. * @param name defines the block name
  51868. * @param target defines the target of that block (Vertex by default)
  51869. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  51870. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  51871. */
  51872. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  51873. /**
  51874. * Initialize the block and prepare the context for build
  51875. * @param state defines the state that will be used for the build
  51876. */
  51877. initialize(state: NodeMaterialBuildState): void;
  51878. /**
  51879. * Bind data to effect. Will only be called for blocks with isBindable === true
  51880. * @param effect defines the effect to bind data to
  51881. * @param nodeMaterial defines the hosting NodeMaterial
  51882. * @param mesh defines the mesh that will be rendered
  51883. */
  51884. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51885. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  51886. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  51887. protected _writeFloat(value: number): string;
  51888. /**
  51889. * Gets the current class name e.g. "NodeMaterialBlock"
  51890. * @returns the class name
  51891. */
  51892. getClassName(): string;
  51893. /**
  51894. * Register a new input. Must be called inside a block constructor
  51895. * @param name defines the connection point name
  51896. * @param type defines the connection point type
  51897. * @param isOptional defines a boolean indicating that this input can be omitted
  51898. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51899. * @returns the current block
  51900. */
  51901. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  51902. /**
  51903. * Register a new output. Must be called inside a block constructor
  51904. * @param name defines the connection point name
  51905. * @param type defines the connection point type
  51906. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51907. * @returns the current block
  51908. */
  51909. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  51910. /**
  51911. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  51912. * @param forOutput defines an optional connection point to check compatibility with
  51913. * @returns the first available input or null
  51914. */
  51915. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  51916. /**
  51917. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  51918. * @param forBlock defines an optional block to check compatibility with
  51919. * @returns the first available input or null
  51920. */
  51921. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  51922. /**
  51923. * Connect current block with another block
  51924. * @param other defines the block to connect with
  51925. * @param options define the various options to help pick the right connections
  51926. * @returns the current block
  51927. */
  51928. connectTo(other: NodeMaterialBlock, options?: {
  51929. input?: string;
  51930. output?: string;
  51931. outputSwizzle?: string;
  51932. }): this | undefined;
  51933. protected _buildBlock(state: NodeMaterialBuildState): void;
  51934. /**
  51935. * Add uniforms, samplers and uniform buffers at compilation time
  51936. * @param state defines the state to update
  51937. * @param nodeMaterial defines the node material requesting the update
  51938. * @param defines defines the material defines to update
  51939. */
  51940. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51941. /**
  51942. * Add potential fallbacks if shader compilation fails
  51943. * @param mesh defines the mesh to be rendered
  51944. * @param fallbacks defines the current prioritized list of fallbacks
  51945. */
  51946. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51947. /**
  51948. * Update defines for shader compilation
  51949. * @param mesh defines the mesh to be rendered
  51950. * @param nodeMaterial defines the node material requesting the update
  51951. * @param defines defines the material defines to update
  51952. * @param useInstances specifies that instances should be used
  51953. */
  51954. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51955. /**
  51956. * Initialize defines for shader compilation
  51957. * @param mesh defines the mesh to be rendered
  51958. * @param nodeMaterial defines the node material requesting the update
  51959. * @param defines defines the material defines to be prepared
  51960. * @param useInstances specifies that instances should be used
  51961. */
  51962. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51963. /**
  51964. * Lets the block try to connect some inputs automatically
  51965. */
  51966. autoConfigure(): void;
  51967. /**
  51968. * Function called when a block is declared as repeatable content generator
  51969. * @param vertexShaderState defines the current compilation state for the vertex shader
  51970. * @param fragmentShaderState defines the current compilation state for the fragment shader
  51971. * @param mesh defines the mesh to be rendered
  51972. * @param defines defines the material defines to update
  51973. */
  51974. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51975. /**
  51976. * Checks if the block is ready
  51977. * @param mesh defines the mesh to be rendered
  51978. * @param nodeMaterial defines the node material requesting the update
  51979. * @param defines defines the material defines to update
  51980. * @param useInstances specifies that instances should be used
  51981. * @returns true if the block is ready
  51982. */
  51983. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  51984. private _processBuild;
  51985. /**
  51986. * Compile the current node and generate the shader code
  51987. * @param state defines the current compilation state (uniforms, samplers, current string)
  51988. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  51989. * @returns true if already built
  51990. */
  51991. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  51992. /**
  51993. * Serializes this block in a JSON representation
  51994. * @returns the serialized block object
  51995. */
  51996. serialize(): any;
  51997. /** @hidden */
  51998. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51999. }
  52000. }
  52001. declare module BABYLON {
  52002. /**
  52003. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52004. */
  52005. export enum NodeMaterialBlockConnectionPointMode {
  52006. /** Value is an uniform */
  52007. Uniform = 0,
  52008. /** Value is a mesh attribute */
  52009. Attribute = 1,
  52010. /** Value is a varying between vertex and fragment shaders */
  52011. Varying = 2,
  52012. /** Mode is undefined */
  52013. Undefined = 3
  52014. }
  52015. }
  52016. declare module BABYLON {
  52017. /**
  52018. * Enum used to define well known values e.g. values automatically provided by the system
  52019. */
  52020. export enum NodeMaterialWellKnownValues {
  52021. /** World */
  52022. World = 1,
  52023. /** View */
  52024. View = 2,
  52025. /** Projection */
  52026. Projection = 3,
  52027. /** ViewProjection */
  52028. ViewProjection = 4,
  52029. /** WorldView */
  52030. WorldView = 5,
  52031. /** WorldViewProjection */
  52032. WorldViewProjection = 6,
  52033. /** CameraPosition */
  52034. CameraPosition = 7,
  52035. /** Fog Color */
  52036. FogColor = 8
  52037. }
  52038. }
  52039. declare module BABYLON {
  52040. /**
  52041. * Contains position and normal vectors for a vertex
  52042. */
  52043. export class PositionNormalVertex {
  52044. /** the position of the vertex (defaut: 0,0,0) */
  52045. position: Vector3;
  52046. /** the normal of the vertex (defaut: 0,1,0) */
  52047. normal: Vector3;
  52048. /**
  52049. * Creates a PositionNormalVertex
  52050. * @param position the position of the vertex (defaut: 0,0,0)
  52051. * @param normal the normal of the vertex (defaut: 0,1,0)
  52052. */
  52053. constructor(
  52054. /** the position of the vertex (defaut: 0,0,0) */
  52055. position?: Vector3,
  52056. /** the normal of the vertex (defaut: 0,1,0) */
  52057. normal?: Vector3);
  52058. /**
  52059. * Clones the PositionNormalVertex
  52060. * @returns the cloned PositionNormalVertex
  52061. */
  52062. clone(): PositionNormalVertex;
  52063. }
  52064. /**
  52065. * Contains position, normal and uv vectors for a vertex
  52066. */
  52067. export class PositionNormalTextureVertex {
  52068. /** the position of the vertex (defaut: 0,0,0) */
  52069. position: Vector3;
  52070. /** the normal of the vertex (defaut: 0,1,0) */
  52071. normal: Vector3;
  52072. /** the uv of the vertex (default: 0,0) */
  52073. uv: Vector2;
  52074. /**
  52075. * Creates a PositionNormalTextureVertex
  52076. * @param position the position of the vertex (defaut: 0,0,0)
  52077. * @param normal the normal of the vertex (defaut: 0,1,0)
  52078. * @param uv the uv of the vertex (default: 0,0)
  52079. */
  52080. constructor(
  52081. /** the position of the vertex (defaut: 0,0,0) */
  52082. position?: Vector3,
  52083. /** the normal of the vertex (defaut: 0,1,0) */
  52084. normal?: Vector3,
  52085. /** the uv of the vertex (default: 0,0) */
  52086. uv?: Vector2);
  52087. /**
  52088. * Clones the PositionNormalTextureVertex
  52089. * @returns the cloned PositionNormalTextureVertex
  52090. */
  52091. clone(): PositionNormalTextureVertex;
  52092. }
  52093. }
  52094. declare module BABYLON {
  52095. /**
  52096. * Block used to expose an input value
  52097. */
  52098. export class InputBlock extends NodeMaterialBlock {
  52099. private _mode;
  52100. private _associatedVariableName;
  52101. private _storedValue;
  52102. private _valueCallback;
  52103. private _type;
  52104. /** @hidden */
  52105. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  52106. /**
  52107. * Gets or sets the connection point type (default is float)
  52108. */
  52109. readonly type: NodeMaterialBlockConnectionPointTypes;
  52110. /**
  52111. * Creates a new InputBlock
  52112. * @param name defines the block name
  52113. * @param target defines the target of that block (Vertex by default)
  52114. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  52115. */
  52116. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  52117. /**
  52118. * Gets the output component
  52119. */
  52120. readonly output: NodeMaterialConnectionPoint;
  52121. /**
  52122. * Set the source of this connection point to a vertex attribute
  52123. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  52124. * @returns the current connection point
  52125. */
  52126. setAsAttribute(attributeName?: string): InputBlock;
  52127. /**
  52128. * Set the source of this connection point to a well known value
  52129. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  52130. * @returns the current connection point
  52131. */
  52132. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  52133. /**
  52134. * Gets or sets the value of that point.
  52135. * Please note that this value will be ignored if valueCallback is defined
  52136. */
  52137. value: any;
  52138. /**
  52139. * Gets or sets a callback used to get the value of that point.
  52140. * Please note that setting this value will force the connection point to ignore the value property
  52141. */
  52142. valueCallback: () => any;
  52143. /**
  52144. * Gets or sets the associated variable name in the shader
  52145. */
  52146. associatedVariableName: string;
  52147. /**
  52148. * Gets a boolean indicating that this connection point not defined yet
  52149. */
  52150. readonly isUndefined: boolean;
  52151. /**
  52152. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  52153. * In this case the connection point name must be the name of the uniform to use.
  52154. * Can only be set on inputs
  52155. */
  52156. isUniform: boolean;
  52157. /**
  52158. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  52159. * In this case the connection point name must be the name of the attribute to use
  52160. * Can only be set on inputs
  52161. */
  52162. isAttribute: boolean;
  52163. /**
  52164. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  52165. * Can only be set on exit points
  52166. */
  52167. isVarying: boolean;
  52168. /**
  52169. * Gets a boolean indicating that the current connection point is a well known value
  52170. */
  52171. readonly isWellKnownValue: boolean;
  52172. /**
  52173. * Gets or sets the current well known value or null if not defined as well know value
  52174. */
  52175. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  52176. /**
  52177. * Gets the current class name
  52178. * @returns the class name
  52179. */
  52180. getClassName(): string;
  52181. private _emitDefine;
  52182. /**
  52183. * Set the input block to its default value (based on its type)
  52184. */
  52185. setDefaultValue(): void;
  52186. private _emit;
  52187. /** @hidden */
  52188. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  52189. /** @hidden */
  52190. _transmit(effect: Effect, scene: Scene): void;
  52191. protected _buildBlock(state: NodeMaterialBuildState): void;
  52192. serialize(): any;
  52193. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52194. }
  52195. }
  52196. declare module BABYLON {
  52197. /**
  52198. * Defines a connection point for a block
  52199. */
  52200. export class NodeMaterialConnectionPoint {
  52201. /** @hidden */
  52202. _ownerBlock: NodeMaterialBlock;
  52203. /** @hidden */
  52204. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52205. private _endpoints;
  52206. private _associatedVariableName;
  52207. /** @hidden */
  52208. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52209. private _type;
  52210. /** @hidden */
  52211. _enforceAssociatedVariableName: boolean;
  52212. /**
  52213. * Gets or sets the associated variable name in the shader
  52214. */
  52215. associatedVariableName: string;
  52216. /**
  52217. * Gets or sets the connection point type (default is float)
  52218. */
  52219. type: NodeMaterialBlockConnectionPointTypes;
  52220. /**
  52221. * Gets or sets the connection point name
  52222. */
  52223. name: string;
  52224. /**
  52225. * Gets or sets the swizzle to apply to this connection point when reading or writing
  52226. */
  52227. swizzle: string;
  52228. /**
  52229. * Gets or sets a boolean indicating that this connection point can be omitted
  52230. */
  52231. isOptional: boolean;
  52232. /**
  52233. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  52234. */
  52235. define: string;
  52236. /** Gets or sets the target of that connection point */
  52237. target: NodeMaterialBlockTargets;
  52238. /**
  52239. * Gets a boolean indicating that the current point is connected
  52240. */
  52241. readonly isConnected: boolean;
  52242. /**
  52243. * Gets a boolean indicating that the current point is connected to an input block
  52244. */
  52245. readonly isConnectedToInput: boolean;
  52246. /**
  52247. * Gets a the connected input block (if any)
  52248. */
  52249. readonly connectInputBlock: Nullable<InputBlock>;
  52250. /** Get the other side of the connection (if any) */
  52251. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52252. /** Get the block that owns this connection point */
  52253. readonly ownerBlock: NodeMaterialBlock;
  52254. /** Get the block connected on the other side of this connection (if any) */
  52255. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  52256. /** Get the block connected on the endpoints of this connection (if any) */
  52257. readonly connectedBlocks: Array<NodeMaterialBlock>;
  52258. /** Gets the list of connected endpoints */
  52259. readonly endpoints: NodeMaterialConnectionPoint[];
  52260. /**
  52261. * Creates a new connection point
  52262. * @param name defines the connection point name
  52263. * @param ownerBlock defines the block hosting this connection point
  52264. */
  52265. constructor(name: string, ownerBlock: NodeMaterialBlock);
  52266. /**
  52267. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  52268. * @returns the class name
  52269. */
  52270. getClassName(): string;
  52271. /**
  52272. * Gets an boolean indicating if the current point can be connected to another point
  52273. * @param connectionPoint defines the other connection point
  52274. * @returns true if the connection is possible
  52275. */
  52276. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  52277. /**
  52278. * Connect this point to another connection point
  52279. * @param connectionPoint defines the other connection point
  52280. * @returns the current connection point
  52281. */
  52282. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52283. /**
  52284. * Disconnect this point from one of his endpoint
  52285. * @param endpoint defines the other connection point
  52286. * @returns the current connection point
  52287. */
  52288. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52289. /**
  52290. * Serializes this point in a JSON representation
  52291. * @returns the serialized point object
  52292. */
  52293. serialize(): any;
  52294. private static _GetTypeLength;
  52295. }
  52296. }
  52297. declare module BABYLON {
  52298. /**
  52299. * Block used to add support for vertex skinning (bones)
  52300. */
  52301. export class BonesBlock extends NodeMaterialBlock {
  52302. /**
  52303. * Creates a new BonesBlock
  52304. * @param name defines the block name
  52305. */
  52306. constructor(name: string);
  52307. /**
  52308. * Initialize the block and prepare the context for build
  52309. * @param state defines the state that will be used for the build
  52310. */
  52311. initialize(state: NodeMaterialBuildState): void;
  52312. /**
  52313. * Gets the current class name
  52314. * @returns the class name
  52315. */
  52316. getClassName(): string;
  52317. /**
  52318. * Gets the matrix indices input component
  52319. */
  52320. readonly matricesIndices: NodeMaterialConnectionPoint;
  52321. /**
  52322. * Gets the matrix weights input component
  52323. */
  52324. readonly matricesWeights: NodeMaterialConnectionPoint;
  52325. /**
  52326. * Gets the extra matrix indices input component
  52327. */
  52328. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  52329. /**
  52330. * Gets the extra matrix weights input component
  52331. */
  52332. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  52333. /**
  52334. * Gets the world input component
  52335. */
  52336. readonly world: NodeMaterialConnectionPoint;
  52337. /**
  52338. * Gets the output component
  52339. */
  52340. readonly output: NodeMaterialConnectionPoint;
  52341. autoConfigure(): void;
  52342. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52343. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52344. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52345. protected _buildBlock(state: NodeMaterialBuildState): this;
  52346. }
  52347. }
  52348. declare module BABYLON {
  52349. /**
  52350. * Block used to add support for instances
  52351. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  52352. */
  52353. export class InstancesBlock extends NodeMaterialBlock {
  52354. /**
  52355. * Creates a new InstancesBlock
  52356. * @param name defines the block name
  52357. */
  52358. constructor(name: string);
  52359. /**
  52360. * Gets the current class name
  52361. * @returns the class name
  52362. */
  52363. getClassName(): string;
  52364. /**
  52365. * Gets the first world row input component
  52366. */
  52367. readonly world0: NodeMaterialConnectionPoint;
  52368. /**
  52369. * Gets the second world row input component
  52370. */
  52371. readonly world1: NodeMaterialConnectionPoint;
  52372. /**
  52373. * Gets the third world row input component
  52374. */
  52375. readonly world2: NodeMaterialConnectionPoint;
  52376. /**
  52377. * Gets the forth world row input component
  52378. */
  52379. readonly world3: NodeMaterialConnectionPoint;
  52380. /**
  52381. * Gets the world input component
  52382. */
  52383. readonly world: NodeMaterialConnectionPoint;
  52384. /**
  52385. * Gets the output component
  52386. */
  52387. readonly output: NodeMaterialConnectionPoint;
  52388. autoConfigure(): void;
  52389. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52390. protected _buildBlock(state: NodeMaterialBuildState): this;
  52391. }
  52392. }
  52393. declare module BABYLON {
  52394. /**
  52395. * Block used to add morph targets support to vertex shader
  52396. */
  52397. export class MorphTargetsBlock extends NodeMaterialBlock {
  52398. private _repeatableContentAnchor;
  52399. private _repeatebleContentGenerated;
  52400. /**
  52401. * Create a new MorphTargetsBlock
  52402. * @param name defines the block name
  52403. */
  52404. constructor(name: string);
  52405. /**
  52406. * Gets the current class name
  52407. * @returns the class name
  52408. */
  52409. getClassName(): string;
  52410. /**
  52411. * Gets the position input component
  52412. */
  52413. readonly position: NodeMaterialConnectionPoint;
  52414. /**
  52415. * Gets the normal input component
  52416. */
  52417. readonly normal: NodeMaterialConnectionPoint;
  52418. /**
  52419. * Gets the tangent input component
  52420. */
  52421. readonly tangent: NodeMaterialConnectionPoint;
  52422. /**
  52423. * Gets the tangent input component
  52424. */
  52425. readonly uv: NodeMaterialConnectionPoint;
  52426. /**
  52427. * Gets the position output component
  52428. */
  52429. readonly positionOutput: NodeMaterialConnectionPoint;
  52430. /**
  52431. * Gets the normal output component
  52432. */
  52433. readonly normalOutput: NodeMaterialConnectionPoint;
  52434. /**
  52435. * Gets the tangent output component
  52436. */
  52437. readonly tangentOutput: NodeMaterialConnectionPoint;
  52438. /**
  52439. * Gets the tangent output component
  52440. */
  52441. readonly uvOutput: NodeMaterialConnectionPoint;
  52442. initialize(state: NodeMaterialBuildState): void;
  52443. autoConfigure(): void;
  52444. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52445. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52446. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52447. protected _buildBlock(state: NodeMaterialBuildState): this;
  52448. }
  52449. }
  52450. declare module BABYLON {
  52451. /**
  52452. * Block used to add an alpha test in the fragment shader
  52453. */
  52454. export class AlphaTestBlock extends NodeMaterialBlock {
  52455. /**
  52456. * Gets or sets the alpha value where alpha testing happens
  52457. */
  52458. alphaCutOff: number;
  52459. /**
  52460. * Create a new AlphaTestBlock
  52461. * @param name defines the block name
  52462. */
  52463. constructor(name: string);
  52464. /**
  52465. * Gets the current class name
  52466. * @returns the class name
  52467. */
  52468. getClassName(): string;
  52469. /**
  52470. * Gets the color input component
  52471. */
  52472. readonly color: NodeMaterialConnectionPoint;
  52473. protected _buildBlock(state: NodeMaterialBuildState): this;
  52474. }
  52475. }
  52476. declare module BABYLON {
  52477. /**
  52478. * Block used to create a Color3/4 out of individual inputs (one for each component)
  52479. */
  52480. export class ColorMergerBlock extends NodeMaterialBlock {
  52481. /**
  52482. * Create a new ColorMergerBlock
  52483. * @param name defines the block name
  52484. */
  52485. constructor(name: string);
  52486. /**
  52487. * Gets the current class name
  52488. * @returns the class name
  52489. */
  52490. getClassName(): string;
  52491. /**
  52492. * Gets the r component input
  52493. */
  52494. readonly r: NodeMaterialConnectionPoint;
  52495. /**
  52496. * Gets the g component input
  52497. */
  52498. readonly g: NodeMaterialConnectionPoint;
  52499. /**
  52500. * Gets the b component input
  52501. */
  52502. readonly b: NodeMaterialConnectionPoint;
  52503. /**
  52504. * Gets the a component input
  52505. */
  52506. readonly a: NodeMaterialConnectionPoint;
  52507. protected _buildBlock(state: NodeMaterialBuildState): this;
  52508. }
  52509. }
  52510. declare module BABYLON {
  52511. /**
  52512. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  52513. */
  52514. export class VectorMergerBlock extends NodeMaterialBlock {
  52515. /**
  52516. * Create a new VectorMergerBlock
  52517. * @param name defines the block name
  52518. */
  52519. constructor(name: string);
  52520. /**
  52521. * Gets the current class name
  52522. * @returns the class name
  52523. */
  52524. getClassName(): string;
  52525. /**
  52526. * Gets the x component input
  52527. */
  52528. readonly x: NodeMaterialConnectionPoint;
  52529. /**
  52530. * Gets the y component input
  52531. */
  52532. readonly y: NodeMaterialConnectionPoint;
  52533. /**
  52534. * Gets the z component input
  52535. */
  52536. readonly z: NodeMaterialConnectionPoint;
  52537. /**
  52538. * Gets the w component input
  52539. */
  52540. readonly w: NodeMaterialConnectionPoint;
  52541. protected _buildBlock(state: NodeMaterialBuildState): this;
  52542. }
  52543. }
  52544. declare module BABYLON {
  52545. /**
  52546. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  52547. */
  52548. export class ColorSplitterBlock extends NodeMaterialBlock {
  52549. /**
  52550. * Create a new ColorSplitterBlock
  52551. * @param name defines the block name
  52552. */
  52553. constructor(name: string);
  52554. /**
  52555. * Gets the current class name
  52556. * @returns the class name
  52557. */
  52558. getClassName(): string;
  52559. /**
  52560. * Gets the rgba input component
  52561. */
  52562. readonly rgba: NodeMaterialConnectionPoint;
  52563. /**
  52564. * Gets the rgb input component
  52565. */
  52566. readonly rgb: NodeMaterialConnectionPoint;
  52567. protected _buildBlock(state: NodeMaterialBuildState): this;
  52568. }
  52569. }
  52570. declare module BABYLON {
  52571. /**
  52572. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  52573. */
  52574. export class VectorSplitterBlock extends NodeMaterialBlock {
  52575. /**
  52576. * Create a new VectorSplitterBlock
  52577. * @param name defines the block name
  52578. */
  52579. constructor(name: string);
  52580. /**
  52581. * Gets the current class name
  52582. * @returns the class name
  52583. */
  52584. getClassName(): string;
  52585. /**
  52586. * Gets the rgba input component
  52587. */
  52588. readonly xyzw: NodeMaterialConnectionPoint;
  52589. /**
  52590. * Gets the rgb input component
  52591. */
  52592. readonly xyz: NodeMaterialConnectionPoint;
  52593. protected _buildBlock(state: NodeMaterialBuildState): this;
  52594. }
  52595. }
  52596. declare module BABYLON {
  52597. /**
  52598. * Block used to add image processing support to fragment shader
  52599. */
  52600. export class ImageProcessingBlock extends NodeMaterialBlock {
  52601. /**
  52602. * Create a new ImageProcessingBlock
  52603. * @param name defines the block name
  52604. */
  52605. constructor(name: string);
  52606. /**
  52607. * Gets the current class name
  52608. * @returns the class name
  52609. */
  52610. getClassName(): string;
  52611. /**
  52612. * Gets the color input component
  52613. */
  52614. readonly color: NodeMaterialConnectionPoint;
  52615. /**
  52616. * Gets the output component
  52617. */
  52618. readonly output: NodeMaterialConnectionPoint;
  52619. /**
  52620. * Initialize the block and prepare the context for build
  52621. * @param state defines the state that will be used for the build
  52622. */
  52623. initialize(state: NodeMaterialBuildState): void;
  52624. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  52625. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52626. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52627. protected _buildBlock(state: NodeMaterialBuildState): this;
  52628. }
  52629. }
  52630. declare module BABYLON {
  52631. /**
  52632. * Block used to add support for scene fog
  52633. */
  52634. export class FogBlock extends NodeMaterialBlock {
  52635. private _fogDistanceName;
  52636. private _fogParameters;
  52637. /**
  52638. * Create a new FogBlock
  52639. * @param name defines the block name
  52640. */
  52641. constructor(name: string);
  52642. /**
  52643. * Gets the current class name
  52644. * @returns the class name
  52645. */
  52646. getClassName(): string;
  52647. /**
  52648. * Gets the world position input component
  52649. */
  52650. readonly worldPosition: NodeMaterialConnectionPoint;
  52651. /**
  52652. * Gets the view input component
  52653. */
  52654. readonly view: NodeMaterialConnectionPoint;
  52655. /**
  52656. * Gets the color input component
  52657. */
  52658. readonly color: NodeMaterialConnectionPoint;
  52659. /**
  52660. * Gets the fog color input component
  52661. */
  52662. readonly fogColor: NodeMaterialConnectionPoint;
  52663. /**
  52664. * Gets the output component
  52665. */
  52666. readonly output: NodeMaterialConnectionPoint;
  52667. autoConfigure(): void;
  52668. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52669. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52670. protected _buildBlock(state: NodeMaterialBuildState): this;
  52671. }
  52672. }
  52673. declare module BABYLON {
  52674. /**
  52675. * Block used to add light in the fragment shader
  52676. */
  52677. export class LightBlock extends NodeMaterialBlock {
  52678. private _lightId;
  52679. /**
  52680. * Gets or sets the light associated with this block
  52681. */
  52682. light: Nullable<Light>;
  52683. /**
  52684. * Create a new LightBlock
  52685. * @param name defines the block name
  52686. */
  52687. constructor(name: string);
  52688. /**
  52689. * Gets the current class name
  52690. * @returns the class name
  52691. */
  52692. getClassName(): string;
  52693. /**
  52694. * Gets the world position input component
  52695. */
  52696. readonly worldPosition: NodeMaterialConnectionPoint;
  52697. /**
  52698. * Gets the world normal input component
  52699. */
  52700. readonly worldNormal: NodeMaterialConnectionPoint;
  52701. /**
  52702. * Gets the camera (or eye) position component
  52703. */
  52704. readonly cameraPosition: NodeMaterialConnectionPoint;
  52705. /**
  52706. * Gets the diffuse output component
  52707. */
  52708. readonly diffuseOutput: NodeMaterialConnectionPoint;
  52709. /**
  52710. * Gets the specular output component
  52711. */
  52712. readonly specularOutput: NodeMaterialConnectionPoint;
  52713. autoConfigure(): void;
  52714. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52715. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52716. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52717. private _injectVertexCode;
  52718. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52719. serialize(): any;
  52720. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52721. }
  52722. }
  52723. declare module BABYLON {
  52724. /**
  52725. * Block used to multiply 2 values
  52726. */
  52727. export class MultiplyBlock extends NodeMaterialBlock {
  52728. /**
  52729. * Creates a new MultiplyBlock
  52730. * @param name defines the block name
  52731. */
  52732. constructor(name: string);
  52733. /**
  52734. * Gets the current class name
  52735. * @returns the class name
  52736. */
  52737. getClassName(): string;
  52738. /**
  52739. * Gets the left operand input component
  52740. */
  52741. readonly left: NodeMaterialConnectionPoint;
  52742. /**
  52743. * Gets the right operand input component
  52744. */
  52745. readonly right: NodeMaterialConnectionPoint;
  52746. /**
  52747. * Gets the output component
  52748. */
  52749. readonly output: NodeMaterialConnectionPoint;
  52750. protected _buildBlock(state: NodeMaterialBuildState): this;
  52751. }
  52752. }
  52753. declare module BABYLON {
  52754. /**
  52755. * Block used to add 2 vectors
  52756. */
  52757. export class AddBlock extends NodeMaterialBlock {
  52758. /**
  52759. * Creates a new AddBlock
  52760. * @param name defines the block name
  52761. */
  52762. constructor(name: string);
  52763. /**
  52764. * Gets the current class name
  52765. * @returns the class name
  52766. */
  52767. getClassName(): string;
  52768. /**
  52769. * Gets the left operand input component
  52770. */
  52771. readonly left: NodeMaterialConnectionPoint;
  52772. /**
  52773. * Gets the right operand input component
  52774. */
  52775. readonly right: NodeMaterialConnectionPoint;
  52776. /**
  52777. * Gets the output component
  52778. */
  52779. readonly output: NodeMaterialConnectionPoint;
  52780. protected _buildBlock(state: NodeMaterialBuildState): this;
  52781. }
  52782. }
  52783. declare module BABYLON {
  52784. /**
  52785. * Block used to clamp a float
  52786. */
  52787. export class ClampBlock extends NodeMaterialBlock {
  52788. /** Gets or sets the minimum range */
  52789. minimum: number;
  52790. /** Gets or sets the maximum range */
  52791. maximum: number;
  52792. /**
  52793. * Creates a new ClampBlock
  52794. * @param name defines the block name
  52795. */
  52796. constructor(name: string);
  52797. /**
  52798. * Gets the current class name
  52799. * @returns the class name
  52800. */
  52801. getClassName(): string;
  52802. /**
  52803. * Gets the value input component
  52804. */
  52805. readonly value: NodeMaterialConnectionPoint;
  52806. /**
  52807. * Gets the output component
  52808. */
  52809. readonly output: NodeMaterialConnectionPoint;
  52810. protected _buildBlock(state: NodeMaterialBuildState): this;
  52811. }
  52812. }
  52813. declare module BABYLON {
  52814. /**
  52815. * Block used to apply a cross product between 2 vectors
  52816. */
  52817. export class CrossBlock extends NodeMaterialBlock {
  52818. /**
  52819. * Creates a new CrossBlock
  52820. * @param name defines the block name
  52821. */
  52822. constructor(name: string);
  52823. /**
  52824. * Gets the current class name
  52825. * @returns the class name
  52826. */
  52827. getClassName(): string;
  52828. /**
  52829. * Gets the left operand input component
  52830. */
  52831. readonly left: NodeMaterialConnectionPoint;
  52832. /**
  52833. * Gets the right operand input component
  52834. */
  52835. readonly right: NodeMaterialConnectionPoint;
  52836. /**
  52837. * Gets the output component
  52838. */
  52839. readonly output: NodeMaterialConnectionPoint;
  52840. protected _buildBlock(state: NodeMaterialBuildState): this;
  52841. }
  52842. }
  52843. declare module BABYLON {
  52844. /**
  52845. * Block used to apply a dot product between 2 vectors
  52846. */
  52847. export class DotBlock extends NodeMaterialBlock {
  52848. /**
  52849. * Creates a new DotBlock
  52850. * @param name defines the block name
  52851. */
  52852. constructor(name: string);
  52853. /**
  52854. * Gets the current class name
  52855. * @returns the class name
  52856. */
  52857. getClassName(): string;
  52858. /**
  52859. * Gets the left operand input component
  52860. */
  52861. readonly left: NodeMaterialConnectionPoint;
  52862. /**
  52863. * Gets the right operand input component
  52864. */
  52865. readonly right: NodeMaterialConnectionPoint;
  52866. /**
  52867. * Gets the output component
  52868. */
  52869. readonly output: NodeMaterialConnectionPoint;
  52870. protected _buildBlock(state: NodeMaterialBuildState): this;
  52871. }
  52872. }
  52873. declare module BABYLON {
  52874. /**
  52875. * Effect Render Options
  52876. */
  52877. export interface IEffectRendererOptions {
  52878. /**
  52879. * Defines the vertices positions.
  52880. */
  52881. positions?: number[];
  52882. /**
  52883. * Defines the indices.
  52884. */
  52885. indices?: number[];
  52886. }
  52887. /**
  52888. * Helper class to render one or more effects
  52889. */
  52890. export class EffectRenderer {
  52891. private engine;
  52892. private static _DefaultOptions;
  52893. private _vertexBuffers;
  52894. private _indexBuffer;
  52895. private _ringBufferIndex;
  52896. private _ringScreenBuffer;
  52897. private _fullscreenViewport;
  52898. private _getNextFrameBuffer;
  52899. /**
  52900. * Creates an effect renderer
  52901. * @param engine the engine to use for rendering
  52902. * @param options defines the options of the effect renderer
  52903. */
  52904. constructor(engine: Engine, options?: IEffectRendererOptions);
  52905. /**
  52906. * Sets the current viewport in normalized coordinates 0-1
  52907. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  52908. */
  52909. setViewport(viewport?: Viewport): void;
  52910. /**
  52911. * Sets the current effect wrapper to use during draw.
  52912. * The effect needs to be ready before calling this api.
  52913. * This also sets the default full screen position attribute.
  52914. * @param effectWrapper Defines the effect to draw with
  52915. */
  52916. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  52917. /**
  52918. * Draws a full screen quad.
  52919. */
  52920. draw(): void;
  52921. /**
  52922. * renders one or more effects to a specified texture
  52923. * @param effectWrappers list of effects to renderer
  52924. * @param outputTexture texture to draw to, if null it will render to the screen
  52925. */
  52926. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  52927. /**
  52928. * Disposes of the effect renderer
  52929. */
  52930. dispose(): void;
  52931. }
  52932. /**
  52933. * Options to create an EffectWrapper
  52934. */
  52935. interface EffectWrapperCreationOptions {
  52936. /**
  52937. * Engine to use to create the effect
  52938. */
  52939. engine: Engine;
  52940. /**
  52941. * Fragment shader for the effect
  52942. */
  52943. fragmentShader: string;
  52944. /**
  52945. * Vertex shader for the effect
  52946. */
  52947. vertexShader: string;
  52948. /**
  52949. * Attributes to use in the shader
  52950. */
  52951. attributeNames?: Array<string>;
  52952. /**
  52953. * Uniforms to use in the shader
  52954. */
  52955. uniformNames?: Array<string>;
  52956. /**
  52957. * Texture sampler names to use in the shader
  52958. */
  52959. samplerNames?: Array<string>;
  52960. /**
  52961. * The friendly name of the effect displayed in Spector.
  52962. */
  52963. name?: string;
  52964. }
  52965. /**
  52966. * Wraps an effect to be used for rendering
  52967. */
  52968. export class EffectWrapper {
  52969. /**
  52970. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  52971. */
  52972. onApplyObservable: Observable<{}>;
  52973. /**
  52974. * The underlying effect
  52975. */
  52976. effect: Effect;
  52977. /**
  52978. * Creates an effect to be renderer
  52979. * @param creationOptions options to create the effect
  52980. */
  52981. constructor(creationOptions: EffectWrapperCreationOptions);
  52982. /**
  52983. * Disposes of the effect wrapper
  52984. */
  52985. dispose(): void;
  52986. }
  52987. }
  52988. declare module BABYLON {
  52989. /**
  52990. * Helper class to push actions to a pool of workers.
  52991. */
  52992. export class WorkerPool implements IDisposable {
  52993. private _workerInfos;
  52994. private _pendingActions;
  52995. /**
  52996. * Constructor
  52997. * @param workers Array of workers to use for actions
  52998. */
  52999. constructor(workers: Array<Worker>);
  53000. /**
  53001. * Terminates all workers and clears any pending actions.
  53002. */
  53003. dispose(): void;
  53004. /**
  53005. * Pushes an action to the worker pool. If all the workers are active, the action will be
  53006. * pended until a worker has completed its action.
  53007. * @param action The action to perform. Call onComplete when the action is complete.
  53008. */
  53009. push(action: (worker: Worker, onComplete: () => void) => void): void;
  53010. private _execute;
  53011. }
  53012. }
  53013. declare module BABYLON {
  53014. /**
  53015. * Configuration for Draco compression
  53016. */
  53017. export interface IDracoCompressionConfiguration {
  53018. /**
  53019. * Configuration for the decoder.
  53020. */
  53021. decoder: {
  53022. /**
  53023. * The url to the WebAssembly module.
  53024. */
  53025. wasmUrl?: string;
  53026. /**
  53027. * The url to the WebAssembly binary.
  53028. */
  53029. wasmBinaryUrl?: string;
  53030. /**
  53031. * The url to the fallback JavaScript module.
  53032. */
  53033. fallbackUrl?: string;
  53034. };
  53035. }
  53036. /**
  53037. * Draco compression (https://google.github.io/draco/)
  53038. *
  53039. * This class wraps the Draco module.
  53040. *
  53041. * **Encoder**
  53042. *
  53043. * The encoder is not currently implemented.
  53044. *
  53045. * **Decoder**
  53046. *
  53047. * 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.
  53048. *
  53049. * To update the configuration, use the following code:
  53050. * ```javascript
  53051. * DracoCompression.Configuration = {
  53052. * decoder: {
  53053. * wasmUrl: "<url to the WebAssembly library>",
  53054. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  53055. * fallbackUrl: "<url to the fallback JavaScript library>",
  53056. * }
  53057. * };
  53058. * ```
  53059. *
  53060. * 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.
  53061. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  53062. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  53063. *
  53064. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  53065. * ```javascript
  53066. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  53067. * ```
  53068. *
  53069. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  53070. */
  53071. export class DracoCompression implements IDisposable {
  53072. private _workerPoolPromise?;
  53073. private _decoderModulePromise?;
  53074. /**
  53075. * The configuration. Defaults to the following urls:
  53076. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  53077. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  53078. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  53079. */
  53080. static Configuration: IDracoCompressionConfiguration;
  53081. /**
  53082. * Returns true if the decoder configuration is available.
  53083. */
  53084. static readonly DecoderAvailable: boolean;
  53085. /**
  53086. * Default number of workers to create when creating the draco compression object.
  53087. */
  53088. static DefaultNumWorkers: number;
  53089. private static GetDefaultNumWorkers;
  53090. private static _Default;
  53091. /**
  53092. * Default instance for the draco compression object.
  53093. */
  53094. static readonly Default: DracoCompression;
  53095. /**
  53096. * Constructor
  53097. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  53098. */
  53099. constructor(numWorkers?: number);
  53100. /**
  53101. * Stop all async operations and release resources.
  53102. */
  53103. dispose(): void;
  53104. /**
  53105. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  53106. * @returns a promise that resolves when ready
  53107. */
  53108. whenReadyAsync(): Promise<void>;
  53109. /**
  53110. * Decode Draco compressed mesh data to vertex data.
  53111. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  53112. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  53113. * @returns A promise that resolves with the decoded vertex data
  53114. */
  53115. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  53116. [kind: string]: number;
  53117. }): Promise<VertexData>;
  53118. }
  53119. }
  53120. declare module BABYLON {
  53121. /**
  53122. * Class for building Constructive Solid Geometry
  53123. */
  53124. export class CSG {
  53125. private polygons;
  53126. /**
  53127. * The world matrix
  53128. */
  53129. matrix: Matrix;
  53130. /**
  53131. * Stores the position
  53132. */
  53133. position: Vector3;
  53134. /**
  53135. * Stores the rotation
  53136. */
  53137. rotation: Vector3;
  53138. /**
  53139. * Stores the rotation quaternion
  53140. */
  53141. rotationQuaternion: Nullable<Quaternion>;
  53142. /**
  53143. * Stores the scaling vector
  53144. */
  53145. scaling: Vector3;
  53146. /**
  53147. * Convert the Mesh to CSG
  53148. * @param mesh The Mesh to convert to CSG
  53149. * @returns A new CSG from the Mesh
  53150. */
  53151. static FromMesh(mesh: Mesh): CSG;
  53152. /**
  53153. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  53154. * @param polygons Polygons used to construct a CSG solid
  53155. */
  53156. private static FromPolygons;
  53157. /**
  53158. * Clones, or makes a deep copy, of the CSG
  53159. * @returns A new CSG
  53160. */
  53161. clone(): CSG;
  53162. /**
  53163. * Unions this CSG with another CSG
  53164. * @param csg The CSG to union against this CSG
  53165. * @returns The unioned CSG
  53166. */
  53167. union(csg: CSG): CSG;
  53168. /**
  53169. * Unions this CSG with another CSG in place
  53170. * @param csg The CSG to union against this CSG
  53171. */
  53172. unionInPlace(csg: CSG): void;
  53173. /**
  53174. * Subtracts this CSG with another CSG
  53175. * @param csg The CSG to subtract against this CSG
  53176. * @returns A new CSG
  53177. */
  53178. subtract(csg: CSG): CSG;
  53179. /**
  53180. * Subtracts this CSG with another CSG in place
  53181. * @param csg The CSG to subtact against this CSG
  53182. */
  53183. subtractInPlace(csg: CSG): void;
  53184. /**
  53185. * Intersect this CSG with another CSG
  53186. * @param csg The CSG to intersect against this CSG
  53187. * @returns A new CSG
  53188. */
  53189. intersect(csg: CSG): CSG;
  53190. /**
  53191. * Intersects this CSG with another CSG in place
  53192. * @param csg The CSG to intersect against this CSG
  53193. */
  53194. intersectInPlace(csg: CSG): void;
  53195. /**
  53196. * Return a new CSG solid with solid and empty space switched. This solid is
  53197. * not modified.
  53198. * @returns A new CSG solid with solid and empty space switched
  53199. */
  53200. inverse(): CSG;
  53201. /**
  53202. * Inverses the CSG in place
  53203. */
  53204. inverseInPlace(): void;
  53205. /**
  53206. * This is used to keep meshes transformations so they can be restored
  53207. * when we build back a Babylon Mesh
  53208. * NB : All CSG operations are performed in world coordinates
  53209. * @param csg The CSG to copy the transform attributes from
  53210. * @returns This CSG
  53211. */
  53212. copyTransformAttributes(csg: CSG): CSG;
  53213. /**
  53214. * Build Raw mesh from CSG
  53215. * Coordinates here are in world space
  53216. * @param name The name of the mesh geometry
  53217. * @param scene The Scene
  53218. * @param keepSubMeshes Specifies if the submeshes should be kept
  53219. * @returns A new Mesh
  53220. */
  53221. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  53222. /**
  53223. * Build Mesh from CSG taking material and transforms into account
  53224. * @param name The name of the Mesh
  53225. * @param material The material of the Mesh
  53226. * @param scene The Scene
  53227. * @param keepSubMeshes Specifies if submeshes should be kept
  53228. * @returns The new Mesh
  53229. */
  53230. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  53231. }
  53232. }
  53233. declare module BABYLON {
  53234. /**
  53235. * Class used to create a trail following a mesh
  53236. */
  53237. export class TrailMesh extends Mesh {
  53238. private _generator;
  53239. private _autoStart;
  53240. private _running;
  53241. private _diameter;
  53242. private _length;
  53243. private _sectionPolygonPointsCount;
  53244. private _sectionVectors;
  53245. private _sectionNormalVectors;
  53246. private _beforeRenderObserver;
  53247. /**
  53248. * @constructor
  53249. * @param name The value used by scene.getMeshByName() to do a lookup.
  53250. * @param generator The mesh to generate a trail.
  53251. * @param scene The scene to add this mesh to.
  53252. * @param diameter Diameter of trailing mesh. Default is 1.
  53253. * @param length Length of trailing mesh. Default is 60.
  53254. * @param autoStart Automatically start trailing mesh. Default true.
  53255. */
  53256. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  53257. /**
  53258. * "TrailMesh"
  53259. * @returns "TrailMesh"
  53260. */
  53261. getClassName(): string;
  53262. private _createMesh;
  53263. /**
  53264. * Start trailing mesh.
  53265. */
  53266. start(): void;
  53267. /**
  53268. * Stop trailing mesh.
  53269. */
  53270. stop(): void;
  53271. /**
  53272. * Update trailing mesh geometry.
  53273. */
  53274. update(): void;
  53275. /**
  53276. * Returns a new TrailMesh object.
  53277. * @param name is a string, the name given to the new mesh
  53278. * @param newGenerator use new generator object for cloned trail mesh
  53279. * @returns a new mesh
  53280. */
  53281. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  53282. /**
  53283. * Serializes this trail mesh
  53284. * @param serializationObject object to write serialization to
  53285. */
  53286. serialize(serializationObject: any): void;
  53287. /**
  53288. * Parses a serialized trail mesh
  53289. * @param parsedMesh the serialized mesh
  53290. * @param scene the scene to create the trail mesh in
  53291. * @returns the created trail mesh
  53292. */
  53293. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  53294. }
  53295. }
  53296. declare module BABYLON {
  53297. /**
  53298. * Class containing static functions to help procedurally build meshes
  53299. */
  53300. export class TiledBoxBuilder {
  53301. /**
  53302. * Creates a box mesh
  53303. * 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)
  53304. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53305. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53306. * * 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
  53307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53308. * @param name defines the name of the mesh
  53309. * @param options defines the options used to create the mesh
  53310. * @param scene defines the hosting scene
  53311. * @returns the box mesh
  53312. */
  53313. static CreateTiledBox(name: string, options: {
  53314. pattern?: number;
  53315. width?: number;
  53316. height?: number;
  53317. depth?: number;
  53318. tileSize?: number;
  53319. tileWidth?: number;
  53320. tileHeight?: number;
  53321. alignHorizontal?: number;
  53322. alignVertical?: number;
  53323. faceUV?: Vector4[];
  53324. faceColors?: Color4[];
  53325. sideOrientation?: number;
  53326. updatable?: boolean;
  53327. }, scene?: Nullable<Scene>): Mesh;
  53328. }
  53329. }
  53330. declare module BABYLON {
  53331. /**
  53332. * Class containing static functions to help procedurally build meshes
  53333. */
  53334. export class TorusKnotBuilder {
  53335. /**
  53336. * Creates a torus knot mesh
  53337. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  53338. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  53339. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  53340. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  53341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53342. * * 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
  53343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53344. * @param name defines the name of the mesh
  53345. * @param options defines the options used to create the mesh
  53346. * @param scene defines the hosting scene
  53347. * @returns the torus knot mesh
  53348. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  53349. */
  53350. static CreateTorusKnot(name: string, options: {
  53351. radius?: number;
  53352. tube?: number;
  53353. radialSegments?: number;
  53354. tubularSegments?: number;
  53355. p?: number;
  53356. q?: number;
  53357. updatable?: boolean;
  53358. sideOrientation?: number;
  53359. frontUVs?: Vector4;
  53360. backUVs?: Vector4;
  53361. }, scene: any): Mesh;
  53362. }
  53363. }
  53364. declare module BABYLON {
  53365. /**
  53366. * Polygon
  53367. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  53368. */
  53369. export class Polygon {
  53370. /**
  53371. * Creates a rectangle
  53372. * @param xmin bottom X coord
  53373. * @param ymin bottom Y coord
  53374. * @param xmax top X coord
  53375. * @param ymax top Y coord
  53376. * @returns points that make the resulting rectation
  53377. */
  53378. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  53379. /**
  53380. * Creates a circle
  53381. * @param radius radius of circle
  53382. * @param cx scale in x
  53383. * @param cy scale in y
  53384. * @param numberOfSides number of sides that make up the circle
  53385. * @returns points that make the resulting circle
  53386. */
  53387. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  53388. /**
  53389. * Creates a polygon from input string
  53390. * @param input Input polygon data
  53391. * @returns the parsed points
  53392. */
  53393. static Parse(input: string): Vector2[];
  53394. /**
  53395. * Starts building a polygon from x and y coordinates
  53396. * @param x x coordinate
  53397. * @param y y coordinate
  53398. * @returns the started path2
  53399. */
  53400. static StartingAt(x: number, y: number): Path2;
  53401. }
  53402. /**
  53403. * Builds a polygon
  53404. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  53405. */
  53406. export class PolygonMeshBuilder {
  53407. private _points;
  53408. private _outlinepoints;
  53409. private _holes;
  53410. private _name;
  53411. private _scene;
  53412. private _epoints;
  53413. private _eholes;
  53414. private _addToepoint;
  53415. /**
  53416. * Babylon reference to the earcut plugin.
  53417. */
  53418. bjsEarcut: any;
  53419. /**
  53420. * Creates a PolygonMeshBuilder
  53421. * @param name name of the builder
  53422. * @param contours Path of the polygon
  53423. * @param scene scene to add to when creating the mesh
  53424. * @param earcutInjection can be used to inject your own earcut reference
  53425. */
  53426. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  53427. /**
  53428. * Adds a whole within the polygon
  53429. * @param hole Array of points defining the hole
  53430. * @returns this
  53431. */
  53432. addHole(hole: Vector2[]): PolygonMeshBuilder;
  53433. /**
  53434. * Creates the polygon
  53435. * @param updatable If the mesh should be updatable
  53436. * @param depth The depth of the mesh created
  53437. * @returns the created mesh
  53438. */
  53439. build(updatable?: boolean, depth?: number): Mesh;
  53440. /**
  53441. * Creates the polygon
  53442. * @param depth The depth of the mesh created
  53443. * @returns the created VertexData
  53444. */
  53445. buildVertexData(depth?: number): VertexData;
  53446. /**
  53447. * Adds a side to the polygon
  53448. * @param positions points that make the polygon
  53449. * @param normals normals of the polygon
  53450. * @param uvs uvs of the polygon
  53451. * @param indices indices of the polygon
  53452. * @param bounds bounds of the polygon
  53453. * @param points points of the polygon
  53454. * @param depth depth of the polygon
  53455. * @param flip flip of the polygon
  53456. */
  53457. private addSide;
  53458. }
  53459. }
  53460. declare module BABYLON {
  53461. /**
  53462. * Class containing static functions to help procedurally build meshes
  53463. */
  53464. export class PolygonBuilder {
  53465. /**
  53466. * Creates a polygon mesh
  53467. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53468. * * 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
  53469. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53471. * * 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)
  53472. * * Remember you can only change the shape positions, not their number when updating a polygon
  53473. * @param name defines the name of the mesh
  53474. * @param options defines the options used to create the mesh
  53475. * @param scene defines the hosting scene
  53476. * @param earcutInjection can be used to inject your own earcut reference
  53477. * @returns the polygon mesh
  53478. */
  53479. static CreatePolygon(name: string, options: {
  53480. shape: Vector3[];
  53481. holes?: Vector3[][];
  53482. depth?: number;
  53483. faceUV?: Vector4[];
  53484. faceColors?: Color4[];
  53485. updatable?: boolean;
  53486. sideOrientation?: number;
  53487. frontUVs?: Vector4;
  53488. backUVs?: Vector4;
  53489. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53490. /**
  53491. * Creates an extruded polygon mesh, with depth in the Y direction.
  53492. * * 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)
  53493. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53494. * @param name defines the name of the mesh
  53495. * @param options defines the options used to create the mesh
  53496. * @param scene defines the hosting scene
  53497. * @param earcutInjection can be used to inject your own earcut reference
  53498. * @returns the polygon mesh
  53499. */
  53500. static ExtrudePolygon(name: string, options: {
  53501. shape: Vector3[];
  53502. holes?: Vector3[][];
  53503. depth?: number;
  53504. faceUV?: Vector4[];
  53505. faceColors?: Color4[];
  53506. updatable?: boolean;
  53507. sideOrientation?: number;
  53508. frontUVs?: Vector4;
  53509. backUVs?: Vector4;
  53510. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53511. }
  53512. }
  53513. declare module BABYLON {
  53514. /**
  53515. * Class containing static functions to help procedurally build meshes
  53516. */
  53517. export class LatheBuilder {
  53518. /**
  53519. * Creates lathe mesh.
  53520. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  53521. * * 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
  53522. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53523. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53524. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53525. * * 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
  53526. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53527. * * 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
  53528. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53529. * * 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
  53530. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53532. * @param name defines the name of the mesh
  53533. * @param options defines the options used to create the mesh
  53534. * @param scene defines the hosting scene
  53535. * @returns the lathe mesh
  53536. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53537. */
  53538. static CreateLathe(name: string, options: {
  53539. shape: Vector3[];
  53540. radius?: number;
  53541. tessellation?: number;
  53542. clip?: number;
  53543. arc?: number;
  53544. closed?: boolean;
  53545. updatable?: boolean;
  53546. sideOrientation?: number;
  53547. frontUVs?: Vector4;
  53548. backUVs?: Vector4;
  53549. cap?: number;
  53550. invertUV?: boolean;
  53551. }, scene?: Nullable<Scene>): Mesh;
  53552. }
  53553. }
  53554. declare module BABYLON {
  53555. /**
  53556. * Class containing static functions to help procedurally build meshes
  53557. */
  53558. export class TiledPlaneBuilder {
  53559. /**
  53560. * Creates a tiled plane mesh
  53561. * * The parameter `pattern` will, depending on value, do nothing or
  53562. * * * flip (reflect about central vertical) alternate tiles across and up
  53563. * * * flip every tile on alternate rows
  53564. * * * rotate (180 degs) alternate tiles across and up
  53565. * * * rotate every tile on alternate rows
  53566. * * * flip and rotate alternate tiles across and up
  53567. * * * flip and rotate every tile on alternate rows
  53568. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  53569. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  53570. * * 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
  53571. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53572. * * 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)
  53573. * * 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)
  53574. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53575. * @param name defines the name of the mesh
  53576. * @param options defines the options used to create the mesh
  53577. * @param scene defines the hosting scene
  53578. * @returns the box mesh
  53579. */
  53580. static CreateTiledPlane(name: string, options: {
  53581. pattern?: number;
  53582. tileSize?: number;
  53583. tileWidth?: number;
  53584. tileHeight?: number;
  53585. size?: number;
  53586. width?: number;
  53587. height?: number;
  53588. alignHorizontal?: number;
  53589. alignVertical?: number;
  53590. sideOrientation?: number;
  53591. frontUVs?: Vector4;
  53592. backUVs?: Vector4;
  53593. updatable?: boolean;
  53594. }, scene?: Nullable<Scene>): Mesh;
  53595. }
  53596. }
  53597. declare module BABYLON {
  53598. /**
  53599. * Class containing static functions to help procedurally build meshes
  53600. */
  53601. export class TubeBuilder {
  53602. /**
  53603. * Creates a tube mesh.
  53604. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53605. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53606. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53607. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53608. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53609. * * 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)
  53610. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53611. * * 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
  53612. * * 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
  53613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53614. * * 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
  53615. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53617. * @param name defines the name of the mesh
  53618. * @param options defines the options used to create the mesh
  53619. * @param scene defines the hosting scene
  53620. * @returns the tube mesh
  53621. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53622. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53623. */
  53624. static CreateTube(name: string, options: {
  53625. path: Vector3[];
  53626. radius?: number;
  53627. tessellation?: number;
  53628. radiusFunction?: {
  53629. (i: number, distance: number): number;
  53630. };
  53631. cap?: number;
  53632. arc?: number;
  53633. updatable?: boolean;
  53634. sideOrientation?: number;
  53635. frontUVs?: Vector4;
  53636. backUVs?: Vector4;
  53637. instance?: Mesh;
  53638. invertUV?: boolean;
  53639. }, scene?: Nullable<Scene>): Mesh;
  53640. }
  53641. }
  53642. declare module BABYLON {
  53643. /**
  53644. * Class containing static functions to help procedurally build meshes
  53645. */
  53646. export class IcoSphereBuilder {
  53647. /**
  53648. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  53649. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  53650. * * 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`)
  53651. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  53652. * * 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
  53653. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53654. * * 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
  53655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53656. * @param name defines the name of the mesh
  53657. * @param options defines the options used to create the mesh
  53658. * @param scene defines the hosting scene
  53659. * @returns the icosahedron mesh
  53660. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  53661. */
  53662. static CreateIcoSphere(name: string, options: {
  53663. radius?: number;
  53664. radiusX?: number;
  53665. radiusY?: number;
  53666. radiusZ?: number;
  53667. flat?: boolean;
  53668. subdivisions?: number;
  53669. sideOrientation?: number;
  53670. frontUVs?: Vector4;
  53671. backUVs?: Vector4;
  53672. updatable?: boolean;
  53673. }, scene?: Nullable<Scene>): Mesh;
  53674. }
  53675. }
  53676. declare module BABYLON {
  53677. /**
  53678. * Class containing static functions to help procedurally build meshes
  53679. */
  53680. export class DecalBuilder {
  53681. /**
  53682. * Creates a decal mesh.
  53683. * 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
  53684. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53685. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53686. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53687. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53688. * @param name defines the name of the mesh
  53689. * @param sourceMesh defines the mesh where the decal must be applied
  53690. * @param options defines the options used to create the mesh
  53691. * @param scene defines the hosting scene
  53692. * @returns the decal mesh
  53693. * @see https://doc.babylonjs.com/how_to/decals
  53694. */
  53695. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53696. position?: Vector3;
  53697. normal?: Vector3;
  53698. size?: Vector3;
  53699. angle?: number;
  53700. }): Mesh;
  53701. }
  53702. }
  53703. declare module BABYLON {
  53704. /**
  53705. * Class containing static functions to help procedurally build meshes
  53706. */
  53707. export class MeshBuilder {
  53708. /**
  53709. * Creates a box mesh
  53710. * * The parameter `size` sets the size (float) of each box side (default 1)
  53711. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53712. * * 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)
  53713. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53714. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53715. * * 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
  53716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53717. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53718. * @param name defines the name of the mesh
  53719. * @param options defines the options used to create the mesh
  53720. * @param scene defines the hosting scene
  53721. * @returns the box mesh
  53722. */
  53723. static CreateBox(name: string, options: {
  53724. size?: number;
  53725. width?: number;
  53726. height?: number;
  53727. depth?: number;
  53728. faceUV?: Vector4[];
  53729. faceColors?: Color4[];
  53730. sideOrientation?: number;
  53731. frontUVs?: Vector4;
  53732. backUVs?: Vector4;
  53733. updatable?: boolean;
  53734. }, scene?: Nullable<Scene>): Mesh;
  53735. /**
  53736. * Creates a tiled box mesh
  53737. * * faceTiles sets the pattern, tile size and number of tiles for a face
  53738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53739. * @param name defines the name of the mesh
  53740. * @param options defines the options used to create the mesh
  53741. * @param scene defines the hosting scene
  53742. * @returns the tiled box mesh
  53743. */
  53744. static CreateTiledBox(name: string, options: {
  53745. pattern?: number;
  53746. size?: number;
  53747. width?: number;
  53748. height?: number;
  53749. depth: number;
  53750. tileSize?: number;
  53751. tileWidth?: number;
  53752. tileHeight?: number;
  53753. faceUV?: Vector4[];
  53754. faceColors?: Color4[];
  53755. alignHorizontal?: number;
  53756. alignVertical?: number;
  53757. sideOrientation?: number;
  53758. updatable?: boolean;
  53759. }, scene?: Nullable<Scene>): Mesh;
  53760. /**
  53761. * Creates a sphere mesh
  53762. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53763. * * 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`)
  53764. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53765. * * 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
  53766. * * 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)
  53767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53768. * * 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
  53769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53770. * @param name defines the name of the mesh
  53771. * @param options defines the options used to create the mesh
  53772. * @param scene defines the hosting scene
  53773. * @returns the sphere mesh
  53774. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53775. */
  53776. static CreateSphere(name: string, options: {
  53777. segments?: number;
  53778. diameter?: number;
  53779. diameterX?: number;
  53780. diameterY?: number;
  53781. diameterZ?: number;
  53782. arc?: number;
  53783. slice?: number;
  53784. sideOrientation?: number;
  53785. frontUVs?: Vector4;
  53786. backUVs?: Vector4;
  53787. updatable?: boolean;
  53788. }, scene?: Nullable<Scene>): Mesh;
  53789. /**
  53790. * Creates a plane polygonal mesh. By default, this is a disc
  53791. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  53792. * * 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
  53793. * * 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
  53794. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53795. * * 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
  53796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53797. * @param name defines the name of the mesh
  53798. * @param options defines the options used to create the mesh
  53799. * @param scene defines the hosting scene
  53800. * @returns the plane polygonal mesh
  53801. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  53802. */
  53803. static CreateDisc(name: string, options: {
  53804. radius?: number;
  53805. tessellation?: number;
  53806. arc?: number;
  53807. updatable?: boolean;
  53808. sideOrientation?: number;
  53809. frontUVs?: Vector4;
  53810. backUVs?: Vector4;
  53811. }, scene?: Nullable<Scene>): Mesh;
  53812. /**
  53813. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  53814. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  53815. * * 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`)
  53816. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  53817. * * 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
  53818. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53819. * * 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
  53820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53821. * @param name defines the name of the mesh
  53822. * @param options defines the options used to create the mesh
  53823. * @param scene defines the hosting scene
  53824. * @returns the icosahedron mesh
  53825. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  53826. */
  53827. static CreateIcoSphere(name: string, options: {
  53828. radius?: number;
  53829. radiusX?: number;
  53830. radiusY?: number;
  53831. radiusZ?: number;
  53832. flat?: boolean;
  53833. subdivisions?: number;
  53834. sideOrientation?: number;
  53835. frontUVs?: Vector4;
  53836. backUVs?: Vector4;
  53837. updatable?: boolean;
  53838. }, scene?: Nullable<Scene>): Mesh;
  53839. /**
  53840. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53841. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53842. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53843. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53844. * * 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
  53845. * * 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
  53846. * * 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
  53847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53848. * * 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
  53849. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53850. * * 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
  53851. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53852. * * 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
  53853. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53855. * @param name defines the name of the mesh
  53856. * @param options defines the options used to create the mesh
  53857. * @param scene defines the hosting scene
  53858. * @returns the ribbon mesh
  53859. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53860. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53861. */
  53862. static CreateRibbon(name: string, options: {
  53863. pathArray: Vector3[][];
  53864. closeArray?: boolean;
  53865. closePath?: boolean;
  53866. offset?: number;
  53867. updatable?: boolean;
  53868. sideOrientation?: number;
  53869. frontUVs?: Vector4;
  53870. backUVs?: Vector4;
  53871. instance?: Mesh;
  53872. invertUV?: boolean;
  53873. uvs?: Vector2[];
  53874. colors?: Color4[];
  53875. }, scene?: Nullable<Scene>): Mesh;
  53876. /**
  53877. * Creates a cylinder or a cone mesh
  53878. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53879. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53880. * * 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.
  53881. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53882. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53883. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53884. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53885. * * 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).
  53886. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53887. * * 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).
  53888. * * 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
  53889. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53890. * * 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
  53891. * * 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.
  53892. * * If `enclose` is false, a ring surface is one element.
  53893. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53894. * * 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
  53895. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53896. * * 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
  53897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53898. * @param name defines the name of the mesh
  53899. * @param options defines the options used to create the mesh
  53900. * @param scene defines the hosting scene
  53901. * @returns the cylinder mesh
  53902. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53903. */
  53904. static CreateCylinder(name: string, options: {
  53905. height?: number;
  53906. diameterTop?: number;
  53907. diameterBottom?: number;
  53908. diameter?: number;
  53909. tessellation?: number;
  53910. subdivisions?: number;
  53911. arc?: number;
  53912. faceColors?: Color4[];
  53913. faceUV?: Vector4[];
  53914. updatable?: boolean;
  53915. hasRings?: boolean;
  53916. enclose?: boolean;
  53917. cap?: number;
  53918. sideOrientation?: number;
  53919. frontUVs?: Vector4;
  53920. backUVs?: Vector4;
  53921. }, scene?: Nullable<Scene>): Mesh;
  53922. /**
  53923. * Creates a torus mesh
  53924. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53925. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53926. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  53927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53928. * * 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
  53929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53930. * @param name defines the name of the mesh
  53931. * @param options defines the options used to create the mesh
  53932. * @param scene defines the hosting scene
  53933. * @returns the torus mesh
  53934. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53935. */
  53936. static CreateTorus(name: string, options: {
  53937. diameter?: number;
  53938. thickness?: number;
  53939. tessellation?: number;
  53940. updatable?: boolean;
  53941. sideOrientation?: number;
  53942. frontUVs?: Vector4;
  53943. backUVs?: Vector4;
  53944. }, scene?: Nullable<Scene>): Mesh;
  53945. /**
  53946. * Creates a torus knot mesh
  53947. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  53948. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  53949. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  53950. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  53951. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53952. * * 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
  53953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53954. * @param name defines the name of the mesh
  53955. * @param options defines the options used to create the mesh
  53956. * @param scene defines the hosting scene
  53957. * @returns the torus knot mesh
  53958. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  53959. */
  53960. static CreateTorusKnot(name: string, options: {
  53961. radius?: number;
  53962. tube?: number;
  53963. radialSegments?: number;
  53964. tubularSegments?: number;
  53965. p?: number;
  53966. q?: number;
  53967. updatable?: boolean;
  53968. sideOrientation?: number;
  53969. frontUVs?: Vector4;
  53970. backUVs?: Vector4;
  53971. }, scene?: Nullable<Scene>): Mesh;
  53972. /**
  53973. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  53974. * * 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
  53975. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  53976. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  53977. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  53978. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  53979. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  53980. * * 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
  53981. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  53982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53983. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  53984. * @param name defines the name of the new line system
  53985. * @param options defines the options used to create the line system
  53986. * @param scene defines the hosting scene
  53987. * @returns a new line system mesh
  53988. */
  53989. static CreateLineSystem(name: string, options: {
  53990. lines: Vector3[][];
  53991. updatable?: boolean;
  53992. instance?: Nullable<LinesMesh>;
  53993. colors?: Nullable<Color4[][]>;
  53994. useVertexAlpha?: boolean;
  53995. }, scene: Nullable<Scene>): LinesMesh;
  53996. /**
  53997. * Creates a line mesh
  53998. * 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
  53999. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54000. * * The parameter `points` is an array successive Vector3
  54001. * * 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
  54002. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54003. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54004. * * When updating an instance, remember that only point positions can change, not the number of points
  54005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54006. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54007. * @param name defines the name of the new line system
  54008. * @param options defines the options used to create the line system
  54009. * @param scene defines the hosting scene
  54010. * @returns a new line mesh
  54011. */
  54012. static CreateLines(name: string, options: {
  54013. points: Vector3[];
  54014. updatable?: boolean;
  54015. instance?: Nullable<LinesMesh>;
  54016. colors?: Color4[];
  54017. useVertexAlpha?: boolean;
  54018. }, scene?: Nullable<Scene>): LinesMesh;
  54019. /**
  54020. * Creates a dashed line mesh
  54021. * * 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
  54022. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54023. * * The parameter `points` is an array successive Vector3
  54024. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54025. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54026. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54027. * * 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
  54028. * * When updating an instance, remember that only point positions can change, not the number of points
  54029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54030. * @param name defines the name of the mesh
  54031. * @param options defines the options used to create the mesh
  54032. * @param scene defines the hosting scene
  54033. * @returns the dashed line mesh
  54034. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54035. */
  54036. static CreateDashedLines(name: string, options: {
  54037. points: Vector3[];
  54038. dashSize?: number;
  54039. gapSize?: number;
  54040. dashNb?: number;
  54041. updatable?: boolean;
  54042. instance?: LinesMesh;
  54043. }, scene?: Nullable<Scene>): LinesMesh;
  54044. /**
  54045. * 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.
  54046. * * 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.
  54047. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54048. * * 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.
  54049. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54050. * * 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
  54051. * * 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
  54052. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54054. * * 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
  54055. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54057. * @param name defines the name of the mesh
  54058. * @param options defines the options used to create the mesh
  54059. * @param scene defines the hosting scene
  54060. * @returns the extruded shape mesh
  54061. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54062. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54063. */
  54064. static ExtrudeShape(name: string, options: {
  54065. shape: Vector3[];
  54066. path: Vector3[];
  54067. scale?: number;
  54068. rotation?: number;
  54069. cap?: number;
  54070. updatable?: boolean;
  54071. sideOrientation?: number;
  54072. frontUVs?: Vector4;
  54073. backUVs?: Vector4;
  54074. instance?: Mesh;
  54075. invertUV?: boolean;
  54076. }, scene?: Nullable<Scene>): Mesh;
  54077. /**
  54078. * Creates an custom extruded shape mesh.
  54079. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54080. * * 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.
  54081. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54082. * * 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
  54083. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54084. * * 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
  54085. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54086. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54087. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54088. * * 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
  54089. * * 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
  54090. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54092. * * 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
  54093. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54095. * @param name defines the name of the mesh
  54096. * @param options defines the options used to create the mesh
  54097. * @param scene defines the hosting scene
  54098. * @returns the custom extruded shape mesh
  54099. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54100. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54101. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54102. */
  54103. static ExtrudeShapeCustom(name: string, options: {
  54104. shape: Vector3[];
  54105. path: Vector3[];
  54106. scaleFunction?: any;
  54107. rotationFunction?: any;
  54108. ribbonCloseArray?: boolean;
  54109. ribbonClosePath?: boolean;
  54110. cap?: number;
  54111. updatable?: boolean;
  54112. sideOrientation?: number;
  54113. frontUVs?: Vector4;
  54114. backUVs?: Vector4;
  54115. instance?: Mesh;
  54116. invertUV?: boolean;
  54117. }, scene?: Nullable<Scene>): Mesh;
  54118. /**
  54119. * Creates lathe mesh.
  54120. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54121. * * 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
  54122. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54123. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54124. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54125. * * 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
  54126. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54127. * * 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
  54128. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54129. * * 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
  54130. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54132. * @param name defines the name of the mesh
  54133. * @param options defines the options used to create the mesh
  54134. * @param scene defines the hosting scene
  54135. * @returns the lathe mesh
  54136. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54137. */
  54138. static CreateLathe(name: string, options: {
  54139. shape: Vector3[];
  54140. radius?: number;
  54141. tessellation?: number;
  54142. clip?: number;
  54143. arc?: number;
  54144. closed?: boolean;
  54145. updatable?: boolean;
  54146. sideOrientation?: number;
  54147. frontUVs?: Vector4;
  54148. backUVs?: Vector4;
  54149. cap?: number;
  54150. invertUV?: boolean;
  54151. }, scene?: Nullable<Scene>): Mesh;
  54152. /**
  54153. * Creates a tiled plane mesh
  54154. * * You can set a limited pattern arrangement with the tiles
  54155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54156. * * 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
  54157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54158. * @param name defines the name of the mesh
  54159. * @param options defines the options used to create the mesh
  54160. * @param scene defines the hosting scene
  54161. * @returns the plane mesh
  54162. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  54163. */
  54164. static CreateTiledPlane(name: string, options: {
  54165. pattern?: number;
  54166. tileSize?: number;
  54167. tileWidth?: number;
  54168. tileHeight?: number;
  54169. size?: number;
  54170. width?: number;
  54171. height?: number;
  54172. alignHorizontal?: number;
  54173. alignVertical?: number;
  54174. sideOrientation?: number;
  54175. frontUVs?: Vector4;
  54176. backUVs?: Vector4;
  54177. updatable?: boolean;
  54178. }, scene?: Nullable<Scene>): Mesh;
  54179. /**
  54180. * Creates a plane mesh
  54181. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  54182. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  54183. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  54184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54185. * * 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
  54186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54187. * @param name defines the name of the mesh
  54188. * @param options defines the options used to create the mesh
  54189. * @param scene defines the hosting scene
  54190. * @returns the plane mesh
  54191. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  54192. */
  54193. static CreatePlane(name: string, options: {
  54194. size?: number;
  54195. width?: number;
  54196. height?: number;
  54197. sideOrientation?: number;
  54198. frontUVs?: Vector4;
  54199. backUVs?: Vector4;
  54200. updatable?: boolean;
  54201. sourcePlane?: Plane;
  54202. }, scene?: Nullable<Scene>): Mesh;
  54203. /**
  54204. * Creates a ground mesh
  54205. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  54206. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  54207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54208. * @param name defines the name of the mesh
  54209. * @param options defines the options used to create the mesh
  54210. * @param scene defines the hosting scene
  54211. * @returns the ground mesh
  54212. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  54213. */
  54214. static CreateGround(name: string, options: {
  54215. width?: number;
  54216. height?: number;
  54217. subdivisions?: number;
  54218. subdivisionsX?: number;
  54219. subdivisionsY?: number;
  54220. updatable?: boolean;
  54221. }, scene?: Nullable<Scene>): Mesh;
  54222. /**
  54223. * Creates a tiled ground mesh
  54224. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  54225. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  54226. * * 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
  54227. * * 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
  54228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54229. * @param name defines the name of the mesh
  54230. * @param options defines the options used to create the mesh
  54231. * @param scene defines the hosting scene
  54232. * @returns the tiled ground mesh
  54233. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  54234. */
  54235. static CreateTiledGround(name: string, options: {
  54236. xmin: number;
  54237. zmin: number;
  54238. xmax: number;
  54239. zmax: number;
  54240. subdivisions?: {
  54241. w: number;
  54242. h: number;
  54243. };
  54244. precision?: {
  54245. w: number;
  54246. h: number;
  54247. };
  54248. updatable?: boolean;
  54249. }, scene?: Nullable<Scene>): Mesh;
  54250. /**
  54251. * Creates a ground mesh from a height map
  54252. * * The parameter `url` sets the URL of the height map image resource.
  54253. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  54254. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  54255. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  54256. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  54257. * * 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.
  54258. * * 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).
  54259. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  54260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54261. * @param name defines the name of the mesh
  54262. * @param url defines the url to the height map
  54263. * @param options defines the options used to create the mesh
  54264. * @param scene defines the hosting scene
  54265. * @returns the ground mesh
  54266. * @see https://doc.babylonjs.com/babylon101/height_map
  54267. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  54268. */
  54269. static CreateGroundFromHeightMap(name: string, url: string, options: {
  54270. width?: number;
  54271. height?: number;
  54272. subdivisions?: number;
  54273. minHeight?: number;
  54274. maxHeight?: number;
  54275. colorFilter?: Color3;
  54276. alphaFilter?: number;
  54277. updatable?: boolean;
  54278. onReady?: (mesh: GroundMesh) => void;
  54279. }, scene?: Nullable<Scene>): GroundMesh;
  54280. /**
  54281. * Creates a polygon mesh
  54282. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54283. * * 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
  54284. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54286. * * 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)
  54287. * * Remember you can only change the shape positions, not their number when updating a polygon
  54288. * @param name defines the name of the mesh
  54289. * @param options defines the options used to create the mesh
  54290. * @param scene defines the hosting scene
  54291. * @param earcutInjection can be used to inject your own earcut reference
  54292. * @returns the polygon mesh
  54293. */
  54294. static CreatePolygon(name: string, options: {
  54295. shape: Vector3[];
  54296. holes?: Vector3[][];
  54297. depth?: number;
  54298. faceUV?: Vector4[];
  54299. faceColors?: Color4[];
  54300. updatable?: boolean;
  54301. sideOrientation?: number;
  54302. frontUVs?: Vector4;
  54303. backUVs?: Vector4;
  54304. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54305. /**
  54306. * Creates an extruded polygon mesh, with depth in the Y direction.
  54307. * * 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)
  54308. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54309. * @param name defines the name of the mesh
  54310. * @param options defines the options used to create the mesh
  54311. * @param scene defines the hosting scene
  54312. * @param earcutInjection can be used to inject your own earcut reference
  54313. * @returns the polygon mesh
  54314. */
  54315. static ExtrudePolygon(name: string, options: {
  54316. shape: Vector3[];
  54317. holes?: Vector3[][];
  54318. depth?: number;
  54319. faceUV?: Vector4[];
  54320. faceColors?: Color4[];
  54321. updatable?: boolean;
  54322. sideOrientation?: number;
  54323. frontUVs?: Vector4;
  54324. backUVs?: Vector4;
  54325. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54326. /**
  54327. * Creates a tube mesh.
  54328. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54329. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  54330. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  54331. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  54332. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  54333. * * 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)
  54334. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  54335. * * 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
  54336. * * 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
  54337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54338. * * 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
  54339. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54341. * @param name defines the name of the mesh
  54342. * @param options defines the options used to create the mesh
  54343. * @param scene defines the hosting scene
  54344. * @returns the tube mesh
  54345. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54346. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  54347. */
  54348. static CreateTube(name: string, options: {
  54349. path: Vector3[];
  54350. radius?: number;
  54351. tessellation?: number;
  54352. radiusFunction?: {
  54353. (i: number, distance: number): number;
  54354. };
  54355. cap?: number;
  54356. arc?: number;
  54357. updatable?: boolean;
  54358. sideOrientation?: number;
  54359. frontUVs?: Vector4;
  54360. backUVs?: Vector4;
  54361. instance?: Mesh;
  54362. invertUV?: boolean;
  54363. }, scene?: Nullable<Scene>): Mesh;
  54364. /**
  54365. * Creates a polyhedron mesh
  54366. * * 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
  54367. * * The parameter `size` (positive float, default 1) sets the polygon size
  54368. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54369. * * 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`
  54370. * * 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
  54371. * * 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)`)
  54372. * * 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
  54373. * * 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
  54374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54375. * * 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
  54376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54377. * @param name defines the name of the mesh
  54378. * @param options defines the options used to create the mesh
  54379. * @param scene defines the hosting scene
  54380. * @returns the polyhedron mesh
  54381. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54382. */
  54383. static CreatePolyhedron(name: string, options: {
  54384. type?: number;
  54385. size?: number;
  54386. sizeX?: number;
  54387. sizeY?: number;
  54388. sizeZ?: number;
  54389. custom?: any;
  54390. faceUV?: Vector4[];
  54391. faceColors?: Color4[];
  54392. flat?: boolean;
  54393. updatable?: boolean;
  54394. sideOrientation?: number;
  54395. frontUVs?: Vector4;
  54396. backUVs?: Vector4;
  54397. }, scene?: Nullable<Scene>): Mesh;
  54398. /**
  54399. * Creates a decal mesh.
  54400. * 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
  54401. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  54402. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  54403. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  54404. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  54405. * @param name defines the name of the mesh
  54406. * @param sourceMesh defines the mesh where the decal must be applied
  54407. * @param options defines the options used to create the mesh
  54408. * @param scene defines the hosting scene
  54409. * @returns the decal mesh
  54410. * @see https://doc.babylonjs.com/how_to/decals
  54411. */
  54412. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  54413. position?: Vector3;
  54414. normal?: Vector3;
  54415. size?: Vector3;
  54416. angle?: number;
  54417. }): Mesh;
  54418. }
  54419. }
  54420. declare module BABYLON {
  54421. /**
  54422. * A simplifier interface for future simplification implementations
  54423. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54424. */
  54425. export interface ISimplifier {
  54426. /**
  54427. * Simplification of a given mesh according to the given settings.
  54428. * Since this requires computation, it is assumed that the function runs async.
  54429. * @param settings The settings of the simplification, including quality and distance
  54430. * @param successCallback A callback that will be called after the mesh was simplified.
  54431. * @param errorCallback in case of an error, this callback will be called. optional.
  54432. */
  54433. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  54434. }
  54435. /**
  54436. * Expected simplification settings.
  54437. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  54438. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54439. */
  54440. export interface ISimplificationSettings {
  54441. /**
  54442. * Gets or sets the expected quality
  54443. */
  54444. quality: number;
  54445. /**
  54446. * Gets or sets the distance when this optimized version should be used
  54447. */
  54448. distance: number;
  54449. /**
  54450. * Gets an already optimized mesh
  54451. */
  54452. optimizeMesh?: boolean;
  54453. }
  54454. /**
  54455. * Class used to specify simplification options
  54456. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54457. */
  54458. export class SimplificationSettings implements ISimplificationSettings {
  54459. /** expected quality */
  54460. quality: number;
  54461. /** distance when this optimized version should be used */
  54462. distance: number;
  54463. /** already optimized mesh */
  54464. optimizeMesh?: boolean | undefined;
  54465. /**
  54466. * Creates a SimplificationSettings
  54467. * @param quality expected quality
  54468. * @param distance distance when this optimized version should be used
  54469. * @param optimizeMesh already optimized mesh
  54470. */
  54471. constructor(
  54472. /** expected quality */
  54473. quality: number,
  54474. /** distance when this optimized version should be used */
  54475. distance: number,
  54476. /** already optimized mesh */
  54477. optimizeMesh?: boolean | undefined);
  54478. }
  54479. /**
  54480. * Interface used to define a simplification task
  54481. */
  54482. export interface ISimplificationTask {
  54483. /**
  54484. * Array of settings
  54485. */
  54486. settings: Array<ISimplificationSettings>;
  54487. /**
  54488. * Simplification type
  54489. */
  54490. simplificationType: SimplificationType;
  54491. /**
  54492. * Mesh to simplify
  54493. */
  54494. mesh: Mesh;
  54495. /**
  54496. * Callback called on success
  54497. */
  54498. successCallback?: () => void;
  54499. /**
  54500. * Defines if parallel processing can be used
  54501. */
  54502. parallelProcessing: boolean;
  54503. }
  54504. /**
  54505. * Queue used to order the simplification tasks
  54506. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54507. */
  54508. export class SimplificationQueue {
  54509. private _simplificationArray;
  54510. /**
  54511. * Gets a boolean indicating that the process is still running
  54512. */
  54513. running: boolean;
  54514. /**
  54515. * Creates a new queue
  54516. */
  54517. constructor();
  54518. /**
  54519. * Adds a new simplification task
  54520. * @param task defines a task to add
  54521. */
  54522. addTask(task: ISimplificationTask): void;
  54523. /**
  54524. * Execute next task
  54525. */
  54526. executeNext(): void;
  54527. /**
  54528. * Execute a simplification task
  54529. * @param task defines the task to run
  54530. */
  54531. runSimplification(task: ISimplificationTask): void;
  54532. private getSimplifier;
  54533. }
  54534. /**
  54535. * The implemented types of simplification
  54536. * At the moment only Quadratic Error Decimation is implemented
  54537. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54538. */
  54539. export enum SimplificationType {
  54540. /** Quadratic error decimation */
  54541. QUADRATIC = 0
  54542. }
  54543. }
  54544. declare module BABYLON {
  54545. interface Scene {
  54546. /** @hidden (Backing field) */
  54547. _simplificationQueue: SimplificationQueue;
  54548. /**
  54549. * Gets or sets the simplification queue attached to the scene
  54550. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54551. */
  54552. simplificationQueue: SimplificationQueue;
  54553. }
  54554. interface Mesh {
  54555. /**
  54556. * Simplify the mesh according to the given array of settings.
  54557. * Function will return immediately and will simplify async
  54558. * @param settings a collection of simplification settings
  54559. * @param parallelProcessing should all levels calculate parallel or one after the other
  54560. * @param simplificationType the type of simplification to run
  54561. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  54562. * @returns the current mesh
  54563. */
  54564. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  54565. }
  54566. /**
  54567. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  54568. * created in a scene
  54569. */
  54570. export class SimplicationQueueSceneComponent implements ISceneComponent {
  54571. /**
  54572. * The component name helpfull to identify the component in the list of scene components.
  54573. */
  54574. readonly name: string;
  54575. /**
  54576. * The scene the component belongs to.
  54577. */
  54578. scene: Scene;
  54579. /**
  54580. * Creates a new instance of the component for the given scene
  54581. * @param scene Defines the scene to register the component in
  54582. */
  54583. constructor(scene: Scene);
  54584. /**
  54585. * Registers the component in a given scene
  54586. */
  54587. register(): void;
  54588. /**
  54589. * Rebuilds the elements related to this component in case of
  54590. * context lost for instance.
  54591. */
  54592. rebuild(): void;
  54593. /**
  54594. * Disposes the component and the associated ressources
  54595. */
  54596. dispose(): void;
  54597. private _beforeCameraUpdate;
  54598. }
  54599. }
  54600. declare module BABYLON {
  54601. /**
  54602. * Navigation plugin interface to add navigation constrained by a navigation mesh
  54603. */
  54604. export interface INavigationEnginePlugin {
  54605. /**
  54606. * plugin name
  54607. */
  54608. name: string;
  54609. /**
  54610. * Creates a navigation mesh
  54611. * @param meshes array of all the geometry used to compute the navigatio mesh
  54612. * @param parameters bunch of parameters used to filter geometry
  54613. */
  54614. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  54615. /**
  54616. * Create a navigation mesh debug mesh
  54617. * @param scene is where the mesh will be added
  54618. * @returns debug display mesh
  54619. */
  54620. createDebugNavMesh(scene: Scene): Mesh;
  54621. /**
  54622. * Get a navigation mesh constrained position, closest to the parameter position
  54623. * @param position world position
  54624. * @returns the closest point to position constrained by the navigation mesh
  54625. */
  54626. getClosestPoint(position: Vector3): Vector3;
  54627. /**
  54628. * Get a navigation mesh constrained position, within a particular radius
  54629. * @param position world position
  54630. * @param maxRadius the maximum distance to the constrained world position
  54631. * @returns the closest point to position constrained by the navigation mesh
  54632. */
  54633. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  54634. /**
  54635. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  54636. * @param start world position
  54637. * @param end world position
  54638. * @returns array containing world position composing the path
  54639. */
  54640. computePath(start: Vector3, end: Vector3): Vector3[];
  54641. /**
  54642. * If this plugin is supported
  54643. * @returns true if plugin is supported
  54644. */
  54645. isSupported(): boolean;
  54646. /**
  54647. * Create a new Crowd so you can add agents
  54648. * @param maxAgents the maximum agent count in the crowd
  54649. * @param maxAgentRadius the maximum radius an agent can have
  54650. * @param scene to attach the crowd to
  54651. * @returns the crowd you can add agents to
  54652. */
  54653. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  54654. /**
  54655. * Release all resources
  54656. */
  54657. dispose(): void;
  54658. }
  54659. /**
  54660. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  54661. */
  54662. export interface ICrowd {
  54663. /**
  54664. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  54665. * You can attach anything to that node. The node position is updated in the scene update tick.
  54666. * @param pos world position that will be constrained by the navigation mesh
  54667. * @param parameters agent parameters
  54668. * @param transform hooked to the agent that will be update by the scene
  54669. * @returns agent index
  54670. */
  54671. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  54672. /**
  54673. * Returns the agent position in world space
  54674. * @param index agent index returned by addAgent
  54675. * @returns world space position
  54676. */
  54677. getAgentPosition(index: number): Vector3;
  54678. /**
  54679. * Gets the agent velocity in world space
  54680. * @param index agent index returned by addAgent
  54681. * @returns world space velocity
  54682. */
  54683. getAgentVelocity(index: number): Vector3;
  54684. /**
  54685. * remove a particular agent previously created
  54686. * @param index agent index returned by addAgent
  54687. */
  54688. removeAgent(index: number): void;
  54689. /**
  54690. * get the list of all agents attached to this crowd
  54691. * @returns list of agent indices
  54692. */
  54693. getAgents(): number[];
  54694. /**
  54695. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  54696. * @param deltaTime in seconds
  54697. */
  54698. update(deltaTime: number): void;
  54699. /**
  54700. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  54701. * @param index agent index returned by addAgent
  54702. * @param destination targeted world position
  54703. */
  54704. agentGoto(index: number, destination: Vector3): void;
  54705. /**
  54706. * Release all resources
  54707. */
  54708. dispose(): void;
  54709. }
  54710. /**
  54711. * Configures an agent
  54712. */
  54713. export interface IAgentParameters {
  54714. /**
  54715. * Agent radius. [Limit: >= 0]
  54716. */
  54717. radius: number;
  54718. /**
  54719. * Agent height. [Limit: > 0]
  54720. */
  54721. height: number;
  54722. /**
  54723. * Maximum allowed acceleration. [Limit: >= 0]
  54724. */
  54725. maxAcceleration: number;
  54726. /**
  54727. * Maximum allowed speed. [Limit: >= 0]
  54728. */
  54729. maxSpeed: number;
  54730. /**
  54731. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  54732. */
  54733. collisionQueryRange: number;
  54734. /**
  54735. * The path visibility optimization range. [Limit: > 0]
  54736. */
  54737. pathOptimizationRange: number;
  54738. /**
  54739. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  54740. */
  54741. separationWeight: number;
  54742. }
  54743. /**
  54744. * Configures the navigation mesh creation
  54745. */
  54746. export interface INavMeshParameters {
  54747. /**
  54748. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  54749. */
  54750. cs: number;
  54751. /**
  54752. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  54753. */
  54754. ch: number;
  54755. /**
  54756. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  54757. */
  54758. walkableSlopeAngle: number;
  54759. /**
  54760. * Minimum floor to 'ceiling' height that will still allow the floor area to
  54761. * be considered walkable. [Limit: >= 3] [Units: vx]
  54762. */
  54763. walkableHeight: number;
  54764. /**
  54765. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  54766. */
  54767. walkableClimb: number;
  54768. /**
  54769. * The distance to erode/shrink the walkable area of the heightfield away from
  54770. * obstructions. [Limit: >=0] [Units: vx]
  54771. */
  54772. walkableRadius: number;
  54773. /**
  54774. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  54775. */
  54776. maxEdgeLen: number;
  54777. /**
  54778. * The maximum distance a simplfied contour's border edges should deviate
  54779. * the original raw contour. [Limit: >=0] [Units: vx]
  54780. */
  54781. maxSimplificationError: number;
  54782. /**
  54783. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  54784. */
  54785. minRegionArea: number;
  54786. /**
  54787. * Any regions with a span count smaller than this value will, if possible,
  54788. * be merged with larger regions. [Limit: >=0] [Units: vx]
  54789. */
  54790. mergeRegionArea: number;
  54791. /**
  54792. * The maximum number of vertices allowed for polygons generated during the
  54793. * contour to polygon conversion process. [Limit: >= 3]
  54794. */
  54795. maxVertsPerPoly: number;
  54796. /**
  54797. * Sets the sampling distance to use when generating the detail mesh.
  54798. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  54799. */
  54800. detailSampleDist: number;
  54801. /**
  54802. * The maximum distance the detail mesh surface should deviate from heightfield
  54803. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  54804. */
  54805. detailSampleMaxError: number;
  54806. }
  54807. }
  54808. declare module BABYLON {
  54809. /**
  54810. * RecastJS navigation plugin
  54811. */
  54812. export class RecastJSPlugin implements INavigationEnginePlugin {
  54813. /**
  54814. * Reference to the Recast library
  54815. */
  54816. bjsRECAST: any;
  54817. /**
  54818. * plugin name
  54819. */
  54820. name: string;
  54821. /**
  54822. * the first navmesh created. We might extend this to support multiple navmeshes
  54823. */
  54824. navMesh: any;
  54825. /**
  54826. * Initializes the recastJS plugin
  54827. * @param recastInjection can be used to inject your own recast reference
  54828. */
  54829. constructor(recastInjection?: any);
  54830. /**
  54831. * Creates a navigation mesh
  54832. * @param meshes array of all the geometry used to compute the navigatio mesh
  54833. * @param parameters bunch of parameters used to filter geometry
  54834. */
  54835. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  54836. /**
  54837. * Create a navigation mesh debug mesh
  54838. * @param scene is where the mesh will be added
  54839. * @returns debug display mesh
  54840. */
  54841. createDebugNavMesh(scene: Scene): Mesh;
  54842. /**
  54843. * Get a navigation mesh constrained position, closest to the parameter position
  54844. * @param position world position
  54845. * @returns the closest point to position constrained by the navigation mesh
  54846. */
  54847. getClosestPoint(position: Vector3): Vector3;
  54848. /**
  54849. * Get a navigation mesh constrained position, within a particular radius
  54850. * @param position world position
  54851. * @param maxRadius the maximum distance to the constrained world position
  54852. * @returns the closest point to position constrained by the navigation mesh
  54853. */
  54854. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  54855. /**
  54856. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  54857. * @param start world position
  54858. * @param end world position
  54859. * @returns array containing world position composing the path
  54860. */
  54861. computePath(start: Vector3, end: Vector3): Vector3[];
  54862. /**
  54863. * Create a new Crowd so you can add agents
  54864. * @param maxAgents the maximum agent count in the crowd
  54865. * @param maxAgentRadius the maximum radius an agent can have
  54866. * @param scene to attach the crowd to
  54867. * @returns the crowd you can add agents to
  54868. */
  54869. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  54870. /**
  54871. * Disposes
  54872. */
  54873. dispose(): void;
  54874. /**
  54875. * If this plugin is supported
  54876. * @returns true if plugin is supported
  54877. */
  54878. isSupported(): boolean;
  54879. }
  54880. /**
  54881. * Recast detour crowd implementation
  54882. */
  54883. export class RecastJSCrowd implements ICrowd {
  54884. /**
  54885. * Recast/detour plugin
  54886. */
  54887. bjsRECASTPlugin: RecastJSPlugin;
  54888. /**
  54889. * Link to the detour crowd
  54890. */
  54891. recastCrowd: any;
  54892. /**
  54893. * One transform per agent
  54894. */
  54895. transforms: TransformNode[];
  54896. /**
  54897. * All agents created
  54898. */
  54899. agents: number[];
  54900. /**
  54901. * Link to the scene is kept to unregister the crowd from the scene
  54902. */
  54903. private _scene;
  54904. /**
  54905. * Observer for crowd updates
  54906. */
  54907. private _onBeforeAnimationsObserver;
  54908. /**
  54909. * Constructor
  54910. * @param plugin recastJS plugin
  54911. * @param maxAgents the maximum agent count in the crowd
  54912. * @param maxAgentRadius the maximum radius an agent can have
  54913. * @param scene to attach the crowd to
  54914. * @returns the crowd you can add agents to
  54915. */
  54916. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  54917. /**
  54918. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  54919. * You can attach anything to that node. The node position is updated in the scene update tick.
  54920. * @param pos world position that will be constrained by the navigation mesh
  54921. * @param parameters agent parameters
  54922. * @param transform hooked to the agent that will be update by the scene
  54923. * @returns agent index
  54924. */
  54925. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  54926. /**
  54927. * Returns the agent position in world space
  54928. * @param index agent index returned by addAgent
  54929. * @returns world space position
  54930. */
  54931. getAgentPosition(index: number): Vector3;
  54932. /**
  54933. * Returns the agent velocity in world space
  54934. * @param index agent index returned by addAgent
  54935. * @returns world space velocity
  54936. */
  54937. getAgentVelocity(index: number): Vector3;
  54938. /**
  54939. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  54940. * @param index agent index returned by addAgent
  54941. * @param destination targeted world position
  54942. */
  54943. agentGoto(index: number, destination: Vector3): void;
  54944. /**
  54945. * remove a particular agent previously created
  54946. * @param index agent index returned by addAgent
  54947. */
  54948. removeAgent(index: number): void;
  54949. /**
  54950. * get the list of all agents attached to this crowd
  54951. * @returns list of agent indices
  54952. */
  54953. getAgents(): number[];
  54954. /**
  54955. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  54956. * @param deltaTime in seconds
  54957. */
  54958. update(deltaTime: number): void;
  54959. /**
  54960. * Release all resources
  54961. */
  54962. dispose(): void;
  54963. }
  54964. }
  54965. declare module BABYLON {
  54966. /**
  54967. * Class used to enable access to IndexedDB
  54968. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  54969. */
  54970. export class Database implements IOfflineProvider {
  54971. private _callbackManifestChecked;
  54972. private _currentSceneUrl;
  54973. private _db;
  54974. private _enableSceneOffline;
  54975. private _enableTexturesOffline;
  54976. private _manifestVersionFound;
  54977. private _mustUpdateRessources;
  54978. private _hasReachedQuota;
  54979. private _isSupported;
  54980. private _idbFactory;
  54981. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  54982. private static IsUASupportingBlobStorage;
  54983. /**
  54984. * Gets a boolean indicating if Database storate is enabled (off by default)
  54985. */
  54986. static IDBStorageEnabled: boolean;
  54987. /**
  54988. * Gets a boolean indicating if scene must be saved in the database
  54989. */
  54990. readonly enableSceneOffline: boolean;
  54991. /**
  54992. * Gets a boolean indicating if textures must be saved in the database
  54993. */
  54994. readonly enableTexturesOffline: boolean;
  54995. /**
  54996. * Creates a new Database
  54997. * @param urlToScene defines the url to load the scene
  54998. * @param callbackManifestChecked defines the callback to use when manifest is checked
  54999. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  55000. */
  55001. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  55002. private static _ParseURL;
  55003. private static _ReturnFullUrlLocation;
  55004. private _checkManifestFile;
  55005. /**
  55006. * Open the database and make it available
  55007. * @param successCallback defines the callback to call on success
  55008. * @param errorCallback defines the callback to call on error
  55009. */
  55010. open(successCallback: () => void, errorCallback: () => void): void;
  55011. /**
  55012. * Loads an image from the database
  55013. * @param url defines the url to load from
  55014. * @param image defines the target DOM image
  55015. */
  55016. loadImage(url: string, image: HTMLImageElement): void;
  55017. private _loadImageFromDBAsync;
  55018. private _saveImageIntoDBAsync;
  55019. private _checkVersionFromDB;
  55020. private _loadVersionFromDBAsync;
  55021. private _saveVersionIntoDBAsync;
  55022. /**
  55023. * Loads a file from database
  55024. * @param url defines the URL to load from
  55025. * @param sceneLoaded defines a callback to call on success
  55026. * @param progressCallBack defines a callback to call when progress changed
  55027. * @param errorCallback defines a callback to call on error
  55028. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  55029. */
  55030. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  55031. private _loadFileAsync;
  55032. private _saveFileAsync;
  55033. /**
  55034. * Validates if xhr data is correct
  55035. * @param xhr defines the request to validate
  55036. * @param dataType defines the expected data type
  55037. * @returns true if data is correct
  55038. */
  55039. private static _ValidateXHRData;
  55040. }
  55041. }
  55042. declare module BABYLON {
  55043. /** @hidden */
  55044. export var gpuUpdateParticlesPixelShader: {
  55045. name: string;
  55046. shader: string;
  55047. };
  55048. }
  55049. declare module BABYLON {
  55050. /** @hidden */
  55051. export var gpuUpdateParticlesVertexShader: {
  55052. name: string;
  55053. shader: string;
  55054. };
  55055. }
  55056. declare module BABYLON {
  55057. /** @hidden */
  55058. export var clipPlaneFragmentDeclaration2: {
  55059. name: string;
  55060. shader: string;
  55061. };
  55062. }
  55063. declare module BABYLON {
  55064. /** @hidden */
  55065. export var gpuRenderParticlesPixelShader: {
  55066. name: string;
  55067. shader: string;
  55068. };
  55069. }
  55070. declare module BABYLON {
  55071. /** @hidden */
  55072. export var clipPlaneVertexDeclaration2: {
  55073. name: string;
  55074. shader: string;
  55075. };
  55076. }
  55077. declare module BABYLON {
  55078. /** @hidden */
  55079. export var gpuRenderParticlesVertexShader: {
  55080. name: string;
  55081. shader: string;
  55082. };
  55083. }
  55084. declare module BABYLON {
  55085. /**
  55086. * This represents a GPU particle system in Babylon
  55087. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  55088. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  55089. */
  55090. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  55091. /**
  55092. * The layer mask we are rendering the particles through.
  55093. */
  55094. layerMask: number;
  55095. private _capacity;
  55096. private _activeCount;
  55097. private _currentActiveCount;
  55098. private _accumulatedCount;
  55099. private _renderEffect;
  55100. private _updateEffect;
  55101. private _buffer0;
  55102. private _buffer1;
  55103. private _spriteBuffer;
  55104. private _updateVAO;
  55105. private _renderVAO;
  55106. private _targetIndex;
  55107. private _sourceBuffer;
  55108. private _targetBuffer;
  55109. private _engine;
  55110. private _currentRenderId;
  55111. private _started;
  55112. private _stopped;
  55113. private _timeDelta;
  55114. private _randomTexture;
  55115. private _randomTexture2;
  55116. private _attributesStrideSize;
  55117. private _updateEffectOptions;
  55118. private _randomTextureSize;
  55119. private _actualFrame;
  55120. private readonly _rawTextureWidth;
  55121. /**
  55122. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  55123. */
  55124. static readonly IsSupported: boolean;
  55125. /**
  55126. * An event triggered when the system is disposed.
  55127. */
  55128. onDisposeObservable: Observable<GPUParticleSystem>;
  55129. /**
  55130. * Gets the maximum number of particles active at the same time.
  55131. * @returns The max number of active particles.
  55132. */
  55133. getCapacity(): number;
  55134. /**
  55135. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  55136. * to override the particles.
  55137. */
  55138. forceDepthWrite: boolean;
  55139. /**
  55140. * Gets or set the number of active particles
  55141. */
  55142. activeParticleCount: number;
  55143. private _preWarmDone;
  55144. /**
  55145. * Is this system ready to be used/rendered
  55146. * @return true if the system is ready
  55147. */
  55148. isReady(): boolean;
  55149. /**
  55150. * Gets if the system has been started. (Note: this will still be true after stop is called)
  55151. * @returns True if it has been started, otherwise false.
  55152. */
  55153. isStarted(): boolean;
  55154. /**
  55155. * Starts the particle system and begins to emit
  55156. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  55157. */
  55158. start(delay?: number): void;
  55159. /**
  55160. * Stops the particle system.
  55161. */
  55162. stop(): void;
  55163. /**
  55164. * Remove all active particles
  55165. */
  55166. reset(): void;
  55167. /**
  55168. * Returns the string "GPUParticleSystem"
  55169. * @returns a string containing the class name
  55170. */
  55171. getClassName(): string;
  55172. private _colorGradientsTexture;
  55173. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  55174. /**
  55175. * Adds a new color gradient
  55176. * @param gradient defines the gradient to use (between 0 and 1)
  55177. * @param color1 defines the color to affect to the specified gradient
  55178. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  55179. * @returns the current particle system
  55180. */
  55181. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  55182. /**
  55183. * Remove a specific color gradient
  55184. * @param gradient defines the gradient to remove
  55185. * @returns the current particle system
  55186. */
  55187. removeColorGradient(gradient: number): GPUParticleSystem;
  55188. private _angularSpeedGradientsTexture;
  55189. private _sizeGradientsTexture;
  55190. private _velocityGradientsTexture;
  55191. private _limitVelocityGradientsTexture;
  55192. private _dragGradientsTexture;
  55193. private _addFactorGradient;
  55194. /**
  55195. * Adds a new size gradient
  55196. * @param gradient defines the gradient to use (between 0 and 1)
  55197. * @param factor defines the size factor to affect to the specified gradient
  55198. * @returns the current particle system
  55199. */
  55200. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  55201. /**
  55202. * Remove a specific size gradient
  55203. * @param gradient defines the gradient to remove
  55204. * @returns the current particle system
  55205. */
  55206. removeSizeGradient(gradient: number): GPUParticleSystem;
  55207. /**
  55208. * Adds a new angular speed gradient
  55209. * @param gradient defines the gradient to use (between 0 and 1)
  55210. * @param factor defines the angular speed to affect to the specified gradient
  55211. * @returns the current particle system
  55212. */
  55213. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  55214. /**
  55215. * Remove a specific angular speed gradient
  55216. * @param gradient defines the gradient to remove
  55217. * @returns the current particle system
  55218. */
  55219. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  55220. /**
  55221. * Adds a new velocity gradient
  55222. * @param gradient defines the gradient to use (between 0 and 1)
  55223. * @param factor defines the velocity to affect to the specified gradient
  55224. * @returns the current particle system
  55225. */
  55226. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  55227. /**
  55228. * Remove a specific velocity gradient
  55229. * @param gradient defines the gradient to remove
  55230. * @returns the current particle system
  55231. */
  55232. removeVelocityGradient(gradient: number): GPUParticleSystem;
  55233. /**
  55234. * Adds a new limit velocity gradient
  55235. * @param gradient defines the gradient to use (between 0 and 1)
  55236. * @param factor defines the limit velocity value to affect to the specified gradient
  55237. * @returns the current particle system
  55238. */
  55239. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  55240. /**
  55241. * Remove a specific limit velocity gradient
  55242. * @param gradient defines the gradient to remove
  55243. * @returns the current particle system
  55244. */
  55245. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  55246. /**
  55247. * Adds a new drag gradient
  55248. * @param gradient defines the gradient to use (between 0 and 1)
  55249. * @param factor defines the drag value to affect to the specified gradient
  55250. * @returns the current particle system
  55251. */
  55252. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  55253. /**
  55254. * Remove a specific drag gradient
  55255. * @param gradient defines the gradient to remove
  55256. * @returns the current particle system
  55257. */
  55258. removeDragGradient(gradient: number): GPUParticleSystem;
  55259. /**
  55260. * Not supported by GPUParticleSystem
  55261. * @param gradient defines the gradient to use (between 0 and 1)
  55262. * @param factor defines the emit rate value to affect to the specified gradient
  55263. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55264. * @returns the current particle system
  55265. */
  55266. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55267. /**
  55268. * Not supported by GPUParticleSystem
  55269. * @param gradient defines the gradient to remove
  55270. * @returns the current particle system
  55271. */
  55272. removeEmitRateGradient(gradient: number): IParticleSystem;
  55273. /**
  55274. * Not supported by GPUParticleSystem
  55275. * @param gradient defines the gradient to use (between 0 and 1)
  55276. * @param factor defines the start size value to affect to the specified gradient
  55277. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55278. * @returns the current particle system
  55279. */
  55280. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55281. /**
  55282. * Not supported by GPUParticleSystem
  55283. * @param gradient defines the gradient to remove
  55284. * @returns the current particle system
  55285. */
  55286. removeStartSizeGradient(gradient: number): IParticleSystem;
  55287. /**
  55288. * Not supported by GPUParticleSystem
  55289. * @param gradient defines the gradient to use (between 0 and 1)
  55290. * @param min defines the color remap minimal range
  55291. * @param max defines the color remap maximal range
  55292. * @returns the current particle system
  55293. */
  55294. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  55295. /**
  55296. * Not supported by GPUParticleSystem
  55297. * @param gradient defines the gradient to remove
  55298. * @returns the current particle system
  55299. */
  55300. removeColorRemapGradient(): IParticleSystem;
  55301. /**
  55302. * Not supported by GPUParticleSystem
  55303. * @param gradient defines the gradient to use (between 0 and 1)
  55304. * @param min defines the alpha remap minimal range
  55305. * @param max defines the alpha remap maximal range
  55306. * @returns the current particle system
  55307. */
  55308. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  55309. /**
  55310. * Not supported by GPUParticleSystem
  55311. * @param gradient defines the gradient to remove
  55312. * @returns the current particle system
  55313. */
  55314. removeAlphaRemapGradient(): IParticleSystem;
  55315. /**
  55316. * Not supported by GPUParticleSystem
  55317. * @param gradient defines the gradient to use (between 0 and 1)
  55318. * @param color defines the color to affect to the specified gradient
  55319. * @returns the current particle system
  55320. */
  55321. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  55322. /**
  55323. * Not supported by GPUParticleSystem
  55324. * @param gradient defines the gradient to remove
  55325. * @returns the current particle system
  55326. */
  55327. removeRampGradient(): IParticleSystem;
  55328. /**
  55329. * Not supported by GPUParticleSystem
  55330. * @returns the list of ramp gradients
  55331. */
  55332. getRampGradients(): Nullable<Array<Color3Gradient>>;
  55333. /**
  55334. * Not supported by GPUParticleSystem
  55335. * Gets or sets a boolean indicating that ramp gradients must be used
  55336. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  55337. */
  55338. useRampGradients: boolean;
  55339. /**
  55340. * Not supported by GPUParticleSystem
  55341. * @param gradient defines the gradient to use (between 0 and 1)
  55342. * @param factor defines the life time factor to affect to the specified gradient
  55343. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55344. * @returns the current particle system
  55345. */
  55346. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55347. /**
  55348. * Not supported by GPUParticleSystem
  55349. * @param gradient defines the gradient to remove
  55350. * @returns the current particle system
  55351. */
  55352. removeLifeTimeGradient(gradient: number): IParticleSystem;
  55353. /**
  55354. * Instantiates a GPU particle system.
  55355. * 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.
  55356. * @param name The name of the particle system
  55357. * @param options The options used to create the system
  55358. * @param scene The scene the particle system belongs to
  55359. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  55360. */
  55361. constructor(name: string, options: Partial<{
  55362. capacity: number;
  55363. randomTextureSize: number;
  55364. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  55365. protected _reset(): void;
  55366. private _createUpdateVAO;
  55367. private _createRenderVAO;
  55368. private _initialize;
  55369. /** @hidden */
  55370. _recreateUpdateEffect(): void;
  55371. /** @hidden */
  55372. _recreateRenderEffect(): void;
  55373. /**
  55374. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  55375. * @param preWarm defines if we are in the pre-warmimg phase
  55376. */
  55377. animate(preWarm?: boolean): void;
  55378. private _createFactorGradientTexture;
  55379. private _createSizeGradientTexture;
  55380. private _createAngularSpeedGradientTexture;
  55381. private _createVelocityGradientTexture;
  55382. private _createLimitVelocityGradientTexture;
  55383. private _createDragGradientTexture;
  55384. private _createColorGradientTexture;
  55385. /**
  55386. * Renders the particle system in its current state
  55387. * @param preWarm defines if the system should only update the particles but not render them
  55388. * @returns the current number of particles
  55389. */
  55390. render(preWarm?: boolean): number;
  55391. /**
  55392. * Rebuilds the particle system
  55393. */
  55394. rebuild(): void;
  55395. private _releaseBuffers;
  55396. private _releaseVAOs;
  55397. /**
  55398. * Disposes the particle system and free the associated resources
  55399. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  55400. */
  55401. dispose(disposeTexture?: boolean): void;
  55402. /**
  55403. * Clones the particle system.
  55404. * @param name The name of the cloned object
  55405. * @param newEmitter The new emitter to use
  55406. * @returns the cloned particle system
  55407. */
  55408. clone(name: string, newEmitter: any): GPUParticleSystem;
  55409. /**
  55410. * Serializes the particle system to a JSON object.
  55411. * @returns the JSON object
  55412. */
  55413. serialize(): any;
  55414. /**
  55415. * Parses a JSON object to create a GPU particle system.
  55416. * @param parsedParticleSystem The JSON object to parse
  55417. * @param scene The scene to create the particle system in
  55418. * @param rootUrl The root url to use to load external dependencies like texture
  55419. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  55420. * @returns the parsed GPU particle system
  55421. */
  55422. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  55423. }
  55424. }
  55425. declare module BABYLON {
  55426. /**
  55427. * Represents a set of particle systems working together to create a specific effect
  55428. */
  55429. export class ParticleSystemSet implements IDisposable {
  55430. private _emitterCreationOptions;
  55431. private _emitterNode;
  55432. /**
  55433. * Gets the particle system list
  55434. */
  55435. systems: IParticleSystem[];
  55436. /**
  55437. * Gets the emitter node used with this set
  55438. */
  55439. readonly emitterNode: Nullable<TransformNode>;
  55440. /**
  55441. * Creates a new emitter mesh as a sphere
  55442. * @param options defines the options used to create the sphere
  55443. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  55444. * @param scene defines the hosting scene
  55445. */
  55446. setEmitterAsSphere(options: {
  55447. diameter: number;
  55448. segments: number;
  55449. color: Color3;
  55450. }, renderingGroupId: number, scene: Scene): void;
  55451. /**
  55452. * Starts all particle systems of the set
  55453. * @param emitter defines an optional mesh to use as emitter for the particle systems
  55454. */
  55455. start(emitter?: AbstractMesh): void;
  55456. /**
  55457. * Release all associated resources
  55458. */
  55459. dispose(): void;
  55460. /**
  55461. * Serialize the set into a JSON compatible object
  55462. * @returns a JSON compatible representation of the set
  55463. */
  55464. serialize(): any;
  55465. /**
  55466. * Parse a new ParticleSystemSet from a serialized source
  55467. * @param data defines a JSON compatible representation of the set
  55468. * @param scene defines the hosting scene
  55469. * @param gpu defines if we want GPU particles or CPU particles
  55470. * @returns a new ParticleSystemSet
  55471. */
  55472. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  55473. }
  55474. }
  55475. declare module BABYLON {
  55476. /**
  55477. * This class is made for on one-liner static method to help creating particle system set.
  55478. */
  55479. export class ParticleHelper {
  55480. /**
  55481. * Gets or sets base Assets URL
  55482. */
  55483. static BaseAssetsUrl: string;
  55484. /**
  55485. * Create a default particle system that you can tweak
  55486. * @param emitter defines the emitter to use
  55487. * @param capacity defines the system capacity (default is 500 particles)
  55488. * @param scene defines the hosting scene
  55489. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  55490. * @returns the new Particle system
  55491. */
  55492. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  55493. /**
  55494. * This is the main static method (one-liner) of this helper to create different particle systems
  55495. * @param type This string represents the type to the particle system to create
  55496. * @param scene The scene where the particle system should live
  55497. * @param gpu If the system will use gpu
  55498. * @returns the ParticleSystemSet created
  55499. */
  55500. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  55501. /**
  55502. * Static function used to export a particle system to a ParticleSystemSet variable.
  55503. * Please note that the emitter shape is not exported
  55504. * @param systems defines the particle systems to export
  55505. * @returns the created particle system set
  55506. */
  55507. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  55508. }
  55509. }
  55510. declare module BABYLON {
  55511. interface Engine {
  55512. /**
  55513. * Create an effect to use with particle systems.
  55514. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  55515. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  55516. * @param uniformsNames defines a list of attribute names
  55517. * @param samplers defines an array of string used to represent textures
  55518. * @param defines defines the string containing the defines to use to compile the shaders
  55519. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  55520. * @param onCompiled defines a function to call when the effect creation is successful
  55521. * @param onError defines a function to call when the effect creation has failed
  55522. * @returns the new Effect
  55523. */
  55524. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  55525. }
  55526. interface Mesh {
  55527. /**
  55528. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  55529. * @returns an array of IParticleSystem
  55530. */
  55531. getEmittedParticleSystems(): IParticleSystem[];
  55532. /**
  55533. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  55534. * @returns an array of IParticleSystem
  55535. */
  55536. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  55537. }
  55538. /**
  55539. * @hidden
  55540. */
  55541. export var _IDoNeedToBeInTheBuild: number;
  55542. }
  55543. declare module BABYLON {
  55544. interface Scene {
  55545. /** @hidden (Backing field) */
  55546. _physicsEngine: Nullable<IPhysicsEngine>;
  55547. /**
  55548. * Gets the current physics engine
  55549. * @returns a IPhysicsEngine or null if none attached
  55550. */
  55551. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  55552. /**
  55553. * Enables physics to the current scene
  55554. * @param gravity defines the scene's gravity for the physics engine
  55555. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  55556. * @return a boolean indicating if the physics engine was initialized
  55557. */
  55558. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  55559. /**
  55560. * Disables and disposes the physics engine associated with the scene
  55561. */
  55562. disablePhysicsEngine(): void;
  55563. /**
  55564. * Gets a boolean indicating if there is an active physics engine
  55565. * @returns a boolean indicating if there is an active physics engine
  55566. */
  55567. isPhysicsEnabled(): boolean;
  55568. /**
  55569. * Deletes a physics compound impostor
  55570. * @param compound defines the compound to delete
  55571. */
  55572. deleteCompoundImpostor(compound: any): void;
  55573. /**
  55574. * An event triggered when physic simulation is about to be run
  55575. */
  55576. onBeforePhysicsObservable: Observable<Scene>;
  55577. /**
  55578. * An event triggered when physic simulation has been done
  55579. */
  55580. onAfterPhysicsObservable: Observable<Scene>;
  55581. }
  55582. interface AbstractMesh {
  55583. /** @hidden */
  55584. _physicsImpostor: Nullable<PhysicsImpostor>;
  55585. /**
  55586. * Gets or sets impostor used for physic simulation
  55587. * @see http://doc.babylonjs.com/features/physics_engine
  55588. */
  55589. physicsImpostor: Nullable<PhysicsImpostor>;
  55590. /**
  55591. * Gets the current physics impostor
  55592. * @see http://doc.babylonjs.com/features/physics_engine
  55593. * @returns a physics impostor or null
  55594. */
  55595. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  55596. /** Apply a physic impulse to the mesh
  55597. * @param force defines the force to apply
  55598. * @param contactPoint defines where to apply the force
  55599. * @returns the current mesh
  55600. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55601. */
  55602. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  55603. /**
  55604. * Creates a physic joint between two meshes
  55605. * @param otherMesh defines the other mesh to use
  55606. * @param pivot1 defines the pivot to use on this mesh
  55607. * @param pivot2 defines the pivot to use on the other mesh
  55608. * @param options defines additional options (can be plugin dependent)
  55609. * @returns the current mesh
  55610. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  55611. */
  55612. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  55613. /** @hidden */
  55614. _disposePhysicsObserver: Nullable<Observer<Node>>;
  55615. }
  55616. /**
  55617. * Defines the physics engine scene component responsible to manage a physics engine
  55618. */
  55619. export class PhysicsEngineSceneComponent implements ISceneComponent {
  55620. /**
  55621. * The component name helpful to identify the component in the list of scene components.
  55622. */
  55623. readonly name: string;
  55624. /**
  55625. * The scene the component belongs to.
  55626. */
  55627. scene: Scene;
  55628. /**
  55629. * Creates a new instance of the component for the given scene
  55630. * @param scene Defines the scene to register the component in
  55631. */
  55632. constructor(scene: Scene);
  55633. /**
  55634. * Registers the component in a given scene
  55635. */
  55636. register(): void;
  55637. /**
  55638. * Rebuilds the elements related to this component in case of
  55639. * context lost for instance.
  55640. */
  55641. rebuild(): void;
  55642. /**
  55643. * Disposes the component and the associated ressources
  55644. */
  55645. dispose(): void;
  55646. }
  55647. }
  55648. declare module BABYLON {
  55649. /**
  55650. * A helper for physics simulations
  55651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55652. */
  55653. export class PhysicsHelper {
  55654. private _scene;
  55655. private _physicsEngine;
  55656. /**
  55657. * Initializes the Physics helper
  55658. * @param scene Babylon.js scene
  55659. */
  55660. constructor(scene: Scene);
  55661. /**
  55662. * Applies a radial explosion impulse
  55663. * @param origin the origin of the explosion
  55664. * @param radiusOrEventOptions the radius or the options of radial explosion
  55665. * @param strength the explosion strength
  55666. * @param falloff possible options: Constant & Linear. Defaults to Constant
  55667. * @returns A physics radial explosion event, or null
  55668. */
  55669. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  55670. /**
  55671. * Applies a radial explosion force
  55672. * @param origin the origin of the explosion
  55673. * @param radiusOrEventOptions the radius or the options of radial explosion
  55674. * @param strength the explosion strength
  55675. * @param falloff possible options: Constant & Linear. Defaults to Constant
  55676. * @returns A physics radial explosion event, or null
  55677. */
  55678. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  55679. /**
  55680. * Creates a gravitational field
  55681. * @param origin the origin of the explosion
  55682. * @param radiusOrEventOptions the radius or the options of radial explosion
  55683. * @param strength the explosion strength
  55684. * @param falloff possible options: Constant & Linear. Defaults to Constant
  55685. * @returns A physics gravitational field event, or null
  55686. */
  55687. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  55688. /**
  55689. * Creates a physics updraft event
  55690. * @param origin the origin of the updraft
  55691. * @param radiusOrEventOptions the radius or the options of the updraft
  55692. * @param strength the strength of the updraft
  55693. * @param height the height of the updraft
  55694. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  55695. * @returns A physics updraft event, or null
  55696. */
  55697. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  55698. /**
  55699. * Creates a physics vortex event
  55700. * @param origin the of the vortex
  55701. * @param radiusOrEventOptions the radius or the options of the vortex
  55702. * @param strength the strength of the vortex
  55703. * @param height the height of the vortex
  55704. * @returns a Physics vortex event, or null
  55705. * A physics vortex event or null
  55706. */
  55707. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  55708. }
  55709. /**
  55710. * Represents a physics radial explosion event
  55711. */
  55712. class PhysicsRadialExplosionEvent {
  55713. private _scene;
  55714. private _options;
  55715. private _sphere;
  55716. private _dataFetched;
  55717. /**
  55718. * Initializes a radial explosioin event
  55719. * @param _scene BabylonJS scene
  55720. * @param _options The options for the vortex event
  55721. */
  55722. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  55723. /**
  55724. * Returns the data related to the radial explosion event (sphere).
  55725. * @returns The radial explosion event data
  55726. */
  55727. getData(): PhysicsRadialExplosionEventData;
  55728. /**
  55729. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  55730. * @param impostor A physics imposter
  55731. * @param origin the origin of the explosion
  55732. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  55733. */
  55734. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  55735. /**
  55736. * Triggers affecterd impostors callbacks
  55737. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  55738. */
  55739. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  55740. /**
  55741. * Disposes the sphere.
  55742. * @param force Specifies if the sphere should be disposed by force
  55743. */
  55744. dispose(force?: boolean): void;
  55745. /*** Helpers ***/
  55746. private _prepareSphere;
  55747. private _intersectsWithSphere;
  55748. }
  55749. /**
  55750. * Represents a gravitational field event
  55751. */
  55752. class PhysicsGravitationalFieldEvent {
  55753. private _physicsHelper;
  55754. private _scene;
  55755. private _origin;
  55756. private _options;
  55757. private _tickCallback;
  55758. private _sphere;
  55759. private _dataFetched;
  55760. /**
  55761. * Initializes the physics gravitational field event
  55762. * @param _physicsHelper A physics helper
  55763. * @param _scene BabylonJS scene
  55764. * @param _origin The origin position of the gravitational field event
  55765. * @param _options The options for the vortex event
  55766. */
  55767. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  55768. /**
  55769. * Returns the data related to the gravitational field event (sphere).
  55770. * @returns A gravitational field event
  55771. */
  55772. getData(): PhysicsGravitationalFieldEventData;
  55773. /**
  55774. * Enables the gravitational field.
  55775. */
  55776. enable(): void;
  55777. /**
  55778. * Disables the gravitational field.
  55779. */
  55780. disable(): void;
  55781. /**
  55782. * Disposes the sphere.
  55783. * @param force The force to dispose from the gravitational field event
  55784. */
  55785. dispose(force?: boolean): void;
  55786. private _tick;
  55787. }
  55788. /**
  55789. * Represents a physics updraft event
  55790. */
  55791. class PhysicsUpdraftEvent {
  55792. private _scene;
  55793. private _origin;
  55794. private _options;
  55795. private _physicsEngine;
  55796. private _originTop;
  55797. private _originDirection;
  55798. private _tickCallback;
  55799. private _cylinder;
  55800. private _cylinderPosition;
  55801. private _dataFetched;
  55802. /**
  55803. * Initializes the physics updraft event
  55804. * @param _scene BabylonJS scene
  55805. * @param _origin The origin position of the updraft
  55806. * @param _options The options for the updraft event
  55807. */
  55808. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  55809. /**
  55810. * Returns the data related to the updraft event (cylinder).
  55811. * @returns A physics updraft event
  55812. */
  55813. getData(): PhysicsUpdraftEventData;
  55814. /**
  55815. * Enables the updraft.
  55816. */
  55817. enable(): void;
  55818. /**
  55819. * Disables the updraft.
  55820. */
  55821. disable(): void;
  55822. /**
  55823. * Disposes the cylinder.
  55824. * @param force Specifies if the updraft should be disposed by force
  55825. */
  55826. dispose(force?: boolean): void;
  55827. private getImpostorHitData;
  55828. private _tick;
  55829. /*** Helpers ***/
  55830. private _prepareCylinder;
  55831. private _intersectsWithCylinder;
  55832. }
  55833. /**
  55834. * Represents a physics vortex event
  55835. */
  55836. class PhysicsVortexEvent {
  55837. private _scene;
  55838. private _origin;
  55839. private _options;
  55840. private _physicsEngine;
  55841. private _originTop;
  55842. private _tickCallback;
  55843. private _cylinder;
  55844. private _cylinderPosition;
  55845. private _dataFetched;
  55846. /**
  55847. * Initializes the physics vortex event
  55848. * @param _scene The BabylonJS scene
  55849. * @param _origin The origin position of the vortex
  55850. * @param _options The options for the vortex event
  55851. */
  55852. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  55853. /**
  55854. * Returns the data related to the vortex event (cylinder).
  55855. * @returns The physics vortex event data
  55856. */
  55857. getData(): PhysicsVortexEventData;
  55858. /**
  55859. * Enables the vortex.
  55860. */
  55861. enable(): void;
  55862. /**
  55863. * Disables the cortex.
  55864. */
  55865. disable(): void;
  55866. /**
  55867. * Disposes the sphere.
  55868. * @param force
  55869. */
  55870. dispose(force?: boolean): void;
  55871. private getImpostorHitData;
  55872. private _tick;
  55873. /*** Helpers ***/
  55874. private _prepareCylinder;
  55875. private _intersectsWithCylinder;
  55876. }
  55877. /**
  55878. * Options fot the radial explosion event
  55879. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55880. */
  55881. export class PhysicsRadialExplosionEventOptions {
  55882. /**
  55883. * The radius of the sphere for the radial explosion.
  55884. */
  55885. radius: number;
  55886. /**
  55887. * The strenth of the explosion.
  55888. */
  55889. strength: number;
  55890. /**
  55891. * The strenght of the force in correspondence to the distance of the affected object
  55892. */
  55893. falloff: PhysicsRadialImpulseFalloff;
  55894. /**
  55895. * Sphere options for the radial explosion.
  55896. */
  55897. sphere: {
  55898. segments: number;
  55899. diameter: number;
  55900. };
  55901. /**
  55902. * Sphere options for the radial explosion.
  55903. */
  55904. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  55905. }
  55906. /**
  55907. * Options fot the updraft event
  55908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55909. */
  55910. export class PhysicsUpdraftEventOptions {
  55911. /**
  55912. * The radius of the cylinder for the vortex
  55913. */
  55914. radius: number;
  55915. /**
  55916. * The strenth of the updraft.
  55917. */
  55918. strength: number;
  55919. /**
  55920. * The height of the cylinder for the updraft.
  55921. */
  55922. height: number;
  55923. /**
  55924. * The mode for the the updraft.
  55925. */
  55926. updraftMode: PhysicsUpdraftMode;
  55927. }
  55928. /**
  55929. * Options fot the vortex event
  55930. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55931. */
  55932. export class PhysicsVortexEventOptions {
  55933. /**
  55934. * The radius of the cylinder for the vortex
  55935. */
  55936. radius: number;
  55937. /**
  55938. * The strenth of the vortex.
  55939. */
  55940. strength: number;
  55941. /**
  55942. * The height of the cylinder for the vortex.
  55943. */
  55944. height: number;
  55945. /**
  55946. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  55947. */
  55948. centripetalForceThreshold: number;
  55949. /**
  55950. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  55951. */
  55952. centripetalForceMultiplier: number;
  55953. /**
  55954. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  55955. */
  55956. centrifugalForceMultiplier: number;
  55957. /**
  55958. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  55959. */
  55960. updraftForceMultiplier: number;
  55961. }
  55962. /**
  55963. * The strenght of the force in correspondence to the distance of the affected object
  55964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55965. */
  55966. export enum PhysicsRadialImpulseFalloff {
  55967. /** Defines that impulse is constant in strength across it's whole radius */
  55968. Constant = 0,
  55969. /** Defines that impulse gets weaker if it's further from the origin */
  55970. Linear = 1
  55971. }
  55972. /**
  55973. * The strength of the force in correspondence to the distance of the affected object
  55974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55975. */
  55976. export enum PhysicsUpdraftMode {
  55977. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  55978. Center = 0,
  55979. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  55980. Perpendicular = 1
  55981. }
  55982. /**
  55983. * Interface for a physics hit data
  55984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55985. */
  55986. export interface PhysicsHitData {
  55987. /**
  55988. * The force applied at the contact point
  55989. */
  55990. force: Vector3;
  55991. /**
  55992. * The contact point
  55993. */
  55994. contactPoint: Vector3;
  55995. /**
  55996. * The distance from the origin to the contact point
  55997. */
  55998. distanceFromOrigin: number;
  55999. }
  56000. /**
  56001. * Interface for radial explosion event data
  56002. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56003. */
  56004. export interface PhysicsRadialExplosionEventData {
  56005. /**
  56006. * A sphere used for the radial explosion event
  56007. */
  56008. sphere: Mesh;
  56009. }
  56010. /**
  56011. * Interface for gravitational field event data
  56012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56013. */
  56014. export interface PhysicsGravitationalFieldEventData {
  56015. /**
  56016. * A sphere mesh used for the gravitational field event
  56017. */
  56018. sphere: Mesh;
  56019. }
  56020. /**
  56021. * Interface for updraft event data
  56022. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56023. */
  56024. export interface PhysicsUpdraftEventData {
  56025. /**
  56026. * A cylinder used for the updraft event
  56027. */
  56028. cylinder: Mesh;
  56029. }
  56030. /**
  56031. * Interface for vortex event data
  56032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56033. */
  56034. export interface PhysicsVortexEventData {
  56035. /**
  56036. * A cylinder used for the vortex event
  56037. */
  56038. cylinder: Mesh;
  56039. }
  56040. /**
  56041. * Interface for an affected physics impostor
  56042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56043. */
  56044. export interface PhysicsAffectedImpostorWithData {
  56045. /**
  56046. * The impostor affected by the effect
  56047. */
  56048. impostor: PhysicsImpostor;
  56049. /**
  56050. * The data about the hit/horce from the explosion
  56051. */
  56052. hitData: PhysicsHitData;
  56053. }
  56054. }
  56055. declare module BABYLON {
  56056. /** @hidden */
  56057. export var blackAndWhitePixelShader: {
  56058. name: string;
  56059. shader: string;
  56060. };
  56061. }
  56062. declare module BABYLON {
  56063. /**
  56064. * Post process used to render in black and white
  56065. */
  56066. export class BlackAndWhitePostProcess extends PostProcess {
  56067. /**
  56068. * Linear about to convert he result to black and white (default: 1)
  56069. */
  56070. degree: number;
  56071. /**
  56072. * Creates a black and white post process
  56073. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  56074. * @param name The name of the effect.
  56075. * @param options The required width/height ratio to downsize to before computing the render pass.
  56076. * @param camera The camera to apply the render pass to.
  56077. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56078. * @param engine The engine which the post process will be applied. (default: current engine)
  56079. * @param reusable If the post process can be reused on the same frame. (default: false)
  56080. */
  56081. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56082. }
  56083. }
  56084. declare module BABYLON {
  56085. /**
  56086. * This represents a set of one or more post processes in Babylon.
  56087. * A post process can be used to apply a shader to a texture after it is rendered.
  56088. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56089. */
  56090. export class PostProcessRenderEffect {
  56091. private _postProcesses;
  56092. private _getPostProcesses;
  56093. private _singleInstance;
  56094. private _cameras;
  56095. private _indicesForCamera;
  56096. /**
  56097. * Name of the effect
  56098. * @hidden
  56099. */
  56100. _name: string;
  56101. /**
  56102. * Instantiates a post process render effect.
  56103. * A post process can be used to apply a shader to a texture after it is rendered.
  56104. * @param engine The engine the effect is tied to
  56105. * @param name The name of the effect
  56106. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  56107. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  56108. */
  56109. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  56110. /**
  56111. * Checks if all the post processes in the effect are supported.
  56112. */
  56113. readonly isSupported: boolean;
  56114. /**
  56115. * Updates the current state of the effect
  56116. * @hidden
  56117. */
  56118. _update(): void;
  56119. /**
  56120. * Attaches the effect on cameras
  56121. * @param cameras The camera to attach to.
  56122. * @hidden
  56123. */
  56124. _attachCameras(cameras: Camera): void;
  56125. /**
  56126. * Attaches the effect on cameras
  56127. * @param cameras The camera to attach to.
  56128. * @hidden
  56129. */
  56130. _attachCameras(cameras: Camera[]): void;
  56131. /**
  56132. * Detaches the effect on cameras
  56133. * @param cameras The camera to detatch from.
  56134. * @hidden
  56135. */
  56136. _detachCameras(cameras: Camera): void;
  56137. /**
  56138. * Detatches the effect on cameras
  56139. * @param cameras The camera to detatch from.
  56140. * @hidden
  56141. */
  56142. _detachCameras(cameras: Camera[]): void;
  56143. /**
  56144. * Enables the effect on given cameras
  56145. * @param cameras The camera to enable.
  56146. * @hidden
  56147. */
  56148. _enable(cameras: Camera): void;
  56149. /**
  56150. * Enables the effect on given cameras
  56151. * @param cameras The camera to enable.
  56152. * @hidden
  56153. */
  56154. _enable(cameras: Nullable<Camera[]>): void;
  56155. /**
  56156. * Disables the effect on the given cameras
  56157. * @param cameras The camera to disable.
  56158. * @hidden
  56159. */
  56160. _disable(cameras: Camera): void;
  56161. /**
  56162. * Disables the effect on the given cameras
  56163. * @param cameras The camera to disable.
  56164. * @hidden
  56165. */
  56166. _disable(cameras: Nullable<Camera[]>): void;
  56167. /**
  56168. * Gets a list of the post processes contained in the effect.
  56169. * @param camera The camera to get the post processes on.
  56170. * @returns The list of the post processes in the effect.
  56171. */
  56172. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  56173. }
  56174. }
  56175. declare module BABYLON {
  56176. /** @hidden */
  56177. export var extractHighlightsPixelShader: {
  56178. name: string;
  56179. shader: string;
  56180. };
  56181. }
  56182. declare module BABYLON {
  56183. /**
  56184. * 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.
  56185. */
  56186. export class ExtractHighlightsPostProcess extends PostProcess {
  56187. /**
  56188. * The luminance threshold, pixels below this value will be set to black.
  56189. */
  56190. threshold: number;
  56191. /** @hidden */
  56192. _exposure: number;
  56193. /**
  56194. * Post process which has the input texture to be used when performing highlight extraction
  56195. * @hidden
  56196. */
  56197. _inputPostProcess: Nullable<PostProcess>;
  56198. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56199. }
  56200. }
  56201. declare module BABYLON {
  56202. /** @hidden */
  56203. export var bloomMergePixelShader: {
  56204. name: string;
  56205. shader: string;
  56206. };
  56207. }
  56208. declare module BABYLON {
  56209. /**
  56210. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  56211. */
  56212. export class BloomMergePostProcess extends PostProcess {
  56213. /** Weight of the bloom to be added to the original input. */
  56214. weight: number;
  56215. /**
  56216. * Creates a new instance of @see BloomMergePostProcess
  56217. * @param name The name of the effect.
  56218. * @param originalFromInput Post process which's input will be used for the merge.
  56219. * @param blurred Blurred highlights post process which's output will be used.
  56220. * @param weight Weight of the bloom to be added to the original input.
  56221. * @param options The required width/height ratio to downsize to before computing the render pass.
  56222. * @param camera The camera to apply the render pass to.
  56223. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56224. * @param engine The engine which the post process will be applied. (default: current engine)
  56225. * @param reusable If the post process can be reused on the same frame. (default: false)
  56226. * @param textureType Type of textures used when performing the post process. (default: 0)
  56227. * @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)
  56228. */
  56229. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  56230. /** Weight of the bloom to be added to the original input. */
  56231. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56232. }
  56233. }
  56234. declare module BABYLON {
  56235. /**
  56236. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  56237. */
  56238. export class BloomEffect extends PostProcessRenderEffect {
  56239. private bloomScale;
  56240. /**
  56241. * @hidden Internal
  56242. */
  56243. _effects: Array<PostProcess>;
  56244. /**
  56245. * @hidden Internal
  56246. */
  56247. _downscale: ExtractHighlightsPostProcess;
  56248. private _blurX;
  56249. private _blurY;
  56250. private _merge;
  56251. /**
  56252. * The luminance threshold to find bright areas of the image to bloom.
  56253. */
  56254. threshold: number;
  56255. /**
  56256. * The strength of the bloom.
  56257. */
  56258. weight: number;
  56259. /**
  56260. * Specifies the size of the bloom blur kernel, relative to the final output size
  56261. */
  56262. kernel: number;
  56263. /**
  56264. * Creates a new instance of @see BloomEffect
  56265. * @param scene The scene the effect belongs to.
  56266. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  56267. * @param bloomKernel The size of the kernel to be used when applying the blur.
  56268. * @param bloomWeight The the strength of bloom.
  56269. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  56270. * @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)
  56271. */
  56272. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  56273. /**
  56274. * Disposes each of the internal effects for a given camera.
  56275. * @param camera The camera to dispose the effect on.
  56276. */
  56277. disposeEffects(camera: Camera): void;
  56278. /**
  56279. * @hidden Internal
  56280. */
  56281. _updateEffects(): void;
  56282. /**
  56283. * Internal
  56284. * @returns if all the contained post processes are ready.
  56285. * @hidden
  56286. */
  56287. _isReady(): boolean;
  56288. }
  56289. }
  56290. declare module BABYLON {
  56291. /** @hidden */
  56292. export var chromaticAberrationPixelShader: {
  56293. name: string;
  56294. shader: string;
  56295. };
  56296. }
  56297. declare module BABYLON {
  56298. /**
  56299. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  56300. */
  56301. export class ChromaticAberrationPostProcess extends PostProcess {
  56302. /**
  56303. * The amount of seperation of rgb channels (default: 30)
  56304. */
  56305. aberrationAmount: number;
  56306. /**
  56307. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  56308. */
  56309. radialIntensity: number;
  56310. /**
  56311. * 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))
  56312. */
  56313. direction: Vector2;
  56314. /**
  56315. * 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))
  56316. */
  56317. centerPosition: Vector2;
  56318. /**
  56319. * Creates a new instance ChromaticAberrationPostProcess
  56320. * @param name The name of the effect.
  56321. * @param screenWidth The width of the screen to apply the effect on.
  56322. * @param screenHeight The height of the screen to apply the effect on.
  56323. * @param options The required width/height ratio to downsize to before computing the render pass.
  56324. * @param camera The camera to apply the render pass to.
  56325. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56326. * @param engine The engine which the post process will be applied. (default: current engine)
  56327. * @param reusable If the post process can be reused on the same frame. (default: false)
  56328. * @param textureType Type of textures used when performing the post process. (default: 0)
  56329. * @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)
  56330. */
  56331. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56332. }
  56333. }
  56334. declare module BABYLON {
  56335. /** @hidden */
  56336. export var circleOfConfusionPixelShader: {
  56337. name: string;
  56338. shader: string;
  56339. };
  56340. }
  56341. declare module BABYLON {
  56342. /**
  56343. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  56344. */
  56345. export class CircleOfConfusionPostProcess extends PostProcess {
  56346. /**
  56347. * 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.
  56348. */
  56349. lensSize: number;
  56350. /**
  56351. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  56352. */
  56353. fStop: number;
  56354. /**
  56355. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  56356. */
  56357. focusDistance: number;
  56358. /**
  56359. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  56360. */
  56361. focalLength: number;
  56362. private _depthTexture;
  56363. /**
  56364. * Creates a new instance CircleOfConfusionPostProcess
  56365. * @param name The name of the effect.
  56366. * @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.
  56367. * @param options The required width/height ratio to downsize to before computing the render pass.
  56368. * @param camera The camera to apply the render pass to.
  56369. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56370. * @param engine The engine which the post process will be applied. (default: current engine)
  56371. * @param reusable If the post process can be reused on the same frame. (default: false)
  56372. * @param textureType Type of textures used when performing the post process. (default: 0)
  56373. * @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)
  56374. */
  56375. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56376. /**
  56377. * 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.
  56378. */
  56379. depthTexture: RenderTargetTexture;
  56380. }
  56381. }
  56382. declare module BABYLON {
  56383. /** @hidden */
  56384. export var colorCorrectionPixelShader: {
  56385. name: string;
  56386. shader: string;
  56387. };
  56388. }
  56389. declare module BABYLON {
  56390. /**
  56391. *
  56392. * This post-process allows the modification of rendered colors by using
  56393. * a 'look-up table' (LUT). This effect is also called Color Grading.
  56394. *
  56395. * The object needs to be provided an url to a texture containing the color
  56396. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  56397. * Use an image editing software to tweak the LUT to match your needs.
  56398. *
  56399. * For an example of a color LUT, see here:
  56400. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  56401. * For explanations on color grading, see here:
  56402. * @see http://udn.epicgames.com/Three/ColorGrading.html
  56403. *
  56404. */
  56405. export class ColorCorrectionPostProcess extends PostProcess {
  56406. private _colorTableTexture;
  56407. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56408. }
  56409. }
  56410. declare module BABYLON {
  56411. /** @hidden */
  56412. export var convolutionPixelShader: {
  56413. name: string;
  56414. shader: string;
  56415. };
  56416. }
  56417. declare module BABYLON {
  56418. /**
  56419. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  56420. * input texture to perform effects such as edge detection or sharpening
  56421. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  56422. */
  56423. export class ConvolutionPostProcess extends PostProcess {
  56424. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  56425. kernel: number[];
  56426. /**
  56427. * Creates a new instance ConvolutionPostProcess
  56428. * @param name The name of the effect.
  56429. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  56430. * @param options The required width/height ratio to downsize to before computing the render pass.
  56431. * @param camera The camera to apply the render pass to.
  56432. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56433. * @param engine The engine which the post process will be applied. (default: current engine)
  56434. * @param reusable If the post process can be reused on the same frame. (default: false)
  56435. * @param textureType Type of textures used when performing the post process. (default: 0)
  56436. */
  56437. constructor(name: string,
  56438. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  56439. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  56440. /**
  56441. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56442. */
  56443. static EdgeDetect0Kernel: number[];
  56444. /**
  56445. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56446. */
  56447. static EdgeDetect1Kernel: number[];
  56448. /**
  56449. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56450. */
  56451. static EdgeDetect2Kernel: number[];
  56452. /**
  56453. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56454. */
  56455. static SharpenKernel: number[];
  56456. /**
  56457. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56458. */
  56459. static EmbossKernel: number[];
  56460. /**
  56461. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56462. */
  56463. static GaussianKernel: number[];
  56464. }
  56465. }
  56466. declare module BABYLON {
  56467. /**
  56468. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  56469. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  56470. * based on samples that have a large difference in distance than the center pixel.
  56471. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  56472. */
  56473. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  56474. direction: Vector2;
  56475. /**
  56476. * Creates a new instance CircleOfConfusionPostProcess
  56477. * @param name The name of the effect.
  56478. * @param scene The scene the effect belongs to.
  56479. * @param direction The direction the blur should be applied.
  56480. * @param kernel The size of the kernel used to blur.
  56481. * @param options The required width/height ratio to downsize to before computing the render pass.
  56482. * @param camera The camera to apply the render pass to.
  56483. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  56484. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  56485. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56486. * @param engine The engine which the post process will be applied. (default: current engine)
  56487. * @param reusable If the post process can be reused on the same frame. (default: false)
  56488. * @param textureType Type of textures used when performing the post process. (default: 0)
  56489. * @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)
  56490. */
  56491. 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);
  56492. }
  56493. }
  56494. declare module BABYLON {
  56495. /** @hidden */
  56496. export var depthOfFieldMergePixelShader: {
  56497. name: string;
  56498. shader: string;
  56499. };
  56500. }
  56501. declare module BABYLON {
  56502. /**
  56503. * Options to be set when merging outputs from the default pipeline.
  56504. */
  56505. export class DepthOfFieldMergePostProcessOptions {
  56506. /**
  56507. * The original image to merge on top of
  56508. */
  56509. originalFromInput: PostProcess;
  56510. /**
  56511. * Parameters to perform the merge of the depth of field effect
  56512. */
  56513. depthOfField?: {
  56514. circleOfConfusion: PostProcess;
  56515. blurSteps: Array<PostProcess>;
  56516. };
  56517. /**
  56518. * Parameters to perform the merge of bloom effect
  56519. */
  56520. bloom?: {
  56521. blurred: PostProcess;
  56522. weight: number;
  56523. };
  56524. }
  56525. /**
  56526. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  56527. */
  56528. export class DepthOfFieldMergePostProcess extends PostProcess {
  56529. private blurSteps;
  56530. /**
  56531. * Creates a new instance of DepthOfFieldMergePostProcess
  56532. * @param name The name of the effect.
  56533. * @param originalFromInput Post process which's input will be used for the merge.
  56534. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  56535. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  56536. * @param options The required width/height ratio to downsize to before computing the render pass.
  56537. * @param camera The camera to apply the render pass to.
  56538. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56539. * @param engine The engine which the post process will be applied. (default: current engine)
  56540. * @param reusable If the post process can be reused on the same frame. (default: false)
  56541. * @param textureType Type of textures used when performing the post process. (default: 0)
  56542. * @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)
  56543. */
  56544. 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);
  56545. /**
  56546. * Updates the effect with the current post process compile time values and recompiles the shader.
  56547. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  56548. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  56549. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  56550. * @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
  56551. * @param onCompiled Called when the shader has been compiled.
  56552. * @param onError Called if there is an error when compiling a shader.
  56553. */
  56554. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  56555. }
  56556. }
  56557. declare module BABYLON {
  56558. /**
  56559. * Specifies the level of max blur that should be applied when using the depth of field effect
  56560. */
  56561. export enum DepthOfFieldEffectBlurLevel {
  56562. /**
  56563. * Subtle blur
  56564. */
  56565. Low = 0,
  56566. /**
  56567. * Medium blur
  56568. */
  56569. Medium = 1,
  56570. /**
  56571. * Large blur
  56572. */
  56573. High = 2
  56574. }
  56575. /**
  56576. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  56577. */
  56578. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  56579. private _circleOfConfusion;
  56580. /**
  56581. * @hidden Internal, blurs from high to low
  56582. */
  56583. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  56584. private _depthOfFieldBlurY;
  56585. private _dofMerge;
  56586. /**
  56587. * @hidden Internal post processes in depth of field effect
  56588. */
  56589. _effects: Array<PostProcess>;
  56590. /**
  56591. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  56592. */
  56593. focalLength: number;
  56594. /**
  56595. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  56596. */
  56597. fStop: number;
  56598. /**
  56599. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  56600. */
  56601. focusDistance: number;
  56602. /**
  56603. * 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.
  56604. */
  56605. lensSize: number;
  56606. /**
  56607. * Creates a new instance DepthOfFieldEffect
  56608. * @param scene The scene the effect belongs to.
  56609. * @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.
  56610. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  56611. * @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)
  56612. */
  56613. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  56614. /**
  56615. * Get the current class name of the current effet
  56616. * @returns "DepthOfFieldEffect"
  56617. */
  56618. getClassName(): string;
  56619. /**
  56620. * 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.
  56621. */
  56622. depthTexture: RenderTargetTexture;
  56623. /**
  56624. * Disposes each of the internal effects for a given camera.
  56625. * @param camera The camera to dispose the effect on.
  56626. */
  56627. disposeEffects(camera: Camera): void;
  56628. /**
  56629. * @hidden Internal
  56630. */
  56631. _updateEffects(): void;
  56632. /**
  56633. * Internal
  56634. * @returns if all the contained post processes are ready.
  56635. * @hidden
  56636. */
  56637. _isReady(): boolean;
  56638. }
  56639. }
  56640. declare module BABYLON {
  56641. /** @hidden */
  56642. export var displayPassPixelShader: {
  56643. name: string;
  56644. shader: string;
  56645. };
  56646. }
  56647. declare module BABYLON {
  56648. /**
  56649. * DisplayPassPostProcess which produces an output the same as it's input
  56650. */
  56651. export class DisplayPassPostProcess extends PostProcess {
  56652. /**
  56653. * Creates the DisplayPassPostProcess
  56654. * @param name The name of the effect.
  56655. * @param options The required width/height ratio to downsize to before computing the render pass.
  56656. * @param camera The camera to apply the render pass to.
  56657. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56658. * @param engine The engine which the post process will be applied. (default: current engine)
  56659. * @param reusable If the post process can be reused on the same frame. (default: false)
  56660. */
  56661. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56662. }
  56663. }
  56664. declare module BABYLON {
  56665. /** @hidden */
  56666. export var filterPixelShader: {
  56667. name: string;
  56668. shader: string;
  56669. };
  56670. }
  56671. declare module BABYLON {
  56672. /**
  56673. * Applies a kernel filter to the image
  56674. */
  56675. export class FilterPostProcess extends PostProcess {
  56676. /** The matrix to be applied to the image */
  56677. kernelMatrix: Matrix;
  56678. /**
  56679. *
  56680. * @param name The name of the effect.
  56681. * @param kernelMatrix The matrix to be applied to the image
  56682. * @param options The required width/height ratio to downsize to before computing the render pass.
  56683. * @param camera The camera to apply the render pass to.
  56684. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56685. * @param engine The engine which the post process will be applied. (default: current engine)
  56686. * @param reusable If the post process can be reused on the same frame. (default: false)
  56687. */
  56688. constructor(name: string,
  56689. /** The matrix to be applied to the image */
  56690. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56691. }
  56692. }
  56693. declare module BABYLON {
  56694. /** @hidden */
  56695. export var fxaaPixelShader: {
  56696. name: string;
  56697. shader: string;
  56698. };
  56699. }
  56700. declare module BABYLON {
  56701. /** @hidden */
  56702. export var fxaaVertexShader: {
  56703. name: string;
  56704. shader: string;
  56705. };
  56706. }
  56707. declare module BABYLON {
  56708. /**
  56709. * Fxaa post process
  56710. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  56711. */
  56712. export class FxaaPostProcess extends PostProcess {
  56713. /** @hidden */
  56714. texelWidth: number;
  56715. /** @hidden */
  56716. texelHeight: number;
  56717. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  56718. private _getDefines;
  56719. }
  56720. }
  56721. declare module BABYLON {
  56722. /** @hidden */
  56723. export var grainPixelShader: {
  56724. name: string;
  56725. shader: string;
  56726. };
  56727. }
  56728. declare module BABYLON {
  56729. /**
  56730. * The GrainPostProcess adds noise to the image at mid luminance levels
  56731. */
  56732. export class GrainPostProcess extends PostProcess {
  56733. /**
  56734. * The intensity of the grain added (default: 30)
  56735. */
  56736. intensity: number;
  56737. /**
  56738. * If the grain should be randomized on every frame
  56739. */
  56740. animated: boolean;
  56741. /**
  56742. * Creates a new instance of @see GrainPostProcess
  56743. * @param name The name of the effect.
  56744. * @param options The required width/height ratio to downsize to before computing the render pass.
  56745. * @param camera The camera to apply the render pass to.
  56746. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56747. * @param engine The engine which the post process will be applied. (default: current engine)
  56748. * @param reusable If the post process can be reused on the same frame. (default: false)
  56749. * @param textureType Type of textures used when performing the post process. (default: 0)
  56750. * @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)
  56751. */
  56752. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56753. }
  56754. }
  56755. declare module BABYLON {
  56756. /** @hidden */
  56757. export var highlightsPixelShader: {
  56758. name: string;
  56759. shader: string;
  56760. };
  56761. }
  56762. declare module BABYLON {
  56763. /**
  56764. * Extracts highlights from the image
  56765. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  56766. */
  56767. export class HighlightsPostProcess extends PostProcess {
  56768. /**
  56769. * Extracts highlights from the image
  56770. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  56771. * @param name The name of the effect.
  56772. * @param options The required width/height ratio to downsize to before computing the render pass.
  56773. * @param camera The camera to apply the render pass to.
  56774. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56775. * @param engine The engine which the post process will be applied. (default: current engine)
  56776. * @param reusable If the post process can be reused on the same frame. (default: false)
  56777. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  56778. */
  56779. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  56780. }
  56781. }
  56782. declare module BABYLON {
  56783. /** @hidden */
  56784. export var mrtFragmentDeclaration: {
  56785. name: string;
  56786. shader: string;
  56787. };
  56788. }
  56789. declare module BABYLON {
  56790. /** @hidden */
  56791. export var geometryPixelShader: {
  56792. name: string;
  56793. shader: string;
  56794. };
  56795. }
  56796. declare module BABYLON {
  56797. /** @hidden */
  56798. export var geometryVertexShader: {
  56799. name: string;
  56800. shader: string;
  56801. };
  56802. }
  56803. declare module BABYLON {
  56804. /** @hidden */
  56805. interface ISavedTransformationMatrix {
  56806. world: Matrix;
  56807. viewProjection: Matrix;
  56808. }
  56809. /**
  56810. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  56811. */
  56812. export class GeometryBufferRenderer {
  56813. /**
  56814. * Constant used to retrieve the position texture index in the G-Buffer textures array
  56815. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  56816. */
  56817. static readonly POSITION_TEXTURE_TYPE: number;
  56818. /**
  56819. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  56820. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  56821. */
  56822. static readonly VELOCITY_TEXTURE_TYPE: number;
  56823. /**
  56824. * Dictionary used to store the previous transformation matrices of each rendered mesh
  56825. * in order to compute objects velocities when enableVelocity is set to "true"
  56826. * @hidden
  56827. */
  56828. _previousTransformationMatrices: {
  56829. [index: number]: ISavedTransformationMatrix;
  56830. };
  56831. /**
  56832. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  56833. * in order to compute objects velocities when enableVelocity is set to "true"
  56834. * @hidden
  56835. */
  56836. _previousBonesTransformationMatrices: {
  56837. [index: number]: Float32Array;
  56838. };
  56839. /**
  56840. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  56841. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  56842. */
  56843. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  56844. private _scene;
  56845. private _multiRenderTarget;
  56846. private _ratio;
  56847. private _enablePosition;
  56848. private _enableVelocity;
  56849. private _positionIndex;
  56850. private _velocityIndex;
  56851. protected _effect: Effect;
  56852. protected _cachedDefines: string;
  56853. /**
  56854. * Set the render list (meshes to be rendered) used in the G buffer.
  56855. */
  56856. renderList: Mesh[];
  56857. /**
  56858. * Gets wether or not G buffer are supported by the running hardware.
  56859. * This requires draw buffer supports
  56860. */
  56861. readonly isSupported: boolean;
  56862. /**
  56863. * Returns the index of the given texture type in the G-Buffer textures array
  56864. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  56865. * @returns the index of the given texture type in the G-Buffer textures array
  56866. */
  56867. getTextureIndex(textureType: number): number;
  56868. /**
  56869. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  56870. */
  56871. /**
  56872. * Sets whether or not objects positions are enabled for the G buffer.
  56873. */
  56874. enablePosition: boolean;
  56875. /**
  56876. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  56877. */
  56878. /**
  56879. * Sets wether or not objects velocities are enabled for the G buffer.
  56880. */
  56881. enableVelocity: boolean;
  56882. /**
  56883. * Gets the scene associated with the buffer.
  56884. */
  56885. readonly scene: Scene;
  56886. /**
  56887. * Gets the ratio used by the buffer during its creation.
  56888. * How big is the buffer related to the main canvas.
  56889. */
  56890. readonly ratio: number;
  56891. /** @hidden */
  56892. static _SceneComponentInitialization: (scene: Scene) => void;
  56893. /**
  56894. * Creates a new G Buffer for the scene
  56895. * @param scene The scene the buffer belongs to
  56896. * @param ratio How big is the buffer related to the main canvas.
  56897. */
  56898. constructor(scene: Scene, ratio?: number);
  56899. /**
  56900. * Checks wether everything is ready to render a submesh to the G buffer.
  56901. * @param subMesh the submesh to check readiness for
  56902. * @param useInstances is the mesh drawn using instance or not
  56903. * @returns true if ready otherwise false
  56904. */
  56905. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56906. /**
  56907. * Gets the current underlying G Buffer.
  56908. * @returns the buffer
  56909. */
  56910. getGBuffer(): MultiRenderTarget;
  56911. /**
  56912. * Gets the number of samples used to render the buffer (anti aliasing).
  56913. */
  56914. /**
  56915. * Sets the number of samples used to render the buffer (anti aliasing).
  56916. */
  56917. samples: number;
  56918. /**
  56919. * Disposes the renderer and frees up associated resources.
  56920. */
  56921. dispose(): void;
  56922. protected _createRenderTargets(): void;
  56923. private _copyBonesTransformationMatrices;
  56924. }
  56925. }
  56926. declare module BABYLON {
  56927. interface Scene {
  56928. /** @hidden (Backing field) */
  56929. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  56930. /**
  56931. * Gets or Sets the current geometry buffer associated to the scene.
  56932. */
  56933. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  56934. /**
  56935. * Enables a GeometryBufferRender and associates it with the scene
  56936. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  56937. * @returns the GeometryBufferRenderer
  56938. */
  56939. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  56940. /**
  56941. * Disables the GeometryBufferRender associated with the scene
  56942. */
  56943. disableGeometryBufferRenderer(): void;
  56944. }
  56945. /**
  56946. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  56947. * in several rendering techniques.
  56948. */
  56949. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  56950. /**
  56951. * The component name helpful to identify the component in the list of scene components.
  56952. */
  56953. readonly name: string;
  56954. /**
  56955. * The scene the component belongs to.
  56956. */
  56957. scene: Scene;
  56958. /**
  56959. * Creates a new instance of the component for the given scene
  56960. * @param scene Defines the scene to register the component in
  56961. */
  56962. constructor(scene: Scene);
  56963. /**
  56964. * Registers the component in a given scene
  56965. */
  56966. register(): void;
  56967. /**
  56968. * Rebuilds the elements related to this component in case of
  56969. * context lost for instance.
  56970. */
  56971. rebuild(): void;
  56972. /**
  56973. * Disposes the component and the associated ressources
  56974. */
  56975. dispose(): void;
  56976. private _gatherRenderTargets;
  56977. }
  56978. }
  56979. declare module BABYLON {
  56980. /** @hidden */
  56981. export var motionBlurPixelShader: {
  56982. name: string;
  56983. shader: string;
  56984. };
  56985. }
  56986. declare module BABYLON {
  56987. /**
  56988. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  56989. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  56990. * As an example, all you have to do is to create the post-process:
  56991. * var mb = new BABYLON.MotionBlurPostProcess(
  56992. * 'mb', // The name of the effect.
  56993. * scene, // The scene containing the objects to blur according to their velocity.
  56994. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  56995. * camera // The camera to apply the render pass to.
  56996. * );
  56997. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  56998. */
  56999. export class MotionBlurPostProcess extends PostProcess {
  57000. /**
  57001. * Defines how much the image is blurred by the movement. Default value is equal to 1
  57002. */
  57003. motionStrength: number;
  57004. /**
  57005. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  57006. */
  57007. /**
  57008. * Sets the number of iterations to be used for motion blur quality
  57009. */
  57010. motionBlurSamples: number;
  57011. private _motionBlurSamples;
  57012. private _geometryBufferRenderer;
  57013. /**
  57014. * Creates a new instance MotionBlurPostProcess
  57015. * @param name The name of the effect.
  57016. * @param scene The scene containing the objects to blur according to their velocity.
  57017. * @param options The required width/height ratio to downsize to before computing the render pass.
  57018. * @param camera The camera to apply the render pass to.
  57019. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57020. * @param engine The engine which the post process will be applied. (default: current engine)
  57021. * @param reusable If the post process can be reused on the same frame. (default: false)
  57022. * @param textureType Type of textures used when performing the post process. (default: 0)
  57023. * @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)
  57024. */
  57025. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57026. /**
  57027. * Excludes the given skinned mesh from computing bones velocities.
  57028. * 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.
  57029. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  57030. */
  57031. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  57032. /**
  57033. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  57034. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  57035. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  57036. */
  57037. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  57038. /**
  57039. * Disposes the post process.
  57040. * @param camera The camera to dispose the post process on.
  57041. */
  57042. dispose(camera?: Camera): void;
  57043. }
  57044. }
  57045. declare module BABYLON {
  57046. /** @hidden */
  57047. export var refractionPixelShader: {
  57048. name: string;
  57049. shader: string;
  57050. };
  57051. }
  57052. declare module BABYLON {
  57053. /**
  57054. * Post process which applies a refractin texture
  57055. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  57056. */
  57057. export class RefractionPostProcess extends PostProcess {
  57058. /** the base color of the refraction (used to taint the rendering) */
  57059. color: Color3;
  57060. /** simulated refraction depth */
  57061. depth: number;
  57062. /** the coefficient of the base color (0 to remove base color tainting) */
  57063. colorLevel: number;
  57064. private _refTexture;
  57065. private _ownRefractionTexture;
  57066. /**
  57067. * Gets or sets the refraction texture
  57068. * Please note that you are responsible for disposing the texture if you set it manually
  57069. */
  57070. refractionTexture: Texture;
  57071. /**
  57072. * Initializes the RefractionPostProcess
  57073. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  57074. * @param name The name of the effect.
  57075. * @param refractionTextureUrl Url of the refraction texture to use
  57076. * @param color the base color of the refraction (used to taint the rendering)
  57077. * @param depth simulated refraction depth
  57078. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  57079. * @param camera The camera to apply the render pass to.
  57080. * @param options The required width/height ratio to downsize to before computing the render pass.
  57081. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57082. * @param engine The engine which the post process will be applied. (default: current engine)
  57083. * @param reusable If the post process can be reused on the same frame. (default: false)
  57084. */
  57085. constructor(name: string, refractionTextureUrl: string,
  57086. /** the base color of the refraction (used to taint the rendering) */
  57087. color: Color3,
  57088. /** simulated refraction depth */
  57089. depth: number,
  57090. /** the coefficient of the base color (0 to remove base color tainting) */
  57091. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57092. /**
  57093. * Disposes of the post process
  57094. * @param camera Camera to dispose post process on
  57095. */
  57096. dispose(camera: Camera): void;
  57097. }
  57098. }
  57099. declare module BABYLON {
  57100. /** @hidden */
  57101. export var sharpenPixelShader: {
  57102. name: string;
  57103. shader: string;
  57104. };
  57105. }
  57106. declare module BABYLON {
  57107. /**
  57108. * The SharpenPostProcess applies a sharpen kernel to every pixel
  57109. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57110. */
  57111. export class SharpenPostProcess extends PostProcess {
  57112. /**
  57113. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  57114. */
  57115. colorAmount: number;
  57116. /**
  57117. * How much sharpness should be applied (default: 0.3)
  57118. */
  57119. edgeAmount: number;
  57120. /**
  57121. * Creates a new instance ConvolutionPostProcess
  57122. * @param name The name of the effect.
  57123. * @param options The required width/height ratio to downsize to before computing the render pass.
  57124. * @param camera The camera to apply the render pass to.
  57125. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57126. * @param engine The engine which the post process will be applied. (default: current engine)
  57127. * @param reusable If the post process can be reused on the same frame. (default: false)
  57128. * @param textureType Type of textures used when performing the post process. (default: 0)
  57129. * @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)
  57130. */
  57131. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57132. }
  57133. }
  57134. declare module BABYLON {
  57135. /**
  57136. * PostProcessRenderPipeline
  57137. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57138. */
  57139. export class PostProcessRenderPipeline {
  57140. private engine;
  57141. private _renderEffects;
  57142. private _renderEffectsForIsolatedPass;
  57143. /**
  57144. * List of inspectable custom properties (used by the Inspector)
  57145. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  57146. */
  57147. inspectableCustomProperties: IInspectable[];
  57148. /**
  57149. * @hidden
  57150. */
  57151. protected _cameras: Camera[];
  57152. /** @hidden */
  57153. _name: string;
  57154. /**
  57155. * Gets pipeline name
  57156. */
  57157. readonly name: string;
  57158. /**
  57159. * Initializes a PostProcessRenderPipeline
  57160. * @param engine engine to add the pipeline to
  57161. * @param name name of the pipeline
  57162. */
  57163. constructor(engine: Engine, name: string);
  57164. /**
  57165. * Gets the class name
  57166. * @returns "PostProcessRenderPipeline"
  57167. */
  57168. getClassName(): string;
  57169. /**
  57170. * If all the render effects in the pipeline are supported
  57171. */
  57172. readonly isSupported: boolean;
  57173. /**
  57174. * Adds an effect to the pipeline
  57175. * @param renderEffect the effect to add
  57176. */
  57177. addEffect(renderEffect: PostProcessRenderEffect): void;
  57178. /** @hidden */
  57179. _rebuild(): void;
  57180. /** @hidden */
  57181. _enableEffect(renderEffectName: string, cameras: Camera): void;
  57182. /** @hidden */
  57183. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  57184. /** @hidden */
  57185. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  57186. /** @hidden */
  57187. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  57188. /** @hidden */
  57189. _attachCameras(cameras: Camera, unique: boolean): void;
  57190. /** @hidden */
  57191. _attachCameras(cameras: Camera[], unique: boolean): void;
  57192. /** @hidden */
  57193. _detachCameras(cameras: Camera): void;
  57194. /** @hidden */
  57195. _detachCameras(cameras: Nullable<Camera[]>): void;
  57196. /** @hidden */
  57197. _update(): void;
  57198. /** @hidden */
  57199. _reset(): void;
  57200. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  57201. /**
  57202. * Disposes of the pipeline
  57203. */
  57204. dispose(): void;
  57205. }
  57206. }
  57207. declare module BABYLON {
  57208. /**
  57209. * PostProcessRenderPipelineManager class
  57210. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57211. */
  57212. export class PostProcessRenderPipelineManager {
  57213. private _renderPipelines;
  57214. /**
  57215. * Initializes a PostProcessRenderPipelineManager
  57216. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57217. */
  57218. constructor();
  57219. /**
  57220. * Gets the list of supported render pipelines
  57221. */
  57222. readonly supportedPipelines: PostProcessRenderPipeline[];
  57223. /**
  57224. * Adds a pipeline to the manager
  57225. * @param renderPipeline The pipeline to add
  57226. */
  57227. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  57228. /**
  57229. * Attaches a camera to the pipeline
  57230. * @param renderPipelineName The name of the pipeline to attach to
  57231. * @param cameras the camera to attach
  57232. * @param unique if the camera can be attached multiple times to the pipeline
  57233. */
  57234. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  57235. /**
  57236. * Detaches a camera from the pipeline
  57237. * @param renderPipelineName The name of the pipeline to detach from
  57238. * @param cameras the camera to detach
  57239. */
  57240. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  57241. /**
  57242. * Enables an effect by name on a pipeline
  57243. * @param renderPipelineName the name of the pipeline to enable the effect in
  57244. * @param renderEffectName the name of the effect to enable
  57245. * @param cameras the cameras that the effect should be enabled on
  57246. */
  57247. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  57248. /**
  57249. * Disables an effect by name on a pipeline
  57250. * @param renderPipelineName the name of the pipeline to disable the effect in
  57251. * @param renderEffectName the name of the effect to disable
  57252. * @param cameras the cameras that the effect should be disabled on
  57253. */
  57254. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  57255. /**
  57256. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  57257. */
  57258. update(): void;
  57259. /** @hidden */
  57260. _rebuild(): void;
  57261. /**
  57262. * Disposes of the manager and pipelines
  57263. */
  57264. dispose(): void;
  57265. }
  57266. }
  57267. declare module BABYLON {
  57268. interface Scene {
  57269. /** @hidden (Backing field) */
  57270. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  57271. /**
  57272. * Gets the postprocess render pipeline manager
  57273. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57274. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  57275. */
  57276. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  57277. }
  57278. /**
  57279. * Defines the Render Pipeline scene component responsible to rendering pipelines
  57280. */
  57281. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  57282. /**
  57283. * The component name helpfull to identify the component in the list of scene components.
  57284. */
  57285. readonly name: string;
  57286. /**
  57287. * The scene the component belongs to.
  57288. */
  57289. scene: Scene;
  57290. /**
  57291. * Creates a new instance of the component for the given scene
  57292. * @param scene Defines the scene to register the component in
  57293. */
  57294. constructor(scene: Scene);
  57295. /**
  57296. * Registers the component in a given scene
  57297. */
  57298. register(): void;
  57299. /**
  57300. * Rebuilds the elements related to this component in case of
  57301. * context lost for instance.
  57302. */
  57303. rebuild(): void;
  57304. /**
  57305. * Disposes the component and the associated ressources
  57306. */
  57307. dispose(): void;
  57308. private _gatherRenderTargets;
  57309. }
  57310. }
  57311. declare module BABYLON {
  57312. /**
  57313. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  57314. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  57315. */
  57316. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  57317. private _scene;
  57318. private _camerasToBeAttached;
  57319. /**
  57320. * ID of the sharpen post process,
  57321. */
  57322. private readonly SharpenPostProcessId;
  57323. /**
  57324. * @ignore
  57325. * ID of the image processing post process;
  57326. */
  57327. readonly ImageProcessingPostProcessId: string;
  57328. /**
  57329. * @ignore
  57330. * ID of the Fast Approximate Anti-Aliasing post process;
  57331. */
  57332. readonly FxaaPostProcessId: string;
  57333. /**
  57334. * ID of the chromatic aberration post process,
  57335. */
  57336. private readonly ChromaticAberrationPostProcessId;
  57337. /**
  57338. * ID of the grain post process
  57339. */
  57340. private readonly GrainPostProcessId;
  57341. /**
  57342. * Sharpen post process which will apply a sharpen convolution to enhance edges
  57343. */
  57344. sharpen: SharpenPostProcess;
  57345. private _sharpenEffect;
  57346. private bloom;
  57347. /**
  57348. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  57349. */
  57350. depthOfField: DepthOfFieldEffect;
  57351. /**
  57352. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  57353. */
  57354. fxaa: FxaaPostProcess;
  57355. /**
  57356. * Image post processing pass used to perform operations such as tone mapping or color grading.
  57357. */
  57358. imageProcessing: ImageProcessingPostProcess;
  57359. /**
  57360. * Chromatic aberration post process which will shift rgb colors in the image
  57361. */
  57362. chromaticAberration: ChromaticAberrationPostProcess;
  57363. private _chromaticAberrationEffect;
  57364. /**
  57365. * Grain post process which add noise to the image
  57366. */
  57367. grain: GrainPostProcess;
  57368. private _grainEffect;
  57369. /**
  57370. * Glow post process which adds a glow to emissive areas of the image
  57371. */
  57372. private _glowLayer;
  57373. /**
  57374. * Animations which can be used to tweak settings over a period of time
  57375. */
  57376. animations: Animation[];
  57377. private _imageProcessingConfigurationObserver;
  57378. private _sharpenEnabled;
  57379. private _bloomEnabled;
  57380. private _depthOfFieldEnabled;
  57381. private _depthOfFieldBlurLevel;
  57382. private _fxaaEnabled;
  57383. private _imageProcessingEnabled;
  57384. private _defaultPipelineTextureType;
  57385. private _bloomScale;
  57386. private _chromaticAberrationEnabled;
  57387. private _grainEnabled;
  57388. private _buildAllowed;
  57389. /**
  57390. * Gets active scene
  57391. */
  57392. readonly scene: Scene;
  57393. /**
  57394. * Enable or disable the sharpen process from the pipeline
  57395. */
  57396. sharpenEnabled: boolean;
  57397. private _resizeObserver;
  57398. private _hardwareScaleLevel;
  57399. private _bloomKernel;
  57400. /**
  57401. * Specifies the size of the bloom blur kernel, relative to the final output size
  57402. */
  57403. bloomKernel: number;
  57404. /**
  57405. * Specifies the weight of the bloom in the final rendering
  57406. */
  57407. private _bloomWeight;
  57408. /**
  57409. * Specifies the luma threshold for the area that will be blurred by the bloom
  57410. */
  57411. private _bloomThreshold;
  57412. private _hdr;
  57413. /**
  57414. * The strength of the bloom.
  57415. */
  57416. bloomWeight: number;
  57417. /**
  57418. * The strength of the bloom.
  57419. */
  57420. bloomThreshold: number;
  57421. /**
  57422. * The scale of the bloom, lower value will provide better performance.
  57423. */
  57424. bloomScale: number;
  57425. /**
  57426. * Enable or disable the bloom from the pipeline
  57427. */
  57428. bloomEnabled: boolean;
  57429. private _rebuildBloom;
  57430. /**
  57431. * If the depth of field is enabled.
  57432. */
  57433. depthOfFieldEnabled: boolean;
  57434. /**
  57435. * Blur level of the depth of field effect. (Higher blur will effect performance)
  57436. */
  57437. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  57438. /**
  57439. * If the anti aliasing is enabled.
  57440. */
  57441. fxaaEnabled: boolean;
  57442. private _samples;
  57443. /**
  57444. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57445. */
  57446. samples: number;
  57447. /**
  57448. * If image processing is enabled.
  57449. */
  57450. imageProcessingEnabled: boolean;
  57451. /**
  57452. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  57453. */
  57454. glowLayerEnabled: boolean;
  57455. /**
  57456. * Gets the glow layer (or null if not defined)
  57457. */
  57458. readonly glowLayer: Nullable<GlowLayer>;
  57459. /**
  57460. * Enable or disable the chromaticAberration process from the pipeline
  57461. */
  57462. chromaticAberrationEnabled: boolean;
  57463. /**
  57464. * Enable or disable the grain process from the pipeline
  57465. */
  57466. grainEnabled: boolean;
  57467. /**
  57468. * @constructor
  57469. * @param name - The rendering pipeline name (default: "")
  57470. * @param hdr - If high dynamic range textures should be used (default: true)
  57471. * @param scene - The scene linked to this pipeline (default: the last created scene)
  57472. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  57473. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  57474. */
  57475. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  57476. /**
  57477. * Get the class name
  57478. * @returns "DefaultRenderingPipeline"
  57479. */
  57480. getClassName(): string;
  57481. /**
  57482. * Force the compilation of the entire pipeline.
  57483. */
  57484. prepare(): void;
  57485. private _hasCleared;
  57486. private _prevPostProcess;
  57487. private _prevPrevPostProcess;
  57488. private _setAutoClearAndTextureSharing;
  57489. private _depthOfFieldSceneObserver;
  57490. private _buildPipeline;
  57491. private _disposePostProcesses;
  57492. /**
  57493. * Adds a camera to the pipeline
  57494. * @param camera the camera to be added
  57495. */
  57496. addCamera(camera: Camera): void;
  57497. /**
  57498. * Removes a camera from the pipeline
  57499. * @param camera the camera to remove
  57500. */
  57501. removeCamera(camera: Camera): void;
  57502. /**
  57503. * Dispose of the pipeline and stop all post processes
  57504. */
  57505. dispose(): void;
  57506. /**
  57507. * Serialize the rendering pipeline (Used when exporting)
  57508. * @returns the serialized object
  57509. */
  57510. serialize(): any;
  57511. /**
  57512. * Parse the serialized pipeline
  57513. * @param source Source pipeline.
  57514. * @param scene The scene to load the pipeline to.
  57515. * @param rootUrl The URL of the serialized pipeline.
  57516. * @returns An instantiated pipeline from the serialized object.
  57517. */
  57518. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  57519. }
  57520. }
  57521. declare module BABYLON {
  57522. /** @hidden */
  57523. export var lensHighlightsPixelShader: {
  57524. name: string;
  57525. shader: string;
  57526. };
  57527. }
  57528. declare module BABYLON {
  57529. /** @hidden */
  57530. export var depthOfFieldPixelShader: {
  57531. name: string;
  57532. shader: string;
  57533. };
  57534. }
  57535. declare module BABYLON {
  57536. /**
  57537. * BABYLON.JS Chromatic Aberration GLSL Shader
  57538. * Author: Olivier Guyot
  57539. * Separates very slightly R, G and B colors on the edges of the screen
  57540. * Inspired by Francois Tarlier & Martins Upitis
  57541. */
  57542. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  57543. /**
  57544. * @ignore
  57545. * The chromatic aberration PostProcess id in the pipeline
  57546. */
  57547. LensChromaticAberrationEffect: string;
  57548. /**
  57549. * @ignore
  57550. * The highlights enhancing PostProcess id in the pipeline
  57551. */
  57552. HighlightsEnhancingEffect: string;
  57553. /**
  57554. * @ignore
  57555. * The depth-of-field PostProcess id in the pipeline
  57556. */
  57557. LensDepthOfFieldEffect: string;
  57558. private _scene;
  57559. private _depthTexture;
  57560. private _grainTexture;
  57561. private _chromaticAberrationPostProcess;
  57562. private _highlightsPostProcess;
  57563. private _depthOfFieldPostProcess;
  57564. private _edgeBlur;
  57565. private _grainAmount;
  57566. private _chromaticAberration;
  57567. private _distortion;
  57568. private _highlightsGain;
  57569. private _highlightsThreshold;
  57570. private _dofDistance;
  57571. private _dofAperture;
  57572. private _dofDarken;
  57573. private _dofPentagon;
  57574. private _blurNoise;
  57575. /**
  57576. * @constructor
  57577. *
  57578. * Effect parameters are as follow:
  57579. * {
  57580. * chromatic_aberration: number; // from 0 to x (1 for realism)
  57581. * edge_blur: number; // from 0 to x (1 for realism)
  57582. * distortion: number; // from 0 to x (1 for realism)
  57583. * grain_amount: number; // from 0 to 1
  57584. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  57585. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  57586. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  57587. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  57588. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  57589. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  57590. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  57591. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  57592. * }
  57593. * Note: if an effect parameter is unset, effect is disabled
  57594. *
  57595. * @param name The rendering pipeline name
  57596. * @param parameters - An object containing all parameters (see above)
  57597. * @param scene The scene linked to this pipeline
  57598. * @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)
  57599. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57600. */
  57601. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  57602. /**
  57603. * Get the class name
  57604. * @returns "LensRenderingPipeline"
  57605. */
  57606. getClassName(): string;
  57607. /**
  57608. * Gets associated scene
  57609. */
  57610. readonly scene: Scene;
  57611. /**
  57612. * Gets or sets the edge blur
  57613. */
  57614. edgeBlur: number;
  57615. /**
  57616. * Gets or sets the grain amount
  57617. */
  57618. grainAmount: number;
  57619. /**
  57620. * Gets or sets the chromatic aberration amount
  57621. */
  57622. chromaticAberration: number;
  57623. /**
  57624. * Gets or sets the depth of field aperture
  57625. */
  57626. dofAperture: number;
  57627. /**
  57628. * Gets or sets the edge distortion
  57629. */
  57630. edgeDistortion: number;
  57631. /**
  57632. * Gets or sets the depth of field distortion
  57633. */
  57634. dofDistortion: number;
  57635. /**
  57636. * Gets or sets the darken out of focus amount
  57637. */
  57638. darkenOutOfFocus: number;
  57639. /**
  57640. * Gets or sets a boolean indicating if blur noise is enabled
  57641. */
  57642. blurNoise: boolean;
  57643. /**
  57644. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  57645. */
  57646. pentagonBokeh: boolean;
  57647. /**
  57648. * Gets or sets the highlight grain amount
  57649. */
  57650. highlightsGain: number;
  57651. /**
  57652. * Gets or sets the highlight threshold
  57653. */
  57654. highlightsThreshold: number;
  57655. /**
  57656. * Sets the amount of blur at the edges
  57657. * @param amount blur amount
  57658. */
  57659. setEdgeBlur(amount: number): void;
  57660. /**
  57661. * Sets edge blur to 0
  57662. */
  57663. disableEdgeBlur(): void;
  57664. /**
  57665. * Sets the amout of grain
  57666. * @param amount Amount of grain
  57667. */
  57668. setGrainAmount(amount: number): void;
  57669. /**
  57670. * Set grain amount to 0
  57671. */
  57672. disableGrain(): void;
  57673. /**
  57674. * Sets the chromatic aberration amount
  57675. * @param amount amount of chromatic aberration
  57676. */
  57677. setChromaticAberration(amount: number): void;
  57678. /**
  57679. * Sets chromatic aberration amount to 0
  57680. */
  57681. disableChromaticAberration(): void;
  57682. /**
  57683. * Sets the EdgeDistortion amount
  57684. * @param amount amount of EdgeDistortion
  57685. */
  57686. setEdgeDistortion(amount: number): void;
  57687. /**
  57688. * Sets edge distortion to 0
  57689. */
  57690. disableEdgeDistortion(): void;
  57691. /**
  57692. * Sets the FocusDistance amount
  57693. * @param amount amount of FocusDistance
  57694. */
  57695. setFocusDistance(amount: number): void;
  57696. /**
  57697. * Disables depth of field
  57698. */
  57699. disableDepthOfField(): void;
  57700. /**
  57701. * Sets the Aperture amount
  57702. * @param amount amount of Aperture
  57703. */
  57704. setAperture(amount: number): void;
  57705. /**
  57706. * Sets the DarkenOutOfFocus amount
  57707. * @param amount amount of DarkenOutOfFocus
  57708. */
  57709. setDarkenOutOfFocus(amount: number): void;
  57710. private _pentagonBokehIsEnabled;
  57711. /**
  57712. * Creates a pentagon bokeh effect
  57713. */
  57714. enablePentagonBokeh(): void;
  57715. /**
  57716. * Disables the pentagon bokeh effect
  57717. */
  57718. disablePentagonBokeh(): void;
  57719. /**
  57720. * Enables noise blur
  57721. */
  57722. enableNoiseBlur(): void;
  57723. /**
  57724. * Disables noise blur
  57725. */
  57726. disableNoiseBlur(): void;
  57727. /**
  57728. * Sets the HighlightsGain amount
  57729. * @param amount amount of HighlightsGain
  57730. */
  57731. setHighlightsGain(amount: number): void;
  57732. /**
  57733. * Sets the HighlightsThreshold amount
  57734. * @param amount amount of HighlightsThreshold
  57735. */
  57736. setHighlightsThreshold(amount: number): void;
  57737. /**
  57738. * Disables highlights
  57739. */
  57740. disableHighlights(): void;
  57741. /**
  57742. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  57743. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  57744. */
  57745. dispose(disableDepthRender?: boolean): void;
  57746. private _createChromaticAberrationPostProcess;
  57747. private _createHighlightsPostProcess;
  57748. private _createDepthOfFieldPostProcess;
  57749. private _createGrainTexture;
  57750. }
  57751. }
  57752. declare module BABYLON {
  57753. /** @hidden */
  57754. export var ssao2PixelShader: {
  57755. name: string;
  57756. shader: string;
  57757. };
  57758. }
  57759. declare module BABYLON {
  57760. /** @hidden */
  57761. export var ssaoCombinePixelShader: {
  57762. name: string;
  57763. shader: string;
  57764. };
  57765. }
  57766. declare module BABYLON {
  57767. /**
  57768. * Render pipeline to produce ssao effect
  57769. */
  57770. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  57771. /**
  57772. * @ignore
  57773. * The PassPostProcess id in the pipeline that contains the original scene color
  57774. */
  57775. SSAOOriginalSceneColorEffect: string;
  57776. /**
  57777. * @ignore
  57778. * The SSAO PostProcess id in the pipeline
  57779. */
  57780. SSAORenderEffect: string;
  57781. /**
  57782. * @ignore
  57783. * The horizontal blur PostProcess id in the pipeline
  57784. */
  57785. SSAOBlurHRenderEffect: string;
  57786. /**
  57787. * @ignore
  57788. * The vertical blur PostProcess id in the pipeline
  57789. */
  57790. SSAOBlurVRenderEffect: string;
  57791. /**
  57792. * @ignore
  57793. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  57794. */
  57795. SSAOCombineRenderEffect: string;
  57796. /**
  57797. * The output strength of the SSAO post-process. Default value is 1.0.
  57798. */
  57799. totalStrength: number;
  57800. /**
  57801. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  57802. */
  57803. maxZ: number;
  57804. /**
  57805. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  57806. */
  57807. minZAspect: number;
  57808. private _samples;
  57809. /**
  57810. * Number of samples used for the SSAO calculations. Default value is 8
  57811. */
  57812. samples: number;
  57813. private _textureSamples;
  57814. /**
  57815. * Number of samples to use for antialiasing
  57816. */
  57817. textureSamples: number;
  57818. /**
  57819. * Ratio object used for SSAO ratio and blur ratio
  57820. */
  57821. private _ratio;
  57822. /**
  57823. * Dynamically generated sphere sampler.
  57824. */
  57825. private _sampleSphere;
  57826. /**
  57827. * Blur filter offsets
  57828. */
  57829. private _samplerOffsets;
  57830. private _expensiveBlur;
  57831. /**
  57832. * If bilateral blur should be used
  57833. */
  57834. expensiveBlur: boolean;
  57835. /**
  57836. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  57837. */
  57838. radius: number;
  57839. /**
  57840. * The base color of the SSAO post-process
  57841. * The final result is "base + ssao" between [0, 1]
  57842. */
  57843. base: number;
  57844. /**
  57845. * Support test.
  57846. */
  57847. static readonly IsSupported: boolean;
  57848. private _scene;
  57849. private _depthTexture;
  57850. private _normalTexture;
  57851. private _randomTexture;
  57852. private _originalColorPostProcess;
  57853. private _ssaoPostProcess;
  57854. private _blurHPostProcess;
  57855. private _blurVPostProcess;
  57856. private _ssaoCombinePostProcess;
  57857. private _firstUpdate;
  57858. /**
  57859. * Gets active scene
  57860. */
  57861. readonly scene: Scene;
  57862. /**
  57863. * @constructor
  57864. * @param name The rendering pipeline name
  57865. * @param scene The scene linked to this pipeline
  57866. * @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 }
  57867. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57868. */
  57869. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  57870. /**
  57871. * Get the class name
  57872. * @returns "SSAO2RenderingPipeline"
  57873. */
  57874. getClassName(): string;
  57875. /**
  57876. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  57877. */
  57878. dispose(disableGeometryBufferRenderer?: boolean): void;
  57879. private _createBlurPostProcess;
  57880. /** @hidden */
  57881. _rebuild(): void;
  57882. private _bits;
  57883. private _radicalInverse_VdC;
  57884. private _hammersley;
  57885. private _hemisphereSample_uniform;
  57886. private _generateHemisphere;
  57887. private _createSSAOPostProcess;
  57888. private _createSSAOCombinePostProcess;
  57889. private _createRandomTexture;
  57890. /**
  57891. * Serialize the rendering pipeline (Used when exporting)
  57892. * @returns the serialized object
  57893. */
  57894. serialize(): any;
  57895. /**
  57896. * Parse the serialized pipeline
  57897. * @param source Source pipeline.
  57898. * @param scene The scene to load the pipeline to.
  57899. * @param rootUrl The URL of the serialized pipeline.
  57900. * @returns An instantiated pipeline from the serialized object.
  57901. */
  57902. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  57903. }
  57904. }
  57905. declare module BABYLON {
  57906. /** @hidden */
  57907. export var ssaoPixelShader: {
  57908. name: string;
  57909. shader: string;
  57910. };
  57911. }
  57912. declare module BABYLON {
  57913. /**
  57914. * Render pipeline to produce ssao effect
  57915. */
  57916. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  57917. /**
  57918. * @ignore
  57919. * The PassPostProcess id in the pipeline that contains the original scene color
  57920. */
  57921. SSAOOriginalSceneColorEffect: string;
  57922. /**
  57923. * @ignore
  57924. * The SSAO PostProcess id in the pipeline
  57925. */
  57926. SSAORenderEffect: string;
  57927. /**
  57928. * @ignore
  57929. * The horizontal blur PostProcess id in the pipeline
  57930. */
  57931. SSAOBlurHRenderEffect: string;
  57932. /**
  57933. * @ignore
  57934. * The vertical blur PostProcess id in the pipeline
  57935. */
  57936. SSAOBlurVRenderEffect: string;
  57937. /**
  57938. * @ignore
  57939. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  57940. */
  57941. SSAOCombineRenderEffect: string;
  57942. /**
  57943. * The output strength of the SSAO post-process. Default value is 1.0.
  57944. */
  57945. totalStrength: number;
  57946. /**
  57947. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  57948. */
  57949. radius: number;
  57950. /**
  57951. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  57952. * Must not be equal to fallOff and superior to fallOff.
  57953. * Default value is 0.0075
  57954. */
  57955. area: number;
  57956. /**
  57957. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  57958. * Must not be equal to area and inferior to area.
  57959. * Default value is 0.000001
  57960. */
  57961. fallOff: number;
  57962. /**
  57963. * The base color of the SSAO post-process
  57964. * The final result is "base + ssao" between [0, 1]
  57965. */
  57966. base: number;
  57967. private _scene;
  57968. private _depthTexture;
  57969. private _randomTexture;
  57970. private _originalColorPostProcess;
  57971. private _ssaoPostProcess;
  57972. private _blurHPostProcess;
  57973. private _blurVPostProcess;
  57974. private _ssaoCombinePostProcess;
  57975. private _firstUpdate;
  57976. /**
  57977. * Gets active scene
  57978. */
  57979. readonly scene: Scene;
  57980. /**
  57981. * @constructor
  57982. * @param name - The rendering pipeline name
  57983. * @param scene - The scene linked to this pipeline
  57984. * @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 }
  57985. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  57986. */
  57987. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  57988. /**
  57989. * Get the class name
  57990. * @returns "SSAORenderingPipeline"
  57991. */
  57992. getClassName(): string;
  57993. /**
  57994. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  57995. */
  57996. dispose(disableDepthRender?: boolean): void;
  57997. private _createBlurPostProcess;
  57998. /** @hidden */
  57999. _rebuild(): void;
  58000. private _createSSAOPostProcess;
  58001. private _createSSAOCombinePostProcess;
  58002. private _createRandomTexture;
  58003. }
  58004. }
  58005. declare module BABYLON {
  58006. /** @hidden */
  58007. export var standardPixelShader: {
  58008. name: string;
  58009. shader: string;
  58010. };
  58011. }
  58012. declare module BABYLON {
  58013. /**
  58014. * Standard rendering pipeline
  58015. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  58016. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  58017. */
  58018. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58019. /**
  58020. * Public members
  58021. */
  58022. /**
  58023. * Post-process which contains the original scene color before the pipeline applies all the effects
  58024. */
  58025. originalPostProcess: Nullable<PostProcess>;
  58026. /**
  58027. * Post-process used to down scale an image x4
  58028. */
  58029. downSampleX4PostProcess: Nullable<PostProcess>;
  58030. /**
  58031. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  58032. */
  58033. brightPassPostProcess: Nullable<PostProcess>;
  58034. /**
  58035. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  58036. */
  58037. blurHPostProcesses: PostProcess[];
  58038. /**
  58039. * Post-process array storing all the vertical blur post-processes used by the pipeline
  58040. */
  58041. blurVPostProcesses: PostProcess[];
  58042. /**
  58043. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  58044. */
  58045. textureAdderPostProcess: Nullable<PostProcess>;
  58046. /**
  58047. * Post-process used to create volumetric lighting effect
  58048. */
  58049. volumetricLightPostProcess: Nullable<PostProcess>;
  58050. /**
  58051. * Post-process used to smooth the previous volumetric light post-process on the X axis
  58052. */
  58053. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  58054. /**
  58055. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  58056. */
  58057. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  58058. /**
  58059. * Post-process used to merge the volumetric light effect and the real scene color
  58060. */
  58061. volumetricLightMergePostProces: Nullable<PostProcess>;
  58062. /**
  58063. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  58064. */
  58065. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  58066. /**
  58067. * Base post-process used to calculate the average luminance of the final image for HDR
  58068. */
  58069. luminancePostProcess: Nullable<PostProcess>;
  58070. /**
  58071. * Post-processes used to create down sample post-processes in order to get
  58072. * the average luminance of the final image for HDR
  58073. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  58074. */
  58075. luminanceDownSamplePostProcesses: PostProcess[];
  58076. /**
  58077. * Post-process used to create a HDR effect (light adaptation)
  58078. */
  58079. hdrPostProcess: Nullable<PostProcess>;
  58080. /**
  58081. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  58082. */
  58083. textureAdderFinalPostProcess: Nullable<PostProcess>;
  58084. /**
  58085. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  58086. */
  58087. lensFlareFinalPostProcess: Nullable<PostProcess>;
  58088. /**
  58089. * Post-process used to merge the final HDR post-process and the real scene color
  58090. */
  58091. hdrFinalPostProcess: Nullable<PostProcess>;
  58092. /**
  58093. * Post-process used to create a lens flare effect
  58094. */
  58095. lensFlarePostProcess: Nullable<PostProcess>;
  58096. /**
  58097. * Post-process that merges the result of the lens flare post-process and the real scene color
  58098. */
  58099. lensFlareComposePostProcess: Nullable<PostProcess>;
  58100. /**
  58101. * Post-process used to create a motion blur effect
  58102. */
  58103. motionBlurPostProcess: Nullable<PostProcess>;
  58104. /**
  58105. * Post-process used to create a depth of field effect
  58106. */
  58107. depthOfFieldPostProcess: Nullable<PostProcess>;
  58108. /**
  58109. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58110. */
  58111. fxaaPostProcess: Nullable<FxaaPostProcess>;
  58112. /**
  58113. * Represents the brightness threshold in order to configure the illuminated surfaces
  58114. */
  58115. brightThreshold: number;
  58116. /**
  58117. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  58118. */
  58119. blurWidth: number;
  58120. /**
  58121. * Sets if the blur for highlighted surfaces must be only horizontal
  58122. */
  58123. horizontalBlur: boolean;
  58124. /**
  58125. * Gets the overall exposure used by the pipeline
  58126. */
  58127. /**
  58128. * Sets the overall exposure used by the pipeline
  58129. */
  58130. exposure: number;
  58131. /**
  58132. * Texture used typically to simulate "dirty" on camera lens
  58133. */
  58134. lensTexture: Nullable<Texture>;
  58135. /**
  58136. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  58137. */
  58138. volumetricLightCoefficient: number;
  58139. /**
  58140. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  58141. */
  58142. volumetricLightPower: number;
  58143. /**
  58144. * Used the set the blur intensity to smooth the volumetric lights
  58145. */
  58146. volumetricLightBlurScale: number;
  58147. /**
  58148. * Light (spot or directional) used to generate the volumetric lights rays
  58149. * The source light must have a shadow generate so the pipeline can get its
  58150. * depth map
  58151. */
  58152. sourceLight: Nullable<SpotLight | DirectionalLight>;
  58153. /**
  58154. * For eye adaptation, represents the minimum luminance the eye can see
  58155. */
  58156. hdrMinimumLuminance: number;
  58157. /**
  58158. * For eye adaptation, represents the decrease luminance speed
  58159. */
  58160. hdrDecreaseRate: number;
  58161. /**
  58162. * For eye adaptation, represents the increase luminance speed
  58163. */
  58164. hdrIncreaseRate: number;
  58165. /**
  58166. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  58167. */
  58168. /**
  58169. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  58170. */
  58171. hdrAutoExposure: boolean;
  58172. /**
  58173. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  58174. */
  58175. lensColorTexture: Nullable<Texture>;
  58176. /**
  58177. * The overall strengh for the lens flare effect
  58178. */
  58179. lensFlareStrength: number;
  58180. /**
  58181. * Dispersion coefficient for lens flare ghosts
  58182. */
  58183. lensFlareGhostDispersal: number;
  58184. /**
  58185. * Main lens flare halo width
  58186. */
  58187. lensFlareHaloWidth: number;
  58188. /**
  58189. * Based on the lens distortion effect, defines how much the lens flare result
  58190. * is distorted
  58191. */
  58192. lensFlareDistortionStrength: number;
  58193. /**
  58194. * Lens star texture must be used to simulate rays on the flares and is available
  58195. * in the documentation
  58196. */
  58197. lensStarTexture: Nullable<Texture>;
  58198. /**
  58199. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  58200. * flare effect by taking account of the dirt texture
  58201. */
  58202. lensFlareDirtTexture: Nullable<Texture>;
  58203. /**
  58204. * Represents the focal length for the depth of field effect
  58205. */
  58206. depthOfFieldDistance: number;
  58207. /**
  58208. * Represents the blur intensity for the blurred part of the depth of field effect
  58209. */
  58210. depthOfFieldBlurWidth: number;
  58211. /**
  58212. * Gets how much the image is blurred by the movement while using the motion blur post-process
  58213. */
  58214. /**
  58215. * Sets how much the image is blurred by the movement while using the motion blur post-process
  58216. */
  58217. motionStrength: number;
  58218. /**
  58219. * Gets wether or not the motion blur post-process is object based or screen based.
  58220. */
  58221. /**
  58222. * Sets wether or not the motion blur post-process should be object based or screen based
  58223. */
  58224. objectBasedMotionBlur: boolean;
  58225. /**
  58226. * List of animations for the pipeline (IAnimatable implementation)
  58227. */
  58228. animations: Animation[];
  58229. /**
  58230. * Private members
  58231. */
  58232. private _scene;
  58233. private _currentDepthOfFieldSource;
  58234. private _basePostProcess;
  58235. private _fixedExposure;
  58236. private _currentExposure;
  58237. private _hdrAutoExposure;
  58238. private _hdrCurrentLuminance;
  58239. private _motionStrength;
  58240. private _isObjectBasedMotionBlur;
  58241. private _floatTextureType;
  58242. private _ratio;
  58243. private _bloomEnabled;
  58244. private _depthOfFieldEnabled;
  58245. private _vlsEnabled;
  58246. private _lensFlareEnabled;
  58247. private _hdrEnabled;
  58248. private _motionBlurEnabled;
  58249. private _fxaaEnabled;
  58250. private _motionBlurSamples;
  58251. private _volumetricLightStepsCount;
  58252. private _samples;
  58253. /**
  58254. * @ignore
  58255. * Specifies if the bloom pipeline is enabled
  58256. */
  58257. BloomEnabled: boolean;
  58258. /**
  58259. * @ignore
  58260. * Specifies if the depth of field pipeline is enabed
  58261. */
  58262. DepthOfFieldEnabled: boolean;
  58263. /**
  58264. * @ignore
  58265. * Specifies if the lens flare pipeline is enabed
  58266. */
  58267. LensFlareEnabled: boolean;
  58268. /**
  58269. * @ignore
  58270. * Specifies if the HDR pipeline is enabled
  58271. */
  58272. HDREnabled: boolean;
  58273. /**
  58274. * @ignore
  58275. * Specifies if the volumetric lights scattering effect is enabled
  58276. */
  58277. VLSEnabled: boolean;
  58278. /**
  58279. * @ignore
  58280. * Specifies if the motion blur effect is enabled
  58281. */
  58282. MotionBlurEnabled: boolean;
  58283. /**
  58284. * Specifies if anti-aliasing is enabled
  58285. */
  58286. fxaaEnabled: boolean;
  58287. /**
  58288. * Specifies the number of steps used to calculate the volumetric lights
  58289. * Typically in interval [50, 200]
  58290. */
  58291. volumetricLightStepsCount: number;
  58292. /**
  58293. * Specifies the number of samples used for the motion blur effect
  58294. * Typically in interval [16, 64]
  58295. */
  58296. motionBlurSamples: number;
  58297. /**
  58298. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58299. */
  58300. samples: number;
  58301. /**
  58302. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  58303. * @constructor
  58304. * @param name The rendering pipeline name
  58305. * @param scene The scene linked to this pipeline
  58306. * @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)
  58307. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  58308. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58309. */
  58310. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  58311. private _buildPipeline;
  58312. private _createDownSampleX4PostProcess;
  58313. private _createBrightPassPostProcess;
  58314. private _createBlurPostProcesses;
  58315. private _createTextureAdderPostProcess;
  58316. private _createVolumetricLightPostProcess;
  58317. private _createLuminancePostProcesses;
  58318. private _createHdrPostProcess;
  58319. private _createLensFlarePostProcess;
  58320. private _createDepthOfFieldPostProcess;
  58321. private _createMotionBlurPostProcess;
  58322. private _getDepthTexture;
  58323. private _disposePostProcesses;
  58324. /**
  58325. * Dispose of the pipeline and stop all post processes
  58326. */
  58327. dispose(): void;
  58328. /**
  58329. * Serialize the rendering pipeline (Used when exporting)
  58330. * @returns the serialized object
  58331. */
  58332. serialize(): any;
  58333. /**
  58334. * Parse the serialized pipeline
  58335. * @param source Source pipeline.
  58336. * @param scene The scene to load the pipeline to.
  58337. * @param rootUrl The URL of the serialized pipeline.
  58338. * @returns An instantiated pipeline from the serialized object.
  58339. */
  58340. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  58341. /**
  58342. * Luminance steps
  58343. */
  58344. static LuminanceSteps: number;
  58345. }
  58346. }
  58347. declare module BABYLON {
  58348. /** @hidden */
  58349. export var tonemapPixelShader: {
  58350. name: string;
  58351. shader: string;
  58352. };
  58353. }
  58354. declare module BABYLON {
  58355. /** Defines operator used for tonemapping */
  58356. export enum TonemappingOperator {
  58357. /** Hable */
  58358. Hable = 0,
  58359. /** Reinhard */
  58360. Reinhard = 1,
  58361. /** HejiDawson */
  58362. HejiDawson = 2,
  58363. /** Photographic */
  58364. Photographic = 3
  58365. }
  58366. /**
  58367. * Defines a post process to apply tone mapping
  58368. */
  58369. export class TonemapPostProcess extends PostProcess {
  58370. private _operator;
  58371. /** Defines the required exposure adjustement */
  58372. exposureAdjustment: number;
  58373. /**
  58374. * Creates a new TonemapPostProcess
  58375. * @param name defines the name of the postprocess
  58376. * @param _operator defines the operator to use
  58377. * @param exposureAdjustment defines the required exposure adjustement
  58378. * @param camera defines the camera to use (can be null)
  58379. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  58380. * @param engine defines the hosting engine (can be ignore if camera is set)
  58381. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58382. */
  58383. constructor(name: string, _operator: TonemappingOperator,
  58384. /** Defines the required exposure adjustement */
  58385. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  58386. }
  58387. }
  58388. declare module BABYLON {
  58389. /** @hidden */
  58390. export var depthVertexShader: {
  58391. name: string;
  58392. shader: string;
  58393. };
  58394. }
  58395. declare module BABYLON {
  58396. /** @hidden */
  58397. export var volumetricLightScatteringPixelShader: {
  58398. name: string;
  58399. shader: string;
  58400. };
  58401. }
  58402. declare module BABYLON {
  58403. /** @hidden */
  58404. export var volumetricLightScatteringPassPixelShader: {
  58405. name: string;
  58406. shader: string;
  58407. };
  58408. }
  58409. declare module BABYLON {
  58410. /**
  58411. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  58412. */
  58413. export class VolumetricLightScatteringPostProcess extends PostProcess {
  58414. private _volumetricLightScatteringPass;
  58415. private _volumetricLightScatteringRTT;
  58416. private _viewPort;
  58417. private _screenCoordinates;
  58418. private _cachedDefines;
  58419. /**
  58420. * If not undefined, the mesh position is computed from the attached node position
  58421. */
  58422. attachedNode: {
  58423. position: Vector3;
  58424. };
  58425. /**
  58426. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  58427. */
  58428. customMeshPosition: Vector3;
  58429. /**
  58430. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  58431. */
  58432. useCustomMeshPosition: boolean;
  58433. /**
  58434. * If the post-process should inverse the light scattering direction
  58435. */
  58436. invert: boolean;
  58437. /**
  58438. * The internal mesh used by the post-process
  58439. */
  58440. mesh: Mesh;
  58441. /**
  58442. * @hidden
  58443. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  58444. */
  58445. useDiffuseColor: boolean;
  58446. /**
  58447. * Array containing the excluded meshes not rendered in the internal pass
  58448. */
  58449. excludedMeshes: AbstractMesh[];
  58450. /**
  58451. * Controls the overall intensity of the post-process
  58452. */
  58453. exposure: number;
  58454. /**
  58455. * Dissipates each sample's contribution in range [0, 1]
  58456. */
  58457. decay: number;
  58458. /**
  58459. * Controls the overall intensity of each sample
  58460. */
  58461. weight: number;
  58462. /**
  58463. * Controls the density of each sample
  58464. */
  58465. density: number;
  58466. /**
  58467. * @constructor
  58468. * @param name The post-process name
  58469. * @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)
  58470. * @param camera The camera that the post-process will be attached to
  58471. * @param mesh The mesh used to create the light scattering
  58472. * @param samples The post-process quality, default 100
  58473. * @param samplingModeThe post-process filtering mode
  58474. * @param engine The babylon engine
  58475. * @param reusable If the post-process is reusable
  58476. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  58477. */
  58478. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  58479. /**
  58480. * Returns the string "VolumetricLightScatteringPostProcess"
  58481. * @returns "VolumetricLightScatteringPostProcess"
  58482. */
  58483. getClassName(): string;
  58484. private _isReady;
  58485. /**
  58486. * Sets the new light position for light scattering effect
  58487. * @param position The new custom light position
  58488. */
  58489. setCustomMeshPosition(position: Vector3): void;
  58490. /**
  58491. * Returns the light position for light scattering effect
  58492. * @return Vector3 The custom light position
  58493. */
  58494. getCustomMeshPosition(): Vector3;
  58495. /**
  58496. * Disposes the internal assets and detaches the post-process from the camera
  58497. */
  58498. dispose(camera: Camera): void;
  58499. /**
  58500. * Returns the render target texture used by the post-process
  58501. * @return the render target texture used by the post-process
  58502. */
  58503. getPass(): RenderTargetTexture;
  58504. private _meshExcluded;
  58505. private _createPass;
  58506. private _updateMeshScreenCoordinates;
  58507. /**
  58508. * Creates a default mesh for the Volumeric Light Scattering post-process
  58509. * @param name The mesh name
  58510. * @param scene The scene where to create the mesh
  58511. * @return the default mesh
  58512. */
  58513. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  58514. }
  58515. }
  58516. declare module BABYLON {
  58517. interface Scene {
  58518. /** @hidden (Backing field) */
  58519. _boundingBoxRenderer: BoundingBoxRenderer;
  58520. /** @hidden (Backing field) */
  58521. _forceShowBoundingBoxes: boolean;
  58522. /**
  58523. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  58524. */
  58525. forceShowBoundingBoxes: boolean;
  58526. /**
  58527. * Gets the bounding box renderer associated with the scene
  58528. * @returns a BoundingBoxRenderer
  58529. */
  58530. getBoundingBoxRenderer(): BoundingBoxRenderer;
  58531. }
  58532. interface AbstractMesh {
  58533. /** @hidden (Backing field) */
  58534. _showBoundingBox: boolean;
  58535. /**
  58536. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  58537. */
  58538. showBoundingBox: boolean;
  58539. }
  58540. /**
  58541. * Component responsible of rendering the bounding box of the meshes in a scene.
  58542. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  58543. */
  58544. export class BoundingBoxRenderer implements ISceneComponent {
  58545. /**
  58546. * The component name helpfull to identify the component in the list of scene components.
  58547. */
  58548. readonly name: string;
  58549. /**
  58550. * The scene the component belongs to.
  58551. */
  58552. scene: Scene;
  58553. /**
  58554. * Color of the bounding box lines placed in front of an object
  58555. */
  58556. frontColor: Color3;
  58557. /**
  58558. * Color of the bounding box lines placed behind an object
  58559. */
  58560. backColor: Color3;
  58561. /**
  58562. * Defines if the renderer should show the back lines or not
  58563. */
  58564. showBackLines: boolean;
  58565. /**
  58566. * @hidden
  58567. */
  58568. renderList: SmartArray<BoundingBox>;
  58569. private _colorShader;
  58570. private _vertexBuffers;
  58571. private _indexBuffer;
  58572. private _fillIndexBuffer;
  58573. private _fillIndexData;
  58574. /**
  58575. * Instantiates a new bounding box renderer in a scene.
  58576. * @param scene the scene the renderer renders in
  58577. */
  58578. constructor(scene: Scene);
  58579. /**
  58580. * Registers the component in a given scene
  58581. */
  58582. register(): void;
  58583. private _evaluateSubMesh;
  58584. private _activeMesh;
  58585. private _prepareRessources;
  58586. private _createIndexBuffer;
  58587. /**
  58588. * Rebuilds the elements related to this component in case of
  58589. * context lost for instance.
  58590. */
  58591. rebuild(): void;
  58592. /**
  58593. * @hidden
  58594. */
  58595. reset(): void;
  58596. /**
  58597. * Render the bounding boxes of a specific rendering group
  58598. * @param renderingGroupId defines the rendering group to render
  58599. */
  58600. render(renderingGroupId: number): void;
  58601. /**
  58602. * In case of occlusion queries, we can render the occlusion bounding box through this method
  58603. * @param mesh Define the mesh to render the occlusion bounding box for
  58604. */
  58605. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  58606. /**
  58607. * Dispose and release the resources attached to this renderer.
  58608. */
  58609. dispose(): void;
  58610. }
  58611. }
  58612. declare module BABYLON {
  58613. /** @hidden */
  58614. export var depthPixelShader: {
  58615. name: string;
  58616. shader: string;
  58617. };
  58618. }
  58619. declare module BABYLON {
  58620. /**
  58621. * This represents a depth renderer in Babylon.
  58622. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58623. */
  58624. export class DepthRenderer {
  58625. private _scene;
  58626. private _depthMap;
  58627. private _effect;
  58628. private readonly _storeNonLinearDepth;
  58629. private readonly _clearColor;
  58630. /** Get if the depth renderer is using packed depth or not */
  58631. readonly isPacked: boolean;
  58632. private _cachedDefines;
  58633. private _camera;
  58634. /**
  58635. * Specifiess that the depth renderer will only be used within
  58636. * the camera it is created for.
  58637. * This can help forcing its rendering during the camera processing.
  58638. */
  58639. useOnlyInActiveCamera: boolean;
  58640. /** @hidden */
  58641. static _SceneComponentInitialization: (scene: Scene) => void;
  58642. /**
  58643. * Instantiates a depth renderer
  58644. * @param scene The scene the renderer belongs to
  58645. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58646. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58647. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58648. */
  58649. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58650. /**
  58651. * Creates the depth rendering effect and checks if the effect is ready.
  58652. * @param subMesh The submesh to be used to render the depth map of
  58653. * @param useInstances If multiple world instances should be used
  58654. * @returns if the depth renderer is ready to render the depth map
  58655. */
  58656. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58657. /**
  58658. * Gets the texture which the depth map will be written to.
  58659. * @returns The depth map texture
  58660. */
  58661. getDepthMap(): RenderTargetTexture;
  58662. /**
  58663. * Disposes of the depth renderer.
  58664. */
  58665. dispose(): void;
  58666. }
  58667. }
  58668. declare module BABYLON {
  58669. interface Scene {
  58670. /** @hidden (Backing field) */
  58671. _depthRenderer: {
  58672. [id: string]: DepthRenderer;
  58673. };
  58674. /**
  58675. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  58676. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  58677. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58678. * @returns the created depth renderer
  58679. */
  58680. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  58681. /**
  58682. * Disables a depth renderer for a given camera
  58683. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  58684. */
  58685. disableDepthRenderer(camera?: Nullable<Camera>): void;
  58686. }
  58687. /**
  58688. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  58689. * in several rendering techniques.
  58690. */
  58691. export class DepthRendererSceneComponent implements ISceneComponent {
  58692. /**
  58693. * The component name helpfull to identify the component in the list of scene components.
  58694. */
  58695. readonly name: string;
  58696. /**
  58697. * The scene the component belongs to.
  58698. */
  58699. scene: Scene;
  58700. /**
  58701. * Creates a new instance of the component for the given scene
  58702. * @param scene Defines the scene to register the component in
  58703. */
  58704. constructor(scene: Scene);
  58705. /**
  58706. * Registers the component in a given scene
  58707. */
  58708. register(): void;
  58709. /**
  58710. * Rebuilds the elements related to this component in case of
  58711. * context lost for instance.
  58712. */
  58713. rebuild(): void;
  58714. /**
  58715. * Disposes the component and the associated ressources
  58716. */
  58717. dispose(): void;
  58718. private _gatherRenderTargets;
  58719. private _gatherActiveCameraRenderTargets;
  58720. }
  58721. }
  58722. declare module BABYLON {
  58723. /** @hidden */
  58724. export var outlinePixelShader: {
  58725. name: string;
  58726. shader: string;
  58727. };
  58728. }
  58729. declare module BABYLON {
  58730. /** @hidden */
  58731. export var outlineVertexShader: {
  58732. name: string;
  58733. shader: string;
  58734. };
  58735. }
  58736. declare module BABYLON {
  58737. interface Scene {
  58738. /** @hidden */
  58739. _outlineRenderer: OutlineRenderer;
  58740. /**
  58741. * Gets the outline renderer associated with the scene
  58742. * @returns a OutlineRenderer
  58743. */
  58744. getOutlineRenderer(): OutlineRenderer;
  58745. }
  58746. interface AbstractMesh {
  58747. /** @hidden (Backing field) */
  58748. _renderOutline: boolean;
  58749. /**
  58750. * Gets or sets a boolean indicating if the outline must be rendered as well
  58751. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  58752. */
  58753. renderOutline: boolean;
  58754. /** @hidden (Backing field) */
  58755. _renderOverlay: boolean;
  58756. /**
  58757. * Gets or sets a boolean indicating if the overlay must be rendered as well
  58758. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  58759. */
  58760. renderOverlay: boolean;
  58761. }
  58762. /**
  58763. * This class is responsible to draw bothe outline/overlay of meshes.
  58764. * It should not be used directly but through the available method on mesh.
  58765. */
  58766. export class OutlineRenderer implements ISceneComponent {
  58767. /**
  58768. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  58769. */
  58770. private static _StencilReference;
  58771. /**
  58772. * The name of the component. Each component must have a unique name.
  58773. */
  58774. name: string;
  58775. /**
  58776. * The scene the component belongs to.
  58777. */
  58778. scene: Scene;
  58779. /**
  58780. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  58781. */
  58782. zOffset: number;
  58783. private _engine;
  58784. private _effect;
  58785. private _cachedDefines;
  58786. private _savedDepthWrite;
  58787. /**
  58788. * Instantiates a new outline renderer. (There could be only one per scene).
  58789. * @param scene Defines the scene it belongs to
  58790. */
  58791. constructor(scene: Scene);
  58792. /**
  58793. * Register the component to one instance of a scene.
  58794. */
  58795. register(): void;
  58796. /**
  58797. * Rebuilds the elements related to this component in case of
  58798. * context lost for instance.
  58799. */
  58800. rebuild(): void;
  58801. /**
  58802. * Disposes the component and the associated ressources.
  58803. */
  58804. dispose(): void;
  58805. /**
  58806. * Renders the outline in the canvas.
  58807. * @param subMesh Defines the sumesh to render
  58808. * @param batch Defines the batch of meshes in case of instances
  58809. * @param useOverlay Defines if the rendering is for the overlay or the outline
  58810. */
  58811. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  58812. /**
  58813. * Returns whether or not the outline renderer is ready for a given submesh.
  58814. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  58815. * @param subMesh Defines the submesh to check readyness for
  58816. * @param useInstances Defines wheter wee are trying to render instances or not
  58817. * @returns true if ready otherwise false
  58818. */
  58819. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58820. private _beforeRenderingMesh;
  58821. private _afterRenderingMesh;
  58822. }
  58823. }
  58824. declare module BABYLON {
  58825. /**
  58826. * Defines the list of states available for a task inside a AssetsManager
  58827. */
  58828. export enum AssetTaskState {
  58829. /**
  58830. * Initialization
  58831. */
  58832. INIT = 0,
  58833. /**
  58834. * Running
  58835. */
  58836. RUNNING = 1,
  58837. /**
  58838. * Done
  58839. */
  58840. DONE = 2,
  58841. /**
  58842. * Error
  58843. */
  58844. ERROR = 3
  58845. }
  58846. /**
  58847. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  58848. */
  58849. export abstract class AbstractAssetTask {
  58850. /**
  58851. * Task name
  58852. */ name: string;
  58853. /**
  58854. * Callback called when the task is successful
  58855. */
  58856. onSuccess: (task: any) => void;
  58857. /**
  58858. * Callback called when the task is not successful
  58859. */
  58860. onError: (task: any, message?: string, exception?: any) => void;
  58861. /**
  58862. * Creates a new AssetsManager
  58863. * @param name defines the name of the task
  58864. */
  58865. constructor(
  58866. /**
  58867. * Task name
  58868. */ name: string);
  58869. private _isCompleted;
  58870. private _taskState;
  58871. private _errorObject;
  58872. /**
  58873. * Get if the task is completed
  58874. */
  58875. readonly isCompleted: boolean;
  58876. /**
  58877. * Gets the current state of the task
  58878. */
  58879. readonly taskState: AssetTaskState;
  58880. /**
  58881. * Gets the current error object (if task is in error)
  58882. */
  58883. readonly errorObject: {
  58884. message?: string;
  58885. exception?: any;
  58886. };
  58887. /**
  58888. * Internal only
  58889. * @hidden
  58890. */
  58891. _setErrorObject(message?: string, exception?: any): void;
  58892. /**
  58893. * Execute the current task
  58894. * @param scene defines the scene where you want your assets to be loaded
  58895. * @param onSuccess is a callback called when the task is successfully executed
  58896. * @param onError is a callback called if an error occurs
  58897. */
  58898. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58899. /**
  58900. * Execute the current task
  58901. * @param scene defines the scene where you want your assets to be loaded
  58902. * @param onSuccess is a callback called when the task is successfully executed
  58903. * @param onError is a callback called if an error occurs
  58904. */
  58905. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58906. /**
  58907. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  58908. * This can be used with failed tasks that have the reason for failure fixed.
  58909. */
  58910. reset(): void;
  58911. private onErrorCallback;
  58912. private onDoneCallback;
  58913. }
  58914. /**
  58915. * Define the interface used by progress events raised during assets loading
  58916. */
  58917. export interface IAssetsProgressEvent {
  58918. /**
  58919. * Defines the number of remaining tasks to process
  58920. */
  58921. remainingCount: number;
  58922. /**
  58923. * Defines the total number of tasks
  58924. */
  58925. totalCount: number;
  58926. /**
  58927. * Defines the task that was just processed
  58928. */
  58929. task: AbstractAssetTask;
  58930. }
  58931. /**
  58932. * Class used to share progress information about assets loading
  58933. */
  58934. export class AssetsProgressEvent implements IAssetsProgressEvent {
  58935. /**
  58936. * Defines the number of remaining tasks to process
  58937. */
  58938. remainingCount: number;
  58939. /**
  58940. * Defines the total number of tasks
  58941. */
  58942. totalCount: number;
  58943. /**
  58944. * Defines the task that was just processed
  58945. */
  58946. task: AbstractAssetTask;
  58947. /**
  58948. * Creates a AssetsProgressEvent
  58949. * @param remainingCount defines the number of remaining tasks to process
  58950. * @param totalCount defines the total number of tasks
  58951. * @param task defines the task that was just processed
  58952. */
  58953. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  58954. }
  58955. /**
  58956. * Define a task used by AssetsManager to load meshes
  58957. */
  58958. export class MeshAssetTask extends AbstractAssetTask {
  58959. /**
  58960. * Defines the name of the task
  58961. */
  58962. name: string;
  58963. /**
  58964. * Defines the list of mesh's names you want to load
  58965. */
  58966. meshesNames: any;
  58967. /**
  58968. * Defines the root url to use as a base to load your meshes and associated resources
  58969. */
  58970. rootUrl: string;
  58971. /**
  58972. * Defines the filename of the scene to load from
  58973. */
  58974. sceneFilename: string;
  58975. /**
  58976. * Gets the list of loaded meshes
  58977. */
  58978. loadedMeshes: Array<AbstractMesh>;
  58979. /**
  58980. * Gets the list of loaded particle systems
  58981. */
  58982. loadedParticleSystems: Array<IParticleSystem>;
  58983. /**
  58984. * Gets the list of loaded skeletons
  58985. */
  58986. loadedSkeletons: Array<Skeleton>;
  58987. /**
  58988. * Gets the list of loaded animation groups
  58989. */
  58990. loadedAnimationGroups: Array<AnimationGroup>;
  58991. /**
  58992. * Callback called when the task is successful
  58993. */
  58994. onSuccess: (task: MeshAssetTask) => void;
  58995. /**
  58996. * Callback called when the task is successful
  58997. */
  58998. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  58999. /**
  59000. * Creates a new MeshAssetTask
  59001. * @param name defines the name of the task
  59002. * @param meshesNames defines the list of mesh's names you want to load
  59003. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  59004. * @param sceneFilename defines the filename of the scene to load from
  59005. */
  59006. constructor(
  59007. /**
  59008. * Defines the name of the task
  59009. */
  59010. name: string,
  59011. /**
  59012. * Defines the list of mesh's names you want to load
  59013. */
  59014. meshesNames: any,
  59015. /**
  59016. * Defines the root url to use as a base to load your meshes and associated resources
  59017. */
  59018. rootUrl: string,
  59019. /**
  59020. * Defines the filename of the scene to load from
  59021. */
  59022. sceneFilename: string);
  59023. /**
  59024. * Execute the current task
  59025. * @param scene defines the scene where you want your assets to be loaded
  59026. * @param onSuccess is a callback called when the task is successfully executed
  59027. * @param onError is a callback called if an error occurs
  59028. */
  59029. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59030. }
  59031. /**
  59032. * Define a task used by AssetsManager to load text content
  59033. */
  59034. export class TextFileAssetTask extends AbstractAssetTask {
  59035. /**
  59036. * Defines the name of the task
  59037. */
  59038. name: string;
  59039. /**
  59040. * Defines the location of the file to load
  59041. */
  59042. url: string;
  59043. /**
  59044. * Gets the loaded text string
  59045. */
  59046. text: string;
  59047. /**
  59048. * Callback called when the task is successful
  59049. */
  59050. onSuccess: (task: TextFileAssetTask) => void;
  59051. /**
  59052. * Callback called when the task is successful
  59053. */
  59054. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  59055. /**
  59056. * Creates a new TextFileAssetTask object
  59057. * @param name defines the name of the task
  59058. * @param url defines the location of the file to load
  59059. */
  59060. constructor(
  59061. /**
  59062. * Defines the name of the task
  59063. */
  59064. name: string,
  59065. /**
  59066. * Defines the location of the file to load
  59067. */
  59068. url: string);
  59069. /**
  59070. * Execute the current task
  59071. * @param scene defines the scene where you want your assets to be loaded
  59072. * @param onSuccess is a callback called when the task is successfully executed
  59073. * @param onError is a callback called if an error occurs
  59074. */
  59075. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59076. }
  59077. /**
  59078. * Define a task used by AssetsManager to load binary data
  59079. */
  59080. export class BinaryFileAssetTask extends AbstractAssetTask {
  59081. /**
  59082. * Defines the name of the task
  59083. */
  59084. name: string;
  59085. /**
  59086. * Defines the location of the file to load
  59087. */
  59088. url: string;
  59089. /**
  59090. * Gets the lodaded data (as an array buffer)
  59091. */
  59092. data: ArrayBuffer;
  59093. /**
  59094. * Callback called when the task is successful
  59095. */
  59096. onSuccess: (task: BinaryFileAssetTask) => void;
  59097. /**
  59098. * Callback called when the task is successful
  59099. */
  59100. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  59101. /**
  59102. * Creates a new BinaryFileAssetTask object
  59103. * @param name defines the name of the new task
  59104. * @param url defines the location of the file to load
  59105. */
  59106. constructor(
  59107. /**
  59108. * Defines the name of the task
  59109. */
  59110. name: string,
  59111. /**
  59112. * Defines the location of the file to load
  59113. */
  59114. url: string);
  59115. /**
  59116. * Execute the current task
  59117. * @param scene defines the scene where you want your assets to be loaded
  59118. * @param onSuccess is a callback called when the task is successfully executed
  59119. * @param onError is a callback called if an error occurs
  59120. */
  59121. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59122. }
  59123. /**
  59124. * Define a task used by AssetsManager to load images
  59125. */
  59126. export class ImageAssetTask extends AbstractAssetTask {
  59127. /**
  59128. * Defines the name of the task
  59129. */
  59130. name: string;
  59131. /**
  59132. * Defines the location of the image to load
  59133. */
  59134. url: string;
  59135. /**
  59136. * Gets the loaded images
  59137. */
  59138. image: HTMLImageElement;
  59139. /**
  59140. * Callback called when the task is successful
  59141. */
  59142. onSuccess: (task: ImageAssetTask) => void;
  59143. /**
  59144. * Callback called when the task is successful
  59145. */
  59146. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  59147. /**
  59148. * Creates a new ImageAssetTask
  59149. * @param name defines the name of the task
  59150. * @param url defines the location of the image to load
  59151. */
  59152. constructor(
  59153. /**
  59154. * Defines the name of the task
  59155. */
  59156. name: string,
  59157. /**
  59158. * Defines the location of the image to load
  59159. */
  59160. url: string);
  59161. /**
  59162. * Execute the current task
  59163. * @param scene defines the scene where you want your assets to be loaded
  59164. * @param onSuccess is a callback called when the task is successfully executed
  59165. * @param onError is a callback called if an error occurs
  59166. */
  59167. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59168. }
  59169. /**
  59170. * Defines the interface used by texture loading tasks
  59171. */
  59172. export interface ITextureAssetTask<TEX extends BaseTexture> {
  59173. /**
  59174. * Gets the loaded texture
  59175. */
  59176. texture: TEX;
  59177. }
  59178. /**
  59179. * Define a task used by AssetsManager to load 2D textures
  59180. */
  59181. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  59182. /**
  59183. * Defines the name of the task
  59184. */
  59185. name: string;
  59186. /**
  59187. * Defines the location of the file to load
  59188. */
  59189. url: string;
  59190. /**
  59191. * Defines if mipmap should not be generated (default is false)
  59192. */
  59193. noMipmap?: boolean | undefined;
  59194. /**
  59195. * Defines if texture must be inverted on Y axis (default is false)
  59196. */
  59197. invertY?: boolean | undefined;
  59198. /**
  59199. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  59200. */
  59201. samplingMode: number;
  59202. /**
  59203. * Gets the loaded texture
  59204. */
  59205. texture: Texture;
  59206. /**
  59207. * Callback called when the task is successful
  59208. */
  59209. onSuccess: (task: TextureAssetTask) => void;
  59210. /**
  59211. * Callback called when the task is successful
  59212. */
  59213. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  59214. /**
  59215. * Creates a new TextureAssetTask object
  59216. * @param name defines the name of the task
  59217. * @param url defines the location of the file to load
  59218. * @param noMipmap defines if mipmap should not be generated (default is false)
  59219. * @param invertY defines if texture must be inverted on Y axis (default is false)
  59220. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  59221. */
  59222. constructor(
  59223. /**
  59224. * Defines the name of the task
  59225. */
  59226. name: string,
  59227. /**
  59228. * Defines the location of the file to load
  59229. */
  59230. url: string,
  59231. /**
  59232. * Defines if mipmap should not be generated (default is false)
  59233. */
  59234. noMipmap?: boolean | undefined,
  59235. /**
  59236. * Defines if texture must be inverted on Y axis (default is false)
  59237. */
  59238. invertY?: boolean | undefined,
  59239. /**
  59240. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  59241. */
  59242. samplingMode?: number);
  59243. /**
  59244. * Execute the current task
  59245. * @param scene defines the scene where you want your assets to be loaded
  59246. * @param onSuccess is a callback called when the task is successfully executed
  59247. * @param onError is a callback called if an error occurs
  59248. */
  59249. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59250. }
  59251. /**
  59252. * Define a task used by AssetsManager to load cube textures
  59253. */
  59254. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  59255. /**
  59256. * Defines the name of the task
  59257. */
  59258. name: string;
  59259. /**
  59260. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  59261. */
  59262. url: string;
  59263. /**
  59264. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  59265. */
  59266. extensions?: string[] | undefined;
  59267. /**
  59268. * Defines if mipmaps should not be generated (default is false)
  59269. */
  59270. noMipmap?: boolean | undefined;
  59271. /**
  59272. * Defines the explicit list of files (undefined by default)
  59273. */
  59274. files?: string[] | undefined;
  59275. /**
  59276. * Gets the loaded texture
  59277. */
  59278. texture: CubeTexture;
  59279. /**
  59280. * Callback called when the task is successful
  59281. */
  59282. onSuccess: (task: CubeTextureAssetTask) => void;
  59283. /**
  59284. * Callback called when the task is successful
  59285. */
  59286. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  59287. /**
  59288. * Creates a new CubeTextureAssetTask
  59289. * @param name defines the name of the task
  59290. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  59291. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  59292. * @param noMipmap defines if mipmaps should not be generated (default is false)
  59293. * @param files defines the explicit list of files (undefined by default)
  59294. */
  59295. constructor(
  59296. /**
  59297. * Defines the name of the task
  59298. */
  59299. name: string,
  59300. /**
  59301. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  59302. */
  59303. url: string,
  59304. /**
  59305. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  59306. */
  59307. extensions?: string[] | undefined,
  59308. /**
  59309. * Defines if mipmaps should not be generated (default is false)
  59310. */
  59311. noMipmap?: boolean | undefined,
  59312. /**
  59313. * Defines the explicit list of files (undefined by default)
  59314. */
  59315. files?: string[] | undefined);
  59316. /**
  59317. * Execute the current task
  59318. * @param scene defines the scene where you want your assets to be loaded
  59319. * @param onSuccess is a callback called when the task is successfully executed
  59320. * @param onError is a callback called if an error occurs
  59321. */
  59322. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59323. }
  59324. /**
  59325. * Define a task used by AssetsManager to load HDR cube textures
  59326. */
  59327. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  59328. /**
  59329. * Defines the name of the task
  59330. */
  59331. name: string;
  59332. /**
  59333. * Defines the location of the file to load
  59334. */
  59335. url: string;
  59336. /**
  59337. * Defines the desired size (the more it increases the longer the generation will be)
  59338. */
  59339. size: number;
  59340. /**
  59341. * Defines if mipmaps should not be generated (default is false)
  59342. */
  59343. noMipmap: boolean;
  59344. /**
  59345. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  59346. */
  59347. generateHarmonics: boolean;
  59348. /**
  59349. * 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)
  59350. */
  59351. gammaSpace: boolean;
  59352. /**
  59353. * Internal Use Only
  59354. */
  59355. reserved: boolean;
  59356. /**
  59357. * Gets the loaded texture
  59358. */
  59359. texture: HDRCubeTexture;
  59360. /**
  59361. * Callback called when the task is successful
  59362. */
  59363. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  59364. /**
  59365. * Callback called when the task is successful
  59366. */
  59367. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  59368. /**
  59369. * Creates a new HDRCubeTextureAssetTask object
  59370. * @param name defines the name of the task
  59371. * @param url defines the location of the file to load
  59372. * @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.
  59373. * @param noMipmap defines if mipmaps should not be generated (default is false)
  59374. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  59375. * @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)
  59376. * @param reserved Internal use only
  59377. */
  59378. constructor(
  59379. /**
  59380. * Defines the name of the task
  59381. */
  59382. name: string,
  59383. /**
  59384. * Defines the location of the file to load
  59385. */
  59386. url: string,
  59387. /**
  59388. * Defines the desired size (the more it increases the longer the generation will be)
  59389. */
  59390. size: number,
  59391. /**
  59392. * Defines if mipmaps should not be generated (default is false)
  59393. */
  59394. noMipmap?: boolean,
  59395. /**
  59396. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  59397. */
  59398. generateHarmonics?: boolean,
  59399. /**
  59400. * 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)
  59401. */
  59402. gammaSpace?: boolean,
  59403. /**
  59404. * Internal Use Only
  59405. */
  59406. reserved?: boolean);
  59407. /**
  59408. * Execute the current task
  59409. * @param scene defines the scene where you want your assets to be loaded
  59410. * @param onSuccess is a callback called when the task is successfully executed
  59411. * @param onError is a callback called if an error occurs
  59412. */
  59413. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59414. }
  59415. /**
  59416. * Define a task used by AssetsManager to load Equirectangular cube textures
  59417. */
  59418. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  59419. /**
  59420. * Defines the name of the task
  59421. */
  59422. name: string;
  59423. /**
  59424. * Defines the location of the file to load
  59425. */
  59426. url: string;
  59427. /**
  59428. * Defines the desired size (the more it increases the longer the generation will be)
  59429. */
  59430. size: number;
  59431. /**
  59432. * Defines if mipmaps should not be generated (default is false)
  59433. */
  59434. noMipmap: boolean;
  59435. /**
  59436. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  59437. * but the standard material would require them in Gamma space) (default is true)
  59438. */
  59439. gammaSpace: boolean;
  59440. /**
  59441. * Gets the loaded texture
  59442. */
  59443. texture: EquiRectangularCubeTexture;
  59444. /**
  59445. * Callback called when the task is successful
  59446. */
  59447. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  59448. /**
  59449. * Callback called when the task is successful
  59450. */
  59451. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  59452. /**
  59453. * Creates a new EquiRectangularCubeTextureAssetTask object
  59454. * @param name defines the name of the task
  59455. * @param url defines the location of the file to load
  59456. * @param size defines the desired size (the more it increases the longer the generation will be)
  59457. * If the size is omitted this implies you are using a preprocessed cubemap.
  59458. * @param noMipmap defines if mipmaps should not be generated (default is false)
  59459. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  59460. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  59461. * (default is true)
  59462. */
  59463. constructor(
  59464. /**
  59465. * Defines the name of the task
  59466. */
  59467. name: string,
  59468. /**
  59469. * Defines the location of the file to load
  59470. */
  59471. url: string,
  59472. /**
  59473. * Defines the desired size (the more it increases the longer the generation will be)
  59474. */
  59475. size: number,
  59476. /**
  59477. * Defines if mipmaps should not be generated (default is false)
  59478. */
  59479. noMipmap?: boolean,
  59480. /**
  59481. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  59482. * but the standard material would require them in Gamma space) (default is true)
  59483. */
  59484. gammaSpace?: boolean);
  59485. /**
  59486. * Execute the current task
  59487. * @param scene defines the scene where you want your assets to be loaded
  59488. * @param onSuccess is a callback called when the task is successfully executed
  59489. * @param onError is a callback called if an error occurs
  59490. */
  59491. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59492. }
  59493. /**
  59494. * This class can be used to easily import assets into a scene
  59495. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  59496. */
  59497. export class AssetsManager {
  59498. private _scene;
  59499. private _isLoading;
  59500. protected _tasks: AbstractAssetTask[];
  59501. protected _waitingTasksCount: number;
  59502. protected _totalTasksCount: number;
  59503. /**
  59504. * Callback called when all tasks are processed
  59505. */
  59506. onFinish: (tasks: AbstractAssetTask[]) => void;
  59507. /**
  59508. * Callback called when a task is successful
  59509. */
  59510. onTaskSuccess: (task: AbstractAssetTask) => void;
  59511. /**
  59512. * Callback called when a task had an error
  59513. */
  59514. onTaskError: (task: AbstractAssetTask) => void;
  59515. /**
  59516. * Callback called when a task is done (whatever the result is)
  59517. */
  59518. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  59519. /**
  59520. * Observable called when all tasks are processed
  59521. */
  59522. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  59523. /**
  59524. * Observable called when a task had an error
  59525. */
  59526. onTaskErrorObservable: Observable<AbstractAssetTask>;
  59527. /**
  59528. * Observable called when all tasks were executed
  59529. */
  59530. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  59531. /**
  59532. * Observable called when a task is done (whatever the result is)
  59533. */
  59534. onProgressObservable: Observable<IAssetsProgressEvent>;
  59535. /**
  59536. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  59537. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  59538. */
  59539. useDefaultLoadingScreen: boolean;
  59540. /**
  59541. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  59542. * when all assets have been downloaded.
  59543. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  59544. */
  59545. autoHideLoadingUI: boolean;
  59546. /**
  59547. * Creates a new AssetsManager
  59548. * @param scene defines the scene to work on
  59549. */
  59550. constructor(scene: Scene);
  59551. /**
  59552. * Add a MeshAssetTask to the list of active tasks
  59553. * @param taskName defines the name of the new task
  59554. * @param meshesNames defines the name of meshes to load
  59555. * @param rootUrl defines the root url to use to locate files
  59556. * @param sceneFilename defines the filename of the scene file
  59557. * @returns a new MeshAssetTask object
  59558. */
  59559. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  59560. /**
  59561. * Add a TextFileAssetTask to the list of active tasks
  59562. * @param taskName defines the name of the new task
  59563. * @param url defines the url of the file to load
  59564. * @returns a new TextFileAssetTask object
  59565. */
  59566. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  59567. /**
  59568. * Add a BinaryFileAssetTask to the list of active tasks
  59569. * @param taskName defines the name of the new task
  59570. * @param url defines the url of the file to load
  59571. * @returns a new BinaryFileAssetTask object
  59572. */
  59573. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  59574. /**
  59575. * Add a ImageAssetTask to the list of active tasks
  59576. * @param taskName defines the name of the new task
  59577. * @param url defines the url of the file to load
  59578. * @returns a new ImageAssetTask object
  59579. */
  59580. addImageTask(taskName: string, url: string): ImageAssetTask;
  59581. /**
  59582. * Add a TextureAssetTask to the list of active tasks
  59583. * @param taskName defines the name of the new task
  59584. * @param url defines the url of the file to load
  59585. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  59586. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  59587. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59588. * @returns a new TextureAssetTask object
  59589. */
  59590. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  59591. /**
  59592. * Add a CubeTextureAssetTask to the list of active tasks
  59593. * @param taskName defines the name of the new task
  59594. * @param url defines the url of the file to load
  59595. * @param extensions defines the extension to use to load the cube map (can be null)
  59596. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  59597. * @param files defines the list of files to load (can be null)
  59598. * @returns a new CubeTextureAssetTask object
  59599. */
  59600. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  59601. /**
  59602. *
  59603. * Add a HDRCubeTextureAssetTask to the list of active tasks
  59604. * @param taskName defines the name of the new task
  59605. * @param url defines the url of the file to load
  59606. * @param size defines the size you want for the cubemap (can be null)
  59607. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  59608. * @param generateHarmonics defines if you want to automatically generate (true by default)
  59609. * @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)
  59610. * @param reserved Internal use only
  59611. * @returns a new HDRCubeTextureAssetTask object
  59612. */
  59613. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  59614. /**
  59615. *
  59616. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  59617. * @param taskName defines the name of the new task
  59618. * @param url defines the url of the file to load
  59619. * @param size defines the size you want for the cubemap (can be null)
  59620. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  59621. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59622. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59623. * @returns a new EquiRectangularCubeTextureAssetTask object
  59624. */
  59625. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  59626. /**
  59627. * Remove a task from the assets manager.
  59628. * @param task the task to remove
  59629. */
  59630. removeTask(task: AbstractAssetTask): void;
  59631. private _decreaseWaitingTasksCount;
  59632. private _runTask;
  59633. /**
  59634. * Reset the AssetsManager and remove all tasks
  59635. * @return the current instance of the AssetsManager
  59636. */
  59637. reset(): AssetsManager;
  59638. /**
  59639. * Start the loading process
  59640. * @return the current instance of the AssetsManager
  59641. */
  59642. load(): AssetsManager;
  59643. /**
  59644. * Start the loading process as an async operation
  59645. * @return a promise returning the list of failed tasks
  59646. */
  59647. loadAsync(): Promise<void>;
  59648. }
  59649. }
  59650. declare module BABYLON {
  59651. /**
  59652. * Wrapper class for promise with external resolve and reject.
  59653. */
  59654. export class Deferred<T> {
  59655. /**
  59656. * The promise associated with this deferred object.
  59657. */
  59658. readonly promise: Promise<T>;
  59659. private _resolve;
  59660. private _reject;
  59661. /**
  59662. * The resolve method of the promise associated with this deferred object.
  59663. */
  59664. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  59665. /**
  59666. * The reject method of the promise associated with this deferred object.
  59667. */
  59668. readonly reject: (reason?: any) => void;
  59669. /**
  59670. * Constructor for this deferred object.
  59671. */
  59672. constructor();
  59673. }
  59674. }
  59675. declare module BABYLON {
  59676. /**
  59677. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  59678. */
  59679. export class MeshExploder {
  59680. private _centerMesh;
  59681. private _meshes;
  59682. private _meshesOrigins;
  59683. private _toCenterVectors;
  59684. private _scaledDirection;
  59685. private _newPosition;
  59686. private _centerPosition;
  59687. /**
  59688. * Explodes meshes from a center mesh.
  59689. * @param meshes The meshes to explode.
  59690. * @param centerMesh The mesh to be center of explosion.
  59691. */
  59692. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  59693. private _setCenterMesh;
  59694. /**
  59695. * Get class name
  59696. * @returns "MeshExploder"
  59697. */
  59698. getClassName(): string;
  59699. /**
  59700. * "Exploded meshes"
  59701. * @returns Array of meshes with the centerMesh at index 0.
  59702. */
  59703. getMeshes(): Array<Mesh>;
  59704. /**
  59705. * Explodes meshes giving a specific direction
  59706. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  59707. */
  59708. explode(direction?: number): void;
  59709. }
  59710. }
  59711. declare module BABYLON {
  59712. /**
  59713. * Class used to help managing file picking and drag'n'drop
  59714. */
  59715. export class FilesInput {
  59716. /**
  59717. * List of files ready to be loaded
  59718. */
  59719. static readonly FilesToLoad: {
  59720. [key: string]: File;
  59721. };
  59722. /**
  59723. * Callback called when a file is processed
  59724. */
  59725. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  59726. private _engine;
  59727. private _currentScene;
  59728. private _sceneLoadedCallback;
  59729. private _progressCallback;
  59730. private _additionalRenderLoopLogicCallback;
  59731. private _textureLoadingCallback;
  59732. private _startingProcessingFilesCallback;
  59733. private _onReloadCallback;
  59734. private _errorCallback;
  59735. private _elementToMonitor;
  59736. private _sceneFileToLoad;
  59737. private _filesToLoad;
  59738. /**
  59739. * Creates a new FilesInput
  59740. * @param engine defines the rendering engine
  59741. * @param scene defines the hosting scene
  59742. * @param sceneLoadedCallback callback called when scene is loaded
  59743. * @param progressCallback callback called to track progress
  59744. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  59745. * @param textureLoadingCallback callback called when a texture is loading
  59746. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  59747. * @param onReloadCallback callback called when a reload is requested
  59748. * @param errorCallback callback call if an error occurs
  59749. */
  59750. 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);
  59751. private _dragEnterHandler;
  59752. private _dragOverHandler;
  59753. private _dropHandler;
  59754. /**
  59755. * Calls this function to listen to drag'n'drop events on a specific DOM element
  59756. * @param elementToMonitor defines the DOM element to track
  59757. */
  59758. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  59759. /**
  59760. * Release all associated resources
  59761. */
  59762. dispose(): void;
  59763. private renderFunction;
  59764. private drag;
  59765. private drop;
  59766. private _traverseFolder;
  59767. private _processFiles;
  59768. /**
  59769. * Load files from a drop event
  59770. * @param event defines the drop event to use as source
  59771. */
  59772. loadFiles(event: any): void;
  59773. private _processReload;
  59774. /**
  59775. * Reload the current scene from the loaded files
  59776. */
  59777. reload(): void;
  59778. }
  59779. }
  59780. declare module BABYLON {
  59781. /**
  59782. * Defines the root class used to create scene optimization to use with SceneOptimizer
  59783. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59784. */
  59785. export class SceneOptimization {
  59786. /**
  59787. * Defines the priority of this optimization (0 by default which means first in the list)
  59788. */
  59789. priority: number;
  59790. /**
  59791. * Gets a string describing the action executed by the current optimization
  59792. * @returns description string
  59793. */
  59794. getDescription(): string;
  59795. /**
  59796. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59797. * @param scene defines the current scene where to apply this optimization
  59798. * @param optimizer defines the current optimizer
  59799. * @returns true if everything that can be done was applied
  59800. */
  59801. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59802. /**
  59803. * Creates the SceneOptimization object
  59804. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59805. * @param desc defines the description associated with the optimization
  59806. */
  59807. constructor(
  59808. /**
  59809. * Defines the priority of this optimization (0 by default which means first in the list)
  59810. */
  59811. priority?: number);
  59812. }
  59813. /**
  59814. * Defines an optimization used to reduce the size of render target textures
  59815. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59816. */
  59817. export class TextureOptimization extends SceneOptimization {
  59818. /**
  59819. * Defines the priority of this optimization (0 by default which means first in the list)
  59820. */
  59821. priority: number;
  59822. /**
  59823. * 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
  59824. */
  59825. maximumSize: number;
  59826. /**
  59827. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  59828. */
  59829. step: number;
  59830. /**
  59831. * Gets a string describing the action executed by the current optimization
  59832. * @returns description string
  59833. */
  59834. getDescription(): string;
  59835. /**
  59836. * Creates the TextureOptimization object
  59837. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59838. * @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
  59839. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  59840. */
  59841. constructor(
  59842. /**
  59843. * Defines the priority of this optimization (0 by default which means first in the list)
  59844. */
  59845. priority?: number,
  59846. /**
  59847. * 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
  59848. */
  59849. maximumSize?: number,
  59850. /**
  59851. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  59852. */
  59853. step?: number);
  59854. /**
  59855. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59856. * @param scene defines the current scene where to apply this optimization
  59857. * @param optimizer defines the current optimizer
  59858. * @returns true if everything that can be done was applied
  59859. */
  59860. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59861. }
  59862. /**
  59863. * Defines an optimization used to increase or decrease the rendering resolution
  59864. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59865. */
  59866. export class HardwareScalingOptimization extends SceneOptimization {
  59867. /**
  59868. * Defines the priority of this optimization (0 by default which means first in the list)
  59869. */
  59870. priority: number;
  59871. /**
  59872. * Defines the maximum scale to use (2 by default)
  59873. */
  59874. maximumScale: number;
  59875. /**
  59876. * Defines the step to use between two passes (0.5 by default)
  59877. */
  59878. step: number;
  59879. private _currentScale;
  59880. private _directionOffset;
  59881. /**
  59882. * Gets a string describing the action executed by the current optimization
  59883. * @return description string
  59884. */
  59885. getDescription(): string;
  59886. /**
  59887. * Creates the HardwareScalingOptimization object
  59888. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59889. * @param maximumScale defines the maximum scale to use (2 by default)
  59890. * @param step defines the step to use between two passes (0.5 by default)
  59891. */
  59892. constructor(
  59893. /**
  59894. * Defines the priority of this optimization (0 by default which means first in the list)
  59895. */
  59896. priority?: number,
  59897. /**
  59898. * Defines the maximum scale to use (2 by default)
  59899. */
  59900. maximumScale?: number,
  59901. /**
  59902. * Defines the step to use between two passes (0.5 by default)
  59903. */
  59904. step?: number);
  59905. /**
  59906. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59907. * @param scene defines the current scene where to apply this optimization
  59908. * @param optimizer defines the current optimizer
  59909. * @returns true if everything that can be done was applied
  59910. */
  59911. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59912. }
  59913. /**
  59914. * Defines an optimization used to remove shadows
  59915. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59916. */
  59917. export class ShadowsOptimization extends SceneOptimization {
  59918. /**
  59919. * Gets a string describing the action executed by the current optimization
  59920. * @return description string
  59921. */
  59922. getDescription(): string;
  59923. /**
  59924. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59925. * @param scene defines the current scene where to apply this optimization
  59926. * @param optimizer defines the current optimizer
  59927. * @returns true if everything that can be done was applied
  59928. */
  59929. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59930. }
  59931. /**
  59932. * Defines an optimization used to turn post-processes off
  59933. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59934. */
  59935. export class PostProcessesOptimization extends SceneOptimization {
  59936. /**
  59937. * Gets a string describing the action executed by the current optimization
  59938. * @return description string
  59939. */
  59940. getDescription(): string;
  59941. /**
  59942. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59943. * @param scene defines the current scene where to apply this optimization
  59944. * @param optimizer defines the current optimizer
  59945. * @returns true if everything that can be done was applied
  59946. */
  59947. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59948. }
  59949. /**
  59950. * Defines an optimization used to turn lens flares off
  59951. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59952. */
  59953. export class LensFlaresOptimization extends SceneOptimization {
  59954. /**
  59955. * Gets a string describing the action executed by the current optimization
  59956. * @return description string
  59957. */
  59958. getDescription(): string;
  59959. /**
  59960. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59961. * @param scene defines the current scene where to apply this optimization
  59962. * @param optimizer defines the current optimizer
  59963. * @returns true if everything that can be done was applied
  59964. */
  59965. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59966. }
  59967. /**
  59968. * Defines an optimization based on user defined callback.
  59969. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59970. */
  59971. export class CustomOptimization extends SceneOptimization {
  59972. /**
  59973. * Callback called to apply the custom optimization.
  59974. */
  59975. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  59976. /**
  59977. * Callback called to get custom description
  59978. */
  59979. onGetDescription: () => string;
  59980. /**
  59981. * Gets a string describing the action executed by the current optimization
  59982. * @returns description string
  59983. */
  59984. getDescription(): string;
  59985. /**
  59986. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59987. * @param scene defines the current scene where to apply this optimization
  59988. * @param optimizer defines the current optimizer
  59989. * @returns true if everything that can be done was applied
  59990. */
  59991. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59992. }
  59993. /**
  59994. * Defines an optimization used to turn particles off
  59995. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59996. */
  59997. export class ParticlesOptimization extends SceneOptimization {
  59998. /**
  59999. * Gets a string describing the action executed by the current optimization
  60000. * @return description string
  60001. */
  60002. getDescription(): string;
  60003. /**
  60004. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60005. * @param scene defines the current scene where to apply this optimization
  60006. * @param optimizer defines the current optimizer
  60007. * @returns true if everything that can be done was applied
  60008. */
  60009. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60010. }
  60011. /**
  60012. * Defines an optimization used to turn render targets off
  60013. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60014. */
  60015. export class RenderTargetsOptimization extends SceneOptimization {
  60016. /**
  60017. * Gets a string describing the action executed by the current optimization
  60018. * @return description string
  60019. */
  60020. getDescription(): string;
  60021. /**
  60022. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60023. * @param scene defines the current scene where to apply this optimization
  60024. * @param optimizer defines the current optimizer
  60025. * @returns true if everything that can be done was applied
  60026. */
  60027. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60028. }
  60029. /**
  60030. * Defines an optimization used to merge meshes with compatible materials
  60031. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60032. */
  60033. export class MergeMeshesOptimization extends SceneOptimization {
  60034. private static _UpdateSelectionTree;
  60035. /**
  60036. * Gets or sets a boolean which defines if optimization octree has to be updated
  60037. */
  60038. /**
  60039. * Gets or sets a boolean which defines if optimization octree has to be updated
  60040. */
  60041. static UpdateSelectionTree: boolean;
  60042. /**
  60043. * Gets a string describing the action executed by the current optimization
  60044. * @return description string
  60045. */
  60046. getDescription(): string;
  60047. private _canBeMerged;
  60048. /**
  60049. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60050. * @param scene defines the current scene where to apply this optimization
  60051. * @param optimizer defines the current optimizer
  60052. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  60053. * @returns true if everything that can be done was applied
  60054. */
  60055. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  60056. }
  60057. /**
  60058. * Defines a list of options used by SceneOptimizer
  60059. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60060. */
  60061. export class SceneOptimizerOptions {
  60062. /**
  60063. * Defines the target frame rate to reach (60 by default)
  60064. */
  60065. targetFrameRate: number;
  60066. /**
  60067. * Defines the interval between two checkes (2000ms by default)
  60068. */
  60069. trackerDuration: number;
  60070. /**
  60071. * Gets the list of optimizations to apply
  60072. */
  60073. optimizations: SceneOptimization[];
  60074. /**
  60075. * Creates a new list of options used by SceneOptimizer
  60076. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  60077. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  60078. */
  60079. constructor(
  60080. /**
  60081. * Defines the target frame rate to reach (60 by default)
  60082. */
  60083. targetFrameRate?: number,
  60084. /**
  60085. * Defines the interval between two checkes (2000ms by default)
  60086. */
  60087. trackerDuration?: number);
  60088. /**
  60089. * Add a new optimization
  60090. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  60091. * @returns the current SceneOptimizerOptions
  60092. */
  60093. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  60094. /**
  60095. * Add a new custom optimization
  60096. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  60097. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  60098. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60099. * @returns the current SceneOptimizerOptions
  60100. */
  60101. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  60102. /**
  60103. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  60104. * @param targetFrameRate defines the target frame rate (60 by default)
  60105. * @returns a SceneOptimizerOptions object
  60106. */
  60107. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  60108. /**
  60109. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  60110. * @param targetFrameRate defines the target frame rate (60 by default)
  60111. * @returns a SceneOptimizerOptions object
  60112. */
  60113. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  60114. /**
  60115. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  60116. * @param targetFrameRate defines the target frame rate (60 by default)
  60117. * @returns a SceneOptimizerOptions object
  60118. */
  60119. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  60120. }
  60121. /**
  60122. * Class used to run optimizations in order to reach a target frame rate
  60123. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60124. */
  60125. export class SceneOptimizer implements IDisposable {
  60126. private _isRunning;
  60127. private _options;
  60128. private _scene;
  60129. private _currentPriorityLevel;
  60130. private _targetFrameRate;
  60131. private _trackerDuration;
  60132. private _currentFrameRate;
  60133. private _sceneDisposeObserver;
  60134. private _improvementMode;
  60135. /**
  60136. * Defines an observable called when the optimizer reaches the target frame rate
  60137. */
  60138. onSuccessObservable: Observable<SceneOptimizer>;
  60139. /**
  60140. * Defines an observable called when the optimizer enables an optimization
  60141. */
  60142. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  60143. /**
  60144. * Defines an observable called when the optimizer is not able to reach the target frame rate
  60145. */
  60146. onFailureObservable: Observable<SceneOptimizer>;
  60147. /**
  60148. * Gets a boolean indicating if the optimizer is in improvement mode
  60149. */
  60150. readonly isInImprovementMode: boolean;
  60151. /**
  60152. * Gets the current priority level (0 at start)
  60153. */
  60154. readonly currentPriorityLevel: number;
  60155. /**
  60156. * Gets the current frame rate checked by the SceneOptimizer
  60157. */
  60158. readonly currentFrameRate: number;
  60159. /**
  60160. * Gets or sets the current target frame rate (60 by default)
  60161. */
  60162. /**
  60163. * Gets or sets the current target frame rate (60 by default)
  60164. */
  60165. targetFrameRate: number;
  60166. /**
  60167. * Gets or sets the current interval between two checks (every 2000ms by default)
  60168. */
  60169. /**
  60170. * Gets or sets the current interval between two checks (every 2000ms by default)
  60171. */
  60172. trackerDuration: number;
  60173. /**
  60174. * Gets the list of active optimizations
  60175. */
  60176. readonly optimizations: SceneOptimization[];
  60177. /**
  60178. * Creates a new SceneOptimizer
  60179. * @param scene defines the scene to work on
  60180. * @param options defines the options to use with the SceneOptimizer
  60181. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  60182. * @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)
  60183. */
  60184. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  60185. /**
  60186. * Stops the current optimizer
  60187. */
  60188. stop(): void;
  60189. /**
  60190. * Reset the optimizer to initial step (current priority level = 0)
  60191. */
  60192. reset(): void;
  60193. /**
  60194. * Start the optimizer. By default it will try to reach a specific framerate
  60195. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  60196. */
  60197. start(): void;
  60198. private _checkCurrentState;
  60199. /**
  60200. * Release all resources
  60201. */
  60202. dispose(): void;
  60203. /**
  60204. * Helper function to create a SceneOptimizer with one single line of code
  60205. * @param scene defines the scene to work on
  60206. * @param options defines the options to use with the SceneOptimizer
  60207. * @param onSuccess defines a callback to call on success
  60208. * @param onFailure defines a callback to call on failure
  60209. * @returns the new SceneOptimizer object
  60210. */
  60211. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  60212. }
  60213. }
  60214. declare module BABYLON {
  60215. /**
  60216. * Class used to serialize a scene into a string
  60217. */
  60218. export class SceneSerializer {
  60219. /**
  60220. * Clear cache used by a previous serialization
  60221. */
  60222. static ClearCache(): void;
  60223. /**
  60224. * Serialize a scene into a JSON compatible object
  60225. * @param scene defines the scene to serialize
  60226. * @returns a JSON compatible object
  60227. */
  60228. static Serialize(scene: Scene): any;
  60229. /**
  60230. * Serialize a mesh into a JSON compatible object
  60231. * @param toSerialize defines the mesh to serialize
  60232. * @param withParents defines if parents must be serialized as well
  60233. * @param withChildren defines if children must be serialized as well
  60234. * @returns a JSON compatible object
  60235. */
  60236. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  60237. }
  60238. }
  60239. declare module BABYLON {
  60240. /**
  60241. * Class used to host texture specific utilities
  60242. */
  60243. export class TextureTools {
  60244. /**
  60245. * Uses the GPU to create a copy texture rescaled at a given size
  60246. * @param texture Texture to copy from
  60247. * @param width defines the desired width
  60248. * @param height defines the desired height
  60249. * @param useBilinearMode defines if bilinear mode has to be used
  60250. * @return the generated texture
  60251. */
  60252. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  60253. }
  60254. }
  60255. declare module BABYLON {
  60256. /**
  60257. * This represents the different options available for the video capture.
  60258. */
  60259. export interface VideoRecorderOptions {
  60260. /** Defines the mime type of the video. */
  60261. mimeType: string;
  60262. /** Defines the FPS the video should be recorded at. */
  60263. fps: number;
  60264. /** Defines the chunk size for the recording data. */
  60265. recordChunckSize: number;
  60266. /** The audio tracks to attach to the recording. */
  60267. audioTracks?: MediaStreamTrack[];
  60268. }
  60269. /**
  60270. * This can help with recording videos from BabylonJS.
  60271. * This is based on the available WebRTC functionalities of the browser.
  60272. *
  60273. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  60274. */
  60275. export class VideoRecorder {
  60276. private static readonly _defaultOptions;
  60277. /**
  60278. * Returns whether or not the VideoRecorder is available in your browser.
  60279. * @param engine Defines the Babylon Engine.
  60280. * @returns true if supported otherwise false.
  60281. */
  60282. static IsSupported(engine: Engine): boolean;
  60283. private readonly _options;
  60284. private _canvas;
  60285. private _mediaRecorder;
  60286. private _recordedChunks;
  60287. private _fileName;
  60288. private _resolve;
  60289. private _reject;
  60290. /**
  60291. * True when a recording is already in progress.
  60292. */
  60293. readonly isRecording: boolean;
  60294. /**
  60295. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  60296. * @param engine Defines the BabylonJS Engine you wish to record.
  60297. * @param options Defines options that can be used to customize the capture.
  60298. */
  60299. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  60300. /**
  60301. * Stops the current recording before the default capture timeout passed in the startRecording function.
  60302. */
  60303. stopRecording(): void;
  60304. /**
  60305. * Starts recording the canvas for a max duration specified in parameters.
  60306. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  60307. * If null no automatic download will start and you can rely on the promise to get the data back.
  60308. * @param maxDuration Defines the maximum recording time in seconds.
  60309. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  60310. * @return A promise callback at the end of the recording with the video data in Blob.
  60311. */
  60312. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  60313. /**
  60314. * Releases internal resources used during the recording.
  60315. */
  60316. dispose(): void;
  60317. private _handleDataAvailable;
  60318. private _handleError;
  60319. private _handleStop;
  60320. }
  60321. }
  60322. declare module BABYLON {
  60323. /**
  60324. * Class containing a set of static utilities functions for screenshots
  60325. */
  60326. export class ScreenshotTools {
  60327. /**
  60328. * Captures a screenshot of the current rendering
  60329. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  60330. * @param engine defines the rendering engine
  60331. * @param camera defines the source camera
  60332. * @param size This parameter can be set to a single number or to an object with the
  60333. * following (optional) properties: precision, width, height. If a single number is passed,
  60334. * it will be used for both width and height. If an object is passed, the screenshot size
  60335. * will be derived from the parameters. The precision property is a multiplier allowing
  60336. * rendering at a higher or lower resolution
  60337. * @param successCallback defines the callback receives a single parameter which contains the
  60338. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  60339. * src parameter of an <img> to display it
  60340. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  60341. * Check your browser for supported MIME types
  60342. */
  60343. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  60344. /**
  60345. * Captures a screenshot of the current rendering
  60346. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  60347. * @param engine defines the rendering engine
  60348. * @param camera defines the source camera
  60349. * @param size This parameter can be set to a single number or to an object with the
  60350. * following (optional) properties: precision, width, height. If a single number is passed,
  60351. * it will be used for both width and height. If an object is passed, the screenshot size
  60352. * will be derived from the parameters. The precision property is a multiplier allowing
  60353. * rendering at a higher or lower resolution
  60354. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  60355. * Check your browser for supported MIME types
  60356. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  60357. * to the src parameter of an <img> to display it
  60358. */
  60359. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  60360. /**
  60361. * Generates an image screenshot from the specified camera.
  60362. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  60363. * @param engine The engine to use for rendering
  60364. * @param camera The camera to use for rendering
  60365. * @param size This parameter can be set to a single number or to an object with the
  60366. * following (optional) properties: precision, width, height. If a single number is passed,
  60367. * it will be used for both width and height. If an object is passed, the screenshot size
  60368. * will be derived from the parameters. The precision property is a multiplier allowing
  60369. * rendering at a higher or lower resolution
  60370. * @param successCallback The callback receives a single parameter which contains the
  60371. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  60372. * src parameter of an <img> to display it
  60373. * @param mimeType The MIME type of the screenshot image (default: image/png).
  60374. * Check your browser for supported MIME types
  60375. * @param samples Texture samples (default: 1)
  60376. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  60377. * @param fileName A name for for the downloaded file.
  60378. */
  60379. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  60380. /**
  60381. * Generates an image screenshot from the specified camera.
  60382. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  60383. * @param engine The engine to use for rendering
  60384. * @param camera The camera to use for rendering
  60385. * @param size This parameter can be set to a single number or to an object with the
  60386. * following (optional) properties: precision, width, height. If a single number is passed,
  60387. * it will be used for both width and height. If an object is passed, the screenshot size
  60388. * will be derived from the parameters. The precision property is a multiplier allowing
  60389. * rendering at a higher or lower resolution
  60390. * @param mimeType The MIME type of the screenshot image (default: image/png).
  60391. * Check your browser for supported MIME types
  60392. * @param samples Texture samples (default: 1)
  60393. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  60394. * @param fileName A name for for the downloaded file.
  60395. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  60396. * to the src parameter of an <img> to display it
  60397. */
  60398. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  60399. }
  60400. }
  60401. declare module BABYLON {
  60402. /**
  60403. * A cursor which tracks a point on a path
  60404. */
  60405. export class PathCursor {
  60406. private path;
  60407. /**
  60408. * Stores path cursor callbacks for when an onchange event is triggered
  60409. */
  60410. private _onchange;
  60411. /**
  60412. * The value of the path cursor
  60413. */
  60414. value: number;
  60415. /**
  60416. * The animation array of the path cursor
  60417. */
  60418. animations: Animation[];
  60419. /**
  60420. * Initializes the path cursor
  60421. * @param path The path to track
  60422. */
  60423. constructor(path: Path2);
  60424. /**
  60425. * Gets the cursor point on the path
  60426. * @returns A point on the path cursor at the cursor location
  60427. */
  60428. getPoint(): Vector3;
  60429. /**
  60430. * Moves the cursor ahead by the step amount
  60431. * @param step The amount to move the cursor forward
  60432. * @returns This path cursor
  60433. */
  60434. moveAhead(step?: number): PathCursor;
  60435. /**
  60436. * Moves the cursor behind by the step amount
  60437. * @param step The amount to move the cursor back
  60438. * @returns This path cursor
  60439. */
  60440. moveBack(step?: number): PathCursor;
  60441. /**
  60442. * Moves the cursor by the step amount
  60443. * If the step amount is greater than one, an exception is thrown
  60444. * @param step The amount to move the cursor
  60445. * @returns This path cursor
  60446. */
  60447. move(step: number): PathCursor;
  60448. /**
  60449. * Ensures that the value is limited between zero and one
  60450. * @returns This path cursor
  60451. */
  60452. private ensureLimits;
  60453. /**
  60454. * Runs onchange callbacks on change (used by the animation engine)
  60455. * @returns This path cursor
  60456. */
  60457. private raiseOnChange;
  60458. /**
  60459. * Executes a function on change
  60460. * @param f A path cursor onchange callback
  60461. * @returns This path cursor
  60462. */
  60463. onchange(f: (cursor: PathCursor) => void): PathCursor;
  60464. }
  60465. }
  60466. declare module BABYLON {
  60467. /** @hidden */
  60468. export var blurPixelShader: {
  60469. name: string;
  60470. shader: string;
  60471. };
  60472. }
  60473. declare module BABYLON {
  60474. /** @hidden */
  60475. export var pointCloudVertexDeclaration: {
  60476. name: string;
  60477. shader: string;
  60478. };
  60479. }
  60480. // Mixins
  60481. interface Window {
  60482. mozIndexedDB: IDBFactory;
  60483. webkitIndexedDB: IDBFactory;
  60484. msIndexedDB: IDBFactory;
  60485. webkitURL: typeof URL;
  60486. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  60487. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  60488. WebGLRenderingContext: WebGLRenderingContext;
  60489. MSGesture: MSGesture;
  60490. CANNON: any;
  60491. AudioContext: AudioContext;
  60492. webkitAudioContext: AudioContext;
  60493. PointerEvent: any;
  60494. Math: Math;
  60495. Uint8Array: Uint8ArrayConstructor;
  60496. Float32Array: Float32ArrayConstructor;
  60497. mozURL: typeof URL;
  60498. msURL: typeof URL;
  60499. VRFrameData: any; // WebVR, from specs 1.1
  60500. DracoDecoderModule: any;
  60501. setImmediate(handler: (...args: any[]) => void): number;
  60502. }
  60503. interface HTMLCanvasElement {
  60504. requestPointerLock(): void;
  60505. msRequestPointerLock?(): void;
  60506. mozRequestPointerLock?(): void;
  60507. webkitRequestPointerLock?(): void;
  60508. /** Track wether a record is in progress */
  60509. isRecording: boolean;
  60510. /** Capture Stream method defined by some browsers */
  60511. captureStream(fps?: number): MediaStream;
  60512. }
  60513. interface CanvasRenderingContext2D {
  60514. msImageSmoothingEnabled: boolean;
  60515. }
  60516. interface MouseEvent {
  60517. mozMovementX: number;
  60518. mozMovementY: number;
  60519. webkitMovementX: number;
  60520. webkitMovementY: number;
  60521. msMovementX: number;
  60522. msMovementY: number;
  60523. }
  60524. interface Navigator {
  60525. mozGetVRDevices: (any: any) => any;
  60526. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  60527. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  60528. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  60529. webkitGetGamepads(): Gamepad[];
  60530. msGetGamepads(): Gamepad[];
  60531. webkitGamepads(): Gamepad[];
  60532. }
  60533. interface HTMLVideoElement {
  60534. mozSrcObject: any;
  60535. }
  60536. interface Math {
  60537. fround(x: number): number;
  60538. imul(a: number, b: number): number;
  60539. }
  60540. interface WebGLRenderingContext {
  60541. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  60542. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  60543. vertexAttribDivisor(index: number, divisor: number): void;
  60544. createVertexArray(): any;
  60545. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  60546. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  60547. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  60548. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  60549. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  60550. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  60551. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  60552. // Queries
  60553. createQuery(): WebGLQuery;
  60554. deleteQuery(query: WebGLQuery): void;
  60555. beginQuery(target: number, query: WebGLQuery): void;
  60556. endQuery(target: number): void;
  60557. getQueryParameter(query: WebGLQuery, pname: number): any;
  60558. getQuery(target: number, pname: number): any;
  60559. MAX_SAMPLES: number;
  60560. RGBA8: number;
  60561. READ_FRAMEBUFFER: number;
  60562. DRAW_FRAMEBUFFER: number;
  60563. UNIFORM_BUFFER: number;
  60564. HALF_FLOAT_OES: number;
  60565. RGBA16F: number;
  60566. RGBA32F: number;
  60567. R32F: number;
  60568. RG32F: number;
  60569. RGB32F: number;
  60570. R16F: number;
  60571. RG16F: number;
  60572. RGB16F: number;
  60573. RED: number;
  60574. RG: number;
  60575. R8: number;
  60576. RG8: number;
  60577. UNSIGNED_INT_24_8: number;
  60578. DEPTH24_STENCIL8: number;
  60579. /* Multiple Render Targets */
  60580. drawBuffers(buffers: number[]): void;
  60581. readBuffer(src: number): void;
  60582. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  60583. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  60584. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  60585. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  60586. // Occlusion Query
  60587. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  60588. ANY_SAMPLES_PASSED: number;
  60589. QUERY_RESULT_AVAILABLE: number;
  60590. QUERY_RESULT: number;
  60591. }
  60592. interface WebGLProgram {
  60593. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  60594. }
  60595. interface EXT_disjoint_timer_query {
  60596. QUERY_COUNTER_BITS_EXT: number;
  60597. TIME_ELAPSED_EXT: number;
  60598. TIMESTAMP_EXT: number;
  60599. GPU_DISJOINT_EXT: number;
  60600. QUERY_RESULT_EXT: number;
  60601. QUERY_RESULT_AVAILABLE_EXT: number;
  60602. queryCounterEXT(query: WebGLQuery, target: number): void;
  60603. createQueryEXT(): WebGLQuery;
  60604. beginQueryEXT(target: number, query: WebGLQuery): void;
  60605. endQueryEXT(target: number): void;
  60606. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  60607. deleteQueryEXT(query: WebGLQuery): void;
  60608. }
  60609. interface WebGLUniformLocation {
  60610. _currentState: any;
  60611. }
  60612. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  60613. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  60614. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  60615. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  60616. interface WebGLRenderingContext {
  60617. readonly RASTERIZER_DISCARD: number;
  60618. readonly DEPTH_COMPONENT24: number;
  60619. readonly TEXTURE_3D: number;
  60620. readonly TEXTURE_2D_ARRAY: number;
  60621. readonly TEXTURE_COMPARE_FUNC: number;
  60622. readonly TEXTURE_COMPARE_MODE: number;
  60623. readonly COMPARE_REF_TO_TEXTURE: number;
  60624. readonly TEXTURE_WRAP_R: number;
  60625. readonly HALF_FLOAT: number;
  60626. readonly RGB8: number;
  60627. readonly RED_INTEGER: number;
  60628. readonly RG_INTEGER: number;
  60629. readonly RGB_INTEGER: number;
  60630. readonly RGBA_INTEGER: number;
  60631. readonly R8_SNORM: number;
  60632. readonly RG8_SNORM: number;
  60633. readonly RGB8_SNORM: number;
  60634. readonly RGBA8_SNORM: number;
  60635. readonly R8I: number;
  60636. readonly RG8I: number;
  60637. readonly RGB8I: number;
  60638. readonly RGBA8I: number;
  60639. readonly R8UI: number;
  60640. readonly RG8UI: number;
  60641. readonly RGB8UI: number;
  60642. readonly RGBA8UI: number;
  60643. readonly R16I: number;
  60644. readonly RG16I: number;
  60645. readonly RGB16I: number;
  60646. readonly RGBA16I: number;
  60647. readonly R16UI: number;
  60648. readonly RG16UI: number;
  60649. readonly RGB16UI: number;
  60650. readonly RGBA16UI: number;
  60651. readonly R32I: number;
  60652. readonly RG32I: number;
  60653. readonly RGB32I: number;
  60654. readonly RGBA32I: number;
  60655. readonly R32UI: number;
  60656. readonly RG32UI: number;
  60657. readonly RGB32UI: number;
  60658. readonly RGBA32UI: number;
  60659. readonly RGB10_A2UI: number;
  60660. readonly R11F_G11F_B10F: number;
  60661. readonly RGB9_E5: number;
  60662. readonly RGB10_A2: number;
  60663. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  60664. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  60665. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  60666. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  60667. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  60668. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  60669. 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;
  60670. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  60671. readonly TRANSFORM_FEEDBACK: number;
  60672. readonly INTERLEAVED_ATTRIBS: number;
  60673. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  60674. createTransformFeedback(): WebGLTransformFeedback;
  60675. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  60676. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  60677. beginTransformFeedback(primitiveMode: number): void;
  60678. endTransformFeedback(): void;
  60679. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  60680. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  60681. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  60682. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  60683. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  60684. }
  60685. interface ImageBitmap {
  60686. readonly width: number;
  60687. readonly height: number;
  60688. close(): void;
  60689. }
  60690. interface WebGLQuery extends WebGLObject {
  60691. }
  60692. declare var WebGLQuery: {
  60693. prototype: WebGLQuery;
  60694. new(): WebGLQuery;
  60695. };
  60696. interface WebGLSampler extends WebGLObject {
  60697. }
  60698. declare var WebGLSampler: {
  60699. prototype: WebGLSampler;
  60700. new(): WebGLSampler;
  60701. };
  60702. interface WebGLSync extends WebGLObject {
  60703. }
  60704. declare var WebGLSync: {
  60705. prototype: WebGLSync;
  60706. new(): WebGLSync;
  60707. };
  60708. interface WebGLTransformFeedback extends WebGLObject {
  60709. }
  60710. declare var WebGLTransformFeedback: {
  60711. prototype: WebGLTransformFeedback;
  60712. new(): WebGLTransformFeedback;
  60713. };
  60714. interface WebGLVertexArrayObject extends WebGLObject {
  60715. }
  60716. declare var WebGLVertexArrayObject: {
  60717. prototype: WebGLVertexArrayObject;
  60718. new(): WebGLVertexArrayObject;
  60719. };
  60720. // Type definitions for WebVR API
  60721. // Project: https://w3c.github.io/webvr/
  60722. // Definitions by: six a <https://github.com/lostfictions>
  60723. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  60724. interface VRDisplay extends EventTarget {
  60725. /**
  60726. * Dictionary of capabilities describing the VRDisplay.
  60727. */
  60728. readonly capabilities: VRDisplayCapabilities;
  60729. /**
  60730. * z-depth defining the far plane of the eye view frustum
  60731. * enables mapping of values in the render target depth
  60732. * attachment to scene coordinates. Initially set to 10000.0.
  60733. */
  60734. depthFar: number;
  60735. /**
  60736. * z-depth defining the near plane of the eye view frustum
  60737. * enables mapping of values in the render target depth
  60738. * attachment to scene coordinates. Initially set to 0.01.
  60739. */
  60740. depthNear: number;
  60741. /**
  60742. * An identifier for this distinct VRDisplay. Used as an
  60743. * association point in the Gamepad API.
  60744. */
  60745. readonly displayId: number;
  60746. /**
  60747. * A display name, a user-readable name identifying it.
  60748. */
  60749. readonly displayName: string;
  60750. readonly isConnected: boolean;
  60751. readonly isPresenting: boolean;
  60752. /**
  60753. * If this VRDisplay supports room-scale experiences, the optional
  60754. * stage attribute contains details on the room-scale parameters.
  60755. */
  60756. readonly stageParameters: VRStageParameters | null;
  60757. /**
  60758. * Passing the value returned by `requestAnimationFrame` to
  60759. * `cancelAnimationFrame` will unregister the callback.
  60760. * @param handle Define the hanle of the request to cancel
  60761. */
  60762. cancelAnimationFrame(handle: number): void;
  60763. /**
  60764. * Stops presenting to the VRDisplay.
  60765. * @returns a promise to know when it stopped
  60766. */
  60767. exitPresent(): Promise<void>;
  60768. /**
  60769. * Return the current VREyeParameters for the given eye.
  60770. * @param whichEye Define the eye we want the parameter for
  60771. * @returns the eye parameters
  60772. */
  60773. getEyeParameters(whichEye: string): VREyeParameters;
  60774. /**
  60775. * Populates the passed VRFrameData with the information required to render
  60776. * the current frame.
  60777. * @param frameData Define the data structure to populate
  60778. * @returns true if ok otherwise false
  60779. */
  60780. getFrameData(frameData: VRFrameData): boolean;
  60781. /**
  60782. * Get the layers currently being presented.
  60783. * @returns the list of VR layers
  60784. */
  60785. getLayers(): VRLayer[];
  60786. /**
  60787. * Return a VRPose containing the future predicted pose of the VRDisplay
  60788. * when the current frame will be presented. The value returned will not
  60789. * change until JavaScript has returned control to the browser.
  60790. *
  60791. * The VRPose will contain the position, orientation, velocity,
  60792. * and acceleration of each of these properties.
  60793. * @returns the pose object
  60794. */
  60795. getPose(): VRPose;
  60796. /**
  60797. * Return the current instantaneous pose of the VRDisplay, with no
  60798. * prediction applied.
  60799. * @returns the current instantaneous pose
  60800. */
  60801. getImmediatePose(): VRPose;
  60802. /**
  60803. * The callback passed to `requestAnimationFrame` will be called
  60804. * any time a new frame should be rendered. When the VRDisplay is
  60805. * presenting the callback will be called at the native refresh
  60806. * rate of the HMD. When not presenting this function acts
  60807. * identically to how window.requestAnimationFrame acts. Content should
  60808. * make no assumptions of frame rate or vsync behavior as the HMD runs
  60809. * asynchronously from other displays and at differing refresh rates.
  60810. * @param callback Define the eaction to run next frame
  60811. * @returns the request handle it
  60812. */
  60813. requestAnimationFrame(callback: FrameRequestCallback): number;
  60814. /**
  60815. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  60816. * Repeat calls while already presenting will update the VRLayers being displayed.
  60817. * @param layers Define the list of layer to present
  60818. * @returns a promise to know when the request has been fulfilled
  60819. */
  60820. requestPresent(layers: VRLayer[]): Promise<void>;
  60821. /**
  60822. * Reset the pose for this display, treating its current position and
  60823. * orientation as the "origin/zero" values. VRPose.position,
  60824. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  60825. * updated when calling resetPose(). This should be called in only
  60826. * sitting-space experiences.
  60827. */
  60828. resetPose(): void;
  60829. /**
  60830. * The VRLayer provided to the VRDisplay will be captured and presented
  60831. * in the HMD. Calling this function has the same effect on the source
  60832. * canvas as any other operation that uses its source image, and canvases
  60833. * created without preserveDrawingBuffer set to true will be cleared.
  60834. * @param pose Define the pose to submit
  60835. */
  60836. submitFrame(pose?: VRPose): void;
  60837. }
  60838. declare var VRDisplay: {
  60839. prototype: VRDisplay;
  60840. new(): VRDisplay;
  60841. };
  60842. interface VRLayer {
  60843. leftBounds?: number[] | Float32Array | null;
  60844. rightBounds?: number[] | Float32Array | null;
  60845. source?: HTMLCanvasElement | null;
  60846. }
  60847. interface VRDisplayCapabilities {
  60848. readonly canPresent: boolean;
  60849. readonly hasExternalDisplay: boolean;
  60850. readonly hasOrientation: boolean;
  60851. readonly hasPosition: boolean;
  60852. readonly maxLayers: number;
  60853. }
  60854. interface VREyeParameters {
  60855. /** @deprecated */
  60856. readonly fieldOfView: VRFieldOfView;
  60857. readonly offset: Float32Array;
  60858. readonly renderHeight: number;
  60859. readonly renderWidth: number;
  60860. }
  60861. interface VRFieldOfView {
  60862. readonly downDegrees: number;
  60863. readonly leftDegrees: number;
  60864. readonly rightDegrees: number;
  60865. readonly upDegrees: number;
  60866. }
  60867. interface VRFrameData {
  60868. readonly leftProjectionMatrix: Float32Array;
  60869. readonly leftViewMatrix: Float32Array;
  60870. readonly pose: VRPose;
  60871. readonly rightProjectionMatrix: Float32Array;
  60872. readonly rightViewMatrix: Float32Array;
  60873. readonly timestamp: number;
  60874. }
  60875. interface VRPose {
  60876. readonly angularAcceleration: Float32Array | null;
  60877. readonly angularVelocity: Float32Array | null;
  60878. readonly linearAcceleration: Float32Array | null;
  60879. readonly linearVelocity: Float32Array | null;
  60880. readonly orientation: Float32Array | null;
  60881. readonly position: Float32Array | null;
  60882. readonly timestamp: number;
  60883. }
  60884. interface VRStageParameters {
  60885. sittingToStandingTransform?: Float32Array;
  60886. sizeX?: number;
  60887. sizeY?: number;
  60888. }
  60889. interface Navigator {
  60890. getVRDisplays(): Promise<VRDisplay[]>;
  60891. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  60892. }
  60893. interface Window {
  60894. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  60895. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  60896. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  60897. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  60898. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  60899. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  60900. }
  60901. interface Gamepad {
  60902. readonly displayId: number;
  60903. }
  60904. type XRSessionMode =
  60905. | "inline"
  60906. | "immersive-vr"
  60907. | "immersive-ar";
  60908. type XRReferenceSpaceType =
  60909. | "viewer"
  60910. | "local"
  60911. | "local-floor"
  60912. | "bounded-floor"
  60913. | "unbounded";
  60914. type XREnvironmentBlendMode =
  60915. | "opaque"
  60916. | "additive"
  60917. | "alpha-blend";
  60918. type XRVisibilityState =
  60919. | "visible"
  60920. | "visible-blurred"
  60921. | "hidden";
  60922. type XRHandedness =
  60923. | "none"
  60924. | "left"
  60925. | "right";
  60926. type XRTargetRayMode =
  60927. | "gaze"
  60928. | "tracked-pointer"
  60929. | "screen";
  60930. type XREye =
  60931. | "none"
  60932. | "left"
  60933. | "right";
  60934. interface XRSpace extends EventTarget {
  60935. }
  60936. interface XRRenderState {
  60937. depthNear?: number;
  60938. depthFar?: number;
  60939. inlineVerticalFieldOfView?: number;
  60940. baseLayer?: XRWebGLLayer;
  60941. }
  60942. interface XRInputSource {
  60943. handedness: XRHandedness;
  60944. targetRayMode: XRTargetRayMode;
  60945. targetRaySpace: XRSpace;
  60946. gripSpace: XRSpace | undefined;
  60947. gamepad: Gamepad | undefined;
  60948. profiles: Array<string>;
  60949. }
  60950. interface XRSession {
  60951. addEventListener: Function;
  60952. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  60953. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  60954. requestAnimationFrame: Function;
  60955. end(): Promise<void>;
  60956. renderState: XRRenderState;
  60957. inputSources: Array<XRInputSource>;
  60958. }
  60959. interface XRReferenceSpace extends XRSpace {
  60960. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  60961. onreset: any;
  60962. }
  60963. interface XRFrame {
  60964. session: XRSession;
  60965. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  60966. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  60967. }
  60968. interface XRViewerPose extends XRPose {
  60969. views: Array<XRView>;
  60970. }
  60971. interface XRPose {
  60972. transform: XRRigidTransform;
  60973. emulatedPosition: boolean;
  60974. }
  60975. declare var XRWebGLLayer: {
  60976. prototype: XRWebGLLayer;
  60977. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  60978. };
  60979. interface XRWebGLLayer {
  60980. framebuffer: WebGLFramebuffer;
  60981. framebufferWidth: number;
  60982. framebufferHeight: number;
  60983. getViewport: Function;
  60984. }
  60985. interface XRRigidTransform {
  60986. position: DOMPointReadOnly;
  60987. orientation: DOMPointReadOnly;
  60988. matrix: Float32Array;
  60989. inverse: XRRigidTransform;
  60990. }
  60991. interface XRView {
  60992. eye: XREye;
  60993. projectionMatrix: Float32Array;
  60994. transform: XRRigidTransform;
  60995. }
  60996. interface XRInputSourceChangeEvent {
  60997. session: XRSession;
  60998. removed: Array<XRInputSource>;
  60999. added: Array<XRInputSource>;
  61000. }
  61001. declare module BABYLON.GUI {
  61002. /**
  61003. * Class used to specific a value and its associated unit
  61004. */
  61005. export class ValueAndUnit {
  61006. /** defines the unit to store */
  61007. unit: number;
  61008. /** defines a boolean indicating if the value can be negative */
  61009. negativeValueAllowed: boolean;
  61010. private _value;
  61011. private _originalUnit;
  61012. /**
  61013. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  61014. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61015. */
  61016. ignoreAdaptiveScaling: boolean;
  61017. /**
  61018. * Creates a new ValueAndUnit
  61019. * @param value defines the value to store
  61020. * @param unit defines the unit to store
  61021. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  61022. */
  61023. constructor(value: number,
  61024. /** defines the unit to store */
  61025. unit?: number,
  61026. /** defines a boolean indicating if the value can be negative */
  61027. negativeValueAllowed?: boolean);
  61028. /** Gets a boolean indicating if the value is a percentage */
  61029. readonly isPercentage: boolean;
  61030. /** Gets a boolean indicating if the value is store as pixel */
  61031. readonly isPixel: boolean;
  61032. /** Gets direct internal value */
  61033. readonly internalValue: number;
  61034. /**
  61035. * Gets value as pixel
  61036. * @param host defines the root host
  61037. * @param refValue defines the reference value for percentages
  61038. * @returns the value as pixel
  61039. */
  61040. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  61041. /**
  61042. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  61043. * @param value defines the value to store
  61044. * @param unit defines the unit to store
  61045. * @returns the current ValueAndUnit
  61046. */
  61047. updateInPlace(value: number, unit?: number): ValueAndUnit;
  61048. /**
  61049. * Gets the value accordingly to its unit
  61050. * @param host defines the root host
  61051. * @returns the value
  61052. */
  61053. getValue(host: AdvancedDynamicTexture): number;
  61054. /**
  61055. * Gets a string representation of the value
  61056. * @param host defines the root host
  61057. * @param decimals defines an optional number of decimals to display
  61058. * @returns a string
  61059. */
  61060. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  61061. /**
  61062. * Store a value parsed from a string
  61063. * @param source defines the source string
  61064. * @returns true if the value was successfully parsed
  61065. */
  61066. fromString(source: string | number): boolean;
  61067. private static _Regex;
  61068. private static _UNITMODE_PERCENTAGE;
  61069. private static _UNITMODE_PIXEL;
  61070. /** UNITMODE_PERCENTAGE */
  61071. static readonly UNITMODE_PERCENTAGE: number;
  61072. /** UNITMODE_PIXEL */
  61073. static readonly UNITMODE_PIXEL: number;
  61074. }
  61075. }
  61076. declare module BABYLON.GUI {
  61077. /**
  61078. * Define a style used by control to automatically setup properties based on a template.
  61079. * Only support font related properties so far
  61080. */
  61081. export class Style implements BABYLON.IDisposable {
  61082. private _fontFamily;
  61083. private _fontStyle;
  61084. private _fontWeight;
  61085. /** @hidden */
  61086. _host: AdvancedDynamicTexture;
  61087. /** @hidden */
  61088. _fontSize: ValueAndUnit;
  61089. /**
  61090. * BABYLON.Observable raised when the style values are changed
  61091. */
  61092. onChangedObservable: BABYLON.Observable<Style>;
  61093. /**
  61094. * Creates a new style object
  61095. * @param host defines the AdvancedDynamicTexture which hosts this style
  61096. */
  61097. constructor(host: AdvancedDynamicTexture);
  61098. /**
  61099. * Gets or sets the font size
  61100. */
  61101. fontSize: string | number;
  61102. /**
  61103. * Gets or sets the font family
  61104. */
  61105. fontFamily: string;
  61106. /**
  61107. * Gets or sets the font style
  61108. */
  61109. fontStyle: string;
  61110. /** Gets or sets font weight */
  61111. fontWeight: string;
  61112. /** Dispose all associated resources */
  61113. dispose(): void;
  61114. }
  61115. }
  61116. declare module BABYLON.GUI {
  61117. /**
  61118. * Class used to transport BABYLON.Vector2 information for pointer events
  61119. */
  61120. export class Vector2WithInfo extends BABYLON.Vector2 {
  61121. /** defines the current mouse button index */
  61122. buttonIndex: number;
  61123. /**
  61124. * Creates a new Vector2WithInfo
  61125. * @param source defines the vector2 data to transport
  61126. * @param buttonIndex defines the current mouse button index
  61127. */
  61128. constructor(source: BABYLON.Vector2,
  61129. /** defines the current mouse button index */
  61130. buttonIndex?: number);
  61131. }
  61132. /** Class used to provide 2D matrix features */
  61133. export class Matrix2D {
  61134. /** Gets the internal array of 6 floats used to store matrix data */
  61135. m: Float32Array;
  61136. /**
  61137. * Creates a new matrix
  61138. * @param m00 defines value for (0, 0)
  61139. * @param m01 defines value for (0, 1)
  61140. * @param m10 defines value for (1, 0)
  61141. * @param m11 defines value for (1, 1)
  61142. * @param m20 defines value for (2, 0)
  61143. * @param m21 defines value for (2, 1)
  61144. */
  61145. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  61146. /**
  61147. * Fills the matrix from direct values
  61148. * @param m00 defines value for (0, 0)
  61149. * @param m01 defines value for (0, 1)
  61150. * @param m10 defines value for (1, 0)
  61151. * @param m11 defines value for (1, 1)
  61152. * @param m20 defines value for (2, 0)
  61153. * @param m21 defines value for (2, 1)
  61154. * @returns the current modified matrix
  61155. */
  61156. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  61157. /**
  61158. * Gets matrix determinant
  61159. * @returns the determinant
  61160. */
  61161. determinant(): number;
  61162. /**
  61163. * Inverses the matrix and stores it in a target matrix
  61164. * @param result defines the target matrix
  61165. * @returns the current matrix
  61166. */
  61167. invertToRef(result: Matrix2D): Matrix2D;
  61168. /**
  61169. * Multiplies the current matrix with another one
  61170. * @param other defines the second operand
  61171. * @param result defines the target matrix
  61172. * @returns the current matrix
  61173. */
  61174. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  61175. /**
  61176. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  61177. * @param x defines the x coordinate to transform
  61178. * @param y defines the x coordinate to transform
  61179. * @param result defines the target vector2
  61180. * @returns the current matrix
  61181. */
  61182. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  61183. /**
  61184. * Creates an identity matrix
  61185. * @returns a new matrix
  61186. */
  61187. static Identity(): Matrix2D;
  61188. /**
  61189. * Creates a translation matrix and stores it in a target matrix
  61190. * @param x defines the x coordinate of the translation
  61191. * @param y defines the y coordinate of the translation
  61192. * @param result defines the target matrix
  61193. */
  61194. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  61195. /**
  61196. * Creates a scaling matrix and stores it in a target matrix
  61197. * @param x defines the x coordinate of the scaling
  61198. * @param y defines the y coordinate of the scaling
  61199. * @param result defines the target matrix
  61200. */
  61201. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  61202. /**
  61203. * Creates a rotation matrix and stores it in a target matrix
  61204. * @param angle defines the rotation angle
  61205. * @param result defines the target matrix
  61206. */
  61207. static RotationToRef(angle: number, result: Matrix2D): void;
  61208. private static _TempPreTranslationMatrix;
  61209. private static _TempPostTranslationMatrix;
  61210. private static _TempRotationMatrix;
  61211. private static _TempScalingMatrix;
  61212. private static _TempCompose0;
  61213. private static _TempCompose1;
  61214. private static _TempCompose2;
  61215. /**
  61216. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  61217. * @param tx defines the x coordinate of the translation
  61218. * @param ty defines the y coordinate of the translation
  61219. * @param angle defines the rotation angle
  61220. * @param scaleX defines the x coordinate of the scaling
  61221. * @param scaleY defines the y coordinate of the scaling
  61222. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  61223. * @param result defines the target matrix
  61224. */
  61225. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  61226. }
  61227. }
  61228. declare module BABYLON.GUI {
  61229. /**
  61230. * Class used to store 2D control sizes
  61231. */
  61232. export class Measure {
  61233. /** defines left coordinate */
  61234. left: number;
  61235. /** defines top coordinate */
  61236. top: number;
  61237. /** defines width dimension */
  61238. width: number;
  61239. /** defines height dimension */
  61240. height: number;
  61241. /**
  61242. * Creates a new measure
  61243. * @param left defines left coordinate
  61244. * @param top defines top coordinate
  61245. * @param width defines width dimension
  61246. * @param height defines height dimension
  61247. */
  61248. constructor(
  61249. /** defines left coordinate */
  61250. left: number,
  61251. /** defines top coordinate */
  61252. top: number,
  61253. /** defines width dimension */
  61254. width: number,
  61255. /** defines height dimension */
  61256. height: number);
  61257. /**
  61258. * Copy from another measure
  61259. * @param other defines the other measure to copy from
  61260. */
  61261. copyFrom(other: Measure): void;
  61262. /**
  61263. * Copy from a group of 4 floats
  61264. * @param left defines left coordinate
  61265. * @param top defines top coordinate
  61266. * @param width defines width dimension
  61267. * @param height defines height dimension
  61268. */
  61269. copyFromFloats(left: number, top: number, width: number, height: number): void;
  61270. /**
  61271. * Computes the axis aligned bounding box measure for two given measures
  61272. * @param a Input measure
  61273. * @param b Input measure
  61274. * @param result the resulting bounding measure
  61275. */
  61276. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  61277. /**
  61278. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  61279. * @param transform the matrix to transform the measure before computing the AABB
  61280. * @param result the resulting AABB
  61281. */
  61282. transformToRef(transform: Matrix2D, result: Measure): void;
  61283. /**
  61284. * Check equality between this measure and another one
  61285. * @param other defines the other measures
  61286. * @returns true if both measures are equals
  61287. */
  61288. isEqualsTo(other: Measure): boolean;
  61289. /**
  61290. * Creates an empty measure
  61291. * @returns a new measure
  61292. */
  61293. static Empty(): Measure;
  61294. }
  61295. }
  61296. declare module BABYLON.GUI {
  61297. /**
  61298. * Interface used to define a control that can receive focus
  61299. */
  61300. export interface IFocusableControl {
  61301. /**
  61302. * Function called when the control receives the focus
  61303. */
  61304. onFocus(): void;
  61305. /**
  61306. * Function called when the control loses the focus
  61307. */
  61308. onBlur(): void;
  61309. /**
  61310. * Function called to let the control handle keyboard events
  61311. * @param evt defines the current keyboard event
  61312. */
  61313. processKeyboard(evt: KeyboardEvent): void;
  61314. /**
  61315. * Function called to get the list of controls that should not steal the focus from this control
  61316. * @returns an array of controls
  61317. */
  61318. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  61319. }
  61320. /**
  61321. * Class used to create texture to support 2D GUI elements
  61322. * @see http://doc.babylonjs.com/how_to/gui
  61323. */
  61324. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  61325. private _isDirty;
  61326. private _renderObserver;
  61327. private _resizeObserver;
  61328. private _preKeyboardObserver;
  61329. private _pointerMoveObserver;
  61330. private _pointerObserver;
  61331. private _canvasPointerOutObserver;
  61332. private _background;
  61333. /** @hidden */
  61334. _rootContainer: Container;
  61335. /** @hidden */
  61336. _lastPickedControl: Control;
  61337. /** @hidden */
  61338. _lastControlOver: {
  61339. [pointerId: number]: Control;
  61340. };
  61341. /** @hidden */
  61342. _lastControlDown: {
  61343. [pointerId: number]: Control;
  61344. };
  61345. /** @hidden */
  61346. _capturingControl: {
  61347. [pointerId: number]: Control;
  61348. };
  61349. /** @hidden */
  61350. _shouldBlockPointer: boolean;
  61351. /** @hidden */
  61352. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  61353. /** @hidden */
  61354. _linkedControls: Control[];
  61355. private _isFullscreen;
  61356. private _fullscreenViewport;
  61357. private _idealWidth;
  61358. private _idealHeight;
  61359. private _useSmallestIdeal;
  61360. private _renderAtIdealSize;
  61361. private _focusedControl;
  61362. private _blockNextFocusCheck;
  61363. private _renderScale;
  61364. private _rootCanvas;
  61365. private _cursorChanged;
  61366. /**
  61367. * Define type to string to ensure compatibility across browsers
  61368. * Safari doesn't support DataTransfer constructor
  61369. */
  61370. private _clipboardData;
  61371. /**
  61372. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  61373. */
  61374. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  61375. /**
  61376. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  61377. */
  61378. onControlPickedObservable: BABYLON.Observable<Control>;
  61379. /**
  61380. * BABYLON.Observable event triggered before layout is evaluated
  61381. */
  61382. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  61383. /**
  61384. * BABYLON.Observable event triggered after the layout was evaluated
  61385. */
  61386. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  61387. /**
  61388. * BABYLON.Observable event triggered before the texture is rendered
  61389. */
  61390. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  61391. /**
  61392. * BABYLON.Observable event triggered after the texture was rendered
  61393. */
  61394. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  61395. /**
  61396. * Gets or sets a boolean defining if alpha is stored as premultiplied
  61397. */
  61398. premulAlpha: boolean;
  61399. /**
  61400. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  61401. * Useful when you want more antialiasing
  61402. */
  61403. renderScale: number;
  61404. /** Gets or sets the background color */
  61405. background: string;
  61406. /**
  61407. * Gets or sets the ideal width used to design controls.
  61408. * The GUI will then rescale everything accordingly
  61409. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61410. */
  61411. idealWidth: number;
  61412. /**
  61413. * Gets or sets the ideal height used to design controls.
  61414. * The GUI will then rescale everything accordingly
  61415. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61416. */
  61417. idealHeight: number;
  61418. /**
  61419. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  61420. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61421. */
  61422. useSmallestIdeal: boolean;
  61423. /**
  61424. * Gets or sets a boolean indicating if adaptive scaling must be used
  61425. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61426. */
  61427. renderAtIdealSize: boolean;
  61428. /**
  61429. * Gets the underlying layer used to render the texture when in fullscreen mode
  61430. */
  61431. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  61432. /**
  61433. * Gets the root container control
  61434. */
  61435. readonly rootContainer: Container;
  61436. /**
  61437. * Returns an array containing the root container.
  61438. * This is mostly used to let the Inspector introspects the ADT
  61439. * @returns an array containing the rootContainer
  61440. */
  61441. getChildren(): Array<Container>;
  61442. /**
  61443. * Will return all controls that are inside this texture
  61444. * @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
  61445. * @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
  61446. * @return all child controls
  61447. */
  61448. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  61449. /**
  61450. * Gets or sets the current focused control
  61451. */
  61452. focusedControl: BABYLON.Nullable<IFocusableControl>;
  61453. /**
  61454. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  61455. */
  61456. isForeground: boolean;
  61457. /**
  61458. * Gets or set information about clipboardData
  61459. */
  61460. clipboardData: string;
  61461. /**
  61462. * Creates a new AdvancedDynamicTexture
  61463. * @param name defines the name of the texture
  61464. * @param width defines the width of the texture
  61465. * @param height defines the height of the texture
  61466. * @param scene defines the hosting scene
  61467. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  61468. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  61469. */
  61470. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  61471. /**
  61472. * Get the current class name of the texture useful for serialization or dynamic coding.
  61473. * @returns "AdvancedDynamicTexture"
  61474. */
  61475. getClassName(): string;
  61476. /**
  61477. * Function used to execute a function on all controls
  61478. * @param func defines the function to execute
  61479. * @param container defines the container where controls belong. If null the root container will be used
  61480. */
  61481. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  61482. private _useInvalidateRectOptimization;
  61483. /**
  61484. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  61485. */
  61486. useInvalidateRectOptimization: boolean;
  61487. private _invalidatedRectangle;
  61488. /**
  61489. * Invalidates a rectangle area on the gui texture
  61490. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  61491. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  61492. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  61493. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  61494. */
  61495. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  61496. /**
  61497. * Marks the texture as dirty forcing a complete update
  61498. */
  61499. markAsDirty(): void;
  61500. /**
  61501. * Helper function used to create a new style
  61502. * @returns a new style
  61503. * @see http://doc.babylonjs.com/how_to/gui#styles
  61504. */
  61505. createStyle(): Style;
  61506. /**
  61507. * Adds a new control to the root container
  61508. * @param control defines the control to add
  61509. * @returns the current texture
  61510. */
  61511. addControl(control: Control): AdvancedDynamicTexture;
  61512. /**
  61513. * Removes a control from the root container
  61514. * @param control defines the control to remove
  61515. * @returns the current texture
  61516. */
  61517. removeControl(control: Control): AdvancedDynamicTexture;
  61518. /**
  61519. * Release all resources
  61520. */
  61521. dispose(): void;
  61522. private _onResize;
  61523. /** @hidden */
  61524. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  61525. /**
  61526. * Get screen coordinates for a vector3
  61527. * @param position defines the position to project
  61528. * @param worldMatrix defines the world matrix to use
  61529. * @returns the projected position
  61530. */
  61531. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  61532. private _checkUpdate;
  61533. private _clearMeasure;
  61534. private _render;
  61535. /** @hidden */
  61536. _changeCursor(cursor: string): void;
  61537. /** @hidden */
  61538. _registerLastControlDown(control: Control, pointerId: number): void;
  61539. private _doPicking;
  61540. /** @hidden */
  61541. _cleanControlAfterRemovalFromList(list: {
  61542. [pointerId: number]: Control;
  61543. }, control: Control): void;
  61544. /** @hidden */
  61545. _cleanControlAfterRemoval(control: Control): void;
  61546. /** Attach to all scene events required to support pointer events */
  61547. attach(): void;
  61548. /** @hidden */
  61549. private onClipboardCopy;
  61550. /** @hidden */
  61551. private onClipboardCut;
  61552. /** @hidden */
  61553. private onClipboardPaste;
  61554. /**
  61555. * Register the clipboard Events onto the canvas
  61556. */
  61557. registerClipboardEvents(): void;
  61558. /**
  61559. * Unregister the clipboard Events from the canvas
  61560. */
  61561. unRegisterClipboardEvents(): void;
  61562. /**
  61563. * Connect the texture to a hosting mesh to enable interactions
  61564. * @param mesh defines the mesh to attach to
  61565. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  61566. */
  61567. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  61568. /**
  61569. * Move the focus to a specific control
  61570. * @param control defines the control which will receive the focus
  61571. */
  61572. moveFocusToControl(control: IFocusableControl): void;
  61573. private _manageFocus;
  61574. private _attachToOnPointerOut;
  61575. /**
  61576. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  61577. * @param mesh defines the mesh which will receive the texture
  61578. * @param width defines the texture width (1024 by default)
  61579. * @param height defines the texture height (1024 by default)
  61580. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  61581. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  61582. * @returns a new AdvancedDynamicTexture
  61583. */
  61584. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  61585. /**
  61586. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  61587. * In this mode the texture will rely on a layer for its rendering.
  61588. * This allows it to be treated like any other layer.
  61589. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  61590. * LayerMask is set through advancedTexture.layer.layerMask
  61591. * @param name defines name for the texture
  61592. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  61593. * @param scene defines the hsoting scene
  61594. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  61595. * @returns a new AdvancedDynamicTexture
  61596. */
  61597. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  61598. }
  61599. }
  61600. declare module BABYLON.GUI {
  61601. /**
  61602. * Root class used for all 2D controls
  61603. * @see http://doc.babylonjs.com/how_to/gui#controls
  61604. */
  61605. export class Control {
  61606. /** defines the name of the control */
  61607. name?: string | undefined;
  61608. /**
  61609. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  61610. */
  61611. static AllowAlphaInheritance: boolean;
  61612. private _alpha;
  61613. private _alphaSet;
  61614. private _zIndex;
  61615. /** @hidden */
  61616. _host: AdvancedDynamicTexture;
  61617. /** Gets or sets the control parent */
  61618. parent: BABYLON.Nullable<Container>;
  61619. /** @hidden */
  61620. _currentMeasure: Measure;
  61621. private _fontFamily;
  61622. private _fontStyle;
  61623. private _fontWeight;
  61624. private _fontSize;
  61625. private _font;
  61626. /** @hidden */
  61627. _width: ValueAndUnit;
  61628. /** @hidden */
  61629. _height: ValueAndUnit;
  61630. /** @hidden */
  61631. protected _fontOffset: {
  61632. ascent: number;
  61633. height: number;
  61634. descent: number;
  61635. };
  61636. private _color;
  61637. private _style;
  61638. private _styleObserver;
  61639. /** @hidden */
  61640. protected _horizontalAlignment: number;
  61641. /** @hidden */
  61642. protected _verticalAlignment: number;
  61643. /** @hidden */
  61644. protected _isDirty: boolean;
  61645. /** @hidden */
  61646. protected _wasDirty: boolean;
  61647. /** @hidden */
  61648. _tempParentMeasure: Measure;
  61649. /** @hidden */
  61650. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  61651. /** @hidden */
  61652. protected _cachedParentMeasure: Measure;
  61653. private _paddingLeft;
  61654. private _paddingRight;
  61655. private _paddingTop;
  61656. private _paddingBottom;
  61657. /** @hidden */
  61658. _left: ValueAndUnit;
  61659. /** @hidden */
  61660. _top: ValueAndUnit;
  61661. private _scaleX;
  61662. private _scaleY;
  61663. private _rotation;
  61664. private _transformCenterX;
  61665. private _transformCenterY;
  61666. /** @hidden */
  61667. _transformMatrix: Matrix2D;
  61668. /** @hidden */
  61669. protected _invertTransformMatrix: Matrix2D;
  61670. /** @hidden */
  61671. protected _transformedPosition: BABYLON.Vector2;
  61672. private _isMatrixDirty;
  61673. private _cachedOffsetX;
  61674. private _cachedOffsetY;
  61675. private _isVisible;
  61676. private _isHighlighted;
  61677. /** @hidden */
  61678. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  61679. private _fontSet;
  61680. private _dummyVector2;
  61681. private _downCount;
  61682. private _enterCount;
  61683. private _doNotRender;
  61684. private _downPointerIds;
  61685. protected _isEnabled: boolean;
  61686. protected _disabledColor: string;
  61687. /** @hidden */
  61688. protected _rebuildLayout: boolean;
  61689. /** @hidden */
  61690. _isClipped: boolean;
  61691. /** @hidden */
  61692. _tag: any;
  61693. /**
  61694. * 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
  61695. */
  61696. uniqueId: number;
  61697. /**
  61698. * Gets or sets an object used to store user defined information for the node
  61699. */
  61700. metadata: any;
  61701. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  61702. isHitTestVisible: boolean;
  61703. /** Gets or sets a boolean indicating if the control can block pointer events */
  61704. isPointerBlocker: boolean;
  61705. /** Gets or sets a boolean indicating if the control can be focusable */
  61706. isFocusInvisible: boolean;
  61707. /**
  61708. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  61709. * 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
  61710. */
  61711. clipChildren: boolean;
  61712. /**
  61713. * Gets or sets a boolean indicating that control content must be clipped
  61714. * 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
  61715. */
  61716. clipContent: boolean;
  61717. /**
  61718. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  61719. */
  61720. useBitmapCache: boolean;
  61721. private _cacheData;
  61722. private _shadowOffsetX;
  61723. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  61724. shadowOffsetX: number;
  61725. private _shadowOffsetY;
  61726. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  61727. shadowOffsetY: number;
  61728. private _shadowBlur;
  61729. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  61730. shadowBlur: number;
  61731. private _shadowColor;
  61732. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  61733. shadowColor: string;
  61734. /** Gets or sets the cursor to use when the control is hovered */
  61735. hoverCursor: string;
  61736. /** @hidden */
  61737. protected _linkOffsetX: ValueAndUnit;
  61738. /** @hidden */
  61739. protected _linkOffsetY: ValueAndUnit;
  61740. /** Gets the control type name */
  61741. readonly typeName: string;
  61742. /**
  61743. * Get the current class name of the control.
  61744. * @returns current class name
  61745. */
  61746. getClassName(): string;
  61747. /**
  61748. * An event triggered when the pointer move over the control.
  61749. */
  61750. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  61751. /**
  61752. * An event triggered when the pointer move out of the control.
  61753. */
  61754. onPointerOutObservable: BABYLON.Observable<Control>;
  61755. /**
  61756. * An event triggered when the pointer taps the control
  61757. */
  61758. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  61759. /**
  61760. * An event triggered when pointer up
  61761. */
  61762. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  61763. /**
  61764. * An event triggered when a control is clicked on
  61765. */
  61766. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  61767. /**
  61768. * An event triggered when pointer enters the control
  61769. */
  61770. onPointerEnterObservable: BABYLON.Observable<Control>;
  61771. /**
  61772. * An event triggered when the control is marked as dirty
  61773. */
  61774. onDirtyObservable: BABYLON.Observable<Control>;
  61775. /**
  61776. * An event triggered before drawing the control
  61777. */
  61778. onBeforeDrawObservable: BABYLON.Observable<Control>;
  61779. /**
  61780. * An event triggered after the control was drawn
  61781. */
  61782. onAfterDrawObservable: BABYLON.Observable<Control>;
  61783. /**
  61784. * Get the hosting AdvancedDynamicTexture
  61785. */
  61786. readonly host: AdvancedDynamicTexture;
  61787. /** Gets or set information about font offsets (used to render and align text) */
  61788. fontOffset: {
  61789. ascent: number;
  61790. height: number;
  61791. descent: number;
  61792. };
  61793. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  61794. alpha: number;
  61795. /**
  61796. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  61797. */
  61798. isHighlighted: boolean;
  61799. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  61800. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61801. */
  61802. scaleX: number;
  61803. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  61804. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61805. */
  61806. scaleY: number;
  61807. /** Gets or sets the rotation angle (0 by default)
  61808. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61809. */
  61810. rotation: number;
  61811. /** Gets or sets the transformation center on Y axis (0 by default)
  61812. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61813. */
  61814. transformCenterY: number;
  61815. /** Gets or sets the transformation center on X axis (0 by default)
  61816. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61817. */
  61818. transformCenterX: number;
  61819. /**
  61820. * Gets or sets the horizontal alignment
  61821. * @see http://doc.babylonjs.com/how_to/gui#alignments
  61822. */
  61823. horizontalAlignment: number;
  61824. /**
  61825. * Gets or sets the vertical alignment
  61826. * @see http://doc.babylonjs.com/how_to/gui#alignments
  61827. */
  61828. verticalAlignment: number;
  61829. /**
  61830. * Gets or sets control width
  61831. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61832. */
  61833. width: string | number;
  61834. /**
  61835. * Gets or sets the control width in pixel
  61836. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61837. */
  61838. widthInPixels: number;
  61839. /**
  61840. * Gets or sets control height
  61841. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61842. */
  61843. height: string | number;
  61844. /**
  61845. * Gets or sets control height in pixel
  61846. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61847. */
  61848. heightInPixels: number;
  61849. /** Gets or set font family */
  61850. fontFamily: string;
  61851. /** Gets or sets font style */
  61852. fontStyle: string;
  61853. /** Gets or sets font weight */
  61854. fontWeight: string;
  61855. /**
  61856. * Gets or sets style
  61857. * @see http://doc.babylonjs.com/how_to/gui#styles
  61858. */
  61859. style: BABYLON.Nullable<Style>;
  61860. /** @hidden */
  61861. readonly _isFontSizeInPercentage: boolean;
  61862. /** Gets or sets font size in pixels */
  61863. fontSizeInPixels: number;
  61864. /** Gets or sets font size */
  61865. fontSize: string | number;
  61866. /** Gets or sets foreground color */
  61867. color: string;
  61868. /** Gets or sets z index which is used to reorder controls on the z axis */
  61869. zIndex: number;
  61870. /** Gets or sets a boolean indicating if the control can be rendered */
  61871. notRenderable: boolean;
  61872. /** Gets or sets a boolean indicating if the control is visible */
  61873. isVisible: boolean;
  61874. /** Gets a boolean indicating that the control needs to update its rendering */
  61875. readonly isDirty: boolean;
  61876. /**
  61877. * Gets the current linked mesh (or null if none)
  61878. */
  61879. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  61880. /**
  61881. * Gets or sets a value indicating the padding to use on the left of the control
  61882. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61883. */
  61884. paddingLeft: string | number;
  61885. /**
  61886. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  61887. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61888. */
  61889. paddingLeftInPixels: number;
  61890. /**
  61891. * Gets or sets a value indicating the padding to use on the right of the control
  61892. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61893. */
  61894. paddingRight: string | number;
  61895. /**
  61896. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  61897. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61898. */
  61899. paddingRightInPixels: number;
  61900. /**
  61901. * Gets or sets a value indicating the padding to use on the top of the control
  61902. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61903. */
  61904. paddingTop: string | number;
  61905. /**
  61906. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  61907. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61908. */
  61909. paddingTopInPixels: number;
  61910. /**
  61911. * Gets or sets a value indicating the padding to use on the bottom of the control
  61912. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61913. */
  61914. paddingBottom: string | number;
  61915. /**
  61916. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  61917. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61918. */
  61919. paddingBottomInPixels: number;
  61920. /**
  61921. * Gets or sets a value indicating the left coordinate of the control
  61922. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61923. */
  61924. left: string | number;
  61925. /**
  61926. * Gets or sets a value indicating the left coordinate in pixels of the control
  61927. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61928. */
  61929. leftInPixels: number;
  61930. /**
  61931. * Gets or sets a value indicating the top coordinate of the control
  61932. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61933. */
  61934. top: string | number;
  61935. /**
  61936. * Gets or sets a value indicating the top coordinate in pixels of the control
  61937. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61938. */
  61939. topInPixels: number;
  61940. /**
  61941. * Gets or sets a value indicating the offset on X axis to the linked mesh
  61942. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61943. */
  61944. linkOffsetX: string | number;
  61945. /**
  61946. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  61947. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61948. */
  61949. linkOffsetXInPixels: number;
  61950. /**
  61951. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  61952. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61953. */
  61954. linkOffsetY: string | number;
  61955. /**
  61956. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  61957. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61958. */
  61959. linkOffsetYInPixels: number;
  61960. /** Gets the center coordinate on X axis */
  61961. readonly centerX: number;
  61962. /** Gets the center coordinate on Y axis */
  61963. readonly centerY: number;
  61964. /** Gets or sets if control is Enabled*/
  61965. isEnabled: boolean;
  61966. /** Gets or sets background color of control if it's disabled*/
  61967. disabledColor: string;
  61968. /**
  61969. * Creates a new control
  61970. * @param name defines the name of the control
  61971. */
  61972. constructor(
  61973. /** defines the name of the control */
  61974. name?: string | undefined);
  61975. /** @hidden */
  61976. protected _getTypeName(): string;
  61977. /**
  61978. * Gets the first ascendant in the hierarchy of the given type
  61979. * @param className defines the required type
  61980. * @returns the ascendant or null if not found
  61981. */
  61982. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  61983. /** @hidden */
  61984. _resetFontCache(): void;
  61985. /**
  61986. * Determines if a container is an ascendant of the current control
  61987. * @param container defines the container to look for
  61988. * @returns true if the container is one of the ascendant of the control
  61989. */
  61990. isAscendant(container: Control): boolean;
  61991. /**
  61992. * Gets coordinates in local control space
  61993. * @param globalCoordinates defines the coordinates to transform
  61994. * @returns the new coordinates in local space
  61995. */
  61996. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  61997. /**
  61998. * Gets coordinates in local control space
  61999. * @param globalCoordinates defines the coordinates to transform
  62000. * @param result defines the target vector2 where to store the result
  62001. * @returns the current control
  62002. */
  62003. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  62004. /**
  62005. * Gets coordinates in parent local control space
  62006. * @param globalCoordinates defines the coordinates to transform
  62007. * @returns the new coordinates in parent local space
  62008. */
  62009. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  62010. /**
  62011. * Move the current control to a vector3 position projected onto the screen.
  62012. * @param position defines the target position
  62013. * @param scene defines the hosting scene
  62014. */
  62015. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  62016. /** @hidden */
  62017. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  62018. /**
  62019. * Will return all controls that have this control as ascendant
  62020. * @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
  62021. * @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
  62022. * @return all child controls
  62023. */
  62024. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  62025. /**
  62026. * Link current control with a target mesh
  62027. * @param mesh defines the mesh to link with
  62028. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62029. */
  62030. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  62031. /** @hidden */
  62032. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  62033. /** @hidden */
  62034. _offsetLeft(offset: number): void;
  62035. /** @hidden */
  62036. _offsetTop(offset: number): void;
  62037. /** @hidden */
  62038. _markMatrixAsDirty(): void;
  62039. /** @hidden */
  62040. _flagDescendantsAsMatrixDirty(): void;
  62041. /** @hidden */
  62042. _intersectsRect(rect: Measure): boolean;
  62043. /** @hidden */
  62044. protected invalidateRect(): void;
  62045. /** @hidden */
  62046. _markAsDirty(force?: boolean): void;
  62047. /** @hidden */
  62048. _markAllAsDirty(): void;
  62049. /** @hidden */
  62050. _link(host: AdvancedDynamicTexture): void;
  62051. /** @hidden */
  62052. protected _transform(context?: CanvasRenderingContext2D): void;
  62053. /** @hidden */
  62054. _renderHighlight(context: CanvasRenderingContext2D): void;
  62055. /** @hidden */
  62056. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62057. /** @hidden */
  62058. protected _applyStates(context: CanvasRenderingContext2D): void;
  62059. /** @hidden */
  62060. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  62061. /** @hidden */
  62062. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62063. protected _evaluateClippingState(parentMeasure: Measure): void;
  62064. /** @hidden */
  62065. _measure(): void;
  62066. /** @hidden */
  62067. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62068. /** @hidden */
  62069. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62070. /** @hidden */
  62071. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62072. /** @hidden */
  62073. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  62074. private static _ClipMeasure;
  62075. private _tmpMeasureA;
  62076. private _clip;
  62077. /** @hidden */
  62078. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  62079. /** @hidden */
  62080. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  62081. /**
  62082. * Tests if a given coordinates belong to the current control
  62083. * @param x defines x coordinate to test
  62084. * @param y defines y coordinate to test
  62085. * @returns true if the coordinates are inside the control
  62086. */
  62087. contains(x: number, y: number): boolean;
  62088. /** @hidden */
  62089. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  62090. /** @hidden */
  62091. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  62092. /** @hidden */
  62093. _onPointerEnter(target: Control): boolean;
  62094. /** @hidden */
  62095. _onPointerOut(target: Control, force?: boolean): void;
  62096. /** @hidden */
  62097. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62098. /** @hidden */
  62099. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62100. /** @hidden */
  62101. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  62102. /** @hidden */
  62103. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  62104. private _prepareFont;
  62105. /** Releases associated resources */
  62106. dispose(): void;
  62107. private static _HORIZONTAL_ALIGNMENT_LEFT;
  62108. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  62109. private static _HORIZONTAL_ALIGNMENT_CENTER;
  62110. private static _VERTICAL_ALIGNMENT_TOP;
  62111. private static _VERTICAL_ALIGNMENT_BOTTOM;
  62112. private static _VERTICAL_ALIGNMENT_CENTER;
  62113. /** HORIZONTAL_ALIGNMENT_LEFT */
  62114. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  62115. /** HORIZONTAL_ALIGNMENT_RIGHT */
  62116. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  62117. /** HORIZONTAL_ALIGNMENT_CENTER */
  62118. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  62119. /** VERTICAL_ALIGNMENT_TOP */
  62120. static readonly VERTICAL_ALIGNMENT_TOP: number;
  62121. /** VERTICAL_ALIGNMENT_BOTTOM */
  62122. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  62123. /** VERTICAL_ALIGNMENT_CENTER */
  62124. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  62125. private static _FontHeightSizes;
  62126. /** @hidden */
  62127. static _GetFontOffset(font: string): {
  62128. ascent: number;
  62129. height: number;
  62130. descent: number;
  62131. };
  62132. /**
  62133. * Creates a stack panel that can be used to render headers
  62134. * @param control defines the control to associate with the header
  62135. * @param text defines the text of the header
  62136. * @param size defines the size of the header
  62137. * @param options defines options used to configure the header
  62138. * @returns a new StackPanel
  62139. * @ignore
  62140. * @hidden
  62141. */
  62142. static AddHeader: (control: Control, text: string, size: string | number, options: {
  62143. isHorizontal: boolean;
  62144. controlFirst: boolean;
  62145. }) => any;
  62146. /** @hidden */
  62147. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  62148. }
  62149. }
  62150. declare module BABYLON.GUI {
  62151. /**
  62152. * Root class for 2D containers
  62153. * @see http://doc.babylonjs.com/how_to/gui#containers
  62154. */
  62155. export class Container extends Control {
  62156. name?: string | undefined;
  62157. /** @hidden */
  62158. protected _children: Control[];
  62159. /** @hidden */
  62160. protected _measureForChildren: Measure;
  62161. /** @hidden */
  62162. protected _background: string;
  62163. /** @hidden */
  62164. protected _adaptWidthToChildren: boolean;
  62165. /** @hidden */
  62166. protected _adaptHeightToChildren: boolean;
  62167. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  62168. adaptHeightToChildren: boolean;
  62169. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  62170. adaptWidthToChildren: boolean;
  62171. /** Gets or sets background color */
  62172. background: string;
  62173. /** Gets the list of children */
  62174. readonly children: Control[];
  62175. /**
  62176. * Creates a new Container
  62177. * @param name defines the name of the container
  62178. */
  62179. constructor(name?: string | undefined);
  62180. protected _getTypeName(): string;
  62181. _flagDescendantsAsMatrixDirty(): void;
  62182. /**
  62183. * Gets a child using its name
  62184. * @param name defines the child name to look for
  62185. * @returns the child control if found
  62186. */
  62187. getChildByName(name: string): BABYLON.Nullable<Control>;
  62188. /**
  62189. * Gets a child using its type and its name
  62190. * @param name defines the child name to look for
  62191. * @param type defines the child type to look for
  62192. * @returns the child control if found
  62193. */
  62194. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  62195. /**
  62196. * Search for a specific control in children
  62197. * @param control defines the control to look for
  62198. * @returns true if the control is in child list
  62199. */
  62200. containsControl(control: Control): boolean;
  62201. /**
  62202. * Adds a new control to the current container
  62203. * @param control defines the control to add
  62204. * @returns the current container
  62205. */
  62206. addControl(control: BABYLON.Nullable<Control>): Container;
  62207. /**
  62208. * Removes all controls from the current container
  62209. * @returns the current container
  62210. */
  62211. clearControls(): Container;
  62212. /**
  62213. * Removes a control from the current container
  62214. * @param control defines the control to remove
  62215. * @returns the current container
  62216. */
  62217. removeControl(control: Control): Container;
  62218. /** @hidden */
  62219. _reOrderControl(control: Control): void;
  62220. /** @hidden */
  62221. _offsetLeft(offset: number): void;
  62222. /** @hidden */
  62223. _offsetTop(offset: number): void;
  62224. /** @hidden */
  62225. _markAllAsDirty(): void;
  62226. /** @hidden */
  62227. protected _localDraw(context: CanvasRenderingContext2D): void;
  62228. /** @hidden */
  62229. _link(host: AdvancedDynamicTexture): void;
  62230. /** @hidden */
  62231. protected _beforeLayout(): void;
  62232. /** @hidden */
  62233. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62234. /** @hidden */
  62235. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  62236. protected _postMeasure(): void;
  62237. /** @hidden */
  62238. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  62239. /** @hidden */
  62240. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  62241. /** @hidden */
  62242. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  62243. /** @hidden */
  62244. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62245. /** Releases associated resources */
  62246. dispose(): void;
  62247. }
  62248. }
  62249. declare module BABYLON.GUI {
  62250. /** Class used to create rectangle container */
  62251. export class Rectangle extends Container {
  62252. name?: string | undefined;
  62253. private _thickness;
  62254. private _cornerRadius;
  62255. /** Gets or sets border thickness */
  62256. thickness: number;
  62257. /** Gets or sets the corner radius angle */
  62258. cornerRadius: number;
  62259. /**
  62260. * Creates a new Rectangle
  62261. * @param name defines the control name
  62262. */
  62263. constructor(name?: string | undefined);
  62264. protected _getTypeName(): string;
  62265. protected _localDraw(context: CanvasRenderingContext2D): void;
  62266. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62267. private _drawRoundedRect;
  62268. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  62269. }
  62270. }
  62271. declare module BABYLON.GUI {
  62272. /**
  62273. * Enum that determines the text-wrapping mode to use.
  62274. */
  62275. export enum TextWrapping {
  62276. /**
  62277. * Clip the text when it's larger than Control.width; this is the default mode.
  62278. */
  62279. Clip = 0,
  62280. /**
  62281. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  62282. */
  62283. WordWrap = 1,
  62284. /**
  62285. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  62286. */
  62287. Ellipsis = 2
  62288. }
  62289. /**
  62290. * Class used to create text block control
  62291. */
  62292. export class TextBlock extends Control {
  62293. /**
  62294. * Defines the name of the control
  62295. */
  62296. name?: string | undefined;
  62297. private _text;
  62298. private _textWrapping;
  62299. private _textHorizontalAlignment;
  62300. private _textVerticalAlignment;
  62301. private _lines;
  62302. private _resizeToFit;
  62303. private _lineSpacing;
  62304. private _outlineWidth;
  62305. private _outlineColor;
  62306. /**
  62307. * An event triggered after the text is changed
  62308. */
  62309. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  62310. /**
  62311. * An event triggered after the text was broken up into lines
  62312. */
  62313. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  62314. /**
  62315. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  62316. */
  62317. readonly lines: any[];
  62318. /**
  62319. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  62320. */
  62321. /**
  62322. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  62323. */
  62324. resizeToFit: boolean;
  62325. /**
  62326. * Gets or sets a boolean indicating if text must be wrapped
  62327. */
  62328. /**
  62329. * Gets or sets a boolean indicating if text must be wrapped
  62330. */
  62331. textWrapping: TextWrapping | boolean;
  62332. /**
  62333. * Gets or sets text to display
  62334. */
  62335. /**
  62336. * Gets or sets text to display
  62337. */
  62338. text: string;
  62339. /**
  62340. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  62341. */
  62342. /**
  62343. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  62344. */
  62345. textHorizontalAlignment: number;
  62346. /**
  62347. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  62348. */
  62349. /**
  62350. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  62351. */
  62352. textVerticalAlignment: number;
  62353. /**
  62354. * Gets or sets line spacing value
  62355. */
  62356. /**
  62357. * Gets or sets line spacing value
  62358. */
  62359. lineSpacing: string | number;
  62360. /**
  62361. * Gets or sets outlineWidth of the text to display
  62362. */
  62363. /**
  62364. * Gets or sets outlineWidth of the text to display
  62365. */
  62366. outlineWidth: number;
  62367. /**
  62368. * Gets or sets outlineColor of the text to display
  62369. */
  62370. /**
  62371. * Gets or sets outlineColor of the text to display
  62372. */
  62373. outlineColor: string;
  62374. /**
  62375. * Creates a new TextBlock object
  62376. * @param name defines the name of the control
  62377. * @param text defines the text to display (emptry string by default)
  62378. */
  62379. constructor(
  62380. /**
  62381. * Defines the name of the control
  62382. */
  62383. name?: string | undefined, text?: string);
  62384. protected _getTypeName(): string;
  62385. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62386. private _drawText;
  62387. /** @hidden */
  62388. _draw(context: CanvasRenderingContext2D): void;
  62389. protected _applyStates(context: CanvasRenderingContext2D): void;
  62390. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  62391. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  62392. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  62393. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  62394. protected _renderLines(context: CanvasRenderingContext2D): void;
  62395. /**
  62396. * Given a width constraint applied on the text block, find the expected height
  62397. * @returns expected height
  62398. */
  62399. computeExpectedHeight(): number;
  62400. dispose(): void;
  62401. }
  62402. }
  62403. declare module BABYLON.GUI {
  62404. /**
  62405. * Class used to create 2D images
  62406. */
  62407. export class Image extends Control {
  62408. name?: string | undefined;
  62409. private static _WorkingCanvas;
  62410. private _domImage;
  62411. private _imageWidth;
  62412. private _imageHeight;
  62413. private _loaded;
  62414. private _stretch;
  62415. private _source;
  62416. private _autoScale;
  62417. private _sourceLeft;
  62418. private _sourceTop;
  62419. private _sourceWidth;
  62420. private _sourceHeight;
  62421. private _cellWidth;
  62422. private _cellHeight;
  62423. private _cellId;
  62424. private _populateNinePatchSlicesFromImage;
  62425. private _sliceLeft;
  62426. private _sliceRight;
  62427. private _sliceTop;
  62428. private _sliceBottom;
  62429. private _detectPointerOnOpaqueOnly;
  62430. /**
  62431. * BABYLON.Observable notified when the content is loaded
  62432. */
  62433. onImageLoadedObservable: BABYLON.Observable<Image>;
  62434. /**
  62435. * Gets a boolean indicating that the content is loaded
  62436. */
  62437. readonly isLoaded: boolean;
  62438. /**
  62439. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  62440. */
  62441. populateNinePatchSlicesFromImage: boolean;
  62442. /**
  62443. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  62444. * Beware using this as this will comsume more memory as the image has to be stored twice
  62445. */
  62446. detectPointerOnOpaqueOnly: boolean;
  62447. /**
  62448. * Gets or sets the left value for slicing (9-patch)
  62449. */
  62450. sliceLeft: number;
  62451. /**
  62452. * Gets or sets the right value for slicing (9-patch)
  62453. */
  62454. sliceRight: number;
  62455. /**
  62456. * Gets or sets the top value for slicing (9-patch)
  62457. */
  62458. sliceTop: number;
  62459. /**
  62460. * Gets or sets the bottom value for slicing (9-patch)
  62461. */
  62462. sliceBottom: number;
  62463. /**
  62464. * Gets or sets the left coordinate in the source image
  62465. */
  62466. sourceLeft: number;
  62467. /**
  62468. * Gets or sets the top coordinate in the source image
  62469. */
  62470. sourceTop: number;
  62471. /**
  62472. * Gets or sets the width to capture in the source image
  62473. */
  62474. sourceWidth: number;
  62475. /**
  62476. * Gets or sets the height to capture in the source image
  62477. */
  62478. sourceHeight: number;
  62479. /**
  62480. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  62481. * @see http://doc.babylonjs.com/how_to/gui#image
  62482. */
  62483. autoScale: boolean;
  62484. /** Gets or sets the streching mode used by the image */
  62485. stretch: number;
  62486. /**
  62487. * Gets or sets the internal DOM image used to render the control
  62488. */
  62489. domImage: HTMLImageElement;
  62490. private _onImageLoaded;
  62491. private _extractNinePatchSliceDataFromImage;
  62492. /**
  62493. * Gets or sets image source url
  62494. */
  62495. source: BABYLON.Nullable<string>;
  62496. /**
  62497. * Gets or sets the cell width to use when animation sheet is enabled
  62498. * @see http://doc.babylonjs.com/how_to/gui#image
  62499. */
  62500. cellWidth: number;
  62501. /**
  62502. * Gets or sets the cell height to use when animation sheet is enabled
  62503. * @see http://doc.babylonjs.com/how_to/gui#image
  62504. */
  62505. cellHeight: number;
  62506. /**
  62507. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  62508. * @see http://doc.babylonjs.com/how_to/gui#image
  62509. */
  62510. cellId: number;
  62511. /**
  62512. * Creates a new Image
  62513. * @param name defines the control name
  62514. * @param url defines the image url
  62515. */
  62516. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  62517. /**
  62518. * Tests if a given coordinates belong to the current control
  62519. * @param x defines x coordinate to test
  62520. * @param y defines y coordinate to test
  62521. * @returns true if the coordinates are inside the control
  62522. */
  62523. contains(x: number, y: number): boolean;
  62524. protected _getTypeName(): string;
  62525. /** Force the control to synchronize with its content */
  62526. synchronizeSizeWithContent(): void;
  62527. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62528. private _prepareWorkingCanvasForOpaqueDetection;
  62529. private _drawImage;
  62530. _draw(context: CanvasRenderingContext2D): void;
  62531. private _renderCornerPatch;
  62532. private _renderNinePatch;
  62533. dispose(): void;
  62534. /** STRETCH_NONE */
  62535. static readonly STRETCH_NONE: number;
  62536. /** STRETCH_FILL */
  62537. static readonly STRETCH_FILL: number;
  62538. /** STRETCH_UNIFORM */
  62539. static readonly STRETCH_UNIFORM: number;
  62540. /** STRETCH_EXTEND */
  62541. static readonly STRETCH_EXTEND: number;
  62542. /** NINE_PATCH */
  62543. static readonly STRETCH_NINE_PATCH: number;
  62544. }
  62545. }
  62546. declare module BABYLON.GUI {
  62547. /**
  62548. * Class used to create 2D buttons
  62549. */
  62550. export class Button extends Rectangle {
  62551. name?: string | undefined;
  62552. /**
  62553. * Function called to generate a pointer enter animation
  62554. */
  62555. pointerEnterAnimation: () => void;
  62556. /**
  62557. * Function called to generate a pointer out animation
  62558. */
  62559. pointerOutAnimation: () => void;
  62560. /**
  62561. * Function called to generate a pointer down animation
  62562. */
  62563. pointerDownAnimation: () => void;
  62564. /**
  62565. * Function called to generate a pointer up animation
  62566. */
  62567. pointerUpAnimation: () => void;
  62568. /**
  62569. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  62570. */
  62571. delegatePickingToChildren: boolean;
  62572. private _image;
  62573. /**
  62574. * Returns the image part of the button (if any)
  62575. */
  62576. readonly image: BABYLON.Nullable<Image>;
  62577. private _textBlock;
  62578. /**
  62579. * Returns the image part of the button (if any)
  62580. */
  62581. readonly textBlock: BABYLON.Nullable<TextBlock>;
  62582. /**
  62583. * Creates a new Button
  62584. * @param name defines the name of the button
  62585. */
  62586. constructor(name?: string | undefined);
  62587. protected _getTypeName(): string;
  62588. /** @hidden */
  62589. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  62590. /** @hidden */
  62591. _onPointerEnter(target: Control): boolean;
  62592. /** @hidden */
  62593. _onPointerOut(target: Control, force?: boolean): void;
  62594. /** @hidden */
  62595. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62596. /** @hidden */
  62597. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62598. /**
  62599. * Creates a new button made with an image and a text
  62600. * @param name defines the name of the button
  62601. * @param text defines the text of the button
  62602. * @param imageUrl defines the url of the image
  62603. * @returns a new Button
  62604. */
  62605. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  62606. /**
  62607. * Creates a new button made with an image
  62608. * @param name defines the name of the button
  62609. * @param imageUrl defines the url of the image
  62610. * @returns a new Button
  62611. */
  62612. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  62613. /**
  62614. * Creates a new button made with a text
  62615. * @param name defines the name of the button
  62616. * @param text defines the text of the button
  62617. * @returns a new Button
  62618. */
  62619. static CreateSimpleButton(name: string, text: string): Button;
  62620. /**
  62621. * Creates a new button made with an image and a centered text
  62622. * @param name defines the name of the button
  62623. * @param text defines the text of the button
  62624. * @param imageUrl defines the url of the image
  62625. * @returns a new Button
  62626. */
  62627. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  62628. }
  62629. }
  62630. declare module BABYLON.GUI {
  62631. /**
  62632. * Class used to create a 2D stack panel container
  62633. */
  62634. export class StackPanel extends Container {
  62635. name?: string | undefined;
  62636. private _isVertical;
  62637. private _manualWidth;
  62638. private _manualHeight;
  62639. private _doNotTrackManualChanges;
  62640. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  62641. isVertical: boolean;
  62642. /**
  62643. * Gets or sets panel width.
  62644. * This value should not be set when in horizontal mode as it will be computed automatically
  62645. */
  62646. width: string | number;
  62647. /**
  62648. * Gets or sets panel height.
  62649. * This value should not be set when in vertical mode as it will be computed automatically
  62650. */
  62651. height: string | number;
  62652. /**
  62653. * Creates a new StackPanel
  62654. * @param name defines control name
  62655. */
  62656. constructor(name?: string | undefined);
  62657. protected _getTypeName(): string;
  62658. /** @hidden */
  62659. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62660. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62661. protected _postMeasure(): void;
  62662. }
  62663. }
  62664. declare module BABYLON.GUI {
  62665. /**
  62666. * Class used to represent a 2D checkbox
  62667. */
  62668. export class Checkbox extends Control {
  62669. name?: string | undefined;
  62670. private _isChecked;
  62671. private _background;
  62672. private _checkSizeRatio;
  62673. private _thickness;
  62674. /** Gets or sets border thickness */
  62675. thickness: number;
  62676. /**
  62677. * BABYLON.Observable raised when isChecked property changes
  62678. */
  62679. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  62680. /** Gets or sets a value indicating the ratio between overall size and check size */
  62681. checkSizeRatio: number;
  62682. /** Gets or sets background color */
  62683. background: string;
  62684. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  62685. isChecked: boolean;
  62686. /**
  62687. * Creates a new CheckBox
  62688. * @param name defines the control name
  62689. */
  62690. constructor(name?: string | undefined);
  62691. protected _getTypeName(): string;
  62692. /** @hidden */
  62693. _draw(context: CanvasRenderingContext2D): void;
  62694. /** @hidden */
  62695. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62696. /**
  62697. * Utility function to easily create a checkbox with a header
  62698. * @param title defines the label to use for the header
  62699. * @param onValueChanged defines the callback to call when value changes
  62700. * @returns a StackPanel containing the checkbox and a textBlock
  62701. */
  62702. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  62703. }
  62704. }
  62705. declare module BABYLON.GUI {
  62706. /**
  62707. * Class used to store key control properties
  62708. */
  62709. export class KeyPropertySet {
  62710. /** Width */
  62711. width?: string;
  62712. /** Height */
  62713. height?: string;
  62714. /** Left padding */
  62715. paddingLeft?: string;
  62716. /** Right padding */
  62717. paddingRight?: string;
  62718. /** Top padding */
  62719. paddingTop?: string;
  62720. /** Bottom padding */
  62721. paddingBottom?: string;
  62722. /** Foreground color */
  62723. color?: string;
  62724. /** Background color */
  62725. background?: string;
  62726. }
  62727. /**
  62728. * Class used to create virtual keyboard
  62729. */
  62730. export class VirtualKeyboard extends StackPanel {
  62731. /** BABYLON.Observable raised when a key is pressed */
  62732. onKeyPressObservable: BABYLON.Observable<string>;
  62733. /** Gets or sets default key button width */
  62734. defaultButtonWidth: string;
  62735. /** Gets or sets default key button height */
  62736. defaultButtonHeight: string;
  62737. /** Gets or sets default key button left padding */
  62738. defaultButtonPaddingLeft: string;
  62739. /** Gets or sets default key button right padding */
  62740. defaultButtonPaddingRight: string;
  62741. /** Gets or sets default key button top padding */
  62742. defaultButtonPaddingTop: string;
  62743. /** Gets or sets default key button bottom padding */
  62744. defaultButtonPaddingBottom: string;
  62745. /** Gets or sets default key button foreground color */
  62746. defaultButtonColor: string;
  62747. /** Gets or sets default key button background color */
  62748. defaultButtonBackground: string;
  62749. /** Gets or sets shift button foreground color */
  62750. shiftButtonColor: string;
  62751. /** Gets or sets shift button thickness*/
  62752. selectedShiftThickness: number;
  62753. /** Gets shift key state */
  62754. shiftState: number;
  62755. protected _getTypeName(): string;
  62756. private _createKey;
  62757. /**
  62758. * Adds a new row of keys
  62759. * @param keys defines the list of keys to add
  62760. * @param propertySets defines the associated property sets
  62761. */
  62762. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  62763. /**
  62764. * Set the shift key to a specific state
  62765. * @param shiftState defines the new shift state
  62766. */
  62767. applyShiftState(shiftState: number): void;
  62768. private _currentlyConnectedInputText;
  62769. private _connectedInputTexts;
  62770. private _onKeyPressObserver;
  62771. /** Gets the input text control currently attached to the keyboard */
  62772. readonly connectedInputText: BABYLON.Nullable<InputText>;
  62773. /**
  62774. * Connects the keyboard with an input text control
  62775. *
  62776. * @param input defines the target control
  62777. */
  62778. connect(input: InputText): void;
  62779. /**
  62780. * Disconnects the keyboard from connected InputText controls
  62781. *
  62782. * @param input optionally defines a target control, otherwise all are disconnected
  62783. */
  62784. disconnect(input?: InputText): void;
  62785. private _removeConnectedInputObservables;
  62786. /**
  62787. * Release all resources
  62788. */
  62789. dispose(): void;
  62790. /**
  62791. * Creates a new keyboard using a default layout
  62792. *
  62793. * @param name defines control name
  62794. * @returns a new VirtualKeyboard
  62795. */
  62796. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  62797. }
  62798. }
  62799. declare module BABYLON.GUI {
  62800. /**
  62801. * Class used to create input text control
  62802. */
  62803. export class InputText extends Control implements IFocusableControl {
  62804. name?: string | undefined;
  62805. private _text;
  62806. private _placeholderText;
  62807. private _background;
  62808. private _focusedBackground;
  62809. private _focusedColor;
  62810. private _placeholderColor;
  62811. private _thickness;
  62812. private _margin;
  62813. private _autoStretchWidth;
  62814. private _maxWidth;
  62815. private _isFocused;
  62816. private _blinkTimeout;
  62817. private _blinkIsEven;
  62818. private _cursorOffset;
  62819. private _scrollLeft;
  62820. private _textWidth;
  62821. private _clickedCoordinate;
  62822. private _deadKey;
  62823. private _addKey;
  62824. private _currentKey;
  62825. private _isTextHighlightOn;
  62826. private _textHighlightColor;
  62827. private _highligherOpacity;
  62828. private _highlightedText;
  62829. private _startHighlightIndex;
  62830. private _endHighlightIndex;
  62831. private _cursorIndex;
  62832. private _onFocusSelectAll;
  62833. private _isPointerDown;
  62834. private _onClipboardObserver;
  62835. private _onPointerDblTapObserver;
  62836. /** @hidden */
  62837. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  62838. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  62839. promptMessage: string;
  62840. /** Force disable prompt on mobile device */
  62841. disableMobilePrompt: boolean;
  62842. /** BABYLON.Observable raised when the text changes */
  62843. onTextChangedObservable: BABYLON.Observable<InputText>;
  62844. /** BABYLON.Observable raised just before an entered character is to be added */
  62845. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  62846. /** BABYLON.Observable raised when the control gets the focus */
  62847. onFocusObservable: BABYLON.Observable<InputText>;
  62848. /** BABYLON.Observable raised when the control loses the focus */
  62849. onBlurObservable: BABYLON.Observable<InputText>;
  62850. /**Observable raised when the text is highlighted */
  62851. onTextHighlightObservable: BABYLON.Observable<InputText>;
  62852. /**Observable raised when copy event is triggered */
  62853. onTextCopyObservable: BABYLON.Observable<InputText>;
  62854. /** BABYLON.Observable raised when cut event is triggered */
  62855. onTextCutObservable: BABYLON.Observable<InputText>;
  62856. /** BABYLON.Observable raised when paste event is triggered */
  62857. onTextPasteObservable: BABYLON.Observable<InputText>;
  62858. /** BABYLON.Observable raised when a key event was processed */
  62859. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  62860. /** Gets or sets the maximum width allowed by the control */
  62861. maxWidth: string | number;
  62862. /** Gets the maximum width allowed by the control in pixels */
  62863. readonly maxWidthInPixels: number;
  62864. /** Gets or sets the text highlighter transparency; default: 0.4 */
  62865. highligherOpacity: number;
  62866. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  62867. onFocusSelectAll: boolean;
  62868. /** Gets or sets the text hightlight color */
  62869. textHighlightColor: string;
  62870. /** Gets or sets control margin */
  62871. margin: string;
  62872. /** Gets control margin in pixels */
  62873. readonly marginInPixels: number;
  62874. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  62875. autoStretchWidth: boolean;
  62876. /** Gets or sets border thickness */
  62877. thickness: number;
  62878. /** Gets or sets the background color when focused */
  62879. focusedBackground: string;
  62880. /** Gets or sets the background color when focused */
  62881. focusedColor: string;
  62882. /** Gets or sets the background color */
  62883. background: string;
  62884. /** Gets or sets the placeholder color */
  62885. placeholderColor: string;
  62886. /** Gets or sets the text displayed when the control is empty */
  62887. placeholderText: string;
  62888. /** Gets or sets the dead key flag */
  62889. deadKey: boolean;
  62890. /** Gets or sets the highlight text */
  62891. highlightedText: string;
  62892. /** Gets or sets if the current key should be added */
  62893. addKey: boolean;
  62894. /** Gets or sets the value of the current key being entered */
  62895. currentKey: string;
  62896. /** Gets or sets the text displayed in the control */
  62897. text: string;
  62898. /** Gets or sets control width */
  62899. width: string | number;
  62900. /**
  62901. * Creates a new InputText
  62902. * @param name defines the control name
  62903. * @param text defines the text of the control
  62904. */
  62905. constructor(name?: string | undefined, text?: string);
  62906. /** @hidden */
  62907. onBlur(): void;
  62908. /** @hidden */
  62909. onFocus(): void;
  62910. protected _getTypeName(): string;
  62911. /**
  62912. * Function called to get the list of controls that should not steal the focus from this control
  62913. * @returns an array of controls
  62914. */
  62915. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  62916. /** @hidden */
  62917. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  62918. /** @hidden */
  62919. private _updateValueFromCursorIndex;
  62920. /** @hidden */
  62921. private _processDblClick;
  62922. /** @hidden */
  62923. private _selectAllText;
  62924. /**
  62925. * Handles the keyboard event
  62926. * @param evt Defines the KeyboardEvent
  62927. */
  62928. processKeyboard(evt: KeyboardEvent): void;
  62929. /** @hidden */
  62930. private _onCopyText;
  62931. /** @hidden */
  62932. private _onCutText;
  62933. /** @hidden */
  62934. private _onPasteText;
  62935. _draw(context: CanvasRenderingContext2D): void;
  62936. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62937. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  62938. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62939. protected _beforeRenderText(text: string): string;
  62940. dispose(): void;
  62941. }
  62942. }
  62943. declare module BABYLON.GUI {
  62944. /**
  62945. * Class used to create a 2D grid container
  62946. */
  62947. export class Grid extends Container {
  62948. name?: string | undefined;
  62949. private _rowDefinitions;
  62950. private _columnDefinitions;
  62951. private _cells;
  62952. private _childControls;
  62953. /**
  62954. * Gets the number of columns
  62955. */
  62956. readonly columnCount: number;
  62957. /**
  62958. * Gets the number of rows
  62959. */
  62960. readonly rowCount: number;
  62961. /** Gets the list of children */
  62962. readonly children: Control[];
  62963. /** Gets the list of cells (e.g. the containers) */
  62964. readonly cells: {
  62965. [key: string]: Container;
  62966. };
  62967. /**
  62968. * Gets the definition of a specific row
  62969. * @param index defines the index of the row
  62970. * @returns the row definition
  62971. */
  62972. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  62973. /**
  62974. * Gets the definition of a specific column
  62975. * @param index defines the index of the column
  62976. * @returns the column definition
  62977. */
  62978. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  62979. /**
  62980. * Adds a new row to the grid
  62981. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  62982. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  62983. * @returns the current grid
  62984. */
  62985. addRowDefinition(height: number, isPixel?: boolean): Grid;
  62986. /**
  62987. * Adds a new column to the grid
  62988. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  62989. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  62990. * @returns the current grid
  62991. */
  62992. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  62993. /**
  62994. * Update a row definition
  62995. * @param index defines the index of the row to update
  62996. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  62997. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  62998. * @returns the current grid
  62999. */
  63000. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  63001. /**
  63002. * Update a column definition
  63003. * @param index defines the index of the column to update
  63004. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  63005. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  63006. * @returns the current grid
  63007. */
  63008. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  63009. /**
  63010. * Gets the list of children stored in a specific cell
  63011. * @param row defines the row to check
  63012. * @param column defines the column to check
  63013. * @returns the list of controls
  63014. */
  63015. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  63016. /**
  63017. * Gets a string representing the child cell info (row x column)
  63018. * @param child defines the control to get info from
  63019. * @returns a string containing the child cell info (row x column)
  63020. */
  63021. getChildCellInfo(child: Control): string;
  63022. private _removeCell;
  63023. private _offsetCell;
  63024. /**
  63025. * Remove a column definition at specified index
  63026. * @param index defines the index of the column to remove
  63027. * @returns the current grid
  63028. */
  63029. removeColumnDefinition(index: number): Grid;
  63030. /**
  63031. * Remove a row definition at specified index
  63032. * @param index defines the index of the row to remove
  63033. * @returns the current grid
  63034. */
  63035. removeRowDefinition(index: number): Grid;
  63036. /**
  63037. * Adds a new control to the current grid
  63038. * @param control defines the control to add
  63039. * @param row defines the row where to add the control (0 by default)
  63040. * @param column defines the column where to add the control (0 by default)
  63041. * @returns the current grid
  63042. */
  63043. addControl(control: Control, row?: number, column?: number): Grid;
  63044. /**
  63045. * Removes a control from the current container
  63046. * @param control defines the control to remove
  63047. * @returns the current container
  63048. */
  63049. removeControl(control: Control): Container;
  63050. /**
  63051. * Creates a new Grid
  63052. * @param name defines control name
  63053. */
  63054. constructor(name?: string | undefined);
  63055. protected _getTypeName(): string;
  63056. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  63057. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63058. _flagDescendantsAsMatrixDirty(): void;
  63059. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63060. /** Releases associated resources */
  63061. dispose(): void;
  63062. }
  63063. }
  63064. declare module BABYLON.GUI {
  63065. /** Class used to create color pickers */
  63066. export class ColorPicker extends Control {
  63067. name?: string | undefined;
  63068. private static _Epsilon;
  63069. private _colorWheelCanvas;
  63070. private _value;
  63071. private _tmpColor;
  63072. private _pointerStartedOnSquare;
  63073. private _pointerStartedOnWheel;
  63074. private _squareLeft;
  63075. private _squareTop;
  63076. private _squareSize;
  63077. private _h;
  63078. private _s;
  63079. private _v;
  63080. private _lastPointerDownID;
  63081. /**
  63082. * BABYLON.Observable raised when the value changes
  63083. */
  63084. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  63085. /** Gets or sets the color of the color picker */
  63086. value: BABYLON.Color3;
  63087. /**
  63088. * Gets or sets control width
  63089. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63090. */
  63091. width: string | number;
  63092. /**
  63093. * Gets or sets control height
  63094. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63095. */
  63096. /** Gets or sets control height */
  63097. height: string | number;
  63098. /** Gets or sets control size */
  63099. size: string | number;
  63100. /**
  63101. * Creates a new ColorPicker
  63102. * @param name defines the control name
  63103. */
  63104. constructor(name?: string | undefined);
  63105. protected _getTypeName(): string;
  63106. /** @hidden */
  63107. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63108. private _updateSquareProps;
  63109. private _drawGradientSquare;
  63110. private _drawCircle;
  63111. private _createColorWheelCanvas;
  63112. /** @hidden */
  63113. _draw(context: CanvasRenderingContext2D): void;
  63114. private _pointerIsDown;
  63115. private _updateValueFromPointer;
  63116. private _isPointOnSquare;
  63117. private _isPointOnWheel;
  63118. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63119. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63120. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63121. /**
  63122. * This function expands the color picker by creating a color picker dialog with manual
  63123. * color value input and the ability to save colors into an array to be used later in
  63124. * subsequent launches of the dialogue.
  63125. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  63126. * @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.
  63127. * @returns picked color as a hex string and the saved colors array as hex strings.
  63128. */
  63129. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  63130. pickerWidth?: string;
  63131. pickerHeight?: string;
  63132. headerHeight?: string;
  63133. lastColor?: string;
  63134. swatchLimit?: number;
  63135. numSwatchesPerLine?: number;
  63136. savedColors?: Array<string>;
  63137. }): Promise<{
  63138. savedColors?: string[];
  63139. pickedColor: string;
  63140. }>;
  63141. }
  63142. }
  63143. declare module BABYLON.GUI {
  63144. /** Class used to create 2D ellipse containers */
  63145. export class Ellipse extends Container {
  63146. name?: string | undefined;
  63147. private _thickness;
  63148. /** Gets or sets border thickness */
  63149. thickness: number;
  63150. /**
  63151. * Creates a new Ellipse
  63152. * @param name defines the control name
  63153. */
  63154. constructor(name?: string | undefined);
  63155. protected _getTypeName(): string;
  63156. protected _localDraw(context: CanvasRenderingContext2D): void;
  63157. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63158. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63159. }
  63160. }
  63161. declare module BABYLON.GUI {
  63162. /**
  63163. * Class used to create a password control
  63164. */
  63165. export class InputPassword extends InputText {
  63166. protected _beforeRenderText(text: string): string;
  63167. }
  63168. }
  63169. declare module BABYLON.GUI {
  63170. /** Class used to render 2D lines */
  63171. export class Line extends Control {
  63172. name?: string | undefined;
  63173. private _lineWidth;
  63174. private _x1;
  63175. private _y1;
  63176. private _x2;
  63177. private _y2;
  63178. private _dash;
  63179. private _connectedControl;
  63180. private _connectedControlDirtyObserver;
  63181. /** Gets or sets the dash pattern */
  63182. dash: Array<number>;
  63183. /** Gets or sets the control connected with the line end */
  63184. connectedControl: Control;
  63185. /** Gets or sets start coordinates on X axis */
  63186. x1: string | number;
  63187. /** Gets or sets start coordinates on Y axis */
  63188. y1: string | number;
  63189. /** Gets or sets end coordinates on X axis */
  63190. x2: string | number;
  63191. /** Gets or sets end coordinates on Y axis */
  63192. y2: string | number;
  63193. /** Gets or sets line width */
  63194. lineWidth: number;
  63195. /** Gets or sets horizontal alignment */
  63196. horizontalAlignment: number;
  63197. /** Gets or sets vertical alignment */
  63198. verticalAlignment: number;
  63199. private readonly _effectiveX2;
  63200. private readonly _effectiveY2;
  63201. /**
  63202. * Creates a new Line
  63203. * @param name defines the control name
  63204. */
  63205. constructor(name?: string | undefined);
  63206. protected _getTypeName(): string;
  63207. _draw(context: CanvasRenderingContext2D): void;
  63208. _measure(): void;
  63209. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63210. /**
  63211. * Move one end of the line given 3D cartesian coordinates.
  63212. * @param position Targeted world position
  63213. * @param scene BABYLON.Scene
  63214. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  63215. */
  63216. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  63217. /**
  63218. * Move one end of the line to a position in screen absolute space.
  63219. * @param projectedPosition Position in screen absolute space (X, Y)
  63220. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  63221. */
  63222. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  63223. }
  63224. }
  63225. declare module BABYLON.GUI {
  63226. /**
  63227. * Class used to store a point for a MultiLine object.
  63228. * The point can be pure 2D coordinates, a mesh or a control
  63229. */
  63230. export class MultiLinePoint {
  63231. private _multiLine;
  63232. private _x;
  63233. private _y;
  63234. private _control;
  63235. private _mesh;
  63236. private _controlObserver;
  63237. private _meshObserver;
  63238. /** @hidden */
  63239. _point: BABYLON.Vector2;
  63240. /**
  63241. * Creates a new MultiLinePoint
  63242. * @param multiLine defines the source MultiLine object
  63243. */
  63244. constructor(multiLine: MultiLine);
  63245. /** Gets or sets x coordinate */
  63246. x: string | number;
  63247. /** Gets or sets y coordinate */
  63248. y: string | number;
  63249. /** Gets or sets the control associated with this point */
  63250. control: BABYLON.Nullable<Control>;
  63251. /** Gets or sets the mesh associated with this point */
  63252. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63253. /** Resets links */
  63254. resetLinks(): void;
  63255. /**
  63256. * Gets a translation vector
  63257. * @returns the translation vector
  63258. */
  63259. translate(): BABYLON.Vector2;
  63260. private _translatePoint;
  63261. /** Release associated resources */
  63262. dispose(): void;
  63263. }
  63264. }
  63265. declare module BABYLON.GUI {
  63266. /**
  63267. * Class used to create multi line control
  63268. */
  63269. export class MultiLine extends Control {
  63270. name?: string | undefined;
  63271. private _lineWidth;
  63272. private _dash;
  63273. private _points;
  63274. private _minX;
  63275. private _minY;
  63276. private _maxX;
  63277. private _maxY;
  63278. /**
  63279. * Creates a new MultiLine
  63280. * @param name defines the control name
  63281. */
  63282. constructor(name?: string | undefined);
  63283. /** Gets or sets dash pattern */
  63284. dash: Array<number>;
  63285. /**
  63286. * Gets point stored at specified index
  63287. * @param index defines the index to look for
  63288. * @returns the requested point if found
  63289. */
  63290. getAt(index: number): MultiLinePoint;
  63291. /** Function called when a point is updated */
  63292. onPointUpdate: () => void;
  63293. /**
  63294. * Adds new points to the point collection
  63295. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  63296. * @returns the list of created MultiLinePoint
  63297. */
  63298. add(...items: (AbstractMesh | Control | {
  63299. x: string | number;
  63300. y: string | number;
  63301. })[]): MultiLinePoint[];
  63302. /**
  63303. * Adds a new point to the point collection
  63304. * @param item defines the item (mesh, control or 2d coordiantes) to add
  63305. * @returns the created MultiLinePoint
  63306. */
  63307. push(item?: (AbstractMesh | Control | {
  63308. x: string | number;
  63309. y: string | number;
  63310. })): MultiLinePoint;
  63311. /**
  63312. * Remove a specific value or point from the active point collection
  63313. * @param value defines the value or point to remove
  63314. */
  63315. remove(value: number | MultiLinePoint): void;
  63316. /**
  63317. * Resets this object to initial state (no point)
  63318. */
  63319. reset(): void;
  63320. /**
  63321. * Resets all links
  63322. */
  63323. resetLinks(): void;
  63324. /** Gets or sets line width */
  63325. lineWidth: number;
  63326. horizontalAlignment: number;
  63327. verticalAlignment: number;
  63328. protected _getTypeName(): string;
  63329. _draw(context: CanvasRenderingContext2D): void;
  63330. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63331. _measure(): void;
  63332. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63333. dispose(): void;
  63334. }
  63335. }
  63336. declare module BABYLON.GUI {
  63337. /**
  63338. * Class used to create radio button controls
  63339. */
  63340. export class RadioButton extends Control {
  63341. name?: string | undefined;
  63342. private _isChecked;
  63343. private _background;
  63344. private _checkSizeRatio;
  63345. private _thickness;
  63346. /** Gets or sets border thickness */
  63347. thickness: number;
  63348. /** Gets or sets group name */
  63349. group: string;
  63350. /** BABYLON.Observable raised when isChecked is changed */
  63351. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  63352. /** Gets or sets a value indicating the ratio between overall size and check size */
  63353. checkSizeRatio: number;
  63354. /** Gets or sets background color */
  63355. background: string;
  63356. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  63357. isChecked: boolean;
  63358. /**
  63359. * Creates a new RadioButton
  63360. * @param name defines the control name
  63361. */
  63362. constructor(name?: string | undefined);
  63363. protected _getTypeName(): string;
  63364. _draw(context: CanvasRenderingContext2D): void;
  63365. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63366. /**
  63367. * Utility function to easily create a radio button with a header
  63368. * @param title defines the label to use for the header
  63369. * @param group defines the group to use for the radio button
  63370. * @param isChecked defines the initial state of the radio button
  63371. * @param onValueChanged defines the callback to call when value changes
  63372. * @returns a StackPanel containing the radio button and a textBlock
  63373. */
  63374. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  63375. }
  63376. }
  63377. declare module BABYLON.GUI {
  63378. /**
  63379. * Class used to create slider controls
  63380. */
  63381. export class BaseSlider extends Control {
  63382. name?: string | undefined;
  63383. protected _thumbWidth: ValueAndUnit;
  63384. private _minimum;
  63385. private _maximum;
  63386. private _value;
  63387. private _isVertical;
  63388. protected _barOffset: ValueAndUnit;
  63389. private _isThumbClamped;
  63390. protected _displayThumb: boolean;
  63391. private _step;
  63392. private _lastPointerDownID;
  63393. protected _effectiveBarOffset: number;
  63394. protected _renderLeft: number;
  63395. protected _renderTop: number;
  63396. protected _renderWidth: number;
  63397. protected _renderHeight: number;
  63398. protected _backgroundBoxLength: number;
  63399. protected _backgroundBoxThickness: number;
  63400. protected _effectiveThumbThickness: number;
  63401. /** BABYLON.Observable raised when the sldier value changes */
  63402. onValueChangedObservable: BABYLON.Observable<number>;
  63403. /** Gets or sets a boolean indicating if the thumb must be rendered */
  63404. displayThumb: boolean;
  63405. /** Gets or sets a step to apply to values (0 by default) */
  63406. step: number;
  63407. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  63408. barOffset: string | number;
  63409. /** Gets main bar offset in pixels*/
  63410. readonly barOffsetInPixels: number;
  63411. /** Gets or sets thumb width */
  63412. thumbWidth: string | number;
  63413. /** Gets thumb width in pixels */
  63414. readonly thumbWidthInPixels: number;
  63415. /** Gets or sets minimum value */
  63416. minimum: number;
  63417. /** Gets or sets maximum value */
  63418. maximum: number;
  63419. /** Gets or sets current value */
  63420. value: number;
  63421. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  63422. isVertical: boolean;
  63423. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  63424. isThumbClamped: boolean;
  63425. /**
  63426. * Creates a new BaseSlider
  63427. * @param name defines the control name
  63428. */
  63429. constructor(name?: string | undefined);
  63430. protected _getTypeName(): string;
  63431. protected _getThumbPosition(): number;
  63432. protected _getThumbThickness(type: string): number;
  63433. protected _prepareRenderingData(type: string): void;
  63434. private _pointerIsDown;
  63435. /** @hidden */
  63436. protected _updateValueFromPointer(x: number, y: number): void;
  63437. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63438. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63439. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63440. }
  63441. }
  63442. declare module BABYLON.GUI {
  63443. /**
  63444. * Class used to create slider controls
  63445. */
  63446. export class Slider extends BaseSlider {
  63447. name?: string | undefined;
  63448. private _background;
  63449. private _borderColor;
  63450. private _isThumbCircle;
  63451. protected _displayValueBar: boolean;
  63452. /** Gets or sets a boolean indicating if the value bar must be rendered */
  63453. displayValueBar: boolean;
  63454. /** Gets or sets border color */
  63455. borderColor: string;
  63456. /** Gets or sets background color */
  63457. background: string;
  63458. /** Gets or sets a boolean indicating if the thumb should be round or square */
  63459. isThumbCircle: boolean;
  63460. /**
  63461. * Creates a new Slider
  63462. * @param name defines the control name
  63463. */
  63464. constructor(name?: string | undefined);
  63465. protected _getTypeName(): string;
  63466. _draw(context: CanvasRenderingContext2D): void;
  63467. }
  63468. }
  63469. declare module BABYLON.GUI {
  63470. /** Class used to create a RadioGroup
  63471. * which contains groups of radio buttons
  63472. */
  63473. export class SelectorGroup {
  63474. /** name of SelectorGroup */
  63475. name: string;
  63476. private _groupPanel;
  63477. private _selectors;
  63478. private _groupHeader;
  63479. /**
  63480. * Creates a new SelectorGroup
  63481. * @param name of group, used as a group heading
  63482. */
  63483. constructor(
  63484. /** name of SelectorGroup */
  63485. name: string);
  63486. /** Gets the groupPanel of the SelectorGroup */
  63487. readonly groupPanel: StackPanel;
  63488. /** Gets the selectors array */
  63489. readonly selectors: StackPanel[];
  63490. /** Gets and sets the group header */
  63491. header: string;
  63492. /** @hidden */
  63493. private _addGroupHeader;
  63494. /** @hidden*/
  63495. _getSelector(selectorNb: number): StackPanel | undefined;
  63496. /** Removes the selector at the given position
  63497. * @param selectorNb the position of the selector within the group
  63498. */
  63499. removeSelector(selectorNb: number): void;
  63500. }
  63501. /** Class used to create a CheckboxGroup
  63502. * which contains groups of checkbox buttons
  63503. */
  63504. export class CheckboxGroup extends SelectorGroup {
  63505. /** Adds a checkbox as a control
  63506. * @param text is the label for the selector
  63507. * @param func is the function called when the Selector is checked
  63508. * @param checked is true when Selector is checked
  63509. */
  63510. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  63511. /** @hidden */
  63512. _setSelectorLabel(selectorNb: number, label: string): void;
  63513. /** @hidden */
  63514. _setSelectorLabelColor(selectorNb: number, color: string): void;
  63515. /** @hidden */
  63516. _setSelectorButtonColor(selectorNb: number, color: string): void;
  63517. /** @hidden */
  63518. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  63519. }
  63520. /** Class used to create a RadioGroup
  63521. * which contains groups of radio buttons
  63522. */
  63523. export class RadioGroup extends SelectorGroup {
  63524. private _selectNb;
  63525. /** Adds a radio button as a control
  63526. * @param label is the label for the selector
  63527. * @param func is the function called when the Selector is checked
  63528. * @param checked is true when Selector is checked
  63529. */
  63530. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  63531. /** @hidden */
  63532. _setSelectorLabel(selectorNb: number, label: string): void;
  63533. /** @hidden */
  63534. _setSelectorLabelColor(selectorNb: number, color: string): void;
  63535. /** @hidden */
  63536. _setSelectorButtonColor(selectorNb: number, color: string): void;
  63537. /** @hidden */
  63538. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  63539. }
  63540. /** Class used to create a SliderGroup
  63541. * which contains groups of slider buttons
  63542. */
  63543. export class SliderGroup extends SelectorGroup {
  63544. /**
  63545. * Adds a slider to the SelectorGroup
  63546. * @param label is the label for the SliderBar
  63547. * @param func is the function called when the Slider moves
  63548. * @param unit is a string describing the units used, eg degrees or metres
  63549. * @param min is the minimum value for the Slider
  63550. * @param max is the maximum value for the Slider
  63551. * @param value is the start value for the Slider between min and max
  63552. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  63553. */
  63554. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  63555. /** @hidden */
  63556. _setSelectorLabel(selectorNb: number, label: string): void;
  63557. /** @hidden */
  63558. _setSelectorLabelColor(selectorNb: number, color: string): void;
  63559. /** @hidden */
  63560. _setSelectorButtonColor(selectorNb: number, color: string): void;
  63561. /** @hidden */
  63562. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  63563. }
  63564. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  63565. * @see http://doc.babylonjs.com/how_to/selector
  63566. */
  63567. export class SelectionPanel extends Rectangle {
  63568. /** name of SelectionPanel */
  63569. name: string;
  63570. /** an array of SelectionGroups */
  63571. groups: SelectorGroup[];
  63572. private _panel;
  63573. private _buttonColor;
  63574. private _buttonBackground;
  63575. private _headerColor;
  63576. private _barColor;
  63577. private _barHeight;
  63578. private _spacerHeight;
  63579. private _labelColor;
  63580. private _groups;
  63581. private _bars;
  63582. /**
  63583. * Creates a new SelectionPanel
  63584. * @param name of SelectionPanel
  63585. * @param groups is an array of SelectionGroups
  63586. */
  63587. constructor(
  63588. /** name of SelectionPanel */
  63589. name: string,
  63590. /** an array of SelectionGroups */
  63591. groups?: SelectorGroup[]);
  63592. protected _getTypeName(): string;
  63593. /** Gets or sets the headerColor */
  63594. headerColor: string;
  63595. private _setHeaderColor;
  63596. /** Gets or sets the button color */
  63597. buttonColor: string;
  63598. private _setbuttonColor;
  63599. /** Gets or sets the label color */
  63600. labelColor: string;
  63601. private _setLabelColor;
  63602. /** Gets or sets the button background */
  63603. buttonBackground: string;
  63604. private _setButtonBackground;
  63605. /** Gets or sets the color of separator bar */
  63606. barColor: string;
  63607. private _setBarColor;
  63608. /** Gets or sets the height of separator bar */
  63609. barHeight: string;
  63610. private _setBarHeight;
  63611. /** Gets or sets the height of spacers*/
  63612. spacerHeight: string;
  63613. private _setSpacerHeight;
  63614. /** Adds a bar between groups */
  63615. private _addSpacer;
  63616. /** Add a group to the selection panel
  63617. * @param group is the selector group to add
  63618. */
  63619. addGroup(group: SelectorGroup): void;
  63620. /** Remove the group from the given position
  63621. * @param groupNb is the position of the group in the list
  63622. */
  63623. removeGroup(groupNb: number): void;
  63624. /** Change a group header label
  63625. * @param label is the new group header label
  63626. * @param groupNb is the number of the group to relabel
  63627. * */
  63628. setHeaderName(label: string, groupNb: number): void;
  63629. /** Change selector label to the one given
  63630. * @param label is the new selector label
  63631. * @param groupNb is the number of the groupcontaining the selector
  63632. * @param selectorNb is the number of the selector within a group to relabel
  63633. * */
  63634. relabel(label: string, groupNb: number, selectorNb: number): void;
  63635. /** For a given group position remove the selector at the given position
  63636. * @param groupNb is the number of the group to remove the selector from
  63637. * @param selectorNb is the number of the selector within the group
  63638. */
  63639. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  63640. /** For a given group position of correct type add a checkbox button
  63641. * @param groupNb is the number of the group to remove the selector from
  63642. * @param label is the label for the selector
  63643. * @param func is the function called when the Selector is checked
  63644. * @param checked is true when Selector is checked
  63645. */
  63646. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  63647. /** For a given group position of correct type add a radio button
  63648. * @param groupNb is the number of the group to remove the selector from
  63649. * @param label is the label for the selector
  63650. * @param func is the function called when the Selector is checked
  63651. * @param checked is true when Selector is checked
  63652. */
  63653. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  63654. /**
  63655. * For a given slider group add a slider
  63656. * @param groupNb is the number of the group to add the slider to
  63657. * @param label is the label for the Slider
  63658. * @param func is the function called when the Slider moves
  63659. * @param unit is a string describing the units used, eg degrees or metres
  63660. * @param min is the minimum value for the Slider
  63661. * @param max is the maximum value for the Slider
  63662. * @param value is the start value for the Slider between min and max
  63663. * @param onVal is the function used to format the value displayed, eg radians to degrees
  63664. */
  63665. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  63666. }
  63667. }
  63668. declare module BABYLON.GUI {
  63669. /**
  63670. * Class used to hold a the container for ScrollViewer
  63671. * @hidden
  63672. */
  63673. export class _ScrollViewerWindow extends Container {
  63674. parentClientWidth: number;
  63675. parentClientHeight: number;
  63676. /**
  63677. * Creates a new ScrollViewerWindow
  63678. * @param name of ScrollViewerWindow
  63679. */
  63680. constructor(name?: string);
  63681. protected _getTypeName(): string;
  63682. /** @hidden */
  63683. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63684. protected _postMeasure(): void;
  63685. }
  63686. }
  63687. declare module BABYLON.GUI {
  63688. /**
  63689. * Class used to create slider controls
  63690. */
  63691. export class ScrollBar extends BaseSlider {
  63692. name?: string | undefined;
  63693. private _background;
  63694. private _borderColor;
  63695. private _thumbMeasure;
  63696. /** Gets or sets border color */
  63697. borderColor: string;
  63698. /** Gets or sets background color */
  63699. background: string;
  63700. /**
  63701. * Creates a new Slider
  63702. * @param name defines the control name
  63703. */
  63704. constructor(name?: string | undefined);
  63705. protected _getTypeName(): string;
  63706. protected _getThumbThickness(): number;
  63707. _draw(context: CanvasRenderingContext2D): void;
  63708. private _first;
  63709. private _originX;
  63710. private _originY;
  63711. /** @hidden */
  63712. protected _updateValueFromPointer(x: number, y: number): void;
  63713. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63714. }
  63715. }
  63716. declare module BABYLON.GUI {
  63717. /**
  63718. * Class used to hold a viewer window and sliders in a grid
  63719. */
  63720. export class ScrollViewer extends Rectangle {
  63721. private _grid;
  63722. private _horizontalBarSpace;
  63723. private _verticalBarSpace;
  63724. private _dragSpace;
  63725. private _horizontalBar;
  63726. private _verticalBar;
  63727. private _barColor;
  63728. private _barBackground;
  63729. private _barSize;
  63730. private _endLeft;
  63731. private _endTop;
  63732. private _window;
  63733. private _pointerIsOver;
  63734. private _wheelPrecision;
  63735. private _onPointerObserver;
  63736. private _clientWidth;
  63737. private _clientHeight;
  63738. /**
  63739. * Gets the horizontal scrollbar
  63740. */
  63741. readonly horizontalBar: ScrollBar;
  63742. /**
  63743. * Gets the vertical scrollbar
  63744. */
  63745. readonly verticalBar: ScrollBar;
  63746. /**
  63747. * Adds a new control to the current container
  63748. * @param control defines the control to add
  63749. * @returns the current container
  63750. */
  63751. addControl(control: BABYLON.Nullable<Control>): Container;
  63752. /**
  63753. * Removes a control from the current container
  63754. * @param control defines the control to remove
  63755. * @returns the current container
  63756. */
  63757. removeControl(control: Control): Container;
  63758. /** Gets the list of children */
  63759. readonly children: Control[];
  63760. _flagDescendantsAsMatrixDirty(): void;
  63761. /**
  63762. * Creates a new ScrollViewer
  63763. * @param name of ScrollViewer
  63764. */
  63765. constructor(name?: string);
  63766. /** Reset the scroll viewer window to initial size */
  63767. resetWindow(): void;
  63768. protected _getTypeName(): string;
  63769. private _buildClientSizes;
  63770. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63771. protected _postMeasure(): void;
  63772. /**
  63773. * Gets or sets the mouse wheel precision
  63774. * from 0 to 1 with a default value of 0.05
  63775. * */
  63776. wheelPrecision: number;
  63777. /** Gets or sets the bar color */
  63778. barColor: string;
  63779. /** Gets or sets the size of the bar */
  63780. barSize: number;
  63781. /** Gets or sets the bar background */
  63782. barBackground: string;
  63783. /** @hidden */
  63784. private _updateScroller;
  63785. _link(host: AdvancedDynamicTexture): void;
  63786. /** @hidden */
  63787. private _attachWheel;
  63788. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63789. /** Releases associated resources */
  63790. dispose(): void;
  63791. }
  63792. }
  63793. declare module BABYLON.GUI {
  63794. /** Class used to render a grid */
  63795. export class DisplayGrid extends Control {
  63796. name?: string | undefined;
  63797. private _cellWidth;
  63798. private _cellHeight;
  63799. private _minorLineTickness;
  63800. private _minorLineColor;
  63801. private _majorLineTickness;
  63802. private _majorLineColor;
  63803. private _majorLineFrequency;
  63804. private _background;
  63805. private _displayMajorLines;
  63806. private _displayMinorLines;
  63807. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  63808. displayMinorLines: boolean;
  63809. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  63810. displayMajorLines: boolean;
  63811. /** Gets or sets background color (Black by default) */
  63812. background: string;
  63813. /** Gets or sets the width of each cell (20 by default) */
  63814. cellWidth: number;
  63815. /** Gets or sets the height of each cell (20 by default) */
  63816. cellHeight: number;
  63817. /** Gets or sets the tickness of minor lines (1 by default) */
  63818. minorLineTickness: number;
  63819. /** Gets or sets the color of minor lines (DarkGray by default) */
  63820. minorLineColor: string;
  63821. /** Gets or sets the tickness of major lines (2 by default) */
  63822. majorLineTickness: number;
  63823. /** Gets or sets the color of major lines (White by default) */
  63824. majorLineColor: string;
  63825. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  63826. majorLineFrequency: number;
  63827. /**
  63828. * Creates a new GridDisplayRectangle
  63829. * @param name defines the control name
  63830. */
  63831. constructor(name?: string | undefined);
  63832. _draw(context: CanvasRenderingContext2D): void;
  63833. protected _getTypeName(): string;
  63834. }
  63835. }
  63836. declare module BABYLON.GUI {
  63837. /**
  63838. * Class used to create slider controls based on images
  63839. */
  63840. export class ImageBasedSlider extends BaseSlider {
  63841. name?: string | undefined;
  63842. private _backgroundImage;
  63843. private _thumbImage;
  63844. private _valueBarImage;
  63845. private _tempMeasure;
  63846. displayThumb: boolean;
  63847. /**
  63848. * Gets or sets the image used to render the background
  63849. */
  63850. backgroundImage: Image;
  63851. /**
  63852. * Gets or sets the image used to render the value bar
  63853. */
  63854. valueBarImage: Image;
  63855. /**
  63856. * Gets or sets the image used to render the thumb
  63857. */
  63858. thumbImage: Image;
  63859. /**
  63860. * Creates a new ImageBasedSlider
  63861. * @param name defines the control name
  63862. */
  63863. constructor(name?: string | undefined);
  63864. protected _getTypeName(): string;
  63865. _draw(context: CanvasRenderingContext2D): void;
  63866. }
  63867. }
  63868. declare module BABYLON.GUI {
  63869. /**
  63870. * Forcing an export so that this code will execute
  63871. * @hidden
  63872. */
  63873. const name = "Statics";
  63874. }
  63875. declare module BABYLON.GUI {
  63876. /**
  63877. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  63878. */
  63879. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  63880. /**
  63881. * Define the instrumented AdvancedDynamicTexture.
  63882. */
  63883. texture: AdvancedDynamicTexture;
  63884. private _captureRenderTime;
  63885. private _renderTime;
  63886. private _captureLayoutTime;
  63887. private _layoutTime;
  63888. private _onBeginRenderObserver;
  63889. private _onEndRenderObserver;
  63890. private _onBeginLayoutObserver;
  63891. private _onEndLayoutObserver;
  63892. /**
  63893. * Gets the perf counter used to capture render time
  63894. */
  63895. readonly renderTimeCounter: BABYLON.PerfCounter;
  63896. /**
  63897. * Gets the perf counter used to capture layout time
  63898. */
  63899. readonly layoutTimeCounter: BABYLON.PerfCounter;
  63900. /**
  63901. * Enable or disable the render time capture
  63902. */
  63903. captureRenderTime: boolean;
  63904. /**
  63905. * Enable or disable the layout time capture
  63906. */
  63907. captureLayoutTime: boolean;
  63908. /**
  63909. * Instantiates a new advanced dynamic texture instrumentation.
  63910. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  63911. * @param texture Defines the AdvancedDynamicTexture to instrument
  63912. */
  63913. constructor(
  63914. /**
  63915. * Define the instrumented AdvancedDynamicTexture.
  63916. */
  63917. texture: AdvancedDynamicTexture);
  63918. /**
  63919. * Dispose and release associated resources.
  63920. */
  63921. dispose(): void;
  63922. }
  63923. }
  63924. declare module BABYLON.GUI {
  63925. /**
  63926. * Class used to create containers for controls
  63927. */
  63928. export class Container3D extends Control3D {
  63929. private _blockLayout;
  63930. /**
  63931. * Gets the list of child controls
  63932. */
  63933. protected _children: Control3D[];
  63934. /**
  63935. * Gets the list of child controls
  63936. */
  63937. readonly children: Array<Control3D>;
  63938. /**
  63939. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  63940. * This is helpful to optimize layout operation when adding multiple children in a row
  63941. */
  63942. blockLayout: boolean;
  63943. /**
  63944. * Creates a new container
  63945. * @param name defines the container name
  63946. */
  63947. constructor(name?: string);
  63948. /**
  63949. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  63950. * @returns the current container
  63951. */
  63952. updateLayout(): Container3D;
  63953. /**
  63954. * Gets a boolean indicating if the given control is in the children of this control
  63955. * @param control defines the control to check
  63956. * @returns true if the control is in the child list
  63957. */
  63958. containsControl(control: Control3D): boolean;
  63959. /**
  63960. * Adds a control to the children of this control
  63961. * @param control defines the control to add
  63962. * @returns the current container
  63963. */
  63964. addControl(control: Control3D): Container3D;
  63965. /**
  63966. * This function will be called everytime a new control is added
  63967. */
  63968. protected _arrangeChildren(): void;
  63969. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  63970. /**
  63971. * Removes a control from the children of this control
  63972. * @param control defines the control to remove
  63973. * @returns the current container
  63974. */
  63975. removeControl(control: Control3D): Container3D;
  63976. protected _getTypeName(): string;
  63977. /**
  63978. * Releases all associated resources
  63979. */
  63980. dispose(): void;
  63981. /** Control rotation will remain unchanged */
  63982. static readonly UNSET_ORIENTATION: number;
  63983. /** Control will rotate to make it look at sphere central axis */
  63984. static readonly FACEORIGIN_ORIENTATION: number;
  63985. /** Control will rotate to make it look back at sphere central axis */
  63986. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  63987. /** Control will rotate to look at z axis (0, 0, 1) */
  63988. static readonly FACEFORWARD_ORIENTATION: number;
  63989. /** Control will rotate to look at negative z axis (0, 0, -1) */
  63990. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  63991. }
  63992. }
  63993. declare module BABYLON.GUI {
  63994. /**
  63995. * Class used to manage 3D user interface
  63996. * @see http://doc.babylonjs.com/how_to/gui3d
  63997. */
  63998. export class GUI3DManager implements BABYLON.IDisposable {
  63999. private _scene;
  64000. private _sceneDisposeObserver;
  64001. private _utilityLayer;
  64002. private _rootContainer;
  64003. private _pointerObserver;
  64004. private _pointerOutObserver;
  64005. /** @hidden */
  64006. _lastPickedControl: Control3D;
  64007. /** @hidden */
  64008. _lastControlOver: {
  64009. [pointerId: number]: Control3D;
  64010. };
  64011. /** @hidden */
  64012. _lastControlDown: {
  64013. [pointerId: number]: Control3D;
  64014. };
  64015. /**
  64016. * BABYLON.Observable raised when the point picked by the pointer events changed
  64017. */
  64018. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  64019. /** @hidden */
  64020. _sharedMaterials: {
  64021. [key: string]: BABYLON.Material;
  64022. };
  64023. /** Gets the hosting scene */
  64024. readonly scene: BABYLON.Scene;
  64025. /** Gets associated utility layer */
  64026. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  64027. /**
  64028. * Creates a new GUI3DManager
  64029. * @param scene
  64030. */
  64031. constructor(scene?: BABYLON.Scene);
  64032. private _handlePointerOut;
  64033. private _doPicking;
  64034. /**
  64035. * Gets the root container
  64036. */
  64037. readonly rootContainer: Container3D;
  64038. /**
  64039. * Gets a boolean indicating if the given control is in the root child list
  64040. * @param control defines the control to check
  64041. * @returns true if the control is in the root child list
  64042. */
  64043. containsControl(control: Control3D): boolean;
  64044. /**
  64045. * Adds a control to the root child list
  64046. * @param control defines the control to add
  64047. * @returns the current manager
  64048. */
  64049. addControl(control: Control3D): GUI3DManager;
  64050. /**
  64051. * Removes a control from the root child list
  64052. * @param control defines the control to remove
  64053. * @returns the current container
  64054. */
  64055. removeControl(control: Control3D): GUI3DManager;
  64056. /**
  64057. * Releases all associated resources
  64058. */
  64059. dispose(): void;
  64060. }
  64061. }
  64062. declare module BABYLON.GUI {
  64063. /**
  64064. * Class used to transport BABYLON.Vector3 information for pointer events
  64065. */
  64066. export class Vector3WithInfo extends BABYLON.Vector3 {
  64067. /** defines the current mouse button index */
  64068. buttonIndex: number;
  64069. /**
  64070. * Creates a new Vector3WithInfo
  64071. * @param source defines the vector3 data to transport
  64072. * @param buttonIndex defines the current mouse button index
  64073. */
  64074. constructor(source: BABYLON.Vector3,
  64075. /** defines the current mouse button index */
  64076. buttonIndex?: number);
  64077. }
  64078. }
  64079. declare module BABYLON.GUI {
  64080. /**
  64081. * Class used as base class for controls
  64082. */
  64083. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  64084. /** Defines the control name */
  64085. name?: string | undefined;
  64086. /** @hidden */
  64087. _host: GUI3DManager;
  64088. private _node;
  64089. private _downCount;
  64090. private _enterCount;
  64091. private _downPointerIds;
  64092. private _isVisible;
  64093. /** Gets or sets the control position in world space */
  64094. position: BABYLON.Vector3;
  64095. /** Gets or sets the control scaling in world space */
  64096. scaling: BABYLON.Vector3;
  64097. /** Callback used to start pointer enter animation */
  64098. pointerEnterAnimation: () => void;
  64099. /** Callback used to start pointer out animation */
  64100. pointerOutAnimation: () => void;
  64101. /** Callback used to start pointer down animation */
  64102. pointerDownAnimation: () => void;
  64103. /** Callback used to start pointer up animation */
  64104. pointerUpAnimation: () => void;
  64105. /**
  64106. * An event triggered when the pointer move over the control
  64107. */
  64108. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  64109. /**
  64110. * An event triggered when the pointer move out of the control
  64111. */
  64112. onPointerOutObservable: BABYLON.Observable<Control3D>;
  64113. /**
  64114. * An event triggered when the pointer taps the control
  64115. */
  64116. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  64117. /**
  64118. * An event triggered when pointer is up
  64119. */
  64120. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  64121. /**
  64122. * An event triggered when a control is clicked on (with a mouse)
  64123. */
  64124. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  64125. /**
  64126. * An event triggered when pointer enters the control
  64127. */
  64128. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  64129. /**
  64130. * Gets or sets the parent container
  64131. */
  64132. parent: BABYLON.Nullable<Container3D>;
  64133. private _behaviors;
  64134. /**
  64135. * Gets the list of attached behaviors
  64136. * @see http://doc.babylonjs.com/features/behaviour
  64137. */
  64138. readonly behaviors: BABYLON.Behavior<Control3D>[];
  64139. /**
  64140. * Attach a behavior to the control
  64141. * @see http://doc.babylonjs.com/features/behaviour
  64142. * @param behavior defines the behavior to attach
  64143. * @returns the current control
  64144. */
  64145. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  64146. /**
  64147. * Remove an attached behavior
  64148. * @see http://doc.babylonjs.com/features/behaviour
  64149. * @param behavior defines the behavior to attach
  64150. * @returns the current control
  64151. */
  64152. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  64153. /**
  64154. * Gets an attached behavior by name
  64155. * @param name defines the name of the behavior to look for
  64156. * @see http://doc.babylonjs.com/features/behaviour
  64157. * @returns null if behavior was not found else the requested behavior
  64158. */
  64159. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  64160. /** Gets or sets a boolean indicating if the control is visible */
  64161. isVisible: boolean;
  64162. /**
  64163. * Creates a new control
  64164. * @param name defines the control name
  64165. */
  64166. constructor(
  64167. /** Defines the control name */
  64168. name?: string | undefined);
  64169. /**
  64170. * Gets a string representing the class name
  64171. */
  64172. readonly typeName: string;
  64173. /**
  64174. * Get the current class name of the control.
  64175. * @returns current class name
  64176. */
  64177. getClassName(): string;
  64178. protected _getTypeName(): string;
  64179. /**
  64180. * Gets the transform node used by this control
  64181. */
  64182. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  64183. /**
  64184. * Gets the mesh used to render this control
  64185. */
  64186. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64187. /**
  64188. * Link the control as child of the given node
  64189. * @param node defines the node to link to. Use null to unlink the control
  64190. * @returns the current control
  64191. */
  64192. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  64193. /** @hidden **/
  64194. _prepareNode(scene: BABYLON.Scene): void;
  64195. /**
  64196. * Node creation.
  64197. * Can be overriden by children
  64198. * @param scene defines the scene where the node must be attached
  64199. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  64200. */
  64201. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  64202. /**
  64203. * Affect a material to the given mesh
  64204. * @param mesh defines the mesh which will represent the control
  64205. */
  64206. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  64207. /** @hidden */
  64208. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  64209. /** @hidden */
  64210. _onPointerEnter(target: Control3D): boolean;
  64211. /** @hidden */
  64212. _onPointerOut(target: Control3D): void;
  64213. /** @hidden */
  64214. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  64215. /** @hidden */
  64216. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64217. /** @hidden */
  64218. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  64219. /** @hidden */
  64220. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  64221. /** @hidden */
  64222. _disposeNode(): void;
  64223. /**
  64224. * Releases all associated resources
  64225. */
  64226. dispose(): void;
  64227. }
  64228. }
  64229. declare module BABYLON.GUI {
  64230. /**
  64231. * Class used as a root to all buttons
  64232. */
  64233. export class AbstractButton3D extends Control3D {
  64234. /**
  64235. * Creates a new button
  64236. * @param name defines the control name
  64237. */
  64238. constructor(name?: string);
  64239. protected _getTypeName(): string;
  64240. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64241. }
  64242. }
  64243. declare module BABYLON.GUI {
  64244. /**
  64245. * Class used to create a button in 3D
  64246. */
  64247. export class Button3D extends AbstractButton3D {
  64248. /** @hidden */
  64249. protected _currentMaterial: BABYLON.Material;
  64250. private _facadeTexture;
  64251. private _content;
  64252. private _contentResolution;
  64253. private _contentScaleRatio;
  64254. /**
  64255. * Gets or sets the texture resolution used to render content (512 by default)
  64256. */
  64257. contentResolution: BABYLON.int;
  64258. /**
  64259. * Gets or sets the texture scale ratio used to render content (2 by default)
  64260. */
  64261. contentScaleRatio: number;
  64262. protected _disposeFacadeTexture(): void;
  64263. protected _resetContent(): void;
  64264. /**
  64265. * Creates a new button
  64266. * @param name defines the control name
  64267. */
  64268. constructor(name?: string);
  64269. /**
  64270. * Gets or sets the GUI 2D content used to display the button's facade
  64271. */
  64272. content: Control;
  64273. /**
  64274. * Apply the facade texture (created from the content property).
  64275. * This function can be overloaded by child classes
  64276. * @param facadeTexture defines the AdvancedDynamicTexture to use
  64277. */
  64278. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  64279. protected _getTypeName(): string;
  64280. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64281. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  64282. /**
  64283. * Releases all associated resources
  64284. */
  64285. dispose(): void;
  64286. }
  64287. }
  64288. declare module BABYLON.GUI {
  64289. /**
  64290. * Abstract class used to create a container panel deployed on the surface of a volume
  64291. */
  64292. export abstract class VolumeBasedPanel extends Container3D {
  64293. private _columns;
  64294. private _rows;
  64295. private _rowThenColum;
  64296. private _orientation;
  64297. protected _cellWidth: number;
  64298. protected _cellHeight: number;
  64299. /**
  64300. * Gets or sets the distance between elements
  64301. */
  64302. margin: number;
  64303. /**
  64304. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  64305. * | Value | Type | Description |
  64306. * | ----- | ----------------------------------- | ----------- |
  64307. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  64308. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  64309. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  64310. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  64311. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  64312. */
  64313. orientation: number;
  64314. /**
  64315. * Gets or sets the number of columns requested (10 by default).
  64316. * The panel will automatically compute the number of rows based on number of child controls.
  64317. */
  64318. columns: BABYLON.int;
  64319. /**
  64320. * Gets or sets a the number of rows requested.
  64321. * The panel will automatically compute the number of columns based on number of child controls.
  64322. */
  64323. rows: BABYLON.int;
  64324. /**
  64325. * Creates new VolumeBasedPanel
  64326. */
  64327. constructor();
  64328. protected _arrangeChildren(): void;
  64329. /** Child classes must implement this function to provide correct control positioning */
  64330. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64331. /** Child classes can implement this function to provide additional processing */
  64332. protected _finalProcessing(): void;
  64333. }
  64334. }
  64335. declare module BABYLON.GUI {
  64336. /**
  64337. * Class used to create a container panel deployed on the surface of a cylinder
  64338. */
  64339. export class CylinderPanel extends VolumeBasedPanel {
  64340. private _radius;
  64341. /**
  64342. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  64343. */
  64344. radius: BABYLON.float;
  64345. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64346. private _cylindricalMapping;
  64347. }
  64348. }
  64349. declare module BABYLON.GUI {
  64350. /** @hidden */
  64351. export var fluentVertexShader: {
  64352. name: string;
  64353. shader: string;
  64354. };
  64355. }
  64356. declare module BABYLON.GUI {
  64357. /** @hidden */
  64358. export var fluentPixelShader: {
  64359. name: string;
  64360. shader: string;
  64361. };
  64362. }
  64363. declare module BABYLON.GUI {
  64364. /** @hidden */
  64365. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  64366. INNERGLOW: boolean;
  64367. BORDER: boolean;
  64368. HOVERLIGHT: boolean;
  64369. TEXTURE: boolean;
  64370. constructor();
  64371. }
  64372. /**
  64373. * Class used to render controls with fluent desgin
  64374. */
  64375. export class FluentMaterial extends BABYLON.PushMaterial {
  64376. /**
  64377. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  64378. */
  64379. innerGlowColorIntensity: number;
  64380. /**
  64381. * Gets or sets the inner glow color (white by default)
  64382. */
  64383. innerGlowColor: BABYLON.Color3;
  64384. /**
  64385. * Gets or sets alpha value (default is 1.0)
  64386. */
  64387. alpha: number;
  64388. /**
  64389. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  64390. */
  64391. albedoColor: BABYLON.Color3;
  64392. /**
  64393. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  64394. */
  64395. renderBorders: boolean;
  64396. /**
  64397. * Gets or sets border width (default is 0.5)
  64398. */
  64399. borderWidth: number;
  64400. /**
  64401. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  64402. */
  64403. edgeSmoothingValue: number;
  64404. /**
  64405. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  64406. */
  64407. borderMinValue: number;
  64408. /**
  64409. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  64410. */
  64411. renderHoverLight: boolean;
  64412. /**
  64413. * Gets or sets the radius used to render the hover light (default is 1.0)
  64414. */
  64415. hoverRadius: number;
  64416. /**
  64417. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  64418. */
  64419. hoverColor: BABYLON.Color4;
  64420. /**
  64421. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  64422. */
  64423. hoverPosition: BABYLON.Vector3;
  64424. private _albedoTexture;
  64425. /** Gets or sets the texture to use for albedo color */
  64426. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  64427. /**
  64428. * Creates a new Fluent material
  64429. * @param name defines the name of the material
  64430. * @param scene defines the hosting scene
  64431. */
  64432. constructor(name: string, scene: BABYLON.Scene);
  64433. needAlphaBlending(): boolean;
  64434. needAlphaTesting(): boolean;
  64435. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64436. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64437. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64438. getActiveTextures(): BABYLON.BaseTexture[];
  64439. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64440. dispose(forceDisposeEffect?: boolean): void;
  64441. clone(name: string): FluentMaterial;
  64442. serialize(): any;
  64443. getClassName(): string;
  64444. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  64445. }
  64446. }
  64447. declare module BABYLON.GUI {
  64448. /**
  64449. * Class used to create a holographic button in 3D
  64450. */
  64451. export class HolographicButton extends Button3D {
  64452. private _backPlate;
  64453. private _textPlate;
  64454. private _frontPlate;
  64455. private _text;
  64456. private _imageUrl;
  64457. private _shareMaterials;
  64458. private _frontMaterial;
  64459. private _backMaterial;
  64460. private _plateMaterial;
  64461. private _pickedPointObserver;
  64462. private _tooltipFade;
  64463. private _tooltipTextBlock;
  64464. private _tooltipTexture;
  64465. private _tooltipMesh;
  64466. private _tooltipHoverObserver;
  64467. private _tooltipOutObserver;
  64468. private _disposeTooltip;
  64469. /**
  64470. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  64471. */
  64472. tooltipText: BABYLON.Nullable<string>;
  64473. /**
  64474. * Gets or sets text for the button
  64475. */
  64476. text: string;
  64477. /**
  64478. * Gets or sets the image url for the button
  64479. */
  64480. imageUrl: string;
  64481. /**
  64482. * Gets the back material used by this button
  64483. */
  64484. readonly backMaterial: FluentMaterial;
  64485. /**
  64486. * Gets the front material used by this button
  64487. */
  64488. readonly frontMaterial: FluentMaterial;
  64489. /**
  64490. * Gets the plate material used by this button
  64491. */
  64492. readonly plateMaterial: BABYLON.StandardMaterial;
  64493. /**
  64494. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  64495. */
  64496. readonly shareMaterials: boolean;
  64497. /**
  64498. * Creates a new button
  64499. * @param name defines the control name
  64500. */
  64501. constructor(name?: string, shareMaterials?: boolean);
  64502. protected _getTypeName(): string;
  64503. private _rebuildContent;
  64504. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64505. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  64506. private _createBackMaterial;
  64507. private _createFrontMaterial;
  64508. private _createPlateMaterial;
  64509. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  64510. /**
  64511. * Releases all associated resources
  64512. */
  64513. dispose(): void;
  64514. }
  64515. }
  64516. declare module BABYLON.GUI {
  64517. /**
  64518. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  64519. */
  64520. export class MeshButton3D extends Button3D {
  64521. /** @hidden */
  64522. protected _currentMesh: BABYLON.Mesh;
  64523. /**
  64524. * Creates a new 3D button based on a mesh
  64525. * @param mesh mesh to become a 3D button
  64526. * @param name defines the control name
  64527. */
  64528. constructor(mesh: BABYLON.Mesh, name?: string);
  64529. protected _getTypeName(): string;
  64530. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64531. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  64532. }
  64533. }
  64534. declare module BABYLON.GUI {
  64535. /**
  64536. * Class used to create a container panel deployed on the surface of a plane
  64537. */
  64538. export class PlanePanel extends VolumeBasedPanel {
  64539. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64540. }
  64541. }
  64542. declare module BABYLON.GUI {
  64543. /**
  64544. * Class used to create a container panel where items get randomized planar mapping
  64545. */
  64546. export class ScatterPanel extends VolumeBasedPanel {
  64547. private _iteration;
  64548. /**
  64549. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  64550. */
  64551. iteration: BABYLON.float;
  64552. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64553. private _scatterMapping;
  64554. protected _finalProcessing(): void;
  64555. }
  64556. }
  64557. declare module BABYLON.GUI {
  64558. /**
  64559. * Class used to create a container panel deployed on the surface of a sphere
  64560. */
  64561. export class SpherePanel extends VolumeBasedPanel {
  64562. private _radius;
  64563. /**
  64564. * Gets or sets the radius of the sphere where to project controls (5 by default)
  64565. */
  64566. radius: BABYLON.float;
  64567. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64568. private _sphericalMapping;
  64569. }
  64570. }
  64571. declare module BABYLON.GUI {
  64572. /**
  64573. * Class used to create a stack panel in 3D on XY plane
  64574. */
  64575. export class StackPanel3D extends Container3D {
  64576. private _isVertical;
  64577. /**
  64578. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  64579. */
  64580. isVertical: boolean;
  64581. /**
  64582. * Gets or sets the distance between elements
  64583. */
  64584. margin: number;
  64585. /**
  64586. * Creates new StackPanel
  64587. * @param isVertical
  64588. */
  64589. constructor(isVertical?: boolean);
  64590. protected _arrangeChildren(): void;
  64591. }
  64592. }
  64593. declare module BABYLON {
  64594. /**
  64595. * Mode that determines the coordinate system to use.
  64596. */
  64597. export enum GLTFLoaderCoordinateSystemMode {
  64598. /**
  64599. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  64600. */
  64601. AUTO = 0,
  64602. /**
  64603. * Sets the useRightHandedSystem flag on the scene.
  64604. */
  64605. FORCE_RIGHT_HANDED = 1
  64606. }
  64607. /**
  64608. * Mode that determines what animations will start.
  64609. */
  64610. export enum GLTFLoaderAnimationStartMode {
  64611. /**
  64612. * No animation will start.
  64613. */
  64614. NONE = 0,
  64615. /**
  64616. * The first animation will start.
  64617. */
  64618. FIRST = 1,
  64619. /**
  64620. * All animations will start.
  64621. */
  64622. ALL = 2
  64623. }
  64624. /**
  64625. * Interface that contains the data for the glTF asset.
  64626. */
  64627. export interface IGLTFLoaderData {
  64628. /**
  64629. * Object that represents the glTF JSON.
  64630. */
  64631. json: Object;
  64632. /**
  64633. * The BIN chunk of a binary glTF.
  64634. */
  64635. bin: Nullable<ArrayBufferView>;
  64636. }
  64637. /**
  64638. * Interface for extending the loader.
  64639. */
  64640. export interface IGLTFLoaderExtension {
  64641. /**
  64642. * The name of this extension.
  64643. */
  64644. readonly name: string;
  64645. /**
  64646. * Defines whether this extension is enabled.
  64647. */
  64648. enabled: boolean;
  64649. }
  64650. /**
  64651. * Loader state.
  64652. */
  64653. export enum GLTFLoaderState {
  64654. /**
  64655. * The asset is loading.
  64656. */
  64657. LOADING = 0,
  64658. /**
  64659. * The asset is ready for rendering.
  64660. */
  64661. READY = 1,
  64662. /**
  64663. * The asset is completely loaded.
  64664. */
  64665. COMPLETE = 2
  64666. }
  64667. /** @hidden */
  64668. export interface IGLTFLoader extends IDisposable {
  64669. readonly state: Nullable<GLTFLoaderState>;
  64670. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  64671. meshes: AbstractMesh[];
  64672. particleSystems: IParticleSystem[];
  64673. skeletons: Skeleton[];
  64674. animationGroups: AnimationGroup[];
  64675. }>;
  64676. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  64677. }
  64678. /**
  64679. * File loader for loading glTF files into a scene.
  64680. */
  64681. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  64682. /** @hidden */
  64683. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  64684. /** @hidden */
  64685. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  64686. /**
  64687. * Raised when the asset has been parsed
  64688. */
  64689. onParsedObservable: Observable<IGLTFLoaderData>;
  64690. private _onParsedObserver;
  64691. /**
  64692. * Raised when the asset has been parsed
  64693. */
  64694. onParsed: (loaderData: IGLTFLoaderData) => void;
  64695. /**
  64696. * 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.
  64697. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  64698. * Defaults to true.
  64699. * @hidden
  64700. */
  64701. static IncrementalLoading: boolean;
  64702. /**
  64703. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  64704. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  64705. * @hidden
  64706. */
  64707. static HomogeneousCoordinates: boolean;
  64708. /**
  64709. * The coordinate system mode. Defaults to AUTO.
  64710. */
  64711. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  64712. /**
  64713. * The animation start mode. Defaults to FIRST.
  64714. */
  64715. animationStartMode: GLTFLoaderAnimationStartMode;
  64716. /**
  64717. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  64718. */
  64719. compileMaterials: boolean;
  64720. /**
  64721. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  64722. */
  64723. useClipPlane: boolean;
  64724. /**
  64725. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  64726. */
  64727. compileShadowGenerators: boolean;
  64728. /**
  64729. * Defines if the Alpha blended materials are only applied as coverage.
  64730. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  64731. * If true, no extra effects are applied to transparent pixels.
  64732. */
  64733. transparencyAsCoverage: boolean;
  64734. /**
  64735. * Function called before loading a url referenced by the asset.
  64736. */
  64737. preprocessUrlAsync: (url: string) => Promise<string>;
  64738. /**
  64739. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  64740. */
  64741. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  64742. private _onMeshLoadedObserver;
  64743. /**
  64744. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  64745. */
  64746. onMeshLoaded: (mesh: AbstractMesh) => void;
  64747. /**
  64748. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  64749. */
  64750. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  64751. private _onTextureLoadedObserver;
  64752. /**
  64753. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  64754. */
  64755. onTextureLoaded: (texture: BaseTexture) => void;
  64756. /**
  64757. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  64758. */
  64759. readonly onMaterialLoadedObservable: Observable<Material>;
  64760. private _onMaterialLoadedObserver;
  64761. /**
  64762. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  64763. */
  64764. onMaterialLoaded: (material: Material) => void;
  64765. /**
  64766. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  64767. */
  64768. readonly onCameraLoadedObservable: Observable<Camera>;
  64769. private _onCameraLoadedObserver;
  64770. /**
  64771. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  64772. */
  64773. onCameraLoaded: (camera: Camera) => void;
  64774. /**
  64775. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  64776. * For assets with LODs, raised when all of the LODs are complete.
  64777. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  64778. */
  64779. readonly onCompleteObservable: Observable<void>;
  64780. private _onCompleteObserver;
  64781. /**
  64782. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  64783. * For assets with LODs, raised when all of the LODs are complete.
  64784. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  64785. */
  64786. onComplete: () => void;
  64787. /**
  64788. * Observable raised when an error occurs.
  64789. */
  64790. readonly onErrorObservable: Observable<any>;
  64791. private _onErrorObserver;
  64792. /**
  64793. * Callback raised when an error occurs.
  64794. */
  64795. onError: (reason: any) => void;
  64796. /**
  64797. * Observable raised after the loader is disposed.
  64798. */
  64799. readonly onDisposeObservable: Observable<void>;
  64800. private _onDisposeObserver;
  64801. /**
  64802. * Callback raised after the loader is disposed.
  64803. */
  64804. onDispose: () => void;
  64805. /**
  64806. * Observable raised after a loader extension is created.
  64807. * Set additional options for a loader extension in this event.
  64808. */
  64809. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  64810. private _onExtensionLoadedObserver;
  64811. /**
  64812. * Callback raised after a loader extension is created.
  64813. */
  64814. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  64815. /**
  64816. * Defines if the loader logging is enabled.
  64817. */
  64818. loggingEnabled: boolean;
  64819. /**
  64820. * Defines if the loader should capture performance counters.
  64821. */
  64822. capturePerformanceCounters: boolean;
  64823. /**
  64824. * Defines if the loader should validate the asset.
  64825. */
  64826. validate: boolean;
  64827. /**
  64828. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  64829. */
  64830. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  64831. private _onValidatedObserver;
  64832. /**
  64833. * Callback raised after a loader extension is created.
  64834. */
  64835. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  64836. private _loader;
  64837. /**
  64838. * Name of the loader ("gltf")
  64839. */
  64840. name: string;
  64841. /**
  64842. * Supported file extensions of the loader (.gltf, .glb)
  64843. */
  64844. extensions: ISceneLoaderPluginExtensions;
  64845. /**
  64846. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  64847. */
  64848. dispose(): void;
  64849. /** @hidden */
  64850. _clear(): void;
  64851. /**
  64852. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  64853. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  64854. * @param scene the scene the meshes should be added to
  64855. * @param data the glTF data to load
  64856. * @param rootUrl root url to load from
  64857. * @param onProgress event that fires when loading progress has occured
  64858. * @param fileName Defines the name of the file to load
  64859. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  64860. */
  64861. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  64862. meshes: AbstractMesh[];
  64863. particleSystems: IParticleSystem[];
  64864. skeletons: Skeleton[];
  64865. animationGroups: AnimationGroup[];
  64866. }>;
  64867. /**
  64868. * Imports all objects from the loaded glTF data and adds them to the scene
  64869. * @param scene the scene the objects should be added to
  64870. * @param data the glTF data to load
  64871. * @param rootUrl root url to load from
  64872. * @param onProgress event that fires when loading progress has occured
  64873. * @param fileName Defines the name of the file to load
  64874. * @returns a promise which completes when objects have been loaded to the scene
  64875. */
  64876. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  64877. /**
  64878. * Load into an asset container.
  64879. * @param scene The scene to load into
  64880. * @param data The data to import
  64881. * @param rootUrl The root url for scene and resources
  64882. * @param onProgress The callback when the load progresses
  64883. * @param fileName Defines the name of the file to load
  64884. * @returns The loaded asset container
  64885. */
  64886. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  64887. /**
  64888. * If the data string can be loaded directly.
  64889. * @param data string contianing the file data
  64890. * @returns if the data can be loaded directly
  64891. */
  64892. canDirectLoad(data: string): boolean;
  64893. /**
  64894. * Rewrites a url by combining a root url and response url.
  64895. */
  64896. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  64897. /**
  64898. * Instantiates a glTF file loader plugin.
  64899. * @returns the created plugin
  64900. */
  64901. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  64902. /**
  64903. * The loader state or null if the loader is not active.
  64904. */
  64905. readonly loaderState: Nullable<GLTFLoaderState>;
  64906. /**
  64907. * Returns a promise that resolves when the asset is completely loaded.
  64908. * @returns a promise that resolves when the asset is completely loaded.
  64909. */
  64910. whenCompleteAsync(): Promise<void>;
  64911. private _parseAsync;
  64912. private _validateAsync;
  64913. private _getLoader;
  64914. private _unpackBinary;
  64915. private _unpackBinaryV1;
  64916. private _unpackBinaryV2;
  64917. private static _parseVersion;
  64918. private static _compareVersion;
  64919. private static _decodeBufferToText;
  64920. private static readonly _logSpaces;
  64921. private _logIndentLevel;
  64922. private _loggingEnabled;
  64923. /** @hidden */
  64924. _log: (message: string) => void;
  64925. /** @hidden */
  64926. _logOpen(message: string): void;
  64927. /** @hidden */
  64928. _logClose(): void;
  64929. private _logEnabled;
  64930. private _logDisabled;
  64931. private _capturePerformanceCounters;
  64932. /** @hidden */
  64933. _startPerformanceCounter: (counterName: string) => void;
  64934. /** @hidden */
  64935. _endPerformanceCounter: (counterName: string) => void;
  64936. private _startPerformanceCounterEnabled;
  64937. private _startPerformanceCounterDisabled;
  64938. private _endPerformanceCounterEnabled;
  64939. private _endPerformanceCounterDisabled;
  64940. }
  64941. }
  64942. declare module BABYLON.GLTF1 {
  64943. /**
  64944. * Enums
  64945. * @hidden
  64946. */
  64947. export enum EComponentType {
  64948. BYTE = 5120,
  64949. UNSIGNED_BYTE = 5121,
  64950. SHORT = 5122,
  64951. UNSIGNED_SHORT = 5123,
  64952. FLOAT = 5126
  64953. }
  64954. /** @hidden */
  64955. export enum EShaderType {
  64956. FRAGMENT = 35632,
  64957. VERTEX = 35633
  64958. }
  64959. /** @hidden */
  64960. export enum EParameterType {
  64961. BYTE = 5120,
  64962. UNSIGNED_BYTE = 5121,
  64963. SHORT = 5122,
  64964. UNSIGNED_SHORT = 5123,
  64965. INT = 5124,
  64966. UNSIGNED_INT = 5125,
  64967. FLOAT = 5126,
  64968. FLOAT_VEC2 = 35664,
  64969. FLOAT_VEC3 = 35665,
  64970. FLOAT_VEC4 = 35666,
  64971. INT_VEC2 = 35667,
  64972. INT_VEC3 = 35668,
  64973. INT_VEC4 = 35669,
  64974. BOOL = 35670,
  64975. BOOL_VEC2 = 35671,
  64976. BOOL_VEC3 = 35672,
  64977. BOOL_VEC4 = 35673,
  64978. FLOAT_MAT2 = 35674,
  64979. FLOAT_MAT3 = 35675,
  64980. FLOAT_MAT4 = 35676,
  64981. SAMPLER_2D = 35678
  64982. }
  64983. /** @hidden */
  64984. export enum ETextureWrapMode {
  64985. CLAMP_TO_EDGE = 33071,
  64986. MIRRORED_REPEAT = 33648,
  64987. REPEAT = 10497
  64988. }
  64989. /** @hidden */
  64990. export enum ETextureFilterType {
  64991. NEAREST = 9728,
  64992. LINEAR = 9728,
  64993. NEAREST_MIPMAP_NEAREST = 9984,
  64994. LINEAR_MIPMAP_NEAREST = 9985,
  64995. NEAREST_MIPMAP_LINEAR = 9986,
  64996. LINEAR_MIPMAP_LINEAR = 9987
  64997. }
  64998. /** @hidden */
  64999. export enum ETextureFormat {
  65000. ALPHA = 6406,
  65001. RGB = 6407,
  65002. RGBA = 6408,
  65003. LUMINANCE = 6409,
  65004. LUMINANCE_ALPHA = 6410
  65005. }
  65006. /** @hidden */
  65007. export enum ECullingType {
  65008. FRONT = 1028,
  65009. BACK = 1029,
  65010. FRONT_AND_BACK = 1032
  65011. }
  65012. /** @hidden */
  65013. export enum EBlendingFunction {
  65014. ZERO = 0,
  65015. ONE = 1,
  65016. SRC_COLOR = 768,
  65017. ONE_MINUS_SRC_COLOR = 769,
  65018. DST_COLOR = 774,
  65019. ONE_MINUS_DST_COLOR = 775,
  65020. SRC_ALPHA = 770,
  65021. ONE_MINUS_SRC_ALPHA = 771,
  65022. DST_ALPHA = 772,
  65023. ONE_MINUS_DST_ALPHA = 773,
  65024. CONSTANT_COLOR = 32769,
  65025. ONE_MINUS_CONSTANT_COLOR = 32770,
  65026. CONSTANT_ALPHA = 32771,
  65027. ONE_MINUS_CONSTANT_ALPHA = 32772,
  65028. SRC_ALPHA_SATURATE = 776
  65029. }
  65030. /** @hidden */
  65031. export interface IGLTFProperty {
  65032. extensions?: {
  65033. [key: string]: any;
  65034. };
  65035. extras?: Object;
  65036. }
  65037. /** @hidden */
  65038. export interface IGLTFChildRootProperty extends IGLTFProperty {
  65039. name?: string;
  65040. }
  65041. /** @hidden */
  65042. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  65043. bufferView: string;
  65044. byteOffset: number;
  65045. byteStride: number;
  65046. count: number;
  65047. type: string;
  65048. componentType: EComponentType;
  65049. max?: number[];
  65050. min?: number[];
  65051. name?: string;
  65052. }
  65053. /** @hidden */
  65054. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  65055. buffer: string;
  65056. byteOffset: number;
  65057. byteLength: number;
  65058. byteStride: number;
  65059. target?: number;
  65060. }
  65061. /** @hidden */
  65062. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  65063. uri: string;
  65064. byteLength?: number;
  65065. type?: string;
  65066. }
  65067. /** @hidden */
  65068. export interface IGLTFShader extends IGLTFChildRootProperty {
  65069. uri: string;
  65070. type: EShaderType;
  65071. }
  65072. /** @hidden */
  65073. export interface IGLTFProgram extends IGLTFChildRootProperty {
  65074. attributes: string[];
  65075. fragmentShader: string;
  65076. vertexShader: string;
  65077. }
  65078. /** @hidden */
  65079. export interface IGLTFTechniqueParameter {
  65080. type: number;
  65081. count?: number;
  65082. semantic?: string;
  65083. node?: string;
  65084. value?: number | boolean | string | Array<any>;
  65085. source?: string;
  65086. babylonValue?: any;
  65087. }
  65088. /** @hidden */
  65089. export interface IGLTFTechniqueCommonProfile {
  65090. lightingModel: string;
  65091. texcoordBindings: Object;
  65092. parameters?: Array<any>;
  65093. }
  65094. /** @hidden */
  65095. export interface IGLTFTechniqueStatesFunctions {
  65096. blendColor?: number[];
  65097. blendEquationSeparate?: number[];
  65098. blendFuncSeparate?: number[];
  65099. colorMask: boolean[];
  65100. cullFace: number[];
  65101. }
  65102. /** @hidden */
  65103. export interface IGLTFTechniqueStates {
  65104. enable: number[];
  65105. functions: IGLTFTechniqueStatesFunctions;
  65106. }
  65107. /** @hidden */
  65108. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  65109. parameters: {
  65110. [key: string]: IGLTFTechniqueParameter;
  65111. };
  65112. program: string;
  65113. attributes: {
  65114. [key: string]: string;
  65115. };
  65116. uniforms: {
  65117. [key: string]: string;
  65118. };
  65119. states: IGLTFTechniqueStates;
  65120. }
  65121. /** @hidden */
  65122. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  65123. technique?: string;
  65124. values: string[];
  65125. }
  65126. /** @hidden */
  65127. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  65128. attributes: {
  65129. [key: string]: string;
  65130. };
  65131. indices: string;
  65132. material: string;
  65133. mode?: number;
  65134. }
  65135. /** @hidden */
  65136. export interface IGLTFMesh extends IGLTFChildRootProperty {
  65137. primitives: IGLTFMeshPrimitive[];
  65138. }
  65139. /** @hidden */
  65140. export interface IGLTFImage extends IGLTFChildRootProperty {
  65141. uri: string;
  65142. }
  65143. /** @hidden */
  65144. export interface IGLTFSampler extends IGLTFChildRootProperty {
  65145. magFilter?: number;
  65146. minFilter?: number;
  65147. wrapS?: number;
  65148. wrapT?: number;
  65149. }
  65150. /** @hidden */
  65151. export interface IGLTFTexture extends IGLTFChildRootProperty {
  65152. sampler: string;
  65153. source: string;
  65154. format?: ETextureFormat;
  65155. internalFormat?: ETextureFormat;
  65156. target?: number;
  65157. type?: number;
  65158. babylonTexture?: Texture;
  65159. }
  65160. /** @hidden */
  65161. export interface IGLTFAmbienLight {
  65162. color?: number[];
  65163. }
  65164. /** @hidden */
  65165. export interface IGLTFDirectionalLight {
  65166. color?: number[];
  65167. }
  65168. /** @hidden */
  65169. export interface IGLTFPointLight {
  65170. color?: number[];
  65171. constantAttenuation?: number;
  65172. linearAttenuation?: number;
  65173. quadraticAttenuation?: number;
  65174. }
  65175. /** @hidden */
  65176. export interface IGLTFSpotLight {
  65177. color?: number[];
  65178. constantAttenuation?: number;
  65179. fallOfAngle?: number;
  65180. fallOffExponent?: number;
  65181. linearAttenuation?: number;
  65182. quadraticAttenuation?: number;
  65183. }
  65184. /** @hidden */
  65185. export interface IGLTFLight extends IGLTFChildRootProperty {
  65186. type: string;
  65187. }
  65188. /** @hidden */
  65189. export interface IGLTFCameraOrthographic {
  65190. xmag: number;
  65191. ymag: number;
  65192. zfar: number;
  65193. znear: number;
  65194. }
  65195. /** @hidden */
  65196. export interface IGLTFCameraPerspective {
  65197. aspectRatio: number;
  65198. yfov: number;
  65199. zfar: number;
  65200. znear: number;
  65201. }
  65202. /** @hidden */
  65203. export interface IGLTFCamera extends IGLTFChildRootProperty {
  65204. type: string;
  65205. }
  65206. /** @hidden */
  65207. export interface IGLTFAnimationChannelTarget {
  65208. id: string;
  65209. path: string;
  65210. }
  65211. /** @hidden */
  65212. export interface IGLTFAnimationChannel {
  65213. sampler: string;
  65214. target: IGLTFAnimationChannelTarget;
  65215. }
  65216. /** @hidden */
  65217. export interface IGLTFAnimationSampler {
  65218. input: string;
  65219. output: string;
  65220. interpolation?: string;
  65221. }
  65222. /** @hidden */
  65223. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  65224. channels?: IGLTFAnimationChannel[];
  65225. parameters?: {
  65226. [key: string]: string;
  65227. };
  65228. samplers?: {
  65229. [key: string]: IGLTFAnimationSampler;
  65230. };
  65231. }
  65232. /** @hidden */
  65233. export interface IGLTFNodeInstanceSkin {
  65234. skeletons: string[];
  65235. skin: string;
  65236. meshes: string[];
  65237. }
  65238. /** @hidden */
  65239. export interface IGLTFSkins extends IGLTFChildRootProperty {
  65240. bindShapeMatrix: number[];
  65241. inverseBindMatrices: string;
  65242. jointNames: string[];
  65243. babylonSkeleton?: Skeleton;
  65244. }
  65245. /** @hidden */
  65246. export interface IGLTFNode extends IGLTFChildRootProperty {
  65247. camera?: string;
  65248. children: string[];
  65249. skin?: string;
  65250. jointName?: string;
  65251. light?: string;
  65252. matrix: number[];
  65253. mesh?: string;
  65254. meshes?: string[];
  65255. rotation?: number[];
  65256. scale?: number[];
  65257. translation?: number[];
  65258. babylonNode?: Node;
  65259. }
  65260. /** @hidden */
  65261. export interface IGLTFScene extends IGLTFChildRootProperty {
  65262. nodes: string[];
  65263. }
  65264. /** @hidden */
  65265. export interface IGLTFRuntime {
  65266. extensions: {
  65267. [key: string]: any;
  65268. };
  65269. accessors: {
  65270. [key: string]: IGLTFAccessor;
  65271. };
  65272. buffers: {
  65273. [key: string]: IGLTFBuffer;
  65274. };
  65275. bufferViews: {
  65276. [key: string]: IGLTFBufferView;
  65277. };
  65278. meshes: {
  65279. [key: string]: IGLTFMesh;
  65280. };
  65281. lights: {
  65282. [key: string]: IGLTFLight;
  65283. };
  65284. cameras: {
  65285. [key: string]: IGLTFCamera;
  65286. };
  65287. nodes: {
  65288. [key: string]: IGLTFNode;
  65289. };
  65290. images: {
  65291. [key: string]: IGLTFImage;
  65292. };
  65293. textures: {
  65294. [key: string]: IGLTFTexture;
  65295. };
  65296. shaders: {
  65297. [key: string]: IGLTFShader;
  65298. };
  65299. programs: {
  65300. [key: string]: IGLTFProgram;
  65301. };
  65302. samplers: {
  65303. [key: string]: IGLTFSampler;
  65304. };
  65305. techniques: {
  65306. [key: string]: IGLTFTechnique;
  65307. };
  65308. materials: {
  65309. [key: string]: IGLTFMaterial;
  65310. };
  65311. animations: {
  65312. [key: string]: IGLTFAnimation;
  65313. };
  65314. skins: {
  65315. [key: string]: IGLTFSkins;
  65316. };
  65317. currentScene?: Object;
  65318. scenes: {
  65319. [key: string]: IGLTFScene;
  65320. };
  65321. extensionsUsed: string[];
  65322. extensionsRequired?: string[];
  65323. buffersCount: number;
  65324. shaderscount: number;
  65325. scene: Scene;
  65326. rootUrl: string;
  65327. loadedBufferCount: number;
  65328. loadedBufferViews: {
  65329. [name: string]: ArrayBufferView;
  65330. };
  65331. loadedShaderCount: number;
  65332. importOnlyMeshes: boolean;
  65333. importMeshesNames?: string[];
  65334. dummyNodes: Node[];
  65335. }
  65336. /** @hidden */
  65337. export interface INodeToRoot {
  65338. bone: Bone;
  65339. node: IGLTFNode;
  65340. id: string;
  65341. }
  65342. /** @hidden */
  65343. export interface IJointNode {
  65344. node: IGLTFNode;
  65345. id: string;
  65346. }
  65347. }
  65348. declare module BABYLON.GLTF1 {
  65349. /**
  65350. * Utils functions for GLTF
  65351. * @hidden
  65352. */
  65353. export class GLTFUtils {
  65354. /**
  65355. * Sets the given "parameter" matrix
  65356. * @param scene: the Scene object
  65357. * @param source: the source node where to pick the matrix
  65358. * @param parameter: the GLTF technique parameter
  65359. * @param uniformName: the name of the shader's uniform
  65360. * @param shaderMaterial: the shader material
  65361. */
  65362. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  65363. /**
  65364. * Sets the given "parameter" matrix
  65365. * @param shaderMaterial: the shader material
  65366. * @param uniform: the name of the shader's uniform
  65367. * @param value: the value of the uniform
  65368. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  65369. */
  65370. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  65371. /**
  65372. * Returns the wrap mode of the texture
  65373. * @param mode: the mode value
  65374. */
  65375. static GetWrapMode(mode: number): number;
  65376. /**
  65377. * Returns the byte stride giving an accessor
  65378. * @param accessor: the GLTF accessor objet
  65379. */
  65380. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  65381. /**
  65382. * Returns the texture filter mode giving a mode value
  65383. * @param mode: the filter mode value
  65384. */
  65385. static GetTextureFilterMode(mode: number): ETextureFilterType;
  65386. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  65387. /**
  65388. * Returns a buffer from its accessor
  65389. * @param gltfRuntime: the GLTF runtime
  65390. * @param accessor: the GLTF accessor
  65391. */
  65392. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  65393. /**
  65394. * Decodes a buffer view into a string
  65395. * @param view: the buffer view
  65396. */
  65397. static DecodeBufferToText(view: ArrayBufferView): string;
  65398. /**
  65399. * Returns the default material of gltf. Related to
  65400. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  65401. * @param scene: the Babylon.js scene
  65402. */
  65403. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  65404. private static _DefaultMaterial;
  65405. }
  65406. }
  65407. declare module BABYLON.GLTF1 {
  65408. /**
  65409. * Implementation of the base glTF spec
  65410. * @hidden
  65411. */
  65412. export class GLTFLoaderBase {
  65413. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  65414. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  65415. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  65416. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  65417. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  65418. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  65419. }
  65420. /**
  65421. * glTF V1 Loader
  65422. * @hidden
  65423. */
  65424. export class GLTFLoader implements IGLTFLoader {
  65425. static Extensions: {
  65426. [name: string]: GLTFLoaderExtension;
  65427. };
  65428. static RegisterExtension(extension: GLTFLoaderExtension): void;
  65429. state: Nullable<GLTFLoaderState>;
  65430. dispose(): void;
  65431. private _importMeshAsync;
  65432. /**
  65433. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  65434. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65435. * @param scene the scene the meshes should be added to
  65436. * @param data gltf data containing information of the meshes in a loaded file
  65437. * @param rootUrl root url to load from
  65438. * @param onProgress event that fires when loading progress has occured
  65439. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65440. */
  65441. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  65442. meshes: AbstractMesh[];
  65443. particleSystems: IParticleSystem[];
  65444. skeletons: Skeleton[];
  65445. animationGroups: AnimationGroup[];
  65446. }>;
  65447. private _loadAsync;
  65448. /**
  65449. * Imports all objects from a loaded gltf file and adds them to the scene
  65450. * @param scene the scene the objects should be added to
  65451. * @param data gltf data containing information of the meshes in a loaded file
  65452. * @param rootUrl root url to load from
  65453. * @param onProgress event that fires when loading progress has occured
  65454. * @returns a promise which completes when objects have been loaded to the scene
  65455. */
  65456. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  65457. private _loadShadersAsync;
  65458. private _loadBuffersAsync;
  65459. private _createNodes;
  65460. }
  65461. /** @hidden */
  65462. export abstract class GLTFLoaderExtension {
  65463. private _name;
  65464. constructor(name: string);
  65465. readonly name: string;
  65466. /**
  65467. * Defines an override for loading the runtime
  65468. * Return true to stop further extensions from loading the runtime
  65469. */
  65470. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  65471. /**
  65472. * Defines an onverride for creating gltf runtime
  65473. * Return true to stop further extensions from creating the runtime
  65474. */
  65475. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  65476. /**
  65477. * Defines an override for loading buffers
  65478. * Return true to stop further extensions from loading this buffer
  65479. */
  65480. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  65481. /**
  65482. * Defines an override for loading texture buffers
  65483. * Return true to stop further extensions from loading this texture data
  65484. */
  65485. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  65486. /**
  65487. * Defines an override for creating textures
  65488. * Return true to stop further extensions from loading this texture
  65489. */
  65490. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  65491. /**
  65492. * Defines an override for loading shader strings
  65493. * Return true to stop further extensions from loading this shader data
  65494. */
  65495. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  65496. /**
  65497. * Defines an override for loading materials
  65498. * Return true to stop further extensions from loading this material
  65499. */
  65500. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  65501. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  65502. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  65503. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  65504. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  65505. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  65506. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  65507. private static LoadTextureBufferAsync;
  65508. private static CreateTextureAsync;
  65509. private static ApplyExtensions;
  65510. }
  65511. }
  65512. declare module BABYLON.GLTF1 {
  65513. /** @hidden */
  65514. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  65515. private _bin;
  65516. constructor();
  65517. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  65518. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  65519. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  65520. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  65521. }
  65522. }
  65523. declare module BABYLON.GLTF1 {
  65524. /** @hidden */
  65525. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  65526. constructor();
  65527. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  65528. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  65529. private _loadTexture;
  65530. }
  65531. }
  65532. declare module BABYLON.GLTF2.Loader {
  65533. /**
  65534. * Loader interface with an index field.
  65535. */
  65536. export interface IArrayItem {
  65537. /**
  65538. * The index of this item in the array.
  65539. */
  65540. index: number;
  65541. }
  65542. /**
  65543. * Loader interface with additional members.
  65544. */
  65545. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  65546. /** @hidden */
  65547. _data?: Promise<ArrayBufferView>;
  65548. /** @hidden */
  65549. _babylonVertexBuffer?: Promise<VertexBuffer>;
  65550. }
  65551. /**
  65552. * Loader interface with additional members.
  65553. */
  65554. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  65555. }
  65556. /** @hidden */
  65557. export interface _IAnimationSamplerData {
  65558. input: Float32Array;
  65559. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  65560. output: Float32Array;
  65561. }
  65562. /**
  65563. * Loader interface with additional members.
  65564. */
  65565. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  65566. /** @hidden */
  65567. _data?: Promise<_IAnimationSamplerData>;
  65568. }
  65569. /**
  65570. * Loader interface with additional members.
  65571. */
  65572. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  65573. channels: IAnimationChannel[];
  65574. samplers: IAnimationSampler[];
  65575. /** @hidden */
  65576. _babylonAnimationGroup?: AnimationGroup;
  65577. }
  65578. /**
  65579. * Loader interface with additional members.
  65580. */
  65581. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  65582. /** @hidden */
  65583. _data?: Promise<ArrayBufferView>;
  65584. }
  65585. /**
  65586. * Loader interface with additional members.
  65587. */
  65588. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  65589. /** @hidden */
  65590. _data?: Promise<ArrayBufferView>;
  65591. /** @hidden */
  65592. _babylonBuffer?: Promise<Buffer>;
  65593. }
  65594. /**
  65595. * Loader interface with additional members.
  65596. */
  65597. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  65598. }
  65599. /**
  65600. * Loader interface with additional members.
  65601. */
  65602. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  65603. /** @hidden */
  65604. _data?: Promise<ArrayBufferView>;
  65605. }
  65606. /**
  65607. * Loader interface with additional members.
  65608. */
  65609. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  65610. }
  65611. /**
  65612. * Loader interface with additional members.
  65613. */
  65614. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  65615. }
  65616. /**
  65617. * Loader interface with additional members.
  65618. */
  65619. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  65620. baseColorTexture?: ITextureInfo;
  65621. metallicRoughnessTexture?: ITextureInfo;
  65622. }
  65623. /**
  65624. * Loader interface with additional members.
  65625. */
  65626. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  65627. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  65628. normalTexture?: IMaterialNormalTextureInfo;
  65629. occlusionTexture?: IMaterialOcclusionTextureInfo;
  65630. emissiveTexture?: ITextureInfo;
  65631. /** @hidden */
  65632. _data?: {
  65633. [babylonDrawMode: number]: {
  65634. babylonMaterial: Material;
  65635. babylonMeshes: AbstractMesh[];
  65636. promise: Promise<void>;
  65637. };
  65638. };
  65639. }
  65640. /**
  65641. * Loader interface with additional members.
  65642. */
  65643. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  65644. primitives: IMeshPrimitive[];
  65645. }
  65646. /**
  65647. * Loader interface with additional members.
  65648. */
  65649. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  65650. /** @hidden */
  65651. _instanceData?: {
  65652. babylonSourceMesh: Mesh;
  65653. promise: Promise<any>;
  65654. };
  65655. }
  65656. /**
  65657. * Loader interface with additional members.
  65658. */
  65659. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  65660. /**
  65661. * The parent glTF node.
  65662. */
  65663. parent?: INode;
  65664. /** @hidden */
  65665. _babylonTransformNode?: TransformNode;
  65666. /** @hidden */
  65667. _primitiveBabylonMeshes?: AbstractMesh[];
  65668. /** @hidden */
  65669. _babylonBones?: Bone[];
  65670. /** @hidden */
  65671. _numMorphTargets?: number;
  65672. }
  65673. /** @hidden */
  65674. export interface _ISamplerData {
  65675. noMipMaps: boolean;
  65676. samplingMode: number;
  65677. wrapU: number;
  65678. wrapV: number;
  65679. }
  65680. /**
  65681. * Loader interface with additional members.
  65682. */
  65683. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  65684. /** @hidden */
  65685. _data?: _ISamplerData;
  65686. }
  65687. /**
  65688. * Loader interface with additional members.
  65689. */
  65690. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  65691. }
  65692. /**
  65693. * Loader interface with additional members.
  65694. */
  65695. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  65696. /** @hidden */
  65697. _data?: {
  65698. babylonSkeleton: Skeleton;
  65699. promise: Promise<void>;
  65700. };
  65701. }
  65702. /**
  65703. * Loader interface with additional members.
  65704. */
  65705. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  65706. }
  65707. /**
  65708. * Loader interface with additional members.
  65709. */
  65710. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  65711. }
  65712. /**
  65713. * Loader interface with additional members.
  65714. */
  65715. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  65716. accessors?: IAccessor[];
  65717. animations?: IAnimation[];
  65718. buffers?: IBuffer[];
  65719. bufferViews?: IBufferView[];
  65720. cameras?: ICamera[];
  65721. images?: IImage[];
  65722. materials?: IMaterial[];
  65723. meshes?: IMesh[];
  65724. nodes?: INode[];
  65725. samplers?: ISampler[];
  65726. scenes?: IScene[];
  65727. skins?: ISkin[];
  65728. textures?: ITexture[];
  65729. }
  65730. }
  65731. declare module BABYLON.GLTF2 {
  65732. /**
  65733. * Interface for a glTF loader extension.
  65734. */
  65735. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  65736. /**
  65737. * Called after the loader state changes to LOADING.
  65738. */
  65739. onLoading?(): void;
  65740. /**
  65741. * Called after the loader state changes to READY.
  65742. */
  65743. onReady?(): void;
  65744. /**
  65745. * Define this method to modify the default behavior when loading scenes.
  65746. * @param context The context when loading the asset
  65747. * @param scene The glTF scene property
  65748. * @returns A promise that resolves when the load is complete or null if not handled
  65749. */
  65750. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  65751. /**
  65752. * Define this method to modify the default behavior when loading nodes.
  65753. * @param context The context when loading the asset
  65754. * @param node The glTF node property
  65755. * @param assign A function called synchronously after parsing the glTF properties
  65756. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  65757. */
  65758. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65759. /**
  65760. * Define this method to modify the default behavior when loading cameras.
  65761. * @param context The context when loading the asset
  65762. * @param camera The glTF camera property
  65763. * @param assign A function called synchronously after parsing the glTF properties
  65764. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  65765. */
  65766. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  65767. /**
  65768. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  65769. * @param context The context when loading the asset
  65770. * @param primitive The glTF mesh primitive property
  65771. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  65772. */
  65773. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  65774. /**
  65775. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  65776. * @param context The context when loading the asset
  65777. * @param name The mesh name when loading the asset
  65778. * @param node The glTF node when loading the asset
  65779. * @param mesh The glTF mesh when loading the asset
  65780. * @param primitive The glTF mesh primitive property
  65781. * @param assign A function called synchronously after parsing the glTF properties
  65782. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  65783. */
  65784. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  65785. /**
  65786. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  65787. * @param context The context when loading the asset
  65788. * @param material The glTF material property
  65789. * @param assign A function called synchronously after parsing the glTF properties
  65790. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  65791. */
  65792. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  65793. /**
  65794. * Define this method to modify the default behavior when creating materials.
  65795. * @param context The context when loading the asset
  65796. * @param material The glTF material property
  65797. * @param babylonDrawMode The draw mode for the Babylon material
  65798. * @returns The Babylon material or null if not handled
  65799. */
  65800. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  65801. /**
  65802. * Define this method to modify the default behavior when loading material properties.
  65803. * @param context The context when loading the asset
  65804. * @param material The glTF material property
  65805. * @param babylonMaterial The Babylon material
  65806. * @returns A promise that resolves when the load is complete or null if not handled
  65807. */
  65808. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65809. /**
  65810. * Define this method to modify the default behavior when loading texture infos.
  65811. * @param context The context when loading the asset
  65812. * @param textureInfo The glTF texture info property
  65813. * @param assign A function called synchronously after parsing the glTF properties
  65814. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  65815. */
  65816. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  65817. /**
  65818. * Define this method to modify the default behavior when loading animations.
  65819. * @param context The context when loading the asset
  65820. * @param animation The glTF animation property
  65821. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  65822. */
  65823. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  65824. /**
  65825. * @hidden Define this method to modify the default behavior when loading skins.
  65826. * @param context The context when loading the asset
  65827. * @param node The glTF node property
  65828. * @param skin The glTF skin property
  65829. * @returns A promise that resolves when the load is complete or null if not handled
  65830. */
  65831. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  65832. /**
  65833. * @hidden Define this method to modify the default behavior when loading uris.
  65834. * @param context The context when loading the asset
  65835. * @param property The glTF property associated with the uri
  65836. * @param uri The uri to load
  65837. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  65838. */
  65839. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  65840. }
  65841. }
  65842. declare module BABYLON.GLTF2 {
  65843. /**
  65844. * Helper class for working with arrays when loading the glTF asset
  65845. */
  65846. export class ArrayItem {
  65847. /**
  65848. * Gets an item from the given array.
  65849. * @param context The context when loading the asset
  65850. * @param array The array to get the item from
  65851. * @param index The index to the array
  65852. * @returns The array item
  65853. */
  65854. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  65855. /**
  65856. * Assign an `index` field to each item of the given array.
  65857. * @param array The array of items
  65858. */
  65859. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  65860. }
  65861. /**
  65862. * The glTF 2.0 loader
  65863. */
  65864. export class GLTFLoader implements IGLTFLoader {
  65865. /** @hidden */
  65866. _completePromises: Promise<any>[];
  65867. private _disposed;
  65868. private _parent;
  65869. private _state;
  65870. private _extensions;
  65871. private _rootUrl;
  65872. private _fileName;
  65873. private _uniqueRootUrl;
  65874. private _gltf;
  65875. private _babylonScene;
  65876. private _rootBabylonMesh;
  65877. private _defaultBabylonMaterialData;
  65878. private _progressCallback?;
  65879. private _requests;
  65880. private static readonly _DefaultSampler;
  65881. private static _ExtensionNames;
  65882. private static _ExtensionFactories;
  65883. /**
  65884. * Registers a loader extension.
  65885. * @param name The name of the loader extension.
  65886. * @param factory The factory function that creates the loader extension.
  65887. */
  65888. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  65889. /**
  65890. * Unregisters a loader extension.
  65891. * @param name The name of the loader extenion.
  65892. * @returns A boolean indicating whether the extension has been unregistered
  65893. */
  65894. static UnregisterExtension(name: string): boolean;
  65895. /**
  65896. * Gets the loader state.
  65897. */
  65898. readonly state: Nullable<GLTFLoaderState>;
  65899. /**
  65900. * The glTF object parsed from the JSON.
  65901. */
  65902. readonly gltf: IGLTF;
  65903. /**
  65904. * The Babylon scene when loading the asset.
  65905. */
  65906. readonly babylonScene: Scene;
  65907. /**
  65908. * The root Babylon mesh when loading the asset.
  65909. */
  65910. readonly rootBabylonMesh: Mesh;
  65911. /** @hidden */
  65912. constructor(parent: GLTFFileLoader);
  65913. /** @hidden */
  65914. dispose(): void;
  65915. /** @hidden */
  65916. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65917. meshes: AbstractMesh[];
  65918. particleSystems: IParticleSystem[];
  65919. skeletons: Skeleton[];
  65920. animationGroups: AnimationGroup[];
  65921. }>;
  65922. /** @hidden */
  65923. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65924. private _loadAsync;
  65925. private _loadData;
  65926. private _setupData;
  65927. private _loadExtensions;
  65928. private _checkExtensions;
  65929. private _setState;
  65930. private _createRootNode;
  65931. /**
  65932. * Loads a glTF scene.
  65933. * @param context The context when loading the asset
  65934. * @param scene The glTF scene property
  65935. * @returns A promise that resolves when the load is complete
  65936. */
  65937. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  65938. private _forEachPrimitive;
  65939. private _getMeshes;
  65940. private _getSkeletons;
  65941. private _getAnimationGroups;
  65942. private _startAnimations;
  65943. /**
  65944. * Loads a glTF node.
  65945. * @param context The context when loading the asset
  65946. * @param node The glTF node property
  65947. * @param assign A function called synchronously after parsing the glTF properties
  65948. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  65949. */
  65950. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  65951. private _loadMeshAsync;
  65952. /**
  65953. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  65954. * @param context The context when loading the asset
  65955. * @param name The mesh name when loading the asset
  65956. * @param node The glTF node when loading the asset
  65957. * @param mesh The glTF mesh when loading the asset
  65958. * @param primitive The glTF mesh primitive property
  65959. * @param assign A function called synchronously after parsing the glTF properties
  65960. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  65961. */
  65962. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  65963. private _loadVertexDataAsync;
  65964. private _createMorphTargets;
  65965. private _loadMorphTargetsAsync;
  65966. private _loadMorphTargetVertexDataAsync;
  65967. private static _LoadTransform;
  65968. private _loadSkinAsync;
  65969. private _loadBones;
  65970. private _loadBone;
  65971. private _loadSkinInverseBindMatricesDataAsync;
  65972. private _updateBoneMatrices;
  65973. private _getNodeMatrix;
  65974. /**
  65975. * Loads a glTF camera.
  65976. * @param context The context when loading the asset
  65977. * @param camera The glTF camera property
  65978. * @param assign A function called synchronously after parsing the glTF properties
  65979. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  65980. */
  65981. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  65982. private _loadAnimationsAsync;
  65983. /**
  65984. * Loads a glTF animation.
  65985. * @param context The context when loading the asset
  65986. * @param animation The glTF animation property
  65987. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  65988. */
  65989. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  65990. /**
  65991. * @hidden Loads a glTF animation channel.
  65992. * @param context The context when loading the asset
  65993. * @param animationContext The context of the animation when loading the asset
  65994. * @param animation The glTF animation property
  65995. * @param channel The glTF animation channel property
  65996. * @param babylonAnimationGroup The babylon animation group property
  65997. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  65998. * @returns A void promise when the channel load is complete
  65999. */
  66000. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  66001. private _loadAnimationSamplerAsync;
  66002. private _loadBufferAsync;
  66003. /**
  66004. * Loads a glTF buffer view.
  66005. * @param context The context when loading the asset
  66006. * @param bufferView The glTF buffer view property
  66007. * @returns A promise that resolves with the loaded data when the load is complete
  66008. */
  66009. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  66010. private _loadAccessorAsync;
  66011. private _loadFloatAccessorAsync;
  66012. private _loadIndicesAccessorAsync;
  66013. private _loadVertexBufferViewAsync;
  66014. private _loadVertexAccessorAsync;
  66015. private _loadMaterialMetallicRoughnessPropertiesAsync;
  66016. /** @hidden */
  66017. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  66018. private _createDefaultMaterial;
  66019. /**
  66020. * Creates a Babylon material from a glTF material.
  66021. * @param context The context when loading the asset
  66022. * @param material The glTF material property
  66023. * @param babylonDrawMode The draw mode for the Babylon material
  66024. * @returns The Babylon material
  66025. */
  66026. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  66027. /**
  66028. * Loads properties from a glTF material into a Babylon material.
  66029. * @param context The context when loading the asset
  66030. * @param material The glTF material property
  66031. * @param babylonMaterial The Babylon material
  66032. * @returns A promise that resolves when the load is complete
  66033. */
  66034. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  66035. /**
  66036. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  66037. * @param context The context when loading the asset
  66038. * @param material The glTF material property
  66039. * @param babylonMaterial The Babylon material
  66040. * @returns A promise that resolves when the load is complete
  66041. */
  66042. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  66043. /**
  66044. * Loads the alpha properties from a glTF material into a Babylon material.
  66045. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  66046. * @param context The context when loading the asset
  66047. * @param material The glTF material property
  66048. * @param babylonMaterial The Babylon material
  66049. */
  66050. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  66051. /**
  66052. * Loads a glTF texture info.
  66053. * @param context The context when loading the asset
  66054. * @param textureInfo The glTF texture info property
  66055. * @param assign A function called synchronously after parsing the glTF properties
  66056. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  66057. */
  66058. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  66059. private _loadTextureAsync;
  66060. private _loadSampler;
  66061. /**
  66062. * Loads a glTF image.
  66063. * @param context The context when loading the asset
  66064. * @param image The glTF image property
  66065. * @returns A promise that resolves with the loaded data when the load is complete
  66066. */
  66067. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  66068. /**
  66069. * Loads a glTF uri.
  66070. * @param context The context when loading the asset
  66071. * @param property The glTF property associated with the uri
  66072. * @param uri The base64 or relative uri
  66073. * @returns A promise that resolves with the loaded data when the load is complete
  66074. */
  66075. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  66076. private _onProgress;
  66077. /**
  66078. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  66079. * @param babylonObject the Babylon object with metadata
  66080. * @param pointer the JSON pointer
  66081. */
  66082. static AddPointerMetadata(babylonObject: {
  66083. metadata: any;
  66084. }, pointer: string): void;
  66085. private static _GetTextureWrapMode;
  66086. private static _GetTextureSamplingMode;
  66087. private static _GetTypedArrayConstructor;
  66088. private static _GetTypedArray;
  66089. private static _GetNumComponents;
  66090. private static _ValidateUri;
  66091. private static _GetDrawMode;
  66092. private _compileMaterialsAsync;
  66093. private _compileShadowGeneratorsAsync;
  66094. private _forEachExtensions;
  66095. private _applyExtensions;
  66096. private _extensionsOnLoading;
  66097. private _extensionsOnReady;
  66098. private _extensionsLoadSceneAsync;
  66099. private _extensionsLoadNodeAsync;
  66100. private _extensionsLoadCameraAsync;
  66101. private _extensionsLoadVertexDataAsync;
  66102. private _extensionsLoadMeshPrimitiveAsync;
  66103. private _extensionsLoadMaterialAsync;
  66104. private _extensionsCreateMaterial;
  66105. private _extensionsLoadMaterialPropertiesAsync;
  66106. private _extensionsLoadTextureInfoAsync;
  66107. private _extensionsLoadAnimationAsync;
  66108. private _extensionsLoadSkinAsync;
  66109. private _extensionsLoadUriAsync;
  66110. /**
  66111. * Helper method called by a loader extension to load an glTF extension.
  66112. * @param context The context when loading the asset
  66113. * @param property The glTF property to load the extension from
  66114. * @param extensionName The name of the extension to load
  66115. * @param actionAsync The action to run
  66116. * @returns The promise returned by actionAsync or null if the extension does not exist
  66117. */
  66118. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  66119. /**
  66120. * Helper method called by a loader extension to load a glTF extra.
  66121. * @param context The context when loading the asset
  66122. * @param property The glTF property to load the extra from
  66123. * @param extensionName The name of the extension to load
  66124. * @param actionAsync The action to run
  66125. * @returns The promise returned by actionAsync or null if the extra does not exist
  66126. */
  66127. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  66128. /**
  66129. * Increments the indentation level and logs a message.
  66130. * @param message The message to log
  66131. */
  66132. logOpen(message: string): void;
  66133. /**
  66134. * Decrements the indentation level.
  66135. */
  66136. logClose(): void;
  66137. /**
  66138. * Logs a message
  66139. * @param message The message to log
  66140. */
  66141. log(message: string): void;
  66142. /**
  66143. * Starts a performance counter.
  66144. * @param counterName The name of the performance counter
  66145. */
  66146. startPerformanceCounter(counterName: string): void;
  66147. /**
  66148. * Ends a performance counter.
  66149. * @param counterName The name of the performance counter
  66150. */
  66151. endPerformanceCounter(counterName: string): void;
  66152. }
  66153. }
  66154. declare module BABYLON.GLTF2.Loader.Extensions {
  66155. /**
  66156. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  66157. */
  66158. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  66159. /** The name of this extension. */
  66160. readonly name: string;
  66161. /** Defines whether this extension is enabled. */
  66162. enabled: boolean;
  66163. private _loader;
  66164. private _lights?;
  66165. /** @hidden */
  66166. constructor(loader: GLTFLoader);
  66167. /** @hidden */
  66168. dispose(): void;
  66169. /** @hidden */
  66170. onLoading(): void;
  66171. /** @hidden */
  66172. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  66173. private _loadLightAsync;
  66174. }
  66175. }
  66176. declare module BABYLON.GLTF2.Loader.Extensions {
  66177. /**
  66178. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  66179. */
  66180. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  66181. /** The name of this extension. */
  66182. readonly name: string;
  66183. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  66184. dracoCompression?: DracoCompression;
  66185. /** Defines whether this extension is enabled. */
  66186. enabled: boolean;
  66187. private _loader;
  66188. /** @hidden */
  66189. constructor(loader: GLTFLoader);
  66190. /** @hidden */
  66191. dispose(): void;
  66192. /** @hidden */
  66193. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  66194. }
  66195. }
  66196. declare module BABYLON.GLTF2.Loader.Extensions {
  66197. /**
  66198. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  66199. */
  66200. export class KHR_lights implements IGLTFLoaderExtension {
  66201. /** The name of this extension. */
  66202. readonly name: string;
  66203. /** Defines whether this extension is enabled. */
  66204. enabled: boolean;
  66205. private _loader;
  66206. private _lights?;
  66207. /** @hidden */
  66208. constructor(loader: GLTFLoader);
  66209. /** @hidden */
  66210. dispose(): void;
  66211. /** @hidden */
  66212. onLoading(): void;
  66213. /** @hidden */
  66214. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66215. }
  66216. }
  66217. declare module BABYLON.GLTF2.Loader.Extensions {
  66218. /**
  66219. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  66220. */
  66221. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  66222. /** The name of this extension. */
  66223. readonly name: string;
  66224. /** Defines whether this extension is enabled. */
  66225. enabled: boolean;
  66226. private _loader;
  66227. /** @hidden */
  66228. constructor(loader: GLTFLoader);
  66229. /** @hidden */
  66230. dispose(): void;
  66231. /** @hidden */
  66232. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66233. private _loadSpecularGlossinessPropertiesAsync;
  66234. }
  66235. }
  66236. declare module BABYLON.GLTF2.Loader.Extensions {
  66237. /**
  66238. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  66239. */
  66240. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  66241. /** The name of this extension. */
  66242. readonly name: string;
  66243. /** Defines whether this extension is enabled. */
  66244. enabled: boolean;
  66245. private _loader;
  66246. /** @hidden */
  66247. constructor(loader: GLTFLoader);
  66248. /** @hidden */
  66249. dispose(): void;
  66250. /** @hidden */
  66251. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66252. private _loadUnlitPropertiesAsync;
  66253. }
  66254. }
  66255. declare module BABYLON.GLTF2.Loader.Extensions {
  66256. /**
  66257. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  66258. */
  66259. export class KHR_texture_transform implements IGLTFLoaderExtension {
  66260. /** The name of this extension. */
  66261. readonly name: string;
  66262. /** Defines whether this extension is enabled. */
  66263. enabled: boolean;
  66264. private _loader;
  66265. /** @hidden */
  66266. constructor(loader: GLTFLoader);
  66267. /** @hidden */
  66268. dispose(): void;
  66269. /** @hidden */
  66270. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  66271. }
  66272. }
  66273. declare module BABYLON.GLTF2.Loader.Extensions {
  66274. /**
  66275. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  66276. */
  66277. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  66278. /** The name of this extension. */
  66279. readonly name: string;
  66280. /** Defines whether this extension is enabled. */
  66281. enabled: boolean;
  66282. private _loader;
  66283. private _clips;
  66284. private _emitters;
  66285. /** @hidden */
  66286. constructor(loader: GLTFLoader);
  66287. /** @hidden */
  66288. dispose(): void;
  66289. /** @hidden */
  66290. onLoading(): void;
  66291. /** @hidden */
  66292. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  66293. /** @hidden */
  66294. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66295. /** @hidden */
  66296. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  66297. private _loadClipAsync;
  66298. private _loadEmitterAsync;
  66299. private _getEventAction;
  66300. private _loadAnimationEventAsync;
  66301. }
  66302. }
  66303. declare module BABYLON.GLTF2.Loader.Extensions {
  66304. /**
  66305. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  66306. */
  66307. export class MSFT_lod implements IGLTFLoaderExtension {
  66308. /** The name of this extension. */
  66309. readonly name: string;
  66310. /** Defines whether this extension is enabled. */
  66311. enabled: boolean;
  66312. /**
  66313. * Maximum number of LODs to load, starting from the lowest LOD.
  66314. */
  66315. maxLODsToLoad: number;
  66316. /**
  66317. * Observable raised when all node LODs of one level are loaded.
  66318. * The event data is the index of the loaded LOD starting from zero.
  66319. * Dispose the loader to cancel the loading of the next level of LODs.
  66320. */
  66321. onNodeLODsLoadedObservable: Observable<number>;
  66322. /**
  66323. * Observable raised when all material LODs of one level are loaded.
  66324. * The event data is the index of the loaded LOD starting from zero.
  66325. * Dispose the loader to cancel the loading of the next level of LODs.
  66326. */
  66327. onMaterialLODsLoadedObservable: Observable<number>;
  66328. private _loader;
  66329. private _nodeIndexLOD;
  66330. private _nodeSignalLODs;
  66331. private _nodePromiseLODs;
  66332. private _materialIndexLOD;
  66333. private _materialSignalLODs;
  66334. private _materialPromiseLODs;
  66335. /** @hidden */
  66336. constructor(loader: GLTFLoader);
  66337. /** @hidden */
  66338. dispose(): void;
  66339. /** @hidden */
  66340. onReady(): void;
  66341. /** @hidden */
  66342. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66343. /** @hidden */
  66344. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  66345. /** @hidden */
  66346. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  66347. /**
  66348. * Gets an array of LOD properties from lowest to highest.
  66349. */
  66350. private _getLODs;
  66351. private _disposeUnusedMaterials;
  66352. }
  66353. }
  66354. declare module BABYLON.GLTF2.Loader.Extensions {
  66355. /** @hidden */
  66356. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  66357. readonly name: string;
  66358. enabled: boolean;
  66359. private _loader;
  66360. constructor(loader: GLTFLoader);
  66361. dispose(): void;
  66362. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66363. }
  66364. }
  66365. declare module BABYLON.GLTF2.Loader.Extensions {
  66366. /** @hidden */
  66367. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  66368. readonly name: string;
  66369. enabled: boolean;
  66370. private _loader;
  66371. constructor(loader: GLTFLoader);
  66372. dispose(): void;
  66373. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66374. }
  66375. }
  66376. declare module BABYLON.GLTF2.Loader.Extensions {
  66377. /**
  66378. * Store glTF extras (if present) in BJS objects' metadata
  66379. */
  66380. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  66381. /** The name of this extension. */
  66382. readonly name: string;
  66383. /** Defines whether this extension is enabled. */
  66384. enabled: boolean;
  66385. private _loader;
  66386. private _assignExtras;
  66387. /** @hidden */
  66388. constructor(loader: GLTFLoader);
  66389. /** @hidden */
  66390. dispose(): void;
  66391. /** @hidden */
  66392. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66393. /** @hidden */
  66394. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  66395. /** @hidden */
  66396. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  66397. }
  66398. }
  66399. declare module BABYLON {
  66400. /**
  66401. * Class reading and parsing the MTL file bundled with the obj file.
  66402. */
  66403. export class MTLFileLoader {
  66404. /**
  66405. * All material loaded from the mtl will be set here
  66406. */
  66407. materials: StandardMaterial[];
  66408. /**
  66409. * This function will read the mtl file and create each material described inside
  66410. * This function could be improve by adding :
  66411. * -some component missing (Ni, Tf...)
  66412. * -including the specific options available
  66413. *
  66414. * @param scene defines the scene the material will be created in
  66415. * @param data defines the mtl data to parse
  66416. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  66417. */
  66418. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  66419. /**
  66420. * Gets the texture for the material.
  66421. *
  66422. * If the material is imported from input file,
  66423. * We sanitize the url to ensure it takes the textre from aside the material.
  66424. *
  66425. * @param rootUrl The root url to load from
  66426. * @param value The value stored in the mtl
  66427. * @return The Texture
  66428. */
  66429. private static _getTexture;
  66430. }
  66431. /**
  66432. * Options for loading OBJ/MTL files
  66433. */
  66434. type MeshLoadOptions = {
  66435. /**
  66436. * Defines if UVs are optimized by default during load.
  66437. */
  66438. OptimizeWithUV: boolean;
  66439. /**
  66440. * Defines custom scaling of UV coordinates of loaded meshes.
  66441. */
  66442. UVScaling: Vector2;
  66443. /**
  66444. * Invert model on y-axis (does a model scaling inversion)
  66445. */
  66446. InvertY: boolean;
  66447. /**
  66448. * Invert Y-Axis of referenced textures on load
  66449. */
  66450. InvertTextureY: boolean;
  66451. /**
  66452. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  66453. */
  66454. ImportVertexColors: boolean;
  66455. /**
  66456. * Compute the normals for the model, even if normals are present in the file.
  66457. */
  66458. ComputeNormals: boolean;
  66459. /**
  66460. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  66461. */
  66462. SkipMaterials: boolean;
  66463. /**
  66464. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  66465. */
  66466. MaterialLoadingFailsSilently: boolean;
  66467. };
  66468. /**
  66469. * OBJ file type loader.
  66470. * This is a babylon scene loader plugin.
  66471. */
  66472. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  66473. /**
  66474. * Defines if UVs are optimized by default during load.
  66475. */
  66476. static OPTIMIZE_WITH_UV: boolean;
  66477. /**
  66478. * Invert model on y-axis (does a model scaling inversion)
  66479. */
  66480. static INVERT_Y: boolean;
  66481. /**
  66482. * Invert Y-Axis of referenced textures on load
  66483. */
  66484. static INVERT_TEXTURE_Y: boolean;
  66485. /**
  66486. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  66487. */
  66488. static IMPORT_VERTEX_COLORS: boolean;
  66489. /**
  66490. * Compute the normals for the model, even if normals are present in the file.
  66491. */
  66492. static COMPUTE_NORMALS: boolean;
  66493. /**
  66494. * Defines custom scaling of UV coordinates of loaded meshes.
  66495. */
  66496. static UV_SCALING: Vector2;
  66497. /**
  66498. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  66499. */
  66500. static SKIP_MATERIALS: boolean;
  66501. /**
  66502. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  66503. *
  66504. * Defaults to true for backwards compatibility.
  66505. */
  66506. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  66507. /**
  66508. * Defines the name of the plugin.
  66509. */
  66510. name: string;
  66511. /**
  66512. * Defines the extension the plugin is able to load.
  66513. */
  66514. extensions: string;
  66515. /** @hidden */
  66516. obj: RegExp;
  66517. /** @hidden */
  66518. group: RegExp;
  66519. /** @hidden */
  66520. mtllib: RegExp;
  66521. /** @hidden */
  66522. usemtl: RegExp;
  66523. /** @hidden */
  66524. smooth: RegExp;
  66525. /** @hidden */
  66526. vertexPattern: RegExp;
  66527. /** @hidden */
  66528. normalPattern: RegExp;
  66529. /** @hidden */
  66530. uvPattern: RegExp;
  66531. /** @hidden */
  66532. facePattern1: RegExp;
  66533. /** @hidden */
  66534. facePattern2: RegExp;
  66535. /** @hidden */
  66536. facePattern3: RegExp;
  66537. /** @hidden */
  66538. facePattern4: RegExp;
  66539. /** @hidden */
  66540. facePattern5: RegExp;
  66541. private _meshLoadOptions;
  66542. /**
  66543. * Creates loader for .OBJ files
  66544. *
  66545. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  66546. */
  66547. constructor(meshLoadOptions?: MeshLoadOptions);
  66548. private static readonly currentMeshLoadOptions;
  66549. /**
  66550. * Calls synchronously the MTL file attached to this obj.
  66551. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  66552. * Without this function materials are not displayed in the first frame (but displayed after).
  66553. * In consequence it is impossible to get material information in your HTML file
  66554. *
  66555. * @param url The URL of the MTL file
  66556. * @param rootUrl
  66557. * @param onSuccess Callback function to be called when the MTL file is loaded
  66558. * @private
  66559. */
  66560. private _loadMTL;
  66561. /**
  66562. * Instantiates a OBJ file loader plugin.
  66563. * @returns the created plugin
  66564. */
  66565. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  66566. /**
  66567. * If the data string can be loaded directly.
  66568. *
  66569. * @param data string containing the file data
  66570. * @returns if the data can be loaded directly
  66571. */
  66572. canDirectLoad(data: string): boolean;
  66573. /**
  66574. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  66575. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66576. * @param scene the scene the meshes should be added to
  66577. * @param data the OBJ data to load
  66578. * @param rootUrl root url to load from
  66579. * @param onProgress event that fires when loading progress has occured
  66580. * @param fileName Defines the name of the file to load
  66581. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66582. */
  66583. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66584. meshes: AbstractMesh[];
  66585. particleSystems: IParticleSystem[];
  66586. skeletons: Skeleton[];
  66587. animationGroups: AnimationGroup[];
  66588. }>;
  66589. /**
  66590. * Imports all objects from the loaded OBJ data and adds them to the scene
  66591. * @param scene the scene the objects should be added to
  66592. * @param data the OBJ data to load
  66593. * @param rootUrl root url to load from
  66594. * @param onProgress event that fires when loading progress has occured
  66595. * @param fileName Defines the name of the file to load
  66596. * @returns a promise which completes when objects have been loaded to the scene
  66597. */
  66598. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66599. /**
  66600. * Load into an asset container.
  66601. * @param scene The scene to load into
  66602. * @param data The data to import
  66603. * @param rootUrl The root url for scene and resources
  66604. * @param onProgress The callback when the load progresses
  66605. * @param fileName Defines the name of the file to load
  66606. * @returns The loaded asset container
  66607. */
  66608. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  66609. /**
  66610. * Read the OBJ file and create an Array of meshes.
  66611. * Each mesh contains all information given by the OBJ and the MTL file.
  66612. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  66613. *
  66614. * @param meshesNames
  66615. * @param scene Scene The scene where are displayed the data
  66616. * @param data String The content of the obj file
  66617. * @param rootUrl String The path to the folder
  66618. * @returns Array<AbstractMesh>
  66619. * @private
  66620. */
  66621. private _parseSolid;
  66622. }
  66623. }
  66624. declare module BABYLON {
  66625. /**
  66626. * STL file type loader.
  66627. * This is a babylon scene loader plugin.
  66628. */
  66629. export class STLFileLoader implements ISceneLoaderPlugin {
  66630. /** @hidden */
  66631. solidPattern: RegExp;
  66632. /** @hidden */
  66633. facetsPattern: RegExp;
  66634. /** @hidden */
  66635. normalPattern: RegExp;
  66636. /** @hidden */
  66637. vertexPattern: RegExp;
  66638. /**
  66639. * Defines the name of the plugin.
  66640. */
  66641. name: string;
  66642. /**
  66643. * Defines the extensions the stl loader is able to load.
  66644. * force data to come in as an ArrayBuffer
  66645. * we'll convert to string if it looks like it's an ASCII .stl
  66646. */
  66647. extensions: ISceneLoaderPluginExtensions;
  66648. /**
  66649. * Import meshes into a scene.
  66650. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  66651. * @param scene The scene to import into
  66652. * @param data The data to import
  66653. * @param rootUrl The root url for scene and resources
  66654. * @param meshes The meshes array to import into
  66655. * @param particleSystems The particle systems array to import into
  66656. * @param skeletons The skeletons array to import into
  66657. * @param onError The callback when import fails
  66658. * @returns True if successful or false otherwise
  66659. */
  66660. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  66661. /**
  66662. * Load into a scene.
  66663. * @param scene The scene to load into
  66664. * @param data The data to import
  66665. * @param rootUrl The root url for scene and resources
  66666. * @param onError The callback when import fails
  66667. * @returns true if successful or false otherwise
  66668. */
  66669. load(scene: Scene, data: any, rootUrl: string): boolean;
  66670. /**
  66671. * Load into an asset container.
  66672. * @param scene The scene to load into
  66673. * @param data The data to import
  66674. * @param rootUrl The root url for scene and resources
  66675. * @param onError The callback when import fails
  66676. * @returns The loaded asset container
  66677. */
  66678. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  66679. private _isBinary;
  66680. private _parseBinary;
  66681. private _parseASCII;
  66682. }
  66683. }
  66684. declare module BABYLON {
  66685. /**
  66686. * Class for generating OBJ data from a Babylon scene.
  66687. */
  66688. export class OBJExport {
  66689. /**
  66690. * Exports the geometry of a Mesh array in .OBJ file format (text)
  66691. * @param mesh defines the list of meshes to serialize
  66692. * @param materials defines if materials should be exported
  66693. * @param matlibname defines the name of the associated mtl file
  66694. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  66695. * @returns the OBJ content
  66696. */
  66697. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  66698. /**
  66699. * Exports the material(s) of a mesh in .MTL file format (text)
  66700. * @param mesh defines the mesh to extract the material from
  66701. * @returns the mtl content
  66702. */
  66703. static MTL(mesh: Mesh): string;
  66704. }
  66705. }
  66706. declare module BABYLON {
  66707. /** @hidden */
  66708. export var __IGLTFExporterExtension: number;
  66709. /**
  66710. * Interface for extending the exporter
  66711. * @hidden
  66712. */
  66713. export interface IGLTFExporterExtension {
  66714. /**
  66715. * The name of this extension
  66716. */
  66717. readonly name: string;
  66718. /**
  66719. * Defines whether this extension is enabled
  66720. */
  66721. enabled: boolean;
  66722. /**
  66723. * Defines whether this extension is required
  66724. */
  66725. required: boolean;
  66726. }
  66727. }
  66728. declare module BABYLON.GLTF2.Exporter {
  66729. /** @hidden */
  66730. export var __IGLTFExporterExtensionV2: number;
  66731. /**
  66732. * Interface for a glTF exporter extension
  66733. * @hidden
  66734. */
  66735. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  66736. /**
  66737. * Define this method to modify the default behavior before exporting a texture
  66738. * @param context The context when loading the asset
  66739. * @param babylonTexture The glTF texture info property
  66740. * @param mimeType The mime-type of the generated image
  66741. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  66742. */
  66743. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  66744. /**
  66745. * Define this method to modify the default behavior when exporting texture info
  66746. * @param context The context when loading the asset
  66747. * @param meshPrimitive glTF mesh primitive
  66748. * @param babylonSubMesh Babylon submesh
  66749. * @param binaryWriter glTF serializer binary writer instance
  66750. * @returns nullable IMeshPrimitive promise
  66751. */
  66752. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  66753. /**
  66754. * Define this method to modify the default behavior when exporting a node
  66755. * @param context The context when exporting the node
  66756. * @param node glTF node
  66757. * @param babylonNode BabylonJS node
  66758. * @returns nullable INode promise
  66759. */
  66760. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  66761. /**
  66762. * Called after the exporter state changes to EXPORTING
  66763. */
  66764. onExporting?(): void;
  66765. }
  66766. }
  66767. declare module BABYLON.GLTF2.Exporter {
  66768. /**
  66769. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  66770. * @hidden
  66771. */
  66772. export class _GLTFMaterialExporter {
  66773. /**
  66774. * Represents the dielectric specular values for R, G and B
  66775. */
  66776. private static readonly _DielectricSpecular;
  66777. /**
  66778. * Allows the maximum specular power to be defined for material calculations
  66779. */
  66780. private static readonly _MaxSpecularPower;
  66781. /**
  66782. * Mapping to store textures
  66783. */
  66784. private _textureMap;
  66785. /**
  66786. * Numeric tolerance value
  66787. */
  66788. private static readonly _Epsilon;
  66789. /**
  66790. * Reference to the glTF Exporter
  66791. */
  66792. private _exporter;
  66793. constructor(exporter: _Exporter);
  66794. /**
  66795. * Specifies if two colors are approximately equal in value
  66796. * @param color1 first color to compare to
  66797. * @param color2 second color to compare to
  66798. * @param epsilon threshold value
  66799. */
  66800. private static FuzzyEquals;
  66801. /**
  66802. * Gets the materials from a Babylon scene and converts them to glTF materials
  66803. * @param scene babylonjs scene
  66804. * @param mimeType texture mime type
  66805. * @param images array of images
  66806. * @param textures array of textures
  66807. * @param materials array of materials
  66808. * @param imageData mapping of texture names to base64 textures
  66809. * @param hasTextureCoords specifies if texture coordinates are present on the material
  66810. */
  66811. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66812. /**
  66813. * Makes a copy of the glTF material without the texture parameters
  66814. * @param originalMaterial original glTF material
  66815. * @returns glTF material without texture parameters
  66816. */
  66817. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  66818. /**
  66819. * Specifies if the material has any texture parameters present
  66820. * @param material glTF Material
  66821. * @returns boolean specifying if texture parameters are present
  66822. */
  66823. _hasTexturesPresent(material: IMaterial): boolean;
  66824. /**
  66825. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  66826. * @param babylonStandardMaterial
  66827. * @returns glTF Metallic Roughness Material representation
  66828. */
  66829. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  66830. /**
  66831. * Computes the metallic factor
  66832. * @param diffuse diffused value
  66833. * @param specular specular value
  66834. * @param oneMinusSpecularStrength one minus the specular strength
  66835. * @returns metallic value
  66836. */
  66837. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  66838. /**
  66839. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  66840. * @param glTFMaterial glTF material
  66841. * @param babylonMaterial Babylon material
  66842. */
  66843. private static _SetAlphaMode;
  66844. /**
  66845. * Converts a Babylon Standard Material to a glTF Material
  66846. * @param babylonStandardMaterial BJS Standard Material
  66847. * @param mimeType mime type to use for the textures
  66848. * @param images array of glTF image interfaces
  66849. * @param textures array of glTF texture interfaces
  66850. * @param materials array of glTF material interfaces
  66851. * @param imageData map of image file name to data
  66852. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66853. */
  66854. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66855. /**
  66856. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  66857. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  66858. * @param mimeType mime type to use for the textures
  66859. * @param images array of glTF image interfaces
  66860. * @param textures array of glTF texture interfaces
  66861. * @param materials array of glTF material interfaces
  66862. * @param imageData map of image file name to data
  66863. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66864. */
  66865. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66866. /**
  66867. * Converts an image typed array buffer to a base64 image
  66868. * @param buffer typed array buffer
  66869. * @param width width of the image
  66870. * @param height height of the image
  66871. * @param mimeType mimetype of the image
  66872. * @returns base64 image string
  66873. */
  66874. private _createBase64FromCanvasAsync;
  66875. /**
  66876. * Generates a white texture based on the specified width and height
  66877. * @param width width of the texture in pixels
  66878. * @param height height of the texture in pixels
  66879. * @param scene babylonjs scene
  66880. * @returns white texture
  66881. */
  66882. private _createWhiteTexture;
  66883. /**
  66884. * 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
  66885. * @param texture1 first texture to resize
  66886. * @param texture2 second texture to resize
  66887. * @param scene babylonjs scene
  66888. * @returns resized textures or null
  66889. */
  66890. private _resizeTexturesToSameDimensions;
  66891. /**
  66892. * Converts an array of pixels to a Float32Array
  66893. * Throws an error if the pixel format is not supported
  66894. * @param pixels - array buffer containing pixel values
  66895. * @returns Float32 of pixels
  66896. */
  66897. private _convertPixelArrayToFloat32;
  66898. /**
  66899. * Convert Specular Glossiness Textures to Metallic Roughness
  66900. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  66901. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  66902. * @param diffuseTexture texture used to store diffuse information
  66903. * @param specularGlossinessTexture texture used to store specular and glossiness information
  66904. * @param factors specular glossiness material factors
  66905. * @param mimeType the mime type to use for the texture
  66906. * @returns pbr metallic roughness interface or null
  66907. */
  66908. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  66909. /**
  66910. * Converts specular glossiness material properties to metallic roughness
  66911. * @param specularGlossiness interface with specular glossiness material properties
  66912. * @returns interface with metallic roughness material properties
  66913. */
  66914. private _convertSpecularGlossinessToMetallicRoughness;
  66915. /**
  66916. * Calculates the surface reflectance, independent of lighting conditions
  66917. * @param color Color source to calculate brightness from
  66918. * @returns number representing the perceived brightness, or zero if color is undefined
  66919. */
  66920. private _getPerceivedBrightness;
  66921. /**
  66922. * Returns the maximum color component value
  66923. * @param color
  66924. * @returns maximum color component value, or zero if color is null or undefined
  66925. */
  66926. private _getMaxComponent;
  66927. /**
  66928. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  66929. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  66930. * @param mimeType mime type to use for the textures
  66931. * @param images array of glTF image interfaces
  66932. * @param textures array of glTF texture interfaces
  66933. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  66934. * @param imageData map of image file name to data
  66935. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66936. * @returns glTF PBR Metallic Roughness factors
  66937. */
  66938. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  66939. private _getGLTFTextureSampler;
  66940. private _getGLTFTextureWrapMode;
  66941. private _getGLTFTextureWrapModesSampler;
  66942. /**
  66943. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  66944. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  66945. * @param mimeType mime type to use for the textures
  66946. * @param images array of glTF image interfaces
  66947. * @param textures array of glTF texture interfaces
  66948. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  66949. * @param imageData map of image file name to data
  66950. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66951. * @returns glTF PBR Metallic Roughness factors
  66952. */
  66953. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  66954. /**
  66955. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  66956. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  66957. * @param mimeType mime type to use for the textures
  66958. * @param images array of glTF image interfaces
  66959. * @param textures array of glTF texture interfaces
  66960. * @param materials array of glTF material interfaces
  66961. * @param imageData map of image file name to data
  66962. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66963. */
  66964. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66965. private setMetallicRoughnessPbrMaterial;
  66966. private getPixelsFromTexture;
  66967. /**
  66968. * Extracts a texture from a Babylon texture into file data and glTF data
  66969. * @param babylonTexture Babylon texture to extract
  66970. * @param mimeType Mime Type of the babylonTexture
  66971. * @return glTF texture info, or null if the texture format is not supported
  66972. */
  66973. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  66974. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  66975. /**
  66976. * Builds a texture from base64 string
  66977. * @param base64Texture base64 texture string
  66978. * @param baseTextureName Name to use for the texture
  66979. * @param mimeType image mime type for the texture
  66980. * @param images array of images
  66981. * @param textures array of textures
  66982. * @param imageData map of image data
  66983. * @returns glTF texture info, or null if the texture format is not supported
  66984. */
  66985. private _getTextureInfoFromBase64;
  66986. }
  66987. }
  66988. declare module BABYLON {
  66989. /**
  66990. * Class for holding and downloading glTF file data
  66991. */
  66992. export class GLTFData {
  66993. /**
  66994. * Object which contains the file name as the key and its data as the value
  66995. */
  66996. glTFFiles: {
  66997. [fileName: string]: string | Blob;
  66998. };
  66999. /**
  67000. * Initializes the glTF file object
  67001. */
  67002. constructor();
  67003. /**
  67004. * Downloads the glTF data as files based on their names and data
  67005. */
  67006. downloadFiles(): void;
  67007. }
  67008. }
  67009. declare module BABYLON {
  67010. /**
  67011. * Holds a collection of exporter options and parameters
  67012. */
  67013. export interface IExportOptions {
  67014. /**
  67015. * Function which indicates whether a babylon node should be exported or not
  67016. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  67017. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  67018. */
  67019. shouldExportNode?(node: Node): boolean;
  67020. /**
  67021. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  67022. * @param metadata source metadata to read from
  67023. * @returns the data to store to glTF node extras
  67024. */
  67025. metadataSelector?(metadata: any): any;
  67026. /**
  67027. * The sample rate to bake animation curves
  67028. */
  67029. animationSampleRate?: number;
  67030. /**
  67031. * Begin serialization without waiting for the scene to be ready
  67032. */
  67033. exportWithoutWaitingForScene?: boolean;
  67034. }
  67035. /**
  67036. * Class for generating glTF data from a Babylon scene.
  67037. */
  67038. export class GLTF2Export {
  67039. /**
  67040. * Exports the geometry of the scene to .gltf file format asynchronously
  67041. * @param scene Babylon scene with scene hierarchy information
  67042. * @param filePrefix File prefix to use when generating the glTF file
  67043. * @param options Exporter options
  67044. * @returns Returns an object with a .gltf file and associates texture names
  67045. * as keys and their data and paths as values
  67046. */
  67047. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  67048. private static _PreExportAsync;
  67049. private static _PostExportAsync;
  67050. /**
  67051. * Exports the geometry of the scene to .glb file format asychronously
  67052. * @param scene Babylon scene with scene hierarchy information
  67053. * @param filePrefix File prefix to use when generating glb file
  67054. * @param options Exporter options
  67055. * @returns Returns an object with a .glb filename as key and data as value
  67056. */
  67057. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  67058. }
  67059. }
  67060. declare module BABYLON.GLTF2.Exporter {
  67061. /**
  67062. * @hidden
  67063. */
  67064. export class _GLTFUtilities {
  67065. /**
  67066. * Creates a buffer view based on the supplied arguments
  67067. * @param bufferIndex index value of the specified buffer
  67068. * @param byteOffset byte offset value
  67069. * @param byteLength byte length of the bufferView
  67070. * @param byteStride byte distance between conequential elements
  67071. * @param name name of the buffer view
  67072. * @returns bufferView for glTF
  67073. */
  67074. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  67075. /**
  67076. * Creates an accessor based on the supplied arguments
  67077. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  67078. * @param name The name of the accessor
  67079. * @param type The type of the accessor
  67080. * @param componentType The datatype of components in the attribute
  67081. * @param count The number of attributes referenced by this accessor
  67082. * @param byteOffset The offset relative to the start of the bufferView in bytes
  67083. * @param min Minimum value of each component in this attribute
  67084. * @param max Maximum value of each component in this attribute
  67085. * @returns accessor for glTF
  67086. */
  67087. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  67088. /**
  67089. * Calculates the minimum and maximum values of an array of position floats
  67090. * @param positions Positions array of a mesh
  67091. * @param vertexStart Starting vertex offset to calculate min and max values
  67092. * @param vertexCount Number of vertices to check for min and max values
  67093. * @returns min number array and max number array
  67094. */
  67095. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  67096. min: number[];
  67097. max: number[];
  67098. };
  67099. /**
  67100. * Converts a new right-handed Vector3
  67101. * @param vector vector3 array
  67102. * @returns right-handed Vector3
  67103. */
  67104. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  67105. /**
  67106. * Converts a Vector3 to right-handed
  67107. * @param vector Vector3 to convert to right-handed
  67108. */
  67109. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  67110. /**
  67111. * Converts a three element number array to right-handed
  67112. * @param vector number array to convert to right-handed
  67113. */
  67114. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  67115. /**
  67116. * Converts a new right-handed Vector3
  67117. * @param vector vector3 array
  67118. * @returns right-handed Vector3
  67119. */
  67120. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  67121. /**
  67122. * Converts a Vector3 to right-handed
  67123. * @param vector Vector3 to convert to right-handed
  67124. */
  67125. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  67126. /**
  67127. * Converts a three element number array to right-handed
  67128. * @param vector number array to convert to right-handed
  67129. */
  67130. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  67131. /**
  67132. * Converts a Vector4 to right-handed
  67133. * @param vector Vector4 to convert to right-handed
  67134. */
  67135. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  67136. /**
  67137. * Converts a Vector4 to right-handed
  67138. * @param vector Vector4 to convert to right-handed
  67139. */
  67140. static _GetRightHandedArray4FromRef(vector: number[]): void;
  67141. /**
  67142. * Converts a Quaternion to right-handed
  67143. * @param quaternion Source quaternion to convert to right-handed
  67144. */
  67145. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  67146. /**
  67147. * Converts a Quaternion to right-handed
  67148. * @param quaternion Source quaternion to convert to right-handed
  67149. */
  67150. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  67151. static _NormalizeTangentFromRef(tangent: Vector4): void;
  67152. }
  67153. }
  67154. declare module BABYLON.GLTF2.Exporter {
  67155. /**
  67156. * Converts Babylon Scene into glTF 2.0.
  67157. * @hidden
  67158. */
  67159. export class _Exporter {
  67160. /**
  67161. * Stores the glTF to export
  67162. */
  67163. _glTF: IGLTF;
  67164. /**
  67165. * Stores all generated buffer views, which represents views into the main glTF buffer data
  67166. */
  67167. _bufferViews: IBufferView[];
  67168. /**
  67169. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  67170. */
  67171. _accessors: IAccessor[];
  67172. /**
  67173. * Stores all the generated nodes, which contains transform and/or mesh information per node
  67174. */
  67175. private _nodes;
  67176. /**
  67177. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  67178. */
  67179. private _scenes;
  67180. /**
  67181. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  67182. */
  67183. private _meshes;
  67184. /**
  67185. * Stores all the generated material information, which represents the appearance of each primitive
  67186. */
  67187. _materials: IMaterial[];
  67188. _materialMap: {
  67189. [materialID: number]: number;
  67190. };
  67191. /**
  67192. * Stores all the generated texture information, which is referenced by glTF materials
  67193. */
  67194. _textures: ITexture[];
  67195. /**
  67196. * Stores all the generated image information, which is referenced by glTF textures
  67197. */
  67198. _images: IImage[];
  67199. /**
  67200. * Stores all the texture samplers
  67201. */
  67202. _samplers: ISampler[];
  67203. /**
  67204. * Stores all the generated animation samplers, which is referenced by glTF animations
  67205. */
  67206. /**
  67207. * Stores the animations for glTF models
  67208. */
  67209. private _animations;
  67210. /**
  67211. * Stores the total amount of bytes stored in the glTF buffer
  67212. */
  67213. private _totalByteLength;
  67214. /**
  67215. * Stores a reference to the Babylon scene containing the source geometry and material information
  67216. */
  67217. _babylonScene: Scene;
  67218. /**
  67219. * Stores a map of the image data, where the key is the file name and the value
  67220. * is the image data
  67221. */
  67222. _imageData: {
  67223. [fileName: string]: {
  67224. data: Uint8Array;
  67225. mimeType: ImageMimeType;
  67226. };
  67227. };
  67228. /**
  67229. * Stores a map of the unique id of a node to its index in the node array
  67230. */
  67231. private _nodeMap;
  67232. /**
  67233. * Specifies if the Babylon scene should be converted to right-handed on export
  67234. */
  67235. _convertToRightHandedSystem: boolean;
  67236. /**
  67237. * Baked animation sample rate
  67238. */
  67239. private _animationSampleRate;
  67240. private _options;
  67241. private _localEngine;
  67242. _glTFMaterialExporter: _GLTFMaterialExporter;
  67243. private _extensions;
  67244. private static _ExtensionNames;
  67245. private static _ExtensionFactories;
  67246. private _applyExtensions;
  67247. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  67248. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  67249. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  67250. private _forEachExtensions;
  67251. private _extensionsOnExporting;
  67252. /**
  67253. * Load glTF serializer extensions
  67254. */
  67255. private _loadExtensions;
  67256. /**
  67257. * Creates a glTF Exporter instance, which can accept optional exporter options
  67258. * @param babylonScene Babylon scene object
  67259. * @param options Options to modify the behavior of the exporter
  67260. */
  67261. constructor(babylonScene: Scene, options?: IExportOptions);
  67262. /**
  67263. * Registers a glTF exporter extension
  67264. * @param name Name of the extension to export
  67265. * @param factory The factory function that creates the exporter extension
  67266. */
  67267. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  67268. /**
  67269. * Un-registers an exporter extension
  67270. * @param name The name fo the exporter extension
  67271. * @returns A boolean indicating whether the extension has been un-registered
  67272. */
  67273. static UnregisterExtension(name: string): boolean;
  67274. /**
  67275. * Lazy load a local engine with premultiplied alpha set to false
  67276. */
  67277. _getLocalEngine(): Engine;
  67278. private reorderIndicesBasedOnPrimitiveMode;
  67279. /**
  67280. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  67281. * clock-wise during export to glTF
  67282. * @param submesh BabylonJS submesh
  67283. * @param primitiveMode Primitive mode of the mesh
  67284. * @param sideOrientation the winding order of the submesh
  67285. * @param vertexBufferKind The type of vertex attribute
  67286. * @param meshAttributeArray The vertex attribute data
  67287. * @param byteOffset The offset to the binary data
  67288. * @param binaryWriter The binary data for the glTF file
  67289. */
  67290. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  67291. /**
  67292. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  67293. * clock-wise during export to glTF
  67294. * @param submesh BabylonJS submesh
  67295. * @param primitiveMode Primitive mode of the mesh
  67296. * @param sideOrientation the winding order of the submesh
  67297. * @param vertexBufferKind The type of vertex attribute
  67298. * @param meshAttributeArray The vertex attribute data
  67299. * @param byteOffset The offset to the binary data
  67300. * @param binaryWriter The binary data for the glTF file
  67301. */
  67302. private reorderTriangleFillMode;
  67303. /**
  67304. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  67305. * clock-wise during export to glTF
  67306. * @param submesh BabylonJS submesh
  67307. * @param primitiveMode Primitive mode of the mesh
  67308. * @param sideOrientation the winding order of the submesh
  67309. * @param vertexBufferKind The type of vertex attribute
  67310. * @param meshAttributeArray The vertex attribute data
  67311. * @param byteOffset The offset to the binary data
  67312. * @param binaryWriter The binary data for the glTF file
  67313. */
  67314. private reorderTriangleStripDrawMode;
  67315. /**
  67316. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  67317. * clock-wise during export to glTF
  67318. * @param submesh BabylonJS submesh
  67319. * @param primitiveMode Primitive mode of the mesh
  67320. * @param sideOrientation the winding order of the submesh
  67321. * @param vertexBufferKind The type of vertex attribute
  67322. * @param meshAttributeArray The vertex attribute data
  67323. * @param byteOffset The offset to the binary data
  67324. * @param binaryWriter The binary data for the glTF file
  67325. */
  67326. private reorderTriangleFanMode;
  67327. /**
  67328. * Writes the vertex attribute data to binary
  67329. * @param vertices The vertices to write to the binary writer
  67330. * @param byteOffset The offset into the binary writer to overwrite binary data
  67331. * @param vertexAttributeKind The vertex attribute type
  67332. * @param meshAttributeArray The vertex attribute data
  67333. * @param binaryWriter The writer containing the binary data
  67334. */
  67335. private writeVertexAttributeData;
  67336. /**
  67337. * Writes mesh attribute data to a data buffer
  67338. * Returns the bytelength of the data
  67339. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  67340. * @param meshAttributeArray Array containing the attribute data
  67341. * @param binaryWriter The buffer to write the binary data to
  67342. * @param indices Used to specify the order of the vertex data
  67343. */
  67344. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  67345. /**
  67346. * Generates glTF json data
  67347. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  67348. * @param glTFPrefix Text to use when prefixing a glTF file
  67349. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  67350. * @returns json data as string
  67351. */
  67352. private generateJSON;
  67353. /**
  67354. * Generates data for .gltf and .bin files based on the glTF prefix string
  67355. * @param glTFPrefix Text to use when prefixing a glTF file
  67356. * @returns GLTFData with glTF file data
  67357. */
  67358. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  67359. /**
  67360. * Creates a binary buffer for glTF
  67361. * @returns array buffer for binary data
  67362. */
  67363. private _generateBinaryAsync;
  67364. /**
  67365. * Pads the number to a multiple of 4
  67366. * @param num number to pad
  67367. * @returns padded number
  67368. */
  67369. private _getPadding;
  67370. /**
  67371. * Generates a glb file from the json and binary data
  67372. * Returns an object with the glb file name as the key and data as the value
  67373. * @param glTFPrefix
  67374. * @returns object with glb filename as key and data as value
  67375. */
  67376. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  67377. /**
  67378. * Sets the TRS for each node
  67379. * @param node glTF Node for storing the transformation data
  67380. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  67381. */
  67382. private setNodeTransformation;
  67383. private getVertexBufferFromMesh;
  67384. /**
  67385. * Creates a bufferview based on the vertices type for the Babylon mesh
  67386. * @param kind Indicates the type of vertices data
  67387. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  67388. * @param binaryWriter The buffer to write the bufferview data to
  67389. */
  67390. private createBufferViewKind;
  67391. /**
  67392. * The primitive mode of the Babylon mesh
  67393. * @param babylonMesh The BabylonJS mesh
  67394. */
  67395. private getMeshPrimitiveMode;
  67396. /**
  67397. * Sets the primitive mode of the glTF mesh primitive
  67398. * @param meshPrimitive glTF mesh primitive
  67399. * @param primitiveMode The primitive mode
  67400. */
  67401. private setPrimitiveMode;
  67402. /**
  67403. * Sets the vertex attribute accessor based of the glTF mesh primitive
  67404. * @param meshPrimitive glTF mesh primitive
  67405. * @param attributeKind vertex attribute
  67406. * @returns boolean specifying if uv coordinates are present
  67407. */
  67408. private setAttributeKind;
  67409. /**
  67410. * Sets data for the primitive attributes of each submesh
  67411. * @param mesh glTF Mesh object to store the primitive attribute information
  67412. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  67413. * @param binaryWriter Buffer to write the attribute data to
  67414. */
  67415. private setPrimitiveAttributesAsync;
  67416. /**
  67417. * Creates a glTF scene based on the array of meshes
  67418. * Returns the the total byte offset
  67419. * @param babylonScene Babylon scene to get the mesh data from
  67420. * @param binaryWriter Buffer to write binary data to
  67421. */
  67422. private createSceneAsync;
  67423. /**
  67424. * Creates a mapping of Node unique id to node index and handles animations
  67425. * @param babylonScene Babylon Scene
  67426. * @param nodes Babylon transform nodes
  67427. * @param binaryWriter Buffer to write binary data to
  67428. * @returns Node mapping of unique id to index
  67429. */
  67430. private createNodeMapAndAnimationsAsync;
  67431. /**
  67432. * Creates a glTF node from a Babylon mesh
  67433. * @param babylonMesh Source Babylon mesh
  67434. * @param binaryWriter Buffer for storing geometry data
  67435. * @returns glTF node
  67436. */
  67437. private createNodeAsync;
  67438. }
  67439. /**
  67440. * @hidden
  67441. *
  67442. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  67443. */
  67444. export class _BinaryWriter {
  67445. /**
  67446. * Array buffer which stores all binary data
  67447. */
  67448. private _arrayBuffer;
  67449. /**
  67450. * View of the array buffer
  67451. */
  67452. private _dataView;
  67453. /**
  67454. * byte offset of data in array buffer
  67455. */
  67456. private _byteOffset;
  67457. /**
  67458. * Initialize binary writer with an initial byte length
  67459. * @param byteLength Initial byte length of the array buffer
  67460. */
  67461. constructor(byteLength: number);
  67462. /**
  67463. * Resize the array buffer to the specified byte length
  67464. * @param byteLength
  67465. */
  67466. private resizeBuffer;
  67467. /**
  67468. * Get an array buffer with the length of the byte offset
  67469. * @returns ArrayBuffer resized to the byte offset
  67470. */
  67471. getArrayBuffer(): ArrayBuffer;
  67472. /**
  67473. * Get the byte offset of the array buffer
  67474. * @returns byte offset
  67475. */
  67476. getByteOffset(): number;
  67477. /**
  67478. * Stores an UInt8 in the array buffer
  67479. * @param entry
  67480. * @param byteOffset If defined, specifies where to set the value as an offset.
  67481. */
  67482. setUInt8(entry: number, byteOffset?: number): void;
  67483. /**
  67484. * Gets an UInt32 in the array buffer
  67485. * @param entry
  67486. * @param byteOffset If defined, specifies where to set the value as an offset.
  67487. */
  67488. getUInt32(byteOffset: number): number;
  67489. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  67490. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  67491. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  67492. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  67493. /**
  67494. * Stores a Float32 in the array buffer
  67495. * @param entry
  67496. */
  67497. setFloat32(entry: number, byteOffset?: number): void;
  67498. /**
  67499. * Stores an UInt32 in the array buffer
  67500. * @param entry
  67501. * @param byteOffset If defined, specifies where to set the value as an offset.
  67502. */
  67503. setUInt32(entry: number, byteOffset?: number): void;
  67504. }
  67505. }
  67506. declare module BABYLON.GLTF2.Exporter {
  67507. /**
  67508. * @hidden
  67509. * Interface to store animation data.
  67510. */
  67511. export interface _IAnimationData {
  67512. /**
  67513. * Keyframe data.
  67514. */
  67515. inputs: number[];
  67516. /**
  67517. * Value data.
  67518. */
  67519. outputs: number[][];
  67520. /**
  67521. * Animation interpolation data.
  67522. */
  67523. samplerInterpolation: AnimationSamplerInterpolation;
  67524. /**
  67525. * Minimum keyframe value.
  67526. */
  67527. inputsMin: number;
  67528. /**
  67529. * Maximum keyframe value.
  67530. */
  67531. inputsMax: number;
  67532. }
  67533. /**
  67534. * @hidden
  67535. */
  67536. export interface _IAnimationInfo {
  67537. /**
  67538. * The target channel for the animation
  67539. */
  67540. animationChannelTargetPath: AnimationChannelTargetPath;
  67541. /**
  67542. * The glTF accessor type for the data.
  67543. */
  67544. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  67545. /**
  67546. * Specifies if quaternions should be used.
  67547. */
  67548. useQuaternion: boolean;
  67549. }
  67550. /**
  67551. * @hidden
  67552. * Utility class for generating glTF animation data from BabylonJS.
  67553. */
  67554. export class _GLTFAnimation {
  67555. /**
  67556. * @ignore
  67557. *
  67558. * Creates glTF channel animation from BabylonJS animation.
  67559. * @param babylonTransformNode - BabylonJS mesh.
  67560. * @param animation - animation.
  67561. * @param animationChannelTargetPath - The target animation channel.
  67562. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  67563. * @param useQuaternion - Specifies if quaternions are used.
  67564. * @returns nullable IAnimationData
  67565. */
  67566. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  67567. private static _DeduceAnimationInfo;
  67568. /**
  67569. * @ignore
  67570. * Create node animations from the transform node animations
  67571. * @param babylonNode
  67572. * @param runtimeGLTFAnimation
  67573. * @param idleGLTFAnimations
  67574. * @param nodeMap
  67575. * @param nodes
  67576. * @param binaryWriter
  67577. * @param bufferViews
  67578. * @param accessors
  67579. * @param convertToRightHandedSystem
  67580. */
  67581. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  67582. [key: number]: number;
  67583. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  67584. /**
  67585. * @ignore
  67586. * Create node animations from the animation groups
  67587. * @param babylonScene
  67588. * @param glTFAnimations
  67589. * @param nodeMap
  67590. * @param nodes
  67591. * @param binaryWriter
  67592. * @param bufferViews
  67593. * @param accessors
  67594. * @param convertToRightHandedSystem
  67595. */
  67596. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  67597. [key: number]: number;
  67598. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  67599. private static AddAnimation;
  67600. /**
  67601. * Create a baked animation
  67602. * @param babylonTransformNode BabylonJS mesh
  67603. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  67604. * @param animationChannelTargetPath animation target channel
  67605. * @param minFrame minimum animation frame
  67606. * @param maxFrame maximum animation frame
  67607. * @param fps frames per second of the animation
  67608. * @param inputs input key frames of the animation
  67609. * @param outputs output key frame data of the animation
  67610. * @param convertToRightHandedSystem converts the values to right-handed
  67611. * @param useQuaternion specifies if quaternions should be used
  67612. */
  67613. private static _CreateBakedAnimation;
  67614. private static _ConvertFactorToVector3OrQuaternion;
  67615. private static _SetInterpolatedValue;
  67616. /**
  67617. * Creates linear animation from the animation key frames
  67618. * @param babylonTransformNode BabylonJS mesh
  67619. * @param animation BabylonJS animation
  67620. * @param animationChannelTargetPath The target animation channel
  67621. * @param frameDelta The difference between the last and first frame of the animation
  67622. * @param inputs Array to store the key frame times
  67623. * @param outputs Array to store the key frame data
  67624. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  67625. * @param useQuaternion Specifies if quaternions are used in the animation
  67626. */
  67627. private static _CreateLinearOrStepAnimation;
  67628. /**
  67629. * Creates cubic spline animation from the animation key frames
  67630. * @param babylonTransformNode BabylonJS mesh
  67631. * @param animation BabylonJS animation
  67632. * @param animationChannelTargetPath The target animation channel
  67633. * @param frameDelta The difference between the last and first frame of the animation
  67634. * @param inputs Array to store the key frame times
  67635. * @param outputs Array to store the key frame data
  67636. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  67637. * @param useQuaternion Specifies if quaternions are used in the animation
  67638. */
  67639. private static _CreateCubicSplineAnimation;
  67640. private static _GetBasePositionRotationOrScale;
  67641. /**
  67642. * Adds a key frame value
  67643. * @param keyFrame
  67644. * @param animation
  67645. * @param outputs
  67646. * @param animationChannelTargetPath
  67647. * @param basePositionRotationOrScale
  67648. * @param convertToRightHandedSystem
  67649. * @param useQuaternion
  67650. */
  67651. private static _AddKeyframeValue;
  67652. /**
  67653. * Determine the interpolation based on the key frames
  67654. * @param keyFrames
  67655. * @param animationChannelTargetPath
  67656. * @param useQuaternion
  67657. */
  67658. private static _DeduceInterpolation;
  67659. /**
  67660. * Adds an input tangent or output tangent to the output data
  67661. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  67662. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  67663. * @param outputs The animation data by keyframe
  67664. * @param animationChannelTargetPath The target animation channel
  67665. * @param interpolation The interpolation type
  67666. * @param keyFrame The key frame with the animation data
  67667. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  67668. * @param useQuaternion Specifies if quaternions are used
  67669. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  67670. */
  67671. private static AddSplineTangent;
  67672. /**
  67673. * Get the minimum and maximum key frames' frame values
  67674. * @param keyFrames animation key frames
  67675. * @returns the minimum and maximum key frame value
  67676. */
  67677. private static calculateMinMaxKeyFrames;
  67678. }
  67679. }
  67680. declare module BABYLON.GLTF2.Exporter {
  67681. /** @hidden */
  67682. export var textureTransformPixelShader: {
  67683. name: string;
  67684. shader: string;
  67685. };
  67686. }
  67687. declare module BABYLON.GLTF2.Exporter.Extensions {
  67688. /**
  67689. * @hidden
  67690. */
  67691. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  67692. /** Name of this extension */
  67693. readonly name: string;
  67694. /** Defines whether this extension is enabled */
  67695. enabled: boolean;
  67696. /** Defines whether this extension is required */
  67697. required: boolean;
  67698. /** Reference to the glTF exporter */
  67699. private _exporter;
  67700. constructor(exporter: _Exporter);
  67701. dispose(): void;
  67702. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  67703. /**
  67704. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  67705. * @param babylonTexture
  67706. * @param offset
  67707. * @param rotation
  67708. * @param scale
  67709. * @param scene
  67710. */
  67711. private _textureTransformTextureAsync;
  67712. }
  67713. }
  67714. declare module BABYLON.GLTF2.Exporter.Extensions {
  67715. /**
  67716. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  67717. */
  67718. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  67719. /** The name of this extension. */
  67720. readonly name: string;
  67721. /** Defines whether this extension is enabled. */
  67722. enabled: boolean;
  67723. /** Defines whether this extension is required */
  67724. required: boolean;
  67725. /** Reference to the glTF exporter */
  67726. private _exporter;
  67727. private _lights;
  67728. /** @hidden */
  67729. constructor(exporter: _Exporter);
  67730. /** @hidden */
  67731. dispose(): void;
  67732. /** @hidden */
  67733. onExporting(): void;
  67734. /**
  67735. * Define this method to modify the default behavior when exporting a node
  67736. * @param context The context when exporting the node
  67737. * @param node glTF node
  67738. * @param babylonNode BabylonJS node
  67739. * @returns nullable INode promise
  67740. */
  67741. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  67742. }
  67743. }
  67744. declare module BABYLON {
  67745. /**
  67746. * Class for generating STL data from a Babylon scene.
  67747. */
  67748. export class STLExport {
  67749. /**
  67750. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  67751. * @param meshes list defines the mesh to serialize
  67752. * @param download triggers the automatic download of the file.
  67753. * @param fileName changes the downloads fileName.
  67754. * @param binary changes the STL to a binary type.
  67755. * @param isLittleEndian toggle for binary type exporter.
  67756. * @returns the STL as UTF8 string
  67757. */
  67758. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  67759. }
  67760. }
  67761. /**
  67762. * @ignoreChildren
  67763. * @ignore
  67764. */
  67765. declare module "babylonjs-gltf2interface" {
  67766. export = BABYLON.GLTF2;
  67767. }
  67768. /**
  67769. * Module for glTF 2.0 Interface
  67770. * @ignoreChildren
  67771. * @ignore
  67772. */
  67773. declare module BABYLON.GLTF2 {
  67774. /**
  67775. * The datatype of the components in the attribute
  67776. */
  67777. const enum AccessorComponentType {
  67778. /**
  67779. * Byte
  67780. */
  67781. BYTE = 5120,
  67782. /**
  67783. * Unsigned Byte
  67784. */
  67785. UNSIGNED_BYTE = 5121,
  67786. /**
  67787. * Short
  67788. */
  67789. SHORT = 5122,
  67790. /**
  67791. * Unsigned Short
  67792. */
  67793. UNSIGNED_SHORT = 5123,
  67794. /**
  67795. * Unsigned Int
  67796. */
  67797. UNSIGNED_INT = 5125,
  67798. /**
  67799. * Float
  67800. */
  67801. FLOAT = 5126,
  67802. }
  67803. /**
  67804. * Specifies if the attirbute is a scalar, vector, or matrix
  67805. */
  67806. const enum AccessorType {
  67807. /**
  67808. * Scalar
  67809. */
  67810. SCALAR = "SCALAR",
  67811. /**
  67812. * Vector2
  67813. */
  67814. VEC2 = "VEC2",
  67815. /**
  67816. * Vector3
  67817. */
  67818. VEC3 = "VEC3",
  67819. /**
  67820. * Vector4
  67821. */
  67822. VEC4 = "VEC4",
  67823. /**
  67824. * Matrix2x2
  67825. */
  67826. MAT2 = "MAT2",
  67827. /**
  67828. * Matrix3x3
  67829. */
  67830. MAT3 = "MAT3",
  67831. /**
  67832. * Matrix4x4
  67833. */
  67834. MAT4 = "MAT4",
  67835. }
  67836. /**
  67837. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  67838. */
  67839. const enum AnimationChannelTargetPath {
  67840. /**
  67841. * Translation
  67842. */
  67843. TRANSLATION = "translation",
  67844. /**
  67845. * Rotation
  67846. */
  67847. ROTATION = "rotation",
  67848. /**
  67849. * Scale
  67850. */
  67851. SCALE = "scale",
  67852. /**
  67853. * Weights
  67854. */
  67855. WEIGHTS = "weights",
  67856. }
  67857. /**
  67858. * Interpolation algorithm
  67859. */
  67860. const enum AnimationSamplerInterpolation {
  67861. /**
  67862. * The animated values are linearly interpolated between keyframes
  67863. */
  67864. LINEAR = "LINEAR",
  67865. /**
  67866. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  67867. */
  67868. STEP = "STEP",
  67869. /**
  67870. * The animation's interpolation is computed using a cubic spline with specified tangents
  67871. */
  67872. CUBICSPLINE = "CUBICSPLINE",
  67873. }
  67874. /**
  67875. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  67876. */
  67877. const enum CameraType {
  67878. /**
  67879. * A perspective camera containing properties to create a perspective projection matrix
  67880. */
  67881. PERSPECTIVE = "perspective",
  67882. /**
  67883. * An orthographic camera containing properties to create an orthographic projection matrix
  67884. */
  67885. ORTHOGRAPHIC = "orthographic",
  67886. }
  67887. /**
  67888. * The mime-type of the image
  67889. */
  67890. const enum ImageMimeType {
  67891. /**
  67892. * JPEG Mime-type
  67893. */
  67894. JPEG = "image/jpeg",
  67895. /**
  67896. * PNG Mime-type
  67897. */
  67898. PNG = "image/png",
  67899. }
  67900. /**
  67901. * The alpha rendering mode of the material
  67902. */
  67903. const enum MaterialAlphaMode {
  67904. /**
  67905. * The alpha value is ignored and the rendered output is fully opaque
  67906. */
  67907. OPAQUE = "OPAQUE",
  67908. /**
  67909. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  67910. */
  67911. MASK = "MASK",
  67912. /**
  67913. * 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)
  67914. */
  67915. BLEND = "BLEND",
  67916. }
  67917. /**
  67918. * The type of the primitives to render
  67919. */
  67920. const enum MeshPrimitiveMode {
  67921. /**
  67922. * Points
  67923. */
  67924. POINTS = 0,
  67925. /**
  67926. * Lines
  67927. */
  67928. LINES = 1,
  67929. /**
  67930. * Line Loop
  67931. */
  67932. LINE_LOOP = 2,
  67933. /**
  67934. * Line Strip
  67935. */
  67936. LINE_STRIP = 3,
  67937. /**
  67938. * Triangles
  67939. */
  67940. TRIANGLES = 4,
  67941. /**
  67942. * Triangle Strip
  67943. */
  67944. TRIANGLE_STRIP = 5,
  67945. /**
  67946. * Triangle Fan
  67947. */
  67948. TRIANGLE_FAN = 6,
  67949. }
  67950. /**
  67951. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  67952. */
  67953. const enum TextureMagFilter {
  67954. /**
  67955. * Nearest
  67956. */
  67957. NEAREST = 9728,
  67958. /**
  67959. * Linear
  67960. */
  67961. LINEAR = 9729,
  67962. }
  67963. /**
  67964. * Minification filter. All valid values correspond to WebGL enums
  67965. */
  67966. const enum TextureMinFilter {
  67967. /**
  67968. * Nearest
  67969. */
  67970. NEAREST = 9728,
  67971. /**
  67972. * Linear
  67973. */
  67974. LINEAR = 9729,
  67975. /**
  67976. * Nearest Mip-Map Nearest
  67977. */
  67978. NEAREST_MIPMAP_NEAREST = 9984,
  67979. /**
  67980. * Linear Mipmap Nearest
  67981. */
  67982. LINEAR_MIPMAP_NEAREST = 9985,
  67983. /**
  67984. * Nearest Mipmap Linear
  67985. */
  67986. NEAREST_MIPMAP_LINEAR = 9986,
  67987. /**
  67988. * Linear Mipmap Linear
  67989. */
  67990. LINEAR_MIPMAP_LINEAR = 9987,
  67991. }
  67992. /**
  67993. * S (U) wrapping mode. All valid values correspond to WebGL enums
  67994. */
  67995. const enum TextureWrapMode {
  67996. /**
  67997. * Clamp to Edge
  67998. */
  67999. CLAMP_TO_EDGE = 33071,
  68000. /**
  68001. * Mirrored Repeat
  68002. */
  68003. MIRRORED_REPEAT = 33648,
  68004. /**
  68005. * Repeat
  68006. */
  68007. REPEAT = 10497,
  68008. }
  68009. /**
  68010. * glTF Property
  68011. */
  68012. interface IProperty {
  68013. /**
  68014. * Dictionary object with extension-specific objects
  68015. */
  68016. extensions?: {
  68017. [key: string]: any;
  68018. };
  68019. /**
  68020. * Application-Specific data
  68021. */
  68022. extras?: any;
  68023. }
  68024. /**
  68025. * glTF Child of Root Property
  68026. */
  68027. interface IChildRootProperty extends IProperty {
  68028. /**
  68029. * The user-defined name of this object
  68030. */
  68031. name?: string;
  68032. }
  68033. /**
  68034. * Indices of those attributes that deviate from their initialization value
  68035. */
  68036. interface IAccessorSparseIndices extends IProperty {
  68037. /**
  68038. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  68039. */
  68040. bufferView: number;
  68041. /**
  68042. * The offset relative to the start of the bufferView in bytes. Must be aligned
  68043. */
  68044. byteOffset?: number;
  68045. /**
  68046. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  68047. */
  68048. componentType: AccessorComponentType;
  68049. }
  68050. /**
  68051. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  68052. */
  68053. interface IAccessorSparseValues extends IProperty {
  68054. /**
  68055. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  68056. */
  68057. bufferView: number;
  68058. /**
  68059. * The offset relative to the start of the bufferView in bytes. Must be aligned
  68060. */
  68061. byteOffset?: number;
  68062. }
  68063. /**
  68064. * Sparse storage of attributes that deviate from their initialization value
  68065. */
  68066. interface IAccessorSparse extends IProperty {
  68067. /**
  68068. * The number of attributes encoded in this sparse accessor
  68069. */
  68070. count: number;
  68071. /**
  68072. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  68073. */
  68074. indices: IAccessorSparseIndices;
  68075. /**
  68076. * 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
  68077. */
  68078. values: IAccessorSparseValues;
  68079. }
  68080. /**
  68081. * 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
  68082. */
  68083. interface IAccessor extends IChildRootProperty {
  68084. /**
  68085. * The index of the bufferview
  68086. */
  68087. bufferView?: number;
  68088. /**
  68089. * The offset relative to the start of the bufferView in bytes
  68090. */
  68091. byteOffset?: number;
  68092. /**
  68093. * The datatype of components in the attribute
  68094. */
  68095. componentType: AccessorComponentType;
  68096. /**
  68097. * Specifies whether integer data values should be normalized
  68098. */
  68099. normalized?: boolean;
  68100. /**
  68101. * The number of attributes referenced by this accessor
  68102. */
  68103. count: number;
  68104. /**
  68105. * Specifies if the attribute is a scalar, vector, or matrix
  68106. */
  68107. type: AccessorType;
  68108. /**
  68109. * Maximum value of each component in this attribute
  68110. */
  68111. max?: number[];
  68112. /**
  68113. * Minimum value of each component in this attribute
  68114. */
  68115. min?: number[];
  68116. /**
  68117. * Sparse storage of attributes that deviate from their initialization value
  68118. */
  68119. sparse?: IAccessorSparse;
  68120. }
  68121. /**
  68122. * Targets an animation's sampler at a node's property
  68123. */
  68124. interface IAnimationChannel extends IProperty {
  68125. /**
  68126. * The index of a sampler in this animation used to compute the value for the target
  68127. */
  68128. sampler: number;
  68129. /**
  68130. * The index of the node and TRS property to target
  68131. */
  68132. target: IAnimationChannelTarget;
  68133. }
  68134. /**
  68135. * The index of the node and TRS property that an animation channel targets
  68136. */
  68137. interface IAnimationChannelTarget extends IProperty {
  68138. /**
  68139. * The index of the node to target
  68140. */
  68141. node: number;
  68142. /**
  68143. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  68144. */
  68145. path: AnimationChannelTargetPath;
  68146. }
  68147. /**
  68148. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  68149. */
  68150. interface IAnimationSampler extends IProperty {
  68151. /**
  68152. * The index of an accessor containing keyframe input values, e.g., time
  68153. */
  68154. input: number;
  68155. /**
  68156. * Interpolation algorithm
  68157. */
  68158. interpolation?: AnimationSamplerInterpolation;
  68159. /**
  68160. * The index of an accessor, containing keyframe output values
  68161. */
  68162. output: number;
  68163. }
  68164. /**
  68165. * A keyframe animation
  68166. */
  68167. interface IAnimation extends IChildRootProperty {
  68168. /**
  68169. * An array of channels, each of which targets an animation's sampler at a node's property
  68170. */
  68171. channels: IAnimationChannel[];
  68172. /**
  68173. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  68174. */
  68175. samplers: IAnimationSampler[];
  68176. }
  68177. /**
  68178. * Metadata about the glTF asset
  68179. */
  68180. interface IAsset extends IChildRootProperty {
  68181. /**
  68182. * A copyright message suitable for display to credit the content creator
  68183. */
  68184. copyright?: string;
  68185. /**
  68186. * Tool that generated this glTF model. Useful for debugging
  68187. */
  68188. generator?: string;
  68189. /**
  68190. * The glTF version that this asset targets
  68191. */
  68192. version: string;
  68193. /**
  68194. * The minimum glTF version that this asset targets
  68195. */
  68196. minVersion?: string;
  68197. }
  68198. /**
  68199. * A buffer points to binary geometry, animation, or skins
  68200. */
  68201. interface IBuffer extends IChildRootProperty {
  68202. /**
  68203. * 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
  68204. */
  68205. uri?: string;
  68206. /**
  68207. * The length of the buffer in bytes
  68208. */
  68209. byteLength: number;
  68210. }
  68211. /**
  68212. * A view into a buffer generally representing a subset of the buffer
  68213. */
  68214. interface IBufferView extends IChildRootProperty {
  68215. /**
  68216. * The index of the buffer
  68217. */
  68218. buffer: number;
  68219. /**
  68220. * The offset into the buffer in bytes
  68221. */
  68222. byteOffset?: number;
  68223. /**
  68224. * The lenth of the bufferView in bytes
  68225. */
  68226. byteLength: number;
  68227. /**
  68228. * The stride, in bytes
  68229. */
  68230. byteStride?: number;
  68231. }
  68232. /**
  68233. * An orthographic camera containing properties to create an orthographic projection matrix
  68234. */
  68235. interface ICameraOrthographic extends IProperty {
  68236. /**
  68237. * The floating-point horizontal magnification of the view. Must not be zero
  68238. */
  68239. xmag: number;
  68240. /**
  68241. * The floating-point vertical magnification of the view. Must not be zero
  68242. */
  68243. ymag: number;
  68244. /**
  68245. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  68246. */
  68247. zfar: number;
  68248. /**
  68249. * The floating-point distance to the near clipping plane
  68250. */
  68251. znear: number;
  68252. }
  68253. /**
  68254. * A perspective camera containing properties to create a perspective projection matrix
  68255. */
  68256. interface ICameraPerspective extends IProperty {
  68257. /**
  68258. * The floating-point aspect ratio of the field of view
  68259. */
  68260. aspectRatio?: number;
  68261. /**
  68262. * The floating-point vertical field of view in radians
  68263. */
  68264. yfov: number;
  68265. /**
  68266. * The floating-point distance to the far clipping plane
  68267. */
  68268. zfar?: number;
  68269. /**
  68270. * The floating-point distance to the near clipping plane
  68271. */
  68272. znear: number;
  68273. }
  68274. /**
  68275. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  68276. */
  68277. interface ICamera extends IChildRootProperty {
  68278. /**
  68279. * An orthographic camera containing properties to create an orthographic projection matrix
  68280. */
  68281. orthographic?: ICameraOrthographic;
  68282. /**
  68283. * A perspective camera containing properties to create a perspective projection matrix
  68284. */
  68285. perspective?: ICameraPerspective;
  68286. /**
  68287. * Specifies if the camera uses a perspective or orthographic projection
  68288. */
  68289. type: CameraType;
  68290. }
  68291. /**
  68292. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  68293. */
  68294. interface IImage extends IChildRootProperty {
  68295. /**
  68296. * 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
  68297. */
  68298. uri?: string;
  68299. /**
  68300. * The image's MIME type
  68301. */
  68302. mimeType?: ImageMimeType;
  68303. /**
  68304. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  68305. */
  68306. bufferView?: number;
  68307. }
  68308. /**
  68309. * Material Normal Texture Info
  68310. */
  68311. interface IMaterialNormalTextureInfo extends ITextureInfo {
  68312. /**
  68313. * The scalar multiplier applied to each normal vector of the normal texture
  68314. */
  68315. scale?: number;
  68316. }
  68317. /**
  68318. * Material Occlusion Texture Info
  68319. */
  68320. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  68321. /**
  68322. * A scalar multiplier controlling the amount of occlusion applied
  68323. */
  68324. strength?: number;
  68325. }
  68326. /**
  68327. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  68328. */
  68329. interface IMaterialPbrMetallicRoughness {
  68330. /**
  68331. * The material's base color factor
  68332. */
  68333. baseColorFactor?: number[];
  68334. /**
  68335. * The base color texture
  68336. */
  68337. baseColorTexture?: ITextureInfo;
  68338. /**
  68339. * The metalness of the material
  68340. */
  68341. metallicFactor?: number;
  68342. /**
  68343. * The roughness of the material
  68344. */
  68345. roughnessFactor?: number;
  68346. /**
  68347. * The metallic-roughness texture
  68348. */
  68349. metallicRoughnessTexture?: ITextureInfo;
  68350. }
  68351. /**
  68352. * The material appearance of a primitive
  68353. */
  68354. interface IMaterial extends IChildRootProperty {
  68355. /**
  68356. * 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
  68357. */
  68358. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  68359. /**
  68360. * The normal map texture
  68361. */
  68362. normalTexture?: IMaterialNormalTextureInfo;
  68363. /**
  68364. * The occlusion map texture
  68365. */
  68366. occlusionTexture?: IMaterialOcclusionTextureInfo;
  68367. /**
  68368. * The emissive map texture
  68369. */
  68370. emissiveTexture?: ITextureInfo;
  68371. /**
  68372. * 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
  68373. */
  68374. emissiveFactor?: number[];
  68375. /**
  68376. * The alpha rendering mode of the material
  68377. */
  68378. alphaMode?: MaterialAlphaMode;
  68379. /**
  68380. * The alpha cutoff value of the material
  68381. */
  68382. alphaCutoff?: number;
  68383. /**
  68384. * Specifies whether the material is double sided
  68385. */
  68386. doubleSided?: boolean;
  68387. }
  68388. /**
  68389. * Geometry to be rendered with the given material
  68390. */
  68391. interface IMeshPrimitive extends IProperty {
  68392. /**
  68393. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  68394. */
  68395. attributes: {
  68396. [name: string]: number;
  68397. };
  68398. /**
  68399. * The index of the accessor that contains the indices
  68400. */
  68401. indices?: number;
  68402. /**
  68403. * The index of the material to apply to this primitive when rendering
  68404. */
  68405. material?: number;
  68406. /**
  68407. * The type of primitives to render. All valid values correspond to WebGL enums
  68408. */
  68409. mode?: MeshPrimitiveMode;
  68410. /**
  68411. * 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
  68412. */
  68413. targets?: {
  68414. [name: string]: number;
  68415. }[];
  68416. }
  68417. /**
  68418. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  68419. */
  68420. interface IMesh extends IChildRootProperty {
  68421. /**
  68422. * An array of primitives, each defining geometry to be rendered with a material
  68423. */
  68424. primitives: IMeshPrimitive[];
  68425. /**
  68426. * Array of weights to be applied to the Morph Targets
  68427. */
  68428. weights?: number[];
  68429. }
  68430. /**
  68431. * A node in the node hierarchy
  68432. */
  68433. interface INode extends IChildRootProperty {
  68434. /**
  68435. * The index of the camera referenced by this node
  68436. */
  68437. camera?: number;
  68438. /**
  68439. * The indices of this node's children
  68440. */
  68441. children?: number[];
  68442. /**
  68443. * The index of the skin referenced by this node
  68444. */
  68445. skin?: number;
  68446. /**
  68447. * A floating-point 4x4 transformation matrix stored in column-major order
  68448. */
  68449. matrix?: number[];
  68450. /**
  68451. * The index of the mesh in this node
  68452. */
  68453. mesh?: number;
  68454. /**
  68455. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  68456. */
  68457. rotation?: number[];
  68458. /**
  68459. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  68460. */
  68461. scale?: number[];
  68462. /**
  68463. * The node's translation along the x, y, and z axes
  68464. */
  68465. translation?: number[];
  68466. /**
  68467. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  68468. */
  68469. weights?: number[];
  68470. }
  68471. /**
  68472. * Texture sampler properties for filtering and wrapping modes
  68473. */
  68474. interface ISampler extends IChildRootProperty {
  68475. /**
  68476. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  68477. */
  68478. magFilter?: TextureMagFilter;
  68479. /**
  68480. * Minification filter. All valid values correspond to WebGL enums
  68481. */
  68482. minFilter?: TextureMinFilter;
  68483. /**
  68484. * S (U) wrapping mode. All valid values correspond to WebGL enums
  68485. */
  68486. wrapS?: TextureWrapMode;
  68487. /**
  68488. * T (V) wrapping mode. All valid values correspond to WebGL enums
  68489. */
  68490. wrapT?: TextureWrapMode;
  68491. }
  68492. /**
  68493. * The root nodes of a scene
  68494. */
  68495. interface IScene extends IChildRootProperty {
  68496. /**
  68497. * The indices of each root node
  68498. */
  68499. nodes: number[];
  68500. }
  68501. /**
  68502. * Joints and matrices defining a skin
  68503. */
  68504. interface ISkin extends IChildRootProperty {
  68505. /**
  68506. * 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
  68507. */
  68508. inverseBindMatrices?: number;
  68509. /**
  68510. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  68511. */
  68512. skeleton?: number;
  68513. /**
  68514. * 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)
  68515. */
  68516. joints: number[];
  68517. }
  68518. /**
  68519. * A texture and its sampler
  68520. */
  68521. interface ITexture extends IChildRootProperty {
  68522. /**
  68523. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  68524. */
  68525. sampler?: number;
  68526. /**
  68527. * The index of the image used by this texture
  68528. */
  68529. source: number;
  68530. }
  68531. /**
  68532. * Reference to a texture
  68533. */
  68534. interface ITextureInfo extends IProperty {
  68535. /**
  68536. * The index of the texture
  68537. */
  68538. index: number;
  68539. /**
  68540. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  68541. */
  68542. texCoord?: number;
  68543. }
  68544. /**
  68545. * The root object for a glTF asset
  68546. */
  68547. interface IGLTF extends IProperty {
  68548. /**
  68549. * An array of accessors. An accessor is a typed view into a bufferView
  68550. */
  68551. accessors?: IAccessor[];
  68552. /**
  68553. * An array of keyframe animations
  68554. */
  68555. animations?: IAnimation[];
  68556. /**
  68557. * Metadata about the glTF asset
  68558. */
  68559. asset: IAsset;
  68560. /**
  68561. * An array of buffers. A buffer points to binary geometry, animation, or skins
  68562. */
  68563. buffers?: IBuffer[];
  68564. /**
  68565. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  68566. */
  68567. bufferViews?: IBufferView[];
  68568. /**
  68569. * An array of cameras
  68570. */
  68571. cameras?: ICamera[];
  68572. /**
  68573. * Names of glTF extensions used somewhere in this asset
  68574. */
  68575. extensionsUsed?: string[];
  68576. /**
  68577. * Names of glTF extensions required to properly load this asset
  68578. */
  68579. extensionsRequired?: string[];
  68580. /**
  68581. * An array of images. An image defines data used to create a texture
  68582. */
  68583. images?: IImage[];
  68584. /**
  68585. * An array of materials. A material defines the appearance of a primitive
  68586. */
  68587. materials?: IMaterial[];
  68588. /**
  68589. * An array of meshes. A mesh is a set of primitives to be rendered
  68590. */
  68591. meshes?: IMesh[];
  68592. /**
  68593. * An array of nodes
  68594. */
  68595. nodes?: INode[];
  68596. /**
  68597. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  68598. */
  68599. samplers?: ISampler[];
  68600. /**
  68601. * The index of the default scene
  68602. */
  68603. scene?: number;
  68604. /**
  68605. * An array of scenes
  68606. */
  68607. scenes?: IScene[];
  68608. /**
  68609. * An array of skins. A skin is defined by joints and matrices
  68610. */
  68611. skins?: ISkin[];
  68612. /**
  68613. * An array of textures
  68614. */
  68615. textures?: ITexture[];
  68616. }
  68617. /**
  68618. * The glTF validation results
  68619. */
  68620. interface IGLTFValidationResults {
  68621. info: {
  68622. generator: string;
  68623. hasAnimations: boolean;
  68624. hasDefaultScene: boolean;
  68625. hasMaterials: boolean;
  68626. hasMorphTargets: boolean;
  68627. hasSkins: boolean;
  68628. hasTextures: boolean;
  68629. maxAttributesUsed: number;
  68630. primitivesCount: number
  68631. };
  68632. issues: {
  68633. messages: Array<string>;
  68634. numErrors: number;
  68635. numHints: number;
  68636. numInfos: number;
  68637. numWarnings: number;
  68638. truncated: boolean
  68639. };
  68640. mimeType: string;
  68641. uri: string;
  68642. validatedAt: string;
  68643. validatorVersion: string;
  68644. }
  68645. /**
  68646. * The glTF validation options
  68647. */
  68648. interface IGLTFValidationOptions {
  68649. uri?: string;
  68650. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  68651. validateAccessorData?: boolean;
  68652. maxIssues?: number;
  68653. ignoredIssues?: Array<string>;
  68654. severityOverrides?: Object;
  68655. }
  68656. /**
  68657. * The glTF validator object
  68658. */
  68659. interface IGLTFValidator {
  68660. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  68661. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  68662. }
  68663. }
  68664. declare module BABYLON {
  68665. /** @hidden */
  68666. export var cellPixelShader: {
  68667. name: string;
  68668. shader: string;
  68669. };
  68670. }
  68671. declare module BABYLON {
  68672. /** @hidden */
  68673. export var cellVertexShader: {
  68674. name: string;
  68675. shader: string;
  68676. };
  68677. }
  68678. declare module BABYLON {
  68679. export class CellMaterial extends BABYLON.PushMaterial {
  68680. private _diffuseTexture;
  68681. diffuseTexture: BABYLON.BaseTexture;
  68682. diffuseColor: BABYLON.Color3;
  68683. _computeHighLevel: boolean;
  68684. computeHighLevel: boolean;
  68685. private _disableLighting;
  68686. disableLighting: boolean;
  68687. private _maxSimultaneousLights;
  68688. maxSimultaneousLights: number;
  68689. private _renderId;
  68690. constructor(name: string, scene: BABYLON.Scene);
  68691. needAlphaBlending(): boolean;
  68692. needAlphaTesting(): boolean;
  68693. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68694. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68695. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68696. getAnimatables(): BABYLON.IAnimatable[];
  68697. getActiveTextures(): BABYLON.BaseTexture[];
  68698. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68699. dispose(forceDisposeEffect?: boolean): void;
  68700. getClassName(): string;
  68701. clone(name: string): CellMaterial;
  68702. serialize(): any;
  68703. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  68704. }
  68705. }
  68706. declare module BABYLON {
  68707. export class CustomShaderStructure {
  68708. FragmentStore: string;
  68709. VertexStore: string;
  68710. constructor();
  68711. }
  68712. export class ShaderSpecialParts {
  68713. constructor();
  68714. Fragment_Begin: string;
  68715. Fragment_Definitions: string;
  68716. Fragment_MainBegin: string;
  68717. Fragment_Custom_Diffuse: string;
  68718. Fragment_Before_Lights: string;
  68719. Fragment_Before_Fog: string;
  68720. Fragment_Custom_Alpha: string;
  68721. Fragment_Before_FragColor: string;
  68722. Vertex_Begin: string;
  68723. Vertex_Definitions: string;
  68724. Vertex_MainBegin: string;
  68725. Vertex_Before_PositionUpdated: string;
  68726. Vertex_Before_NormalUpdated: string;
  68727. Vertex_MainEnd: string;
  68728. }
  68729. export class CustomMaterial extends BABYLON.StandardMaterial {
  68730. static ShaderIndexer: number;
  68731. CustomParts: ShaderSpecialParts;
  68732. _isCreatedShader: boolean;
  68733. _createdShaderName: string;
  68734. _customUniform: string[];
  68735. _newUniforms: string[];
  68736. _newUniformInstances: any[];
  68737. _newSamplerInstances: BABYLON.Texture[];
  68738. FragmentShader: string;
  68739. VertexShader: string;
  68740. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  68741. ReviewUniform(name: string, arr: string[]): string[];
  68742. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  68743. constructor(name: string, scene: BABYLON.Scene);
  68744. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  68745. Fragment_Begin(shaderPart: string): CustomMaterial;
  68746. Fragment_Definitions(shaderPart: string): CustomMaterial;
  68747. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  68748. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  68749. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  68750. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  68751. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  68752. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  68753. Vertex_Begin(shaderPart: string): CustomMaterial;
  68754. Vertex_Definitions(shaderPart: string): CustomMaterial;
  68755. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  68756. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  68757. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  68758. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  68759. }
  68760. }
  68761. declare module BABYLON {
  68762. export class ShaderAlebdoParts {
  68763. constructor();
  68764. Fragment_Begin: string;
  68765. Fragment_Definitions: string;
  68766. Fragment_MainBegin: string;
  68767. Fragment_Custom_Albedo: string;
  68768. Fragment_Before_Lights: string;
  68769. Fragment_Custom_MetallicRoughness: string;
  68770. Fragment_Custom_MicroSurface: string;
  68771. Fragment_Before_Fog: string;
  68772. Fragment_Custom_Alpha: string;
  68773. Fragment_Before_FragColor: string;
  68774. Vertex_Begin: string;
  68775. Vertex_Definitions: string;
  68776. Vertex_MainBegin: string;
  68777. Vertex_Before_PositionUpdated: string;
  68778. Vertex_Before_NormalUpdated: string;
  68779. Vertex_MainEnd: string;
  68780. }
  68781. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  68782. static ShaderIndexer: number;
  68783. CustomParts: ShaderAlebdoParts;
  68784. _isCreatedShader: boolean;
  68785. _createdShaderName: string;
  68786. _customUniform: string[];
  68787. _newUniforms: string[];
  68788. _newUniformInstances: any[];
  68789. _newSamplerInstances: BABYLON.Texture[];
  68790. FragmentShader: string;
  68791. VertexShader: string;
  68792. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  68793. ReviewUniform(name: string, arr: string[]): string[];
  68794. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  68795. constructor(name: string, scene: BABYLON.Scene);
  68796. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  68797. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  68798. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  68799. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  68800. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  68801. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  68802. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  68803. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  68804. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  68805. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  68806. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  68807. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  68808. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  68809. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  68810. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  68811. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  68812. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  68813. }
  68814. }
  68815. declare module BABYLON {
  68816. /** @hidden */
  68817. export var firePixelShader: {
  68818. name: string;
  68819. shader: string;
  68820. };
  68821. }
  68822. declare module BABYLON {
  68823. /** @hidden */
  68824. export var fireVertexShader: {
  68825. name: string;
  68826. shader: string;
  68827. };
  68828. }
  68829. declare module BABYLON {
  68830. export class FireMaterial extends BABYLON.PushMaterial {
  68831. private _diffuseTexture;
  68832. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68833. private _distortionTexture;
  68834. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68835. private _opacityTexture;
  68836. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68837. diffuseColor: BABYLON.Color3;
  68838. speed: number;
  68839. private _scaledDiffuse;
  68840. private _renderId;
  68841. private _lastTime;
  68842. constructor(name: string, scene: BABYLON.Scene);
  68843. needAlphaBlending(): boolean;
  68844. needAlphaTesting(): boolean;
  68845. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68846. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68847. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68848. getAnimatables(): BABYLON.IAnimatable[];
  68849. getActiveTextures(): BABYLON.BaseTexture[];
  68850. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68851. getClassName(): string;
  68852. dispose(forceDisposeEffect?: boolean): void;
  68853. clone(name: string): FireMaterial;
  68854. serialize(): any;
  68855. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  68856. }
  68857. }
  68858. declare module BABYLON {
  68859. /** @hidden */
  68860. export var furPixelShader: {
  68861. name: string;
  68862. shader: string;
  68863. };
  68864. }
  68865. declare module BABYLON {
  68866. /** @hidden */
  68867. export var furVertexShader: {
  68868. name: string;
  68869. shader: string;
  68870. };
  68871. }
  68872. declare module BABYLON {
  68873. export class FurMaterial extends BABYLON.PushMaterial {
  68874. private _diffuseTexture;
  68875. diffuseTexture: BABYLON.BaseTexture;
  68876. private _heightTexture;
  68877. heightTexture: BABYLON.BaseTexture;
  68878. diffuseColor: BABYLON.Color3;
  68879. furLength: number;
  68880. furAngle: number;
  68881. furColor: BABYLON.Color3;
  68882. furOffset: number;
  68883. furSpacing: number;
  68884. furGravity: BABYLON.Vector3;
  68885. furSpeed: number;
  68886. furDensity: number;
  68887. furOcclusion: number;
  68888. furTexture: BABYLON.DynamicTexture;
  68889. private _disableLighting;
  68890. disableLighting: boolean;
  68891. private _maxSimultaneousLights;
  68892. maxSimultaneousLights: number;
  68893. highLevelFur: boolean;
  68894. _meshes: BABYLON.AbstractMesh[];
  68895. private _renderId;
  68896. private _furTime;
  68897. constructor(name: string, scene: BABYLON.Scene);
  68898. furTime: number;
  68899. needAlphaBlending(): boolean;
  68900. needAlphaTesting(): boolean;
  68901. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68902. updateFur(): void;
  68903. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68904. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68905. getAnimatables(): BABYLON.IAnimatable[];
  68906. getActiveTextures(): BABYLON.BaseTexture[];
  68907. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68908. dispose(forceDisposeEffect?: boolean): void;
  68909. clone(name: string): FurMaterial;
  68910. serialize(): any;
  68911. getClassName(): string;
  68912. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  68913. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  68914. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  68915. }
  68916. }
  68917. declare module BABYLON {
  68918. /** @hidden */
  68919. export var gradientPixelShader: {
  68920. name: string;
  68921. shader: string;
  68922. };
  68923. }
  68924. declare module BABYLON {
  68925. /** @hidden */
  68926. export var gradientVertexShader: {
  68927. name: string;
  68928. shader: string;
  68929. };
  68930. }
  68931. declare module BABYLON {
  68932. export class GradientMaterial extends BABYLON.PushMaterial {
  68933. private _maxSimultaneousLights;
  68934. maxSimultaneousLights: number;
  68935. topColor: BABYLON.Color3;
  68936. topColorAlpha: number;
  68937. bottomColor: BABYLON.Color3;
  68938. bottomColorAlpha: number;
  68939. offset: number;
  68940. scale: number;
  68941. smoothness: number;
  68942. private _disableLighting;
  68943. disableLighting: boolean;
  68944. private _renderId;
  68945. constructor(name: string, scene: BABYLON.Scene);
  68946. needAlphaBlending(): boolean;
  68947. needAlphaTesting(): boolean;
  68948. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68949. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68950. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68951. getAnimatables(): BABYLON.IAnimatable[];
  68952. dispose(forceDisposeEffect?: boolean): void;
  68953. clone(name: string): GradientMaterial;
  68954. serialize(): any;
  68955. getClassName(): string;
  68956. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  68957. }
  68958. }
  68959. declare module BABYLON {
  68960. /** @hidden */
  68961. export var gridPixelShader: {
  68962. name: string;
  68963. shader: string;
  68964. };
  68965. }
  68966. declare module BABYLON {
  68967. /** @hidden */
  68968. export var gridVertexShader: {
  68969. name: string;
  68970. shader: string;
  68971. };
  68972. }
  68973. declare module BABYLON {
  68974. /**
  68975. * The grid materials allows you to wrap any shape with a grid.
  68976. * Colors are customizable.
  68977. */
  68978. export class GridMaterial extends BABYLON.PushMaterial {
  68979. /**
  68980. * Main color of the grid (e.g. between lines)
  68981. */
  68982. mainColor: BABYLON.Color3;
  68983. /**
  68984. * Color of the grid lines.
  68985. */
  68986. lineColor: BABYLON.Color3;
  68987. /**
  68988. * The scale of the grid compared to unit.
  68989. */
  68990. gridRatio: number;
  68991. /**
  68992. * Allows setting an offset for the grid lines.
  68993. */
  68994. gridOffset: BABYLON.Vector3;
  68995. /**
  68996. * The frequency of thicker lines.
  68997. */
  68998. majorUnitFrequency: number;
  68999. /**
  69000. * The visibility of minor units in the grid.
  69001. */
  69002. minorUnitVisibility: number;
  69003. /**
  69004. * The grid opacity outside of the lines.
  69005. */
  69006. opacity: number;
  69007. /**
  69008. * Determine RBG output is premultiplied by alpha value.
  69009. */
  69010. preMultiplyAlpha: boolean;
  69011. private _opacityTexture;
  69012. opacityTexture: BABYLON.BaseTexture;
  69013. private _gridControl;
  69014. private _renderId;
  69015. /**
  69016. * constructor
  69017. * @param name The name given to the material in order to identify it afterwards.
  69018. * @param scene The scene the material is used in.
  69019. */
  69020. constructor(name: string, scene: BABYLON.Scene);
  69021. /**
  69022. * Returns wehter or not the grid requires alpha blending.
  69023. */
  69024. needAlphaBlending(): boolean;
  69025. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  69026. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69027. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69028. /**
  69029. * Dispose the material and its associated resources.
  69030. * @param forceDisposeEffect will also dispose the used effect when true
  69031. */
  69032. dispose(forceDisposeEffect?: boolean): void;
  69033. clone(name: string): GridMaterial;
  69034. serialize(): any;
  69035. getClassName(): string;
  69036. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  69037. }
  69038. }
  69039. declare module BABYLON {
  69040. /** @hidden */
  69041. export var lavaPixelShader: {
  69042. name: string;
  69043. shader: string;
  69044. };
  69045. }
  69046. declare module BABYLON {
  69047. /** @hidden */
  69048. export var lavaVertexShader: {
  69049. name: string;
  69050. shader: string;
  69051. };
  69052. }
  69053. declare module BABYLON {
  69054. export class LavaMaterial extends BABYLON.PushMaterial {
  69055. private _diffuseTexture;
  69056. diffuseTexture: BABYLON.BaseTexture;
  69057. noiseTexture: BABYLON.BaseTexture;
  69058. fogColor: BABYLON.Color3;
  69059. speed: number;
  69060. movingSpeed: number;
  69061. lowFrequencySpeed: number;
  69062. fogDensity: number;
  69063. private _lastTime;
  69064. diffuseColor: BABYLON.Color3;
  69065. private _disableLighting;
  69066. disableLighting: boolean;
  69067. private _unlit;
  69068. unlit: boolean;
  69069. private _maxSimultaneousLights;
  69070. maxSimultaneousLights: number;
  69071. private _scaledDiffuse;
  69072. private _renderId;
  69073. constructor(name: string, scene: BABYLON.Scene);
  69074. needAlphaBlending(): boolean;
  69075. needAlphaTesting(): boolean;
  69076. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69077. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69078. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69079. getAnimatables(): BABYLON.IAnimatable[];
  69080. getActiveTextures(): BABYLON.BaseTexture[];
  69081. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69082. dispose(forceDisposeEffect?: boolean): void;
  69083. clone(name: string): LavaMaterial;
  69084. serialize(): any;
  69085. getClassName(): string;
  69086. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  69087. }
  69088. }
  69089. declare module BABYLON {
  69090. /** @hidden */
  69091. export var mixPixelShader: {
  69092. name: string;
  69093. shader: string;
  69094. };
  69095. }
  69096. declare module BABYLON {
  69097. /** @hidden */
  69098. export var mixVertexShader: {
  69099. name: string;
  69100. shader: string;
  69101. };
  69102. }
  69103. declare module BABYLON {
  69104. export class MixMaterial extends BABYLON.PushMaterial {
  69105. /**
  69106. * Mix textures
  69107. */
  69108. private _mixTexture1;
  69109. mixTexture1: BABYLON.BaseTexture;
  69110. private _mixTexture2;
  69111. mixTexture2: BABYLON.BaseTexture;
  69112. /**
  69113. * Diffuse textures
  69114. */
  69115. private _diffuseTexture1;
  69116. diffuseTexture1: BABYLON.Texture;
  69117. private _diffuseTexture2;
  69118. diffuseTexture2: BABYLON.Texture;
  69119. private _diffuseTexture3;
  69120. diffuseTexture3: BABYLON.Texture;
  69121. private _diffuseTexture4;
  69122. diffuseTexture4: BABYLON.Texture;
  69123. private _diffuseTexture5;
  69124. diffuseTexture5: BABYLON.Texture;
  69125. private _diffuseTexture6;
  69126. diffuseTexture6: BABYLON.Texture;
  69127. private _diffuseTexture7;
  69128. diffuseTexture7: BABYLON.Texture;
  69129. private _diffuseTexture8;
  69130. diffuseTexture8: BABYLON.Texture;
  69131. /**
  69132. * Uniforms
  69133. */
  69134. diffuseColor: BABYLON.Color3;
  69135. specularColor: BABYLON.Color3;
  69136. specularPower: number;
  69137. private _disableLighting;
  69138. disableLighting: boolean;
  69139. private _maxSimultaneousLights;
  69140. maxSimultaneousLights: number;
  69141. private _renderId;
  69142. constructor(name: string, scene: BABYLON.Scene);
  69143. needAlphaBlending(): boolean;
  69144. needAlphaTesting(): boolean;
  69145. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69146. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69147. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69148. getAnimatables(): BABYLON.IAnimatable[];
  69149. getActiveTextures(): BABYLON.BaseTexture[];
  69150. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69151. dispose(forceDisposeEffect?: boolean): void;
  69152. clone(name: string): MixMaterial;
  69153. serialize(): any;
  69154. getClassName(): string;
  69155. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  69156. }
  69157. }
  69158. declare module BABYLON {
  69159. /** @hidden */
  69160. export var normalPixelShader: {
  69161. name: string;
  69162. shader: string;
  69163. };
  69164. }
  69165. declare module BABYLON {
  69166. /** @hidden */
  69167. export var normalVertexShader: {
  69168. name: string;
  69169. shader: string;
  69170. };
  69171. }
  69172. declare module BABYLON {
  69173. export class NormalMaterial extends BABYLON.PushMaterial {
  69174. private _diffuseTexture;
  69175. diffuseTexture: BABYLON.BaseTexture;
  69176. diffuseColor: BABYLON.Color3;
  69177. private _disableLighting;
  69178. disableLighting: boolean;
  69179. private _maxSimultaneousLights;
  69180. maxSimultaneousLights: number;
  69181. private _renderId;
  69182. constructor(name: string, scene: BABYLON.Scene);
  69183. needAlphaBlending(): boolean;
  69184. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  69185. needAlphaTesting(): boolean;
  69186. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69187. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69188. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69189. getAnimatables(): BABYLON.IAnimatable[];
  69190. getActiveTextures(): BABYLON.BaseTexture[];
  69191. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69192. dispose(forceDisposeEffect?: boolean): void;
  69193. clone(name: string): NormalMaterial;
  69194. serialize(): any;
  69195. getClassName(): string;
  69196. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  69197. }
  69198. }
  69199. declare module BABYLON {
  69200. /** @hidden */
  69201. export var shadowOnlyPixelShader: {
  69202. name: string;
  69203. shader: string;
  69204. };
  69205. }
  69206. declare module BABYLON {
  69207. /** @hidden */
  69208. export var shadowOnlyVertexShader: {
  69209. name: string;
  69210. shader: string;
  69211. };
  69212. }
  69213. declare module BABYLON {
  69214. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  69215. private _renderId;
  69216. private _activeLight;
  69217. constructor(name: string, scene: BABYLON.Scene);
  69218. shadowColor: BABYLON.Color3;
  69219. needAlphaBlending(): boolean;
  69220. needAlphaTesting(): boolean;
  69221. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69222. activeLight: BABYLON.IShadowLight;
  69223. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69224. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69225. clone(name: string): ShadowOnlyMaterial;
  69226. serialize(): any;
  69227. getClassName(): string;
  69228. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  69229. }
  69230. }
  69231. declare module BABYLON {
  69232. /** @hidden */
  69233. export var simplePixelShader: {
  69234. name: string;
  69235. shader: string;
  69236. };
  69237. }
  69238. declare module BABYLON {
  69239. /** @hidden */
  69240. export var simpleVertexShader: {
  69241. name: string;
  69242. shader: string;
  69243. };
  69244. }
  69245. declare module BABYLON {
  69246. export class SimpleMaterial extends BABYLON.PushMaterial {
  69247. private _diffuseTexture;
  69248. diffuseTexture: BABYLON.BaseTexture;
  69249. diffuseColor: BABYLON.Color3;
  69250. private _disableLighting;
  69251. disableLighting: boolean;
  69252. private _maxSimultaneousLights;
  69253. maxSimultaneousLights: number;
  69254. private _renderId;
  69255. constructor(name: string, scene: BABYLON.Scene);
  69256. needAlphaBlending(): boolean;
  69257. needAlphaTesting(): boolean;
  69258. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69259. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69260. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69261. getAnimatables(): BABYLON.IAnimatable[];
  69262. getActiveTextures(): BABYLON.BaseTexture[];
  69263. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69264. dispose(forceDisposeEffect?: boolean): void;
  69265. clone(name: string): SimpleMaterial;
  69266. serialize(): any;
  69267. getClassName(): string;
  69268. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  69269. }
  69270. }
  69271. declare module BABYLON {
  69272. /** @hidden */
  69273. export var skyPixelShader: {
  69274. name: string;
  69275. shader: string;
  69276. };
  69277. }
  69278. declare module BABYLON {
  69279. /** @hidden */
  69280. export var skyVertexShader: {
  69281. name: string;
  69282. shader: string;
  69283. };
  69284. }
  69285. declare module BABYLON {
  69286. /**
  69287. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  69288. * @see https://doc.babylonjs.com/extensions/sky
  69289. */
  69290. export class SkyMaterial extends BABYLON.PushMaterial {
  69291. /**
  69292. * Defines the overall luminance of sky in interval ]0, 1[.
  69293. */
  69294. luminance: number;
  69295. /**
  69296. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  69297. */
  69298. turbidity: number;
  69299. /**
  69300. * Defines the sky appearance (light intensity).
  69301. */
  69302. rayleigh: number;
  69303. /**
  69304. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  69305. */
  69306. mieCoefficient: number;
  69307. /**
  69308. * Defines the amount of haze particles following the Mie scattering theory.
  69309. */
  69310. mieDirectionalG: number;
  69311. /**
  69312. * Defines the distance of the sun according to the active scene camera.
  69313. */
  69314. distance: number;
  69315. /**
  69316. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  69317. * "inclined".
  69318. */
  69319. inclination: number;
  69320. /**
  69321. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  69322. * an object direction and a reference direction.
  69323. */
  69324. azimuth: number;
  69325. /**
  69326. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  69327. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  69328. */
  69329. sunPosition: BABYLON.Vector3;
  69330. /**
  69331. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  69332. * .sunPosition property.
  69333. */
  69334. useSunPosition: boolean;
  69335. /**
  69336. * Defines an offset vector used to get a horizon offset.
  69337. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  69338. */
  69339. cameraOffset: BABYLON.Vector3;
  69340. private _cameraPosition;
  69341. private _renderId;
  69342. /**
  69343. * Instantiates a new sky material.
  69344. * This material allows to create dynamic and texture free
  69345. * effects for skyboxes by taking care of the atmosphere state.
  69346. * @see https://doc.babylonjs.com/extensions/sky
  69347. * @param name Define the name of the material in the scene
  69348. * @param scene Define the scene the material belong to
  69349. */
  69350. constructor(name: string, scene: BABYLON.Scene);
  69351. /**
  69352. * Specifies if the material will require alpha blending
  69353. * @returns a boolean specifying if alpha blending is needed
  69354. */
  69355. needAlphaBlending(): boolean;
  69356. /**
  69357. * Specifies if this material should be rendered in alpha test mode
  69358. * @returns false as the sky material doesn't need alpha testing.
  69359. */
  69360. needAlphaTesting(): boolean;
  69361. /**
  69362. * Get the texture used for alpha test purpose.
  69363. * @returns null as the sky material has no texture.
  69364. */
  69365. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69366. /**
  69367. * Get if the submesh is ready to be used and all its information available.
  69368. * Child classes can use it to update shaders
  69369. * @param mesh defines the mesh to check
  69370. * @param subMesh defines which submesh to check
  69371. * @param useInstances specifies that instances should be used
  69372. * @returns a boolean indicating that the submesh is ready or not
  69373. */
  69374. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69375. /**
  69376. * Binds the submesh to this material by preparing the effect and shader to draw
  69377. * @param world defines the world transformation matrix
  69378. * @param mesh defines the mesh containing the submesh
  69379. * @param subMesh defines the submesh to bind the material to
  69380. */
  69381. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69382. /**
  69383. * Get the list of animatables in the material.
  69384. * @returns the list of animatables object used in the material
  69385. */
  69386. getAnimatables(): BABYLON.IAnimatable[];
  69387. /**
  69388. * Disposes the material
  69389. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  69390. */
  69391. dispose(forceDisposeEffect?: boolean): void;
  69392. /**
  69393. * Makes a duplicate of the material, and gives it a new name
  69394. * @param name defines the new name for the duplicated material
  69395. * @returns the cloned material
  69396. */
  69397. clone(name: string): SkyMaterial;
  69398. /**
  69399. * Serializes this material in a JSON representation
  69400. * @returns the serialized material object
  69401. */
  69402. serialize(): any;
  69403. /**
  69404. * Gets the current class name of the material e.g. "SkyMaterial"
  69405. * Mainly use in serialization.
  69406. * @returns the class name
  69407. */
  69408. getClassName(): string;
  69409. /**
  69410. * Creates a sky material from parsed material data
  69411. * @param source defines the JSON representation of the material
  69412. * @param scene defines the hosting scene
  69413. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69414. * @returns a new sky material
  69415. */
  69416. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  69417. }
  69418. }
  69419. declare module BABYLON {
  69420. /** @hidden */
  69421. export var terrainPixelShader: {
  69422. name: string;
  69423. shader: string;
  69424. };
  69425. }
  69426. declare module BABYLON {
  69427. /** @hidden */
  69428. export var terrainVertexShader: {
  69429. name: string;
  69430. shader: string;
  69431. };
  69432. }
  69433. declare module BABYLON {
  69434. export class TerrainMaterial extends BABYLON.PushMaterial {
  69435. private _mixTexture;
  69436. mixTexture: BABYLON.BaseTexture;
  69437. private _diffuseTexture1;
  69438. diffuseTexture1: BABYLON.Texture;
  69439. private _diffuseTexture2;
  69440. diffuseTexture2: BABYLON.Texture;
  69441. private _diffuseTexture3;
  69442. diffuseTexture3: BABYLON.Texture;
  69443. private _bumpTexture1;
  69444. bumpTexture1: BABYLON.Texture;
  69445. private _bumpTexture2;
  69446. bumpTexture2: BABYLON.Texture;
  69447. private _bumpTexture3;
  69448. bumpTexture3: BABYLON.Texture;
  69449. diffuseColor: BABYLON.Color3;
  69450. specularColor: BABYLON.Color3;
  69451. specularPower: number;
  69452. private _disableLighting;
  69453. disableLighting: boolean;
  69454. private _maxSimultaneousLights;
  69455. maxSimultaneousLights: number;
  69456. private _renderId;
  69457. constructor(name: string, scene: BABYLON.Scene);
  69458. needAlphaBlending(): boolean;
  69459. needAlphaTesting(): boolean;
  69460. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69461. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69462. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69463. getAnimatables(): BABYLON.IAnimatable[];
  69464. getActiveTextures(): BABYLON.BaseTexture[];
  69465. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69466. dispose(forceDisposeEffect?: boolean): void;
  69467. clone(name: string): TerrainMaterial;
  69468. serialize(): any;
  69469. getClassName(): string;
  69470. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  69471. }
  69472. }
  69473. declare module BABYLON {
  69474. /** @hidden */
  69475. export var triplanarPixelShader: {
  69476. name: string;
  69477. shader: string;
  69478. };
  69479. }
  69480. declare module BABYLON {
  69481. /** @hidden */
  69482. export var triplanarVertexShader: {
  69483. name: string;
  69484. shader: string;
  69485. };
  69486. }
  69487. declare module BABYLON {
  69488. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  69489. mixTexture: BABYLON.BaseTexture;
  69490. private _diffuseTextureX;
  69491. diffuseTextureX: BABYLON.BaseTexture;
  69492. private _diffuseTextureY;
  69493. diffuseTextureY: BABYLON.BaseTexture;
  69494. private _diffuseTextureZ;
  69495. diffuseTextureZ: BABYLON.BaseTexture;
  69496. private _normalTextureX;
  69497. normalTextureX: BABYLON.BaseTexture;
  69498. private _normalTextureY;
  69499. normalTextureY: BABYLON.BaseTexture;
  69500. private _normalTextureZ;
  69501. normalTextureZ: BABYLON.BaseTexture;
  69502. tileSize: number;
  69503. diffuseColor: BABYLON.Color3;
  69504. specularColor: BABYLON.Color3;
  69505. specularPower: number;
  69506. private _disableLighting;
  69507. disableLighting: boolean;
  69508. private _maxSimultaneousLights;
  69509. maxSimultaneousLights: number;
  69510. private _renderId;
  69511. constructor(name: string, scene: BABYLON.Scene);
  69512. needAlphaBlending(): boolean;
  69513. needAlphaTesting(): boolean;
  69514. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69515. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69516. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69517. getAnimatables(): BABYLON.IAnimatable[];
  69518. getActiveTextures(): BABYLON.BaseTexture[];
  69519. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69520. dispose(forceDisposeEffect?: boolean): void;
  69521. clone(name: string): TriPlanarMaterial;
  69522. serialize(): any;
  69523. getClassName(): string;
  69524. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  69525. }
  69526. }
  69527. declare module BABYLON {
  69528. /** @hidden */
  69529. export var waterPixelShader: {
  69530. name: string;
  69531. shader: string;
  69532. };
  69533. }
  69534. declare module BABYLON {
  69535. /** @hidden */
  69536. export var waterVertexShader: {
  69537. name: string;
  69538. shader: string;
  69539. };
  69540. }
  69541. declare module BABYLON {
  69542. export class WaterMaterial extends BABYLON.PushMaterial {
  69543. renderTargetSize: BABYLON.Vector2;
  69544. private _bumpTexture;
  69545. bumpTexture: BABYLON.BaseTexture;
  69546. diffuseColor: BABYLON.Color3;
  69547. specularColor: BABYLON.Color3;
  69548. specularPower: number;
  69549. private _disableLighting;
  69550. disableLighting: boolean;
  69551. private _maxSimultaneousLights;
  69552. maxSimultaneousLights: number;
  69553. /**
  69554. * @param {number}: Represents the wind force
  69555. */
  69556. windForce: number;
  69557. /**
  69558. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  69559. */
  69560. windDirection: BABYLON.Vector2;
  69561. /**
  69562. * @param {number}: Wave height, represents the height of the waves
  69563. */
  69564. waveHeight: number;
  69565. /**
  69566. * @param {number}: Bump height, represents the bump height related to the bump map
  69567. */
  69568. bumpHeight: number;
  69569. /**
  69570. * @param {boolean}: Add a smaller moving bump to less steady waves.
  69571. */
  69572. private _bumpSuperimpose;
  69573. bumpSuperimpose: boolean;
  69574. /**
  69575. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  69576. */
  69577. private _fresnelSeparate;
  69578. fresnelSeparate: boolean;
  69579. /**
  69580. * @param {boolean}: bump Waves modify the reflection.
  69581. */
  69582. private _bumpAffectsReflection;
  69583. bumpAffectsReflection: boolean;
  69584. /**
  69585. * @param {number}: The water color blended with the refraction (near)
  69586. */
  69587. waterColor: BABYLON.Color3;
  69588. /**
  69589. * @param {number}: The blend factor related to the water color
  69590. */
  69591. colorBlendFactor: number;
  69592. /**
  69593. * @param {number}: The water color blended with the reflection (far)
  69594. */
  69595. waterColor2: BABYLON.Color3;
  69596. /**
  69597. * @param {number}: The blend factor related to the water color (reflection, far)
  69598. */
  69599. colorBlendFactor2: number;
  69600. /**
  69601. * @param {number}: Represents the maximum length of a wave
  69602. */
  69603. waveLength: number;
  69604. /**
  69605. * @param {number}: Defines the waves speed
  69606. */
  69607. waveSpeed: number;
  69608. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  69609. private _mesh;
  69610. private _refractionRTT;
  69611. private _reflectionRTT;
  69612. private _reflectionTransform;
  69613. private _lastTime;
  69614. private _lastDeltaTime;
  69615. private _renderId;
  69616. private _useLogarithmicDepth;
  69617. private _waitingRenderList;
  69618. /**
  69619. * Gets a boolean indicating that current material needs to register RTT
  69620. */
  69621. readonly hasRenderTargetTextures: boolean;
  69622. /**
  69623. * Constructor
  69624. */
  69625. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  69626. useLogarithmicDepth: boolean;
  69627. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  69628. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  69629. addToRenderList(node: any): void;
  69630. enableRenderTargets(enable: boolean): void;
  69631. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  69632. readonly renderTargetsEnabled: boolean;
  69633. needAlphaBlending(): boolean;
  69634. needAlphaTesting(): boolean;
  69635. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69636. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69637. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69638. private _createRenderTargets;
  69639. getAnimatables(): BABYLON.IAnimatable[];
  69640. getActiveTextures(): BABYLON.BaseTexture[];
  69641. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69642. dispose(forceDisposeEffect?: boolean): void;
  69643. clone(name: string): WaterMaterial;
  69644. serialize(): any;
  69645. getClassName(): string;
  69646. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  69647. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  69648. }
  69649. }
  69650. declare module BABYLON {
  69651. /** @hidden */
  69652. export var asciiartPixelShader: {
  69653. name: string;
  69654. shader: string;
  69655. };
  69656. }
  69657. declare module BABYLON {
  69658. /**
  69659. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  69660. *
  69661. * It basically takes care rendering the font front the given font size to a texture.
  69662. * This is used later on in the postprocess.
  69663. */
  69664. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  69665. private _font;
  69666. private _text;
  69667. private _charSize;
  69668. /**
  69669. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  69670. */
  69671. readonly charSize: number;
  69672. /**
  69673. * Create a new instance of the Ascii Art FontTexture class
  69674. * @param name the name of the texture
  69675. * @param font the font to use, use the W3C CSS notation
  69676. * @param text the caracter set to use in the rendering.
  69677. * @param scene the scene that owns the texture
  69678. */
  69679. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  69680. /**
  69681. * Gets the max char width of a font.
  69682. * @param font the font to use, use the W3C CSS notation
  69683. * @return the max char width
  69684. */
  69685. private getFontWidth;
  69686. /**
  69687. * Gets the max char height of a font.
  69688. * @param font the font to use, use the W3C CSS notation
  69689. * @return the max char height
  69690. */
  69691. private getFontHeight;
  69692. /**
  69693. * Clones the current AsciiArtTexture.
  69694. * @return the clone of the texture.
  69695. */
  69696. clone(): AsciiArtFontTexture;
  69697. /**
  69698. * Parses a json object representing the texture and returns an instance of it.
  69699. * @param source the source JSON representation
  69700. * @param scene the scene to create the texture for
  69701. * @return the parsed texture
  69702. */
  69703. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  69704. }
  69705. /**
  69706. * Option available in the Ascii Art Post Process.
  69707. */
  69708. export interface IAsciiArtPostProcessOptions {
  69709. /**
  69710. * The font to use following the w3c font definition.
  69711. */
  69712. font?: string;
  69713. /**
  69714. * The character set to use in the postprocess.
  69715. */
  69716. characterSet?: string;
  69717. /**
  69718. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  69719. * This number is defined between 0 and 1;
  69720. */
  69721. mixToTile?: number;
  69722. /**
  69723. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  69724. * This number is defined between 0 and 1;
  69725. */
  69726. mixToNormal?: number;
  69727. }
  69728. /**
  69729. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  69730. *
  69731. * Simmply add it to your scene and let the nerd that lives in you have fun.
  69732. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  69733. */
  69734. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  69735. /**
  69736. * The font texture used to render the char in the post process.
  69737. */
  69738. private _asciiArtFontTexture;
  69739. /**
  69740. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  69741. * This number is defined between 0 and 1;
  69742. */
  69743. mixToTile: number;
  69744. /**
  69745. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  69746. * This number is defined between 0 and 1;
  69747. */
  69748. mixToNormal: number;
  69749. /**
  69750. * Instantiates a new Ascii Art Post Process.
  69751. * @param name the name to give to the postprocess
  69752. * @camera the camera to apply the post process to.
  69753. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  69754. */
  69755. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  69756. }
  69757. }
  69758. declare module BABYLON {
  69759. /** @hidden */
  69760. export var digitalrainPixelShader: {
  69761. name: string;
  69762. shader: string;
  69763. };
  69764. }
  69765. declare module BABYLON {
  69766. /**
  69767. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  69768. *
  69769. * It basically takes care rendering the font front the given font size to a texture.
  69770. * This is used later on in the postprocess.
  69771. */
  69772. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  69773. private _font;
  69774. private _text;
  69775. private _charSize;
  69776. /**
  69777. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  69778. */
  69779. readonly charSize: number;
  69780. /**
  69781. * Create a new instance of the Digital Rain FontTexture class
  69782. * @param name the name of the texture
  69783. * @param font the font to use, use the W3C CSS notation
  69784. * @param text the caracter set to use in the rendering.
  69785. * @param scene the scene that owns the texture
  69786. */
  69787. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  69788. /**
  69789. * Gets the max char width of a font.
  69790. * @param font the font to use, use the W3C CSS notation
  69791. * @return the max char width
  69792. */
  69793. private getFontWidth;
  69794. /**
  69795. * Gets the max char height of a font.
  69796. * @param font the font to use, use the W3C CSS notation
  69797. * @return the max char height
  69798. */
  69799. private getFontHeight;
  69800. /**
  69801. * Clones the current DigitalRainFontTexture.
  69802. * @return the clone of the texture.
  69803. */
  69804. clone(): DigitalRainFontTexture;
  69805. /**
  69806. * Parses a json object representing the texture and returns an instance of it.
  69807. * @param source the source JSON representation
  69808. * @param scene the scene to create the texture for
  69809. * @return the parsed texture
  69810. */
  69811. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  69812. }
  69813. /**
  69814. * Option available in the Digital Rain Post Process.
  69815. */
  69816. export interface IDigitalRainPostProcessOptions {
  69817. /**
  69818. * The font to use following the w3c font definition.
  69819. */
  69820. font?: string;
  69821. /**
  69822. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  69823. * This number is defined between 0 and 1;
  69824. */
  69825. mixToTile?: number;
  69826. /**
  69827. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  69828. * This number is defined between 0 and 1;
  69829. */
  69830. mixToNormal?: number;
  69831. }
  69832. /**
  69833. * DigitalRainPostProcess helps rendering everithing in digital rain.
  69834. *
  69835. * Simmply add it to your scene and let the nerd that lives in you have fun.
  69836. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  69837. */
  69838. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  69839. /**
  69840. * The font texture used to render the char in the post process.
  69841. */
  69842. private _digitalRainFontTexture;
  69843. /**
  69844. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  69845. * This number is defined between 0 and 1;
  69846. */
  69847. mixToTile: number;
  69848. /**
  69849. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  69850. * This number is defined between 0 and 1;
  69851. */
  69852. mixToNormal: number;
  69853. /**
  69854. * Instantiates a new Digital Rain Post Process.
  69855. * @param name the name to give to the postprocess
  69856. * @camera the camera to apply the post process to.
  69857. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  69858. */
  69859. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  69860. }
  69861. }
  69862. declare module BABYLON {
  69863. /** @hidden */
  69864. export var oceanPostProcessPixelShader: {
  69865. name: string;
  69866. shader: string;
  69867. };
  69868. }
  69869. declare module BABYLON {
  69870. /**
  69871. * Option available in the Ocean Post Process.
  69872. */
  69873. export interface IOceanPostProcessOptions {
  69874. /**
  69875. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  69876. */
  69877. reflectionSize?: number | {
  69878. width: number;
  69879. height: number;
  69880. } | {
  69881. ratio: number;
  69882. };
  69883. /**
  69884. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  69885. */
  69886. refractionSize?: number | {
  69887. width: number;
  69888. height: number;
  69889. } | {
  69890. ratio: number;
  69891. };
  69892. }
  69893. /**
  69894. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  69895. *
  69896. * Simmply add it to your scene and let the nerd that lives in you have fun.
  69897. * Example usage:
  69898. * var pp = new OceanPostProcess("myOcean", camera);
  69899. * pp.reflectionEnabled = true;
  69900. * pp.refractionEnabled = true;
  69901. */
  69902. export class OceanPostProcess extends BABYLON.PostProcess {
  69903. /**
  69904. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  69905. */
  69906. /**
  69907. * Sets weither or not the real-time reflection is enabled on the ocean.
  69908. * Is set to true, the reflection mirror texture will be used as reflection texture.
  69909. */
  69910. reflectionEnabled: boolean;
  69911. /**
  69912. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  69913. */
  69914. /**
  69915. * Sets weither or not the real-time refraction is enabled on the ocean.
  69916. * Is set to true, the refraction render target texture will be used as refraction texture.
  69917. */
  69918. refractionEnabled: boolean;
  69919. /**
  69920. * Gets wether or not the post-processes is supported by the running hardware.
  69921. * This requires draw buffer supports.
  69922. */
  69923. readonly isSupported: boolean;
  69924. /**
  69925. * This is the reflection mirror texture used to display reflections on the ocean.
  69926. * By default, render list is empty.
  69927. */
  69928. reflectionTexture: BABYLON.MirrorTexture;
  69929. /**
  69930. * This is the refraction render target texture used to display refraction on the ocean.
  69931. * By default, render list is empty.
  69932. */
  69933. refractionTexture: BABYLON.RenderTargetTexture;
  69934. private _time;
  69935. private _cameraRotation;
  69936. private _cameraViewMatrix;
  69937. private _reflectionEnabled;
  69938. private _refractionEnabled;
  69939. private _geometryRenderer;
  69940. /**
  69941. * Instantiates a new Ocean Post Process.
  69942. * @param name the name to give to the postprocess.
  69943. * @camera the camera to apply the post process to.
  69944. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  69945. */
  69946. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  69947. /**
  69948. * Returns the appropriate defines according to the current configuration.
  69949. */
  69950. private _getDefines;
  69951. /**
  69952. * Computes the current camera rotation as the shader requires a camera rotation.
  69953. */
  69954. private _computeCameraRotation;
  69955. }
  69956. }
  69957. declare module BABYLON {
  69958. /** @hidden */
  69959. export var brickProceduralTexturePixelShader: {
  69960. name: string;
  69961. shader: string;
  69962. };
  69963. }
  69964. declare module BABYLON {
  69965. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  69966. private _numberOfBricksHeight;
  69967. private _numberOfBricksWidth;
  69968. private _jointColor;
  69969. private _brickColor;
  69970. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69971. updateShaderUniforms(): void;
  69972. numberOfBricksHeight: number;
  69973. numberOfBricksWidth: number;
  69974. jointColor: BABYLON.Color3;
  69975. brickColor: BABYLON.Color3;
  69976. /**
  69977. * Serializes this brick procedural texture
  69978. * @returns a serialized brick procedural texture object
  69979. */
  69980. serialize(): any;
  69981. /**
  69982. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  69983. * @param parsedTexture defines parsed texture data
  69984. * @param scene defines the current scene
  69985. * @param rootUrl defines the root URL containing brick procedural texture information
  69986. * @returns a parsed Brick Procedural BABYLON.Texture
  69987. */
  69988. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  69989. }
  69990. }
  69991. declare module BABYLON {
  69992. /** @hidden */
  69993. export var cloudProceduralTexturePixelShader: {
  69994. name: string;
  69995. shader: string;
  69996. };
  69997. }
  69998. declare module BABYLON {
  69999. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  70000. private _skyColor;
  70001. private _cloudColor;
  70002. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70003. updateShaderUniforms(): void;
  70004. skyColor: BABYLON.Color4;
  70005. cloudColor: BABYLON.Color4;
  70006. /**
  70007. * Serializes this cloud procedural texture
  70008. * @returns a serialized cloud procedural texture object
  70009. */
  70010. serialize(): any;
  70011. /**
  70012. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  70013. * @param parsedTexture defines parsed texture data
  70014. * @param scene defines the current scene
  70015. * @param rootUrl defines the root URL containing cloud procedural texture information
  70016. * @returns a parsed Cloud Procedural BABYLON.Texture
  70017. */
  70018. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  70019. }
  70020. }
  70021. declare module BABYLON {
  70022. /** @hidden */
  70023. export var fireProceduralTexturePixelShader: {
  70024. name: string;
  70025. shader: string;
  70026. };
  70027. }
  70028. declare module BABYLON {
  70029. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  70030. private _time;
  70031. private _speed;
  70032. private _autoGenerateTime;
  70033. private _fireColors;
  70034. private _alphaThreshold;
  70035. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70036. updateShaderUniforms(): void;
  70037. render(useCameraPostProcess?: boolean): void;
  70038. static readonly PurpleFireColors: BABYLON.Color3[];
  70039. static readonly GreenFireColors: BABYLON.Color3[];
  70040. static readonly RedFireColors: BABYLON.Color3[];
  70041. static readonly BlueFireColors: BABYLON.Color3[];
  70042. autoGenerateTime: boolean;
  70043. fireColors: BABYLON.Color3[];
  70044. time: number;
  70045. speed: BABYLON.Vector2;
  70046. alphaThreshold: number;
  70047. /**
  70048. * Serializes this fire procedural texture
  70049. * @returns a serialized fire procedural texture object
  70050. */
  70051. serialize(): any;
  70052. /**
  70053. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  70054. * @param parsedTexture defines parsed texture data
  70055. * @param scene defines the current scene
  70056. * @param rootUrl defines the root URL containing fire procedural texture information
  70057. * @returns a parsed Fire Procedural BABYLON.Texture
  70058. */
  70059. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  70060. }
  70061. }
  70062. declare module BABYLON {
  70063. /** @hidden */
  70064. export var grassProceduralTexturePixelShader: {
  70065. name: string;
  70066. shader: string;
  70067. };
  70068. }
  70069. declare module BABYLON {
  70070. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  70071. private _grassColors;
  70072. private _groundColor;
  70073. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70074. updateShaderUniforms(): void;
  70075. grassColors: BABYLON.Color3[];
  70076. groundColor: BABYLON.Color3;
  70077. /**
  70078. * Serializes this grass procedural texture
  70079. * @returns a serialized grass procedural texture object
  70080. */
  70081. serialize(): any;
  70082. /**
  70083. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  70084. * @param parsedTexture defines parsed texture data
  70085. * @param scene defines the current scene
  70086. * @param rootUrl defines the root URL containing grass procedural texture information
  70087. * @returns a parsed Grass Procedural BABYLON.Texture
  70088. */
  70089. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  70090. }
  70091. }
  70092. declare module BABYLON {
  70093. /** @hidden */
  70094. export var marbleProceduralTexturePixelShader: {
  70095. name: string;
  70096. shader: string;
  70097. };
  70098. }
  70099. declare module BABYLON {
  70100. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  70101. private _numberOfTilesHeight;
  70102. private _numberOfTilesWidth;
  70103. private _amplitude;
  70104. private _jointColor;
  70105. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70106. updateShaderUniforms(): void;
  70107. numberOfTilesHeight: number;
  70108. amplitude: number;
  70109. numberOfTilesWidth: number;
  70110. jointColor: BABYLON.Color3;
  70111. /**
  70112. * Serializes this marble procedural texture
  70113. * @returns a serialized marble procedural texture object
  70114. */
  70115. serialize(): any;
  70116. /**
  70117. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  70118. * @param parsedTexture defines parsed texture data
  70119. * @param scene defines the current scene
  70120. * @param rootUrl defines the root URL containing marble procedural texture information
  70121. * @returns a parsed Marble Procedural BABYLON.Texture
  70122. */
  70123. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  70124. }
  70125. }
  70126. declare module BABYLON {
  70127. /** @hidden */
  70128. export var normalMapProceduralTexturePixelShader: {
  70129. name: string;
  70130. shader: string;
  70131. };
  70132. }
  70133. declare module BABYLON {
  70134. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  70135. private _baseTexture;
  70136. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70137. updateShaderUniforms(): void;
  70138. render(useCameraPostProcess?: boolean): void;
  70139. resize(size: any, generateMipMaps: any): void;
  70140. baseTexture: BABYLON.Texture;
  70141. /**
  70142. * Serializes this normal map procedural texture
  70143. * @returns a serialized normal map procedural texture object
  70144. */
  70145. serialize(): any;
  70146. /**
  70147. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  70148. * @param parsedTexture defines parsed texture data
  70149. * @param scene defines the current scene
  70150. * @param rootUrl defines the root URL containing normal map procedural texture information
  70151. * @returns a parsed Normal Map Procedural BABYLON.Texture
  70152. */
  70153. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  70154. }
  70155. }
  70156. declare module BABYLON {
  70157. /** @hidden */
  70158. export var perlinNoiseProceduralTexturePixelShader: {
  70159. name: string;
  70160. shader: string;
  70161. };
  70162. }
  70163. declare module BABYLON {
  70164. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  70165. time: number;
  70166. timeScale: number;
  70167. translationSpeed: number;
  70168. private _currentTranslation;
  70169. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70170. updateShaderUniforms(): void;
  70171. render(useCameraPostProcess?: boolean): void;
  70172. resize(size: any, generateMipMaps: any): void;
  70173. /**
  70174. * Serializes this perlin noise procedural texture
  70175. * @returns a serialized perlin noise procedural texture object
  70176. */
  70177. serialize(): any;
  70178. /**
  70179. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  70180. * @param parsedTexture defines parsed texture data
  70181. * @param scene defines the current scene
  70182. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  70183. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  70184. */
  70185. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  70186. }
  70187. }
  70188. declare module BABYLON {
  70189. /** @hidden */
  70190. export var roadProceduralTexturePixelShader: {
  70191. name: string;
  70192. shader: string;
  70193. };
  70194. }
  70195. declare module BABYLON {
  70196. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  70197. private _roadColor;
  70198. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70199. updateShaderUniforms(): void;
  70200. roadColor: BABYLON.Color3;
  70201. /**
  70202. * Serializes this road procedural texture
  70203. * @returns a serialized road procedural texture object
  70204. */
  70205. serialize(): any;
  70206. /**
  70207. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  70208. * @param parsedTexture defines parsed texture data
  70209. * @param scene defines the current scene
  70210. * @param rootUrl defines the root URL containing road procedural texture information
  70211. * @returns a parsed Road Procedural BABYLON.Texture
  70212. */
  70213. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  70214. }
  70215. }
  70216. declare module BABYLON {
  70217. /** @hidden */
  70218. export var starfieldProceduralTexturePixelShader: {
  70219. name: string;
  70220. shader: string;
  70221. };
  70222. }
  70223. declare module BABYLON {
  70224. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  70225. private _time;
  70226. private _alpha;
  70227. private _beta;
  70228. private _zoom;
  70229. private _formuparam;
  70230. private _stepsize;
  70231. private _tile;
  70232. private _brightness;
  70233. private _darkmatter;
  70234. private _distfading;
  70235. private _saturation;
  70236. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70237. updateShaderUniforms(): void;
  70238. time: number;
  70239. alpha: number;
  70240. beta: number;
  70241. formuparam: number;
  70242. stepsize: number;
  70243. zoom: number;
  70244. tile: number;
  70245. brightness: number;
  70246. darkmatter: number;
  70247. distfading: number;
  70248. saturation: number;
  70249. /**
  70250. * Serializes this starfield procedural texture
  70251. * @returns a serialized starfield procedural texture object
  70252. */
  70253. serialize(): any;
  70254. /**
  70255. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  70256. * @param parsedTexture defines parsed texture data
  70257. * @param scene defines the current scene
  70258. * @param rootUrl defines the root URL containing startfield procedural texture information
  70259. * @returns a parsed Starfield Procedural BABYLON.Texture
  70260. */
  70261. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  70262. }
  70263. }
  70264. declare module BABYLON {
  70265. /** @hidden */
  70266. export var woodProceduralTexturePixelShader: {
  70267. name: string;
  70268. shader: string;
  70269. };
  70270. }
  70271. declare module BABYLON {
  70272. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  70273. private _ampScale;
  70274. private _woodColor;
  70275. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70276. updateShaderUniforms(): void;
  70277. ampScale: number;
  70278. woodColor: BABYLON.Color3;
  70279. /**
  70280. * Serializes this wood procedural texture
  70281. * @returns a serialized wood procedural texture object
  70282. */
  70283. serialize(): any;
  70284. /**
  70285. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  70286. * @param parsedTexture defines parsed texture data
  70287. * @param scene defines the current scene
  70288. * @param rootUrl defines the root URL containing wood procedural texture information
  70289. * @returns a parsed Wood Procedural BABYLON.Texture
  70290. */
  70291. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  70292. }
  70293. }