documentation.d.ts 3.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279
  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. * Checks if the navigator object exists
  283. * @returns true if the navigator object exists
  284. */
  285. static IsNavigatorAvailable(): boolean;
  286. /**
  287. * Extracts text content from a DOM element hierarchy
  288. * @param element defines the root element
  289. * @returns a string
  290. */
  291. static GetDOMTextContent(element: HTMLElement): string;
  292. }
  293. }
  294. declare module BABYLON {
  295. /**
  296. * Logger used througouht the application to allow configuration of
  297. * the log level required for the messages.
  298. */
  299. export class Logger {
  300. /**
  301. * No log
  302. */
  303. static readonly NoneLogLevel: number;
  304. /**
  305. * Only message logs
  306. */
  307. static readonly MessageLogLevel: number;
  308. /**
  309. * Only warning logs
  310. */
  311. static readonly WarningLogLevel: number;
  312. /**
  313. * Only error logs
  314. */
  315. static readonly ErrorLogLevel: number;
  316. /**
  317. * All logs
  318. */
  319. static readonly AllLogLevel: number;
  320. private static _LogCache;
  321. /**
  322. * Gets a value indicating the number of loading errors
  323. * @ignorenaming
  324. */
  325. static errorsCount: number;
  326. /**
  327. * Callback called when a new log is added
  328. */
  329. static OnNewCacheEntry: (entry: string) => void;
  330. private static _AddLogEntry;
  331. private static _FormatMessage;
  332. private static _LogDisabled;
  333. private static _LogEnabled;
  334. private static _WarnDisabled;
  335. private static _WarnEnabled;
  336. private static _ErrorDisabled;
  337. private static _ErrorEnabled;
  338. /**
  339. * Log a message to the console
  340. */
  341. static Log: (message: string) => void;
  342. /**
  343. * Write a warning message to the console
  344. */
  345. static Warn: (message: string) => void;
  346. /**
  347. * Write an error message to the console
  348. */
  349. static Error: (message: string) => void;
  350. /**
  351. * Gets current log cache (list of logs)
  352. */
  353. static readonly LogCache: string;
  354. /**
  355. * Clears the log cache
  356. */
  357. static ClearLogCache(): void;
  358. /**
  359. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  360. */
  361. static LogLevels: number;
  362. }
  363. }
  364. declare module BABYLON {
  365. /** @hidden */
  366. export class _TypeStore {
  367. /** @hidden */
  368. static RegisteredTypes: {
  369. [key: string]: Object;
  370. };
  371. /** @hidden */
  372. static GetClass(fqdn: string): any;
  373. }
  374. }
  375. declare module BABYLON {
  376. /**
  377. * Class containing a set of static utilities functions for deep copy.
  378. */
  379. export class DeepCopier {
  380. /**
  381. * Tries to copy an object by duplicating every property
  382. * @param source defines the source object
  383. * @param destination defines the target object
  384. * @param doNotCopyList defines a list of properties to avoid
  385. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  386. */
  387. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  388. }
  389. }
  390. declare module BABYLON {
  391. /**
  392. * Class containing a set of static utilities functions for precision date
  393. */
  394. export class PrecisionDate {
  395. /**
  396. * Gets either window.performance.now() if supported or Date.now() else
  397. */
  398. static readonly Now: number;
  399. }
  400. }
  401. declare module BABYLON {
  402. /** @hidden */
  403. export class _DevTools {
  404. static WarnImport(name: string): string;
  405. }
  406. }
  407. declare module BABYLON {
  408. /**
  409. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  410. */
  411. export class WebRequest {
  412. private _xhr;
  413. /**
  414. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  415. * i.e. when loading files, where the server/service expects an Authorization header
  416. */
  417. static CustomRequestHeaders: {
  418. [key: string]: string;
  419. };
  420. /**
  421. * Add callback functions in this array to update all the requests before they get sent to the network
  422. */
  423. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  424. private _injectCustomRequestHeaders;
  425. /**
  426. * Gets or sets a function to be called when loading progress changes
  427. */
  428. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  429. /**
  430. * Returns client's state
  431. */
  432. readonly readyState: number;
  433. /**
  434. * Returns client's status
  435. */
  436. readonly status: number;
  437. /**
  438. * Returns client's status as a text
  439. */
  440. readonly statusText: string;
  441. /**
  442. * Returns client's response
  443. */
  444. readonly response: any;
  445. /**
  446. * Returns client's response url
  447. */
  448. readonly responseURL: string;
  449. /**
  450. * Returns client's response as text
  451. */
  452. readonly responseText: string;
  453. /**
  454. * Gets or sets the expected response type
  455. */
  456. responseType: XMLHttpRequestResponseType;
  457. /** @hidden */
  458. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  459. /** @hidden */
  460. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  461. /**
  462. * Cancels any network activity
  463. */
  464. abort(): void;
  465. /**
  466. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  467. * @param body defines an optional request body
  468. */
  469. send(body?: Document | BodyInit | null): void;
  470. /**
  471. * Sets the request method, request URL
  472. * @param method defines the method to use (GET, POST, etc..)
  473. * @param url defines the url to connect with
  474. */
  475. open(method: string, url: string): void;
  476. }
  477. }
  478. declare module BABYLON {
  479. /**
  480. * File request interface
  481. */
  482. export interface IFileRequest {
  483. /**
  484. * Raised when the request is complete (success or error).
  485. */
  486. onCompleteObservable: Observable<IFileRequest>;
  487. /**
  488. * Aborts the request for a file.
  489. */
  490. abort: () => void;
  491. }
  492. }
  493. declare module BABYLON {
  494. /**
  495. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  496. */
  497. export class PerformanceMonitor {
  498. private _enabled;
  499. private _rollingFrameTime;
  500. private _lastFrameTimeMs;
  501. /**
  502. * constructor
  503. * @param frameSampleSize The number of samples required to saturate the sliding window
  504. */
  505. constructor(frameSampleSize?: number);
  506. /**
  507. * Samples current frame
  508. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  509. */
  510. sampleFrame(timeMs?: number): void;
  511. /**
  512. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  513. */
  514. readonly averageFrameTime: number;
  515. /**
  516. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  517. */
  518. readonly averageFrameTimeVariance: number;
  519. /**
  520. * Returns the frame time of the most recent frame
  521. */
  522. readonly instantaneousFrameTime: number;
  523. /**
  524. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  525. */
  526. readonly averageFPS: number;
  527. /**
  528. * Returns the average framerate in frames per second using the most recent frame time
  529. */
  530. readonly instantaneousFPS: number;
  531. /**
  532. * Returns true if enough samples have been taken to completely fill the sliding window
  533. */
  534. readonly isSaturated: boolean;
  535. /**
  536. * Enables contributions to the sliding window sample set
  537. */
  538. enable(): void;
  539. /**
  540. * Disables contributions to the sliding window sample set
  541. * Samples will not be interpolated over the disabled period
  542. */
  543. disable(): void;
  544. /**
  545. * Returns true if sampling is enabled
  546. */
  547. readonly isEnabled: boolean;
  548. /**
  549. * Resets performance monitor
  550. */
  551. reset(): void;
  552. }
  553. /**
  554. * RollingAverage
  555. *
  556. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  557. */
  558. export class RollingAverage {
  559. /**
  560. * Current average
  561. */
  562. average: number;
  563. /**
  564. * Current variance
  565. */
  566. variance: number;
  567. protected _samples: Array<number>;
  568. protected _sampleCount: number;
  569. protected _pos: number;
  570. protected _m2: number;
  571. /**
  572. * constructor
  573. * @param length The number of samples required to saturate the sliding window
  574. */
  575. constructor(length: number);
  576. /**
  577. * Adds a sample to the sample set
  578. * @param v The sample value
  579. */
  580. add(v: number): void;
  581. /**
  582. * Returns previously added values or null if outside of history or outside the sliding window domain
  583. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  584. * @return Value previously recorded with add() or null if outside of range
  585. */
  586. history(i: number): number;
  587. /**
  588. * Returns true if enough samples have been taken to completely fill the sliding window
  589. * @return true if sample-set saturated
  590. */
  591. isSaturated(): boolean;
  592. /**
  593. * Resets the rolling average (equivalent to 0 samples taken so far)
  594. */
  595. reset(): void;
  596. /**
  597. * Wraps a value around the sample range boundaries
  598. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  599. * @return Wrapped position in sample range
  600. */
  601. protected _wrapPosition(i: number): number;
  602. }
  603. }
  604. declare module BABYLON {
  605. /**
  606. * This class implement a typical dictionary using a string as key and the generic type T as value.
  607. * The underlying implementation relies on an associative array to ensure the best performances.
  608. * The value can be anything including 'null' but except 'undefined'
  609. */
  610. export class StringDictionary<T> {
  611. /**
  612. * This will clear this dictionary and copy the content from the 'source' one.
  613. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  614. * @param source the dictionary to take the content from and copy to this dictionary
  615. */
  616. copyFrom(source: StringDictionary<T>): void;
  617. /**
  618. * Get a value based from its key
  619. * @param key the given key to get the matching value from
  620. * @return the value if found, otherwise undefined is returned
  621. */
  622. get(key: string): T | undefined;
  623. /**
  624. * Get a value from its key or add it if it doesn't exist.
  625. * This method will ensure you that a given key/data will be present in the dictionary.
  626. * @param key the given key to get the matching value from
  627. * @param factory the factory that will create the value if the key is not present in the dictionary.
  628. * The factory will only be invoked if there's no data for the given key.
  629. * @return the value corresponding to the key.
  630. */
  631. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  632. /**
  633. * Get a value from its key if present in the dictionary otherwise add it
  634. * @param key the key to get the value from
  635. * @param val if there's no such key/value pair in the dictionary add it with this value
  636. * @return the value corresponding to the key
  637. */
  638. getOrAdd(key: string, val: T): T;
  639. /**
  640. * Check if there's a given key in the dictionary
  641. * @param key the key to check for
  642. * @return true if the key is present, false otherwise
  643. */
  644. contains(key: string): boolean;
  645. /**
  646. * Add a new key and its corresponding value
  647. * @param key the key to add
  648. * @param value the value corresponding to the key
  649. * @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
  650. */
  651. add(key: string, value: T): boolean;
  652. /**
  653. * Update a specific value associated to a key
  654. * @param key defines the key to use
  655. * @param value defines the value to store
  656. * @returns true if the value was updated (or false if the key was not found)
  657. */
  658. set(key: string, value: T): boolean;
  659. /**
  660. * Get the element of the given key and remove it from the dictionary
  661. * @param key defines the key to search
  662. * @returns the value associated with the key or null if not found
  663. */
  664. getAndRemove(key: string): Nullable<T>;
  665. /**
  666. * Remove a key/value from the dictionary.
  667. * @param key the key to remove
  668. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  669. */
  670. remove(key: string): boolean;
  671. /**
  672. * Clear the whole content of the dictionary
  673. */
  674. clear(): void;
  675. /**
  676. * Gets the current count
  677. */
  678. readonly count: number;
  679. /**
  680. * Execute a callback on each key/val of the dictionary.
  681. * Note that you can remove any element in this dictionary in the callback implementation
  682. * @param callback the callback to execute on a given key/value pair
  683. */
  684. forEach(callback: (key: string, val: T) => void): void;
  685. /**
  686. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  687. * If the callback returns null or undefined the method will iterate to the next key/value pair
  688. * Note that you can remove any element in this dictionary in the callback implementation
  689. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  690. * @returns the first item
  691. */
  692. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  693. private _count;
  694. private _data;
  695. }
  696. }
  697. declare module BABYLON {
  698. /**
  699. * Class used to store gfx data (like WebGLBuffer)
  700. */
  701. export class DataBuffer {
  702. /**
  703. * Gets or sets the number of objects referencing this buffer
  704. */
  705. references: number;
  706. /** Gets or sets the size of the underlying buffer */
  707. capacity: number;
  708. /**
  709. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  710. */
  711. is32Bits: boolean;
  712. /**
  713. * Gets the underlying buffer
  714. */
  715. readonly underlyingResource: any;
  716. }
  717. }
  718. declare module BABYLON {
  719. /**
  720. * Class used to store data that will be store in GPU memory
  721. */
  722. export class Buffer {
  723. private _engine;
  724. private _buffer;
  725. /** @hidden */
  726. _data: Nullable<DataArray>;
  727. private _updatable;
  728. private _instanced;
  729. /**
  730. * Gets the byte stride.
  731. */
  732. readonly byteStride: number;
  733. /**
  734. * Constructor
  735. * @param engine the engine
  736. * @param data the data to use for this buffer
  737. * @param updatable whether the data is updatable
  738. * @param stride the stride (optional)
  739. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  740. * @param instanced whether the buffer is instanced (optional)
  741. * @param useBytes set to true if the stride in in bytes (optional)
  742. */
  743. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  744. /**
  745. * Create a new VertexBuffer based on the current buffer
  746. * @param kind defines the vertex buffer kind (position, normal, etc.)
  747. * @param offset defines offset in the buffer (0 by default)
  748. * @param size defines the size in floats of attributes (position is 3 for instance)
  749. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  750. * @param instanced defines if the vertex buffer contains indexed data
  751. * @param useBytes defines if the offset and stride are in bytes
  752. * @returns the new vertex buffer
  753. */
  754. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  755. /**
  756. * Gets a boolean indicating if the Buffer is updatable?
  757. * @returns true if the buffer is updatable
  758. */
  759. isUpdatable(): boolean;
  760. /**
  761. * Gets current buffer's data
  762. * @returns a DataArray or null
  763. */
  764. getData(): Nullable<DataArray>;
  765. /**
  766. * Gets underlying native buffer
  767. * @returns underlying native buffer
  768. */
  769. getBuffer(): Nullable<DataBuffer>;
  770. /**
  771. * Gets the stride in float32 units (i.e. byte stride / 4).
  772. * May not be an integer if the byte stride is not divisible by 4.
  773. * DEPRECATED. Use byteStride instead.
  774. * @returns the stride in float32 units
  775. */
  776. getStrideSize(): number;
  777. /**
  778. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  779. * @param data defines the data to store
  780. */
  781. create(data?: Nullable<DataArray>): void;
  782. /** @hidden */
  783. _rebuild(): void;
  784. /**
  785. * Update current buffer data
  786. * @param data defines the data to store
  787. */
  788. update(data: DataArray): void;
  789. /**
  790. * Updates the data directly.
  791. * @param data the new data
  792. * @param offset the new offset
  793. * @param vertexCount the vertex count (optional)
  794. * @param useBytes set to true if the offset is in bytes
  795. */
  796. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  797. /**
  798. * Release all resources
  799. */
  800. dispose(): void;
  801. }
  802. /**
  803. * Specialized buffer used to store vertex data
  804. */
  805. export class VertexBuffer {
  806. /** @hidden */
  807. _buffer: Buffer;
  808. private _kind;
  809. private _size;
  810. private _ownsBuffer;
  811. private _instanced;
  812. private _instanceDivisor;
  813. /**
  814. * The byte type.
  815. */
  816. static readonly BYTE: number;
  817. /**
  818. * The unsigned byte type.
  819. */
  820. static readonly UNSIGNED_BYTE: number;
  821. /**
  822. * The short type.
  823. */
  824. static readonly SHORT: number;
  825. /**
  826. * The unsigned short type.
  827. */
  828. static readonly UNSIGNED_SHORT: number;
  829. /**
  830. * The integer type.
  831. */
  832. static readonly INT: number;
  833. /**
  834. * The unsigned integer type.
  835. */
  836. static readonly UNSIGNED_INT: number;
  837. /**
  838. * The float type.
  839. */
  840. static readonly FLOAT: number;
  841. /**
  842. * Gets or sets the instance divisor when in instanced mode
  843. */
  844. instanceDivisor: number;
  845. /**
  846. * Gets the byte stride.
  847. */
  848. readonly byteStride: number;
  849. /**
  850. * Gets the byte offset.
  851. */
  852. readonly byteOffset: number;
  853. /**
  854. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  855. */
  856. readonly normalized: boolean;
  857. /**
  858. * Gets the data type of each component in the array.
  859. */
  860. readonly type: number;
  861. /**
  862. * Constructor
  863. * @param engine the engine
  864. * @param data the data to use for this vertex buffer
  865. * @param kind the vertex buffer kind
  866. * @param updatable whether the data is updatable
  867. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  868. * @param stride the stride (optional)
  869. * @param instanced whether the buffer is instanced (optional)
  870. * @param offset the offset of the data (optional)
  871. * @param size the number of components (optional)
  872. * @param type the type of the component (optional)
  873. * @param normalized whether the data contains normalized data (optional)
  874. * @param useBytes set to true if stride and offset are in bytes (optional)
  875. */
  876. 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);
  877. /** @hidden */
  878. _rebuild(): void;
  879. /**
  880. * Returns the kind of the VertexBuffer (string)
  881. * @returns a string
  882. */
  883. getKind(): string;
  884. /**
  885. * Gets a boolean indicating if the VertexBuffer is updatable?
  886. * @returns true if the buffer is updatable
  887. */
  888. isUpdatable(): boolean;
  889. /**
  890. * Gets current buffer's data
  891. * @returns a DataArray or null
  892. */
  893. getData(): Nullable<DataArray>;
  894. /**
  895. * Gets underlying native buffer
  896. * @returns underlying native buffer
  897. */
  898. getBuffer(): Nullable<DataBuffer>;
  899. /**
  900. * Gets the stride in float32 units (i.e. byte stride / 4).
  901. * May not be an integer if the byte stride is not divisible by 4.
  902. * DEPRECATED. Use byteStride instead.
  903. * @returns the stride in float32 units
  904. */
  905. getStrideSize(): number;
  906. /**
  907. * Returns the offset as a multiple of the type byte length.
  908. * DEPRECATED. Use byteOffset instead.
  909. * @returns the offset in bytes
  910. */
  911. getOffset(): number;
  912. /**
  913. * Returns the number of components per vertex attribute (integer)
  914. * @returns the size in float
  915. */
  916. getSize(): number;
  917. /**
  918. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  919. * @returns true if this buffer is instanced
  920. */
  921. getIsInstanced(): boolean;
  922. /**
  923. * Returns the instancing divisor, zero for non-instanced (integer).
  924. * @returns a number
  925. */
  926. getInstanceDivisor(): number;
  927. /**
  928. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  929. * @param data defines the data to store
  930. */
  931. create(data?: DataArray): void;
  932. /**
  933. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  934. * This function will create a new buffer if the current one is not updatable
  935. * @param data defines the data to store
  936. */
  937. update(data: DataArray): void;
  938. /**
  939. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  940. * Returns the directly updated WebGLBuffer.
  941. * @param data the new data
  942. * @param offset the new offset
  943. * @param useBytes set to true if the offset is in bytes
  944. */
  945. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  946. /**
  947. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  948. */
  949. dispose(): void;
  950. /**
  951. * Enumerates each value of this vertex buffer as numbers.
  952. * @param count the number of values to enumerate
  953. * @param callback the callback function called for each value
  954. */
  955. forEach(count: number, callback: (value: number, index: number) => void): void;
  956. /**
  957. * Positions
  958. */
  959. static readonly PositionKind: string;
  960. /**
  961. * Normals
  962. */
  963. static readonly NormalKind: string;
  964. /**
  965. * Tangents
  966. */
  967. static readonly TangentKind: string;
  968. /**
  969. * Texture coordinates
  970. */
  971. static readonly UVKind: string;
  972. /**
  973. * Texture coordinates 2
  974. */
  975. static readonly UV2Kind: string;
  976. /**
  977. * Texture coordinates 3
  978. */
  979. static readonly UV3Kind: string;
  980. /**
  981. * Texture coordinates 4
  982. */
  983. static readonly UV4Kind: string;
  984. /**
  985. * Texture coordinates 5
  986. */
  987. static readonly UV5Kind: string;
  988. /**
  989. * Texture coordinates 6
  990. */
  991. static readonly UV6Kind: string;
  992. /**
  993. * Colors
  994. */
  995. static readonly ColorKind: string;
  996. /**
  997. * Matrix indices (for bones)
  998. */
  999. static readonly MatricesIndicesKind: string;
  1000. /**
  1001. * Matrix weights (for bones)
  1002. */
  1003. static readonly MatricesWeightsKind: string;
  1004. /**
  1005. * Additional matrix indices (for bones)
  1006. */
  1007. static readonly MatricesIndicesExtraKind: string;
  1008. /**
  1009. * Additional matrix weights (for bones)
  1010. */
  1011. static readonly MatricesWeightsExtraKind: string;
  1012. /**
  1013. * Deduces the stride given a kind.
  1014. * @param kind The kind string to deduce
  1015. * @returns The deduced stride
  1016. */
  1017. static DeduceStride(kind: string): number;
  1018. /**
  1019. * Gets the byte length of the given type.
  1020. * @param type the type
  1021. * @returns the number of bytes
  1022. */
  1023. static GetTypeByteLength(type: number): number;
  1024. /**
  1025. * Enumerates each value of the given parameters as numbers.
  1026. * @param data the data to enumerate
  1027. * @param byteOffset the byte offset of the data
  1028. * @param byteStride the byte stride of the data
  1029. * @param componentCount the number of components per element
  1030. * @param componentType the type of the component
  1031. * @param count the number of values to enumerate
  1032. * @param normalized whether the data is normalized
  1033. * @param callback the callback function called for each value
  1034. */
  1035. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1036. private static _GetFloatValue;
  1037. }
  1038. }
  1039. declare module BABYLON {
  1040. /**
  1041. * Scalar computation library
  1042. */
  1043. export class Scalar {
  1044. /**
  1045. * Two pi constants convenient for computation.
  1046. */
  1047. static TwoPi: number;
  1048. /**
  1049. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1050. * @param a number
  1051. * @param b number
  1052. * @param epsilon (default = 1.401298E-45)
  1053. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1054. */
  1055. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1056. /**
  1057. * Returns a string : the upper case translation of the number i to hexadecimal.
  1058. * @param i number
  1059. * @returns the upper case translation of the number i to hexadecimal.
  1060. */
  1061. static ToHex(i: number): string;
  1062. /**
  1063. * Returns -1 if value is negative and +1 is value is positive.
  1064. * @param value the value
  1065. * @returns the value itself if it's equal to zero.
  1066. */
  1067. static Sign(value: number): number;
  1068. /**
  1069. * Returns the value itself if it's between min and max.
  1070. * Returns min if the value is lower than min.
  1071. * Returns max if the value is greater than max.
  1072. * @param value the value to clmap
  1073. * @param min the min value to clamp to (default: 0)
  1074. * @param max the max value to clamp to (default: 1)
  1075. * @returns the clamped value
  1076. */
  1077. static Clamp(value: number, min?: number, max?: number): number;
  1078. /**
  1079. * the log2 of value.
  1080. * @param value the value to compute log2 of
  1081. * @returns the log2 of value.
  1082. */
  1083. static Log2(value: number): number;
  1084. /**
  1085. * Loops the value, so that it is never larger than length and never smaller than 0.
  1086. *
  1087. * This is similar to the modulo operator but it works with floating point numbers.
  1088. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1089. * With t = 5 and length = 2.5, the result would be 0.0.
  1090. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1091. * @param value the value
  1092. * @param length the length
  1093. * @returns the looped value
  1094. */
  1095. static Repeat(value: number, length: number): number;
  1096. /**
  1097. * Normalize the value between 0.0 and 1.0 using min and max values
  1098. * @param value value to normalize
  1099. * @param min max to normalize between
  1100. * @param max min to normalize between
  1101. * @returns the normalized value
  1102. */
  1103. static Normalize(value: number, min: number, max: number): number;
  1104. /**
  1105. * Denormalize the value from 0.0 and 1.0 using min and max values
  1106. * @param normalized value to denormalize
  1107. * @param min max to denormalize between
  1108. * @param max min to denormalize between
  1109. * @returns the denormalized value
  1110. */
  1111. static Denormalize(normalized: number, min: number, max: number): number;
  1112. /**
  1113. * Calculates the shortest difference between two given angles given in degrees.
  1114. * @param current current angle in degrees
  1115. * @param target target angle in degrees
  1116. * @returns the delta
  1117. */
  1118. static DeltaAngle(current: number, target: number): number;
  1119. /**
  1120. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1121. * @param tx value
  1122. * @param length length
  1123. * @returns The returned value will move back and forth between 0 and length
  1124. */
  1125. static PingPong(tx: number, length: number): number;
  1126. /**
  1127. * Interpolates between min and max with smoothing at the limits.
  1128. *
  1129. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1130. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1131. * @param from from
  1132. * @param to to
  1133. * @param tx value
  1134. * @returns the smooth stepped value
  1135. */
  1136. static SmoothStep(from: number, to: number, tx: number): number;
  1137. /**
  1138. * Moves a value current towards target.
  1139. *
  1140. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1141. * Negative values of maxDelta pushes the value away from target.
  1142. * @param current current value
  1143. * @param target target value
  1144. * @param maxDelta max distance to move
  1145. * @returns resulting value
  1146. */
  1147. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1148. /**
  1149. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1150. *
  1151. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1152. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1153. * @param current current value
  1154. * @param target target value
  1155. * @param maxDelta max distance to move
  1156. * @returns resulting angle
  1157. */
  1158. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1159. /**
  1160. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1161. * @param start start value
  1162. * @param end target value
  1163. * @param amount amount to lerp between
  1164. * @returns the lerped value
  1165. */
  1166. static Lerp(start: number, end: number, amount: number): number;
  1167. /**
  1168. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1169. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1170. * @param start start value
  1171. * @param end target value
  1172. * @param amount amount to lerp between
  1173. * @returns the lerped value
  1174. */
  1175. static LerpAngle(start: number, end: number, amount: number): number;
  1176. /**
  1177. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1178. * @param a start value
  1179. * @param b target value
  1180. * @param value value between a and b
  1181. * @returns the inverseLerp value
  1182. */
  1183. static InverseLerp(a: number, b: number, value: number): number;
  1184. /**
  1185. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1186. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1187. * @param value1 spline value
  1188. * @param tangent1 spline value
  1189. * @param value2 spline value
  1190. * @param tangent2 spline value
  1191. * @param amount input value
  1192. * @returns hermite result
  1193. */
  1194. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1195. /**
  1196. * Returns a random float number between and min and max values
  1197. * @param min min value of random
  1198. * @param max max value of random
  1199. * @returns random value
  1200. */
  1201. static RandomRange(min: number, max: number): number;
  1202. /**
  1203. * This function returns percentage of a number in a given range.
  1204. *
  1205. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1206. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1207. * @param number to convert to percentage
  1208. * @param min min range
  1209. * @param max max range
  1210. * @returns the percentage
  1211. */
  1212. static RangeToPercent(number: number, min: number, max: number): number;
  1213. /**
  1214. * This function returns number that corresponds to the percentage in a given range.
  1215. *
  1216. * PercentToRange(0.34,0,100) will return 34.
  1217. * @param percent to convert to number
  1218. * @param min min range
  1219. * @param max max range
  1220. * @returns the number
  1221. */
  1222. static PercentToRange(percent: number, min: number, max: number): number;
  1223. /**
  1224. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1225. * @param angle The angle to normalize in radian.
  1226. * @return The converted angle.
  1227. */
  1228. static NormalizeRadians(angle: number): number;
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /**
  1233. * Constant used to convert a value to gamma space
  1234. * @ignorenaming
  1235. */
  1236. export const ToGammaSpace: number;
  1237. /**
  1238. * Constant used to convert a value to linear space
  1239. * @ignorenaming
  1240. */
  1241. export const ToLinearSpace = 2.2;
  1242. /**
  1243. * Constant used to define the minimal number value in Babylon.js
  1244. * @ignorenaming
  1245. */
  1246. let Epsilon: number;
  1247. }
  1248. declare module BABYLON {
  1249. /**
  1250. * Class used to represent a viewport on screen
  1251. */
  1252. export class Viewport {
  1253. /** viewport left coordinate */
  1254. x: number;
  1255. /** viewport top coordinate */
  1256. y: number;
  1257. /**viewport width */
  1258. width: number;
  1259. /** viewport height */
  1260. height: number;
  1261. /**
  1262. * Creates a Viewport object located at (x, y) and sized (width, height)
  1263. * @param x defines viewport left coordinate
  1264. * @param y defines viewport top coordinate
  1265. * @param width defines the viewport width
  1266. * @param height defines the viewport height
  1267. */
  1268. constructor(
  1269. /** viewport left coordinate */
  1270. x: number,
  1271. /** viewport top coordinate */
  1272. y: number,
  1273. /**viewport width */
  1274. width: number,
  1275. /** viewport height */
  1276. height: number);
  1277. /**
  1278. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1279. * @param renderWidth defines the rendering width
  1280. * @param renderHeight defines the rendering height
  1281. * @returns a new Viewport
  1282. */
  1283. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1284. /**
  1285. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1286. * @param renderWidth defines the rendering width
  1287. * @param renderHeight defines the rendering height
  1288. * @param ref defines the target viewport
  1289. * @returns the current viewport
  1290. */
  1291. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1292. /**
  1293. * Returns a new Viewport copied from the current one
  1294. * @returns a new Viewport
  1295. */
  1296. clone(): Viewport;
  1297. }
  1298. }
  1299. declare module BABYLON {
  1300. /**
  1301. * Class containing a set of static utilities functions for arrays.
  1302. */
  1303. export class ArrayTools {
  1304. /**
  1305. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1306. * @param size the number of element to construct and put in the array
  1307. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1308. * @returns a new array filled with new objects
  1309. */
  1310. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1311. }
  1312. }
  1313. declare module BABYLON {
  1314. /**
  1315. * @hidden
  1316. */
  1317. export interface IColor4Like {
  1318. r: float;
  1319. g: float;
  1320. b: float;
  1321. a: float;
  1322. }
  1323. /**
  1324. * @hidden
  1325. */
  1326. export interface IColor3Like {
  1327. r: float;
  1328. g: float;
  1329. b: float;
  1330. }
  1331. /**
  1332. * @hidden
  1333. */
  1334. export interface IVector4Like {
  1335. x: float;
  1336. y: float;
  1337. z: float;
  1338. w: float;
  1339. }
  1340. /**
  1341. * @hidden
  1342. */
  1343. export interface IVector3Like {
  1344. x: float;
  1345. y: float;
  1346. z: float;
  1347. }
  1348. /**
  1349. * @hidden
  1350. */
  1351. export interface IVector2Like {
  1352. x: float;
  1353. y: float;
  1354. }
  1355. /**
  1356. * @hidden
  1357. */
  1358. export interface IMatrixLike {
  1359. toArray(): DeepImmutable<Float32Array>;
  1360. updateFlag: int;
  1361. }
  1362. /**
  1363. * @hidden
  1364. */
  1365. export interface IViewportLike {
  1366. x: float;
  1367. y: float;
  1368. width: float;
  1369. height: float;
  1370. }
  1371. /**
  1372. * @hidden
  1373. */
  1374. export interface IPlaneLike {
  1375. normal: IVector3Like;
  1376. d: float;
  1377. normalize(): void;
  1378. }
  1379. }
  1380. declare module BABYLON {
  1381. /**
  1382. * Class representing a vector containing 2 coordinates
  1383. */
  1384. export class Vector2 {
  1385. /** defines the first coordinate */
  1386. x: number;
  1387. /** defines the second coordinate */
  1388. y: number;
  1389. /**
  1390. * Creates a new Vector2 from the given x and y coordinates
  1391. * @param x defines the first coordinate
  1392. * @param y defines the second coordinate
  1393. */
  1394. constructor(
  1395. /** defines the first coordinate */
  1396. x?: number,
  1397. /** defines the second coordinate */
  1398. y?: number);
  1399. /**
  1400. * Gets a string with the Vector2 coordinates
  1401. * @returns a string with the Vector2 coordinates
  1402. */
  1403. toString(): string;
  1404. /**
  1405. * Gets class name
  1406. * @returns the string "Vector2"
  1407. */
  1408. getClassName(): string;
  1409. /**
  1410. * Gets current vector hash code
  1411. * @returns the Vector2 hash code as a number
  1412. */
  1413. getHashCode(): number;
  1414. /**
  1415. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1416. * @param array defines the source array
  1417. * @param index defines the offset in source array
  1418. * @returns the current Vector2
  1419. */
  1420. toArray(array: FloatArray, index?: number): Vector2;
  1421. /**
  1422. * Copy the current vector to an array
  1423. * @returns a new array with 2 elements: the Vector2 coordinates.
  1424. */
  1425. asArray(): number[];
  1426. /**
  1427. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1428. * @param source defines the source Vector2
  1429. * @returns the current updated Vector2
  1430. */
  1431. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1432. /**
  1433. * Sets the Vector2 coordinates with the given floats
  1434. * @param x defines the first coordinate
  1435. * @param y defines the second coordinate
  1436. * @returns the current updated Vector2
  1437. */
  1438. copyFromFloats(x: number, y: number): Vector2;
  1439. /**
  1440. * Sets the Vector2 coordinates with the given floats
  1441. * @param x defines the first coordinate
  1442. * @param y defines the second coordinate
  1443. * @returns the current updated Vector2
  1444. */
  1445. set(x: number, y: number): Vector2;
  1446. /**
  1447. * Add another vector with the current one
  1448. * @param otherVector defines the other vector
  1449. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1450. */
  1451. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1452. /**
  1453. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1454. * @param otherVector defines the other vector
  1455. * @param result defines the target vector
  1456. * @returns the unmodified current Vector2
  1457. */
  1458. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1459. /**
  1460. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1461. * @param otherVector defines the other vector
  1462. * @returns the current updated Vector2
  1463. */
  1464. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1465. /**
  1466. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1467. * @param otherVector defines the other vector
  1468. * @returns a new Vector2
  1469. */
  1470. addVector3(otherVector: Vector3): Vector2;
  1471. /**
  1472. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1473. * @param otherVector defines the other vector
  1474. * @returns a new Vector2
  1475. */
  1476. subtract(otherVector: Vector2): Vector2;
  1477. /**
  1478. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1479. * @param otherVector defines the other vector
  1480. * @param result defines the target vector
  1481. * @returns the unmodified current Vector2
  1482. */
  1483. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1484. /**
  1485. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1486. * @param otherVector defines the other vector
  1487. * @returns the current updated Vector2
  1488. */
  1489. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1490. /**
  1491. * Multiplies in place the current Vector2 coordinates by the given ones
  1492. * @param otherVector defines the other vector
  1493. * @returns the current updated Vector2
  1494. */
  1495. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1496. /**
  1497. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1498. * @param otherVector defines the other vector
  1499. * @returns a new Vector2
  1500. */
  1501. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1502. /**
  1503. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1504. * @param otherVector defines the other vector
  1505. * @param result defines the target vector
  1506. * @returns the unmodified current Vector2
  1507. */
  1508. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1509. /**
  1510. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1511. * @param x defines the first coordinate
  1512. * @param y defines the second coordinate
  1513. * @returns a new Vector2
  1514. */
  1515. multiplyByFloats(x: number, y: number): Vector2;
  1516. /**
  1517. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1518. * @param otherVector defines the other vector
  1519. * @returns a new Vector2
  1520. */
  1521. divide(otherVector: Vector2): Vector2;
  1522. /**
  1523. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1524. * @param otherVector defines the other vector
  1525. * @param result defines the target vector
  1526. * @returns the unmodified current Vector2
  1527. */
  1528. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1529. /**
  1530. * Divides the current Vector2 coordinates by the given ones
  1531. * @param otherVector defines the other vector
  1532. * @returns the current updated Vector2
  1533. */
  1534. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1535. /**
  1536. * Gets a new Vector2 with current Vector2 negated coordinates
  1537. * @returns a new Vector2
  1538. */
  1539. negate(): Vector2;
  1540. /**
  1541. * Multiply the Vector2 coordinates by scale
  1542. * @param scale defines the scaling factor
  1543. * @returns the current updated Vector2
  1544. */
  1545. scaleInPlace(scale: number): Vector2;
  1546. /**
  1547. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1548. * @param scale defines the scaling factor
  1549. * @returns a new Vector2
  1550. */
  1551. scale(scale: number): Vector2;
  1552. /**
  1553. * Scale the current Vector2 values by a factor to a given Vector2
  1554. * @param scale defines the scale factor
  1555. * @param result defines the Vector2 object where to store the result
  1556. * @returns the unmodified current Vector2
  1557. */
  1558. scaleToRef(scale: number, result: Vector2): Vector2;
  1559. /**
  1560. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1561. * @param scale defines the scale factor
  1562. * @param result defines the Vector2 object where to store the result
  1563. * @returns the unmodified current Vector2
  1564. */
  1565. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1566. /**
  1567. * Gets a boolean if two vectors are equals
  1568. * @param otherVector defines the other vector
  1569. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1570. */
  1571. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1572. /**
  1573. * Gets a boolean if two vectors are equals (using an epsilon value)
  1574. * @param otherVector defines the other vector
  1575. * @param epsilon defines the minimal distance to consider equality
  1576. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1577. */
  1578. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1579. /**
  1580. * Gets a new Vector2 from current Vector2 floored values
  1581. * @returns a new Vector2
  1582. */
  1583. floor(): Vector2;
  1584. /**
  1585. * Gets a new Vector2 from current Vector2 floored values
  1586. * @returns a new Vector2
  1587. */
  1588. fract(): Vector2;
  1589. /**
  1590. * Gets the length of the vector
  1591. * @returns the vector length (float)
  1592. */
  1593. length(): number;
  1594. /**
  1595. * Gets the vector squared length
  1596. * @returns the vector squared length (float)
  1597. */
  1598. lengthSquared(): number;
  1599. /**
  1600. * Normalize the vector
  1601. * @returns the current updated Vector2
  1602. */
  1603. normalize(): Vector2;
  1604. /**
  1605. * Gets a new Vector2 copied from the Vector2
  1606. * @returns a new Vector2
  1607. */
  1608. clone(): Vector2;
  1609. /**
  1610. * Gets a new Vector2(0, 0)
  1611. * @returns a new Vector2
  1612. */
  1613. static Zero(): Vector2;
  1614. /**
  1615. * Gets a new Vector2(1, 1)
  1616. * @returns a new Vector2
  1617. */
  1618. static One(): Vector2;
  1619. /**
  1620. * Gets a new Vector2 set from the given index element of the given array
  1621. * @param array defines the data source
  1622. * @param offset defines the offset in the data source
  1623. * @returns a new Vector2
  1624. */
  1625. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1626. /**
  1627. * Sets "result" from the given index element of the given array
  1628. * @param array defines the data source
  1629. * @param offset defines the offset in the data source
  1630. * @param result defines the target vector
  1631. */
  1632. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1633. /**
  1634. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1635. * @param value1 defines 1st point of control
  1636. * @param value2 defines 2nd point of control
  1637. * @param value3 defines 3rd point of control
  1638. * @param value4 defines 4th point of control
  1639. * @param amount defines the interpolation factor
  1640. * @returns a new Vector2
  1641. */
  1642. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1643. /**
  1644. * 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".
  1645. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1646. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1647. * @param value defines the value to clamp
  1648. * @param min defines the lower limit
  1649. * @param max defines the upper limit
  1650. * @returns a new Vector2
  1651. */
  1652. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1653. /**
  1654. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1655. * @param value1 defines the 1st control point
  1656. * @param tangent1 defines the outgoing tangent
  1657. * @param value2 defines the 2nd control point
  1658. * @param tangent2 defines the incoming tangent
  1659. * @param amount defines the interpolation factor
  1660. * @returns a new Vector2
  1661. */
  1662. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1663. /**
  1664. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1665. * @param start defines the start vector
  1666. * @param end defines the end vector
  1667. * @param amount defines the interpolation factor
  1668. * @returns a new Vector2
  1669. */
  1670. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1671. /**
  1672. * Gets the dot product of the vector "left" and the vector "right"
  1673. * @param left defines first vector
  1674. * @param right defines second vector
  1675. * @returns the dot product (float)
  1676. */
  1677. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1678. /**
  1679. * Returns a new Vector2 equal to the normalized given vector
  1680. * @param vector defines the vector to normalize
  1681. * @returns a new Vector2
  1682. */
  1683. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1684. /**
  1685. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1686. * @param left defines 1st vector
  1687. * @param right defines 2nd vector
  1688. * @returns a new Vector2
  1689. */
  1690. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1691. /**
  1692. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1693. * @param left defines 1st vector
  1694. * @param right defines 2nd vector
  1695. * @returns a new Vector2
  1696. */
  1697. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1698. /**
  1699. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1700. * @param vector defines the vector to transform
  1701. * @param transformation defines the matrix to apply
  1702. * @returns a new Vector2
  1703. */
  1704. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1705. /**
  1706. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1707. * @param vector defines the vector to transform
  1708. * @param transformation defines the matrix to apply
  1709. * @param result defines the target vector
  1710. */
  1711. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1712. /**
  1713. * Determines if a given vector is included in a triangle
  1714. * @param p defines the vector to test
  1715. * @param p0 defines 1st triangle point
  1716. * @param p1 defines 2nd triangle point
  1717. * @param p2 defines 3rd triangle point
  1718. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1719. */
  1720. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1721. /**
  1722. * Gets the distance between the vectors "value1" and "value2"
  1723. * @param value1 defines first vector
  1724. * @param value2 defines second vector
  1725. * @returns the distance between vectors
  1726. */
  1727. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1728. /**
  1729. * Returns the squared distance between the vectors "value1" and "value2"
  1730. * @param value1 defines first vector
  1731. * @param value2 defines second vector
  1732. * @returns the squared distance between vectors
  1733. */
  1734. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1735. /**
  1736. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1737. * @param value1 defines first vector
  1738. * @param value2 defines second vector
  1739. * @returns a new Vector2
  1740. */
  1741. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1742. /**
  1743. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1744. * @param p defines the middle point
  1745. * @param segA defines one point of the segment
  1746. * @param segB defines the other point of the segment
  1747. * @returns the shortest distance
  1748. */
  1749. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1750. }
  1751. /**
  1752. * Classed used to store (x,y,z) vector representation
  1753. * A Vector3 is the main object used in 3D geometry
  1754. * It can represent etiher the coordinates of a point the space, either a direction
  1755. * Reminder: js uses a left handed forward facing system
  1756. */
  1757. export class Vector3 {
  1758. /**
  1759. * Defines the first coordinates (on X axis)
  1760. */
  1761. x: number;
  1762. /**
  1763. * Defines the second coordinates (on Y axis)
  1764. */
  1765. y: number;
  1766. /**
  1767. * Defines the third coordinates (on Z axis)
  1768. */
  1769. z: number;
  1770. private static _UpReadOnly;
  1771. private static _ZeroReadOnly;
  1772. /**
  1773. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1774. * @param x defines the first coordinates (on X axis)
  1775. * @param y defines the second coordinates (on Y axis)
  1776. * @param z defines the third coordinates (on Z axis)
  1777. */
  1778. constructor(
  1779. /**
  1780. * Defines the first coordinates (on X axis)
  1781. */
  1782. x?: number,
  1783. /**
  1784. * Defines the second coordinates (on Y axis)
  1785. */
  1786. y?: number,
  1787. /**
  1788. * Defines the third coordinates (on Z axis)
  1789. */
  1790. z?: number);
  1791. /**
  1792. * Creates a string representation of the Vector3
  1793. * @returns a string with the Vector3 coordinates.
  1794. */
  1795. toString(): string;
  1796. /**
  1797. * Gets the class name
  1798. * @returns the string "Vector3"
  1799. */
  1800. getClassName(): string;
  1801. /**
  1802. * Creates the Vector3 hash code
  1803. * @returns a number which tends to be unique between Vector3 instances
  1804. */
  1805. getHashCode(): number;
  1806. /**
  1807. * Creates an array containing three elements : the coordinates of the Vector3
  1808. * @returns a new array of numbers
  1809. */
  1810. asArray(): number[];
  1811. /**
  1812. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1813. * @param array defines the destination array
  1814. * @param index defines the offset in the destination array
  1815. * @returns the current Vector3
  1816. */
  1817. toArray(array: FloatArray, index?: number): Vector3;
  1818. /**
  1819. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1820. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1821. */
  1822. toQuaternion(): Quaternion;
  1823. /**
  1824. * Adds the given vector to the current Vector3
  1825. * @param otherVector defines the second operand
  1826. * @returns the current updated Vector3
  1827. */
  1828. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1829. /**
  1830. * Adds the given coordinates to the current Vector3
  1831. * @param x defines the x coordinate of the operand
  1832. * @param y defines the y coordinate of the operand
  1833. * @param z defines the z coordinate of the operand
  1834. * @returns the current updated Vector3
  1835. */
  1836. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1837. /**
  1838. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1839. * @param otherVector defines the second operand
  1840. * @returns the resulting Vector3
  1841. */
  1842. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1843. /**
  1844. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1845. * @param otherVector defines the second operand
  1846. * @param result defines the Vector3 object where to store the result
  1847. * @returns the current Vector3
  1848. */
  1849. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1850. /**
  1851. * Subtract the given vector from the current Vector3
  1852. * @param otherVector defines the second operand
  1853. * @returns the current updated Vector3
  1854. */
  1855. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1856. /**
  1857. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1858. * @param otherVector defines the second operand
  1859. * @returns the resulting Vector3
  1860. */
  1861. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1862. /**
  1863. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1864. * @param otherVector defines the second operand
  1865. * @param result defines the Vector3 object where to store the result
  1866. * @returns the current Vector3
  1867. */
  1868. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1869. /**
  1870. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1871. * @param x defines the x coordinate of the operand
  1872. * @param y defines the y coordinate of the operand
  1873. * @param z defines the z coordinate of the operand
  1874. * @returns the resulting Vector3
  1875. */
  1876. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1877. /**
  1878. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1879. * @param x defines the x coordinate of the operand
  1880. * @param y defines the y coordinate of the operand
  1881. * @param z defines the z coordinate of the operand
  1882. * @param result defines the Vector3 object where to store the result
  1883. * @returns the current Vector3
  1884. */
  1885. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1886. /**
  1887. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1888. * @returns a new Vector3
  1889. */
  1890. negate(): Vector3;
  1891. /**
  1892. * Multiplies the Vector3 coordinates by the float "scale"
  1893. * @param scale defines the multiplier factor
  1894. * @returns the current updated Vector3
  1895. */
  1896. scaleInPlace(scale: number): Vector3;
  1897. /**
  1898. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1899. * @param scale defines the multiplier factor
  1900. * @returns a new Vector3
  1901. */
  1902. scale(scale: number): Vector3;
  1903. /**
  1904. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1905. * @param scale defines the multiplier factor
  1906. * @param result defines the Vector3 object where to store the result
  1907. * @returns the current Vector3
  1908. */
  1909. scaleToRef(scale: number, result: Vector3): Vector3;
  1910. /**
  1911. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1912. * @param scale defines the scale factor
  1913. * @param result defines the Vector3 object where to store the result
  1914. * @returns the unmodified current Vector3
  1915. */
  1916. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1917. /**
  1918. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1919. * @param otherVector defines the second operand
  1920. * @returns true if both vectors are equals
  1921. */
  1922. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1923. /**
  1924. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1925. * @param otherVector defines the second operand
  1926. * @param epsilon defines the minimal distance to define values as equals
  1927. * @returns true if both vectors are distant less than epsilon
  1928. */
  1929. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1930. /**
  1931. * Returns true if the current Vector3 coordinates equals the given floats
  1932. * @param x defines the x coordinate of the operand
  1933. * @param y defines the y coordinate of the operand
  1934. * @param z defines the z coordinate of the operand
  1935. * @returns true if both vectors are equals
  1936. */
  1937. equalsToFloats(x: number, y: number, z: number): boolean;
  1938. /**
  1939. * Multiplies the current Vector3 coordinates by the given ones
  1940. * @param otherVector defines the second operand
  1941. * @returns the current updated Vector3
  1942. */
  1943. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1944. /**
  1945. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1946. * @param otherVector defines the second operand
  1947. * @returns the new Vector3
  1948. */
  1949. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1950. /**
  1951. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1952. * @param otherVector defines the second operand
  1953. * @param result defines the Vector3 object where to store the result
  1954. * @returns the current Vector3
  1955. */
  1956. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1957. /**
  1958. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1959. * @param x defines the x coordinate of the operand
  1960. * @param y defines the y coordinate of the operand
  1961. * @param z defines the z coordinate of the operand
  1962. * @returns the new Vector3
  1963. */
  1964. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1965. /**
  1966. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1967. * @param otherVector defines the second operand
  1968. * @returns the new Vector3
  1969. */
  1970. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1971. /**
  1972. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1973. * @param otherVector defines the second operand
  1974. * @param result defines the Vector3 object where to store the result
  1975. * @returns the current Vector3
  1976. */
  1977. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1978. /**
  1979. * Divides the current Vector3 coordinates by the given ones.
  1980. * @param otherVector defines the second operand
  1981. * @returns the current updated Vector3
  1982. */
  1983. divideInPlace(otherVector: Vector3): Vector3;
  1984. /**
  1985. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1986. * @param other defines the second operand
  1987. * @returns the current updated Vector3
  1988. */
  1989. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1990. /**
  1991. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1992. * @param other defines the second operand
  1993. * @returns the current updated Vector3
  1994. */
  1995. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1996. /**
  1997. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1998. * @param x defines the x coordinate of the operand
  1999. * @param y defines the y coordinate of the operand
  2000. * @param z defines the z coordinate of the operand
  2001. * @returns the current updated Vector3
  2002. */
  2003. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2004. /**
  2005. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2006. * @param x defines the x coordinate of the operand
  2007. * @param y defines the y coordinate of the operand
  2008. * @param z defines the z coordinate of the operand
  2009. * @returns the current updated Vector3
  2010. */
  2011. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2012. /**
  2013. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2014. * Check if is non uniform within a certain amount of decimal places to account for this
  2015. * @param epsilon the amount the values can differ
  2016. * @returns if the the vector is non uniform to a certain number of decimal places
  2017. */
  2018. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2019. /**
  2020. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2021. */
  2022. readonly isNonUniform: boolean;
  2023. /**
  2024. * Gets a new Vector3 from current Vector3 floored values
  2025. * @returns a new Vector3
  2026. */
  2027. floor(): Vector3;
  2028. /**
  2029. * Gets a new Vector3 from current Vector3 floored values
  2030. * @returns a new Vector3
  2031. */
  2032. fract(): Vector3;
  2033. /**
  2034. * Gets the length of the Vector3
  2035. * @returns the length of the Vector3
  2036. */
  2037. length(): number;
  2038. /**
  2039. * Gets the squared length of the Vector3
  2040. * @returns squared length of the Vector3
  2041. */
  2042. lengthSquared(): number;
  2043. /**
  2044. * Normalize the current Vector3.
  2045. * Please note that this is an in place operation.
  2046. * @returns the current updated Vector3
  2047. */
  2048. normalize(): Vector3;
  2049. /**
  2050. * Reorders the x y z properties of the vector in place
  2051. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2052. * @returns the current updated vector
  2053. */
  2054. reorderInPlace(order: string): this;
  2055. /**
  2056. * Rotates the vector around 0,0,0 by a quaternion
  2057. * @param quaternion the rotation quaternion
  2058. * @param result vector to store the result
  2059. * @returns the resulting vector
  2060. */
  2061. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2062. /**
  2063. * Rotates a vector around a given point
  2064. * @param quaternion the rotation quaternion
  2065. * @param point the point to rotate around
  2066. * @param result vector to store the result
  2067. * @returns the resulting vector
  2068. */
  2069. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2070. /**
  2071. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2072. * The cross product is then orthogonal to both current and "other"
  2073. * @param other defines the right operand
  2074. * @returns the cross product
  2075. */
  2076. cross(other: Vector3): Vector3;
  2077. /**
  2078. * Normalize the current Vector3 with the given input length.
  2079. * Please note that this is an in place operation.
  2080. * @param len the length of the vector
  2081. * @returns the current updated Vector3
  2082. */
  2083. normalizeFromLength(len: number): Vector3;
  2084. /**
  2085. * Normalize the current Vector3 to a new vector
  2086. * @returns the new Vector3
  2087. */
  2088. normalizeToNew(): Vector3;
  2089. /**
  2090. * Normalize the current Vector3 to the reference
  2091. * @param reference define the Vector3 to update
  2092. * @returns the updated Vector3
  2093. */
  2094. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2095. /**
  2096. * Creates a new Vector3 copied from the current Vector3
  2097. * @returns the new Vector3
  2098. */
  2099. clone(): Vector3;
  2100. /**
  2101. * Copies the given vector coordinates to the current Vector3 ones
  2102. * @param source defines the source Vector3
  2103. * @returns the current updated Vector3
  2104. */
  2105. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2106. /**
  2107. * Copies the given floats to the current Vector3 coordinates
  2108. * @param x defines the x coordinate of the operand
  2109. * @param y defines the y coordinate of the operand
  2110. * @param z defines the z coordinate of the operand
  2111. * @returns the current updated Vector3
  2112. */
  2113. copyFromFloats(x: number, y: number, z: number): Vector3;
  2114. /**
  2115. * Copies the given floats to the current Vector3 coordinates
  2116. * @param x defines the x coordinate of the operand
  2117. * @param y defines the y coordinate of the operand
  2118. * @param z defines the z coordinate of the operand
  2119. * @returns the current updated Vector3
  2120. */
  2121. set(x: number, y: number, z: number): Vector3;
  2122. /**
  2123. * Copies the given float to the current Vector3 coordinates
  2124. * @param v defines the x, y and z coordinates of the operand
  2125. * @returns the current updated Vector3
  2126. */
  2127. setAll(v: number): Vector3;
  2128. /**
  2129. * Get the clip factor between two vectors
  2130. * @param vector0 defines the first operand
  2131. * @param vector1 defines the second operand
  2132. * @param axis defines the axis to use
  2133. * @param size defines the size along the axis
  2134. * @returns the clip factor
  2135. */
  2136. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2137. /**
  2138. * Get angle between two vectors
  2139. * @param vector0 angle between vector0 and vector1
  2140. * @param vector1 angle between vector0 and vector1
  2141. * @param normal direction of the normal
  2142. * @return the angle between vector0 and vector1
  2143. */
  2144. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2145. /**
  2146. * Returns a new Vector3 set from the index "offset" of the given array
  2147. * @param array defines the source array
  2148. * @param offset defines the offset in the source array
  2149. * @returns the new Vector3
  2150. */
  2151. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2152. /**
  2153. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2154. * This function is deprecated. Use FromArray instead
  2155. * @param array defines the source array
  2156. * @param offset defines the offset in the source array
  2157. * @returns the new Vector3
  2158. */
  2159. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2160. /**
  2161. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2162. * @param array defines the source array
  2163. * @param offset defines the offset in the source array
  2164. * @param result defines the Vector3 where to store the result
  2165. */
  2166. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2167. /**
  2168. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2169. * This function is deprecated. Use FromArrayToRef instead.
  2170. * @param array defines the source array
  2171. * @param offset defines the offset in the source array
  2172. * @param result defines the Vector3 where to store the result
  2173. */
  2174. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2175. /**
  2176. * Sets the given vector "result" with the given floats.
  2177. * @param x defines the x coordinate of the source
  2178. * @param y defines the y coordinate of the source
  2179. * @param z defines the z coordinate of the source
  2180. * @param result defines the Vector3 where to store the result
  2181. */
  2182. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2183. /**
  2184. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2185. * @returns a new empty Vector3
  2186. */
  2187. static Zero(): Vector3;
  2188. /**
  2189. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2190. * @returns a new unit Vector3
  2191. */
  2192. static One(): Vector3;
  2193. /**
  2194. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2195. * @returns a new up Vector3
  2196. */
  2197. static Up(): Vector3;
  2198. /**
  2199. * Gets a up Vector3 that must not be updated
  2200. */
  2201. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2202. /**
  2203. * Gets a zero Vector3 that must not be updated
  2204. */
  2205. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2206. /**
  2207. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2208. * @returns a new down Vector3
  2209. */
  2210. static Down(): Vector3;
  2211. /**
  2212. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2213. * @returns a new forward Vector3
  2214. */
  2215. static Forward(): Vector3;
  2216. /**
  2217. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2218. * @returns a new forward Vector3
  2219. */
  2220. static Backward(): Vector3;
  2221. /**
  2222. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2223. * @returns a new right Vector3
  2224. */
  2225. static Right(): Vector3;
  2226. /**
  2227. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2228. * @returns a new left Vector3
  2229. */
  2230. static Left(): Vector3;
  2231. /**
  2232. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2233. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2234. * @param vector defines the Vector3 to transform
  2235. * @param transformation defines the transformation matrix
  2236. * @returns the transformed Vector3
  2237. */
  2238. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2239. /**
  2240. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2241. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2242. * @param vector defines the Vector3 to transform
  2243. * @param transformation defines the transformation matrix
  2244. * @param result defines the Vector3 where to store the result
  2245. */
  2246. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2247. /**
  2248. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2249. * This method computes tranformed coordinates only, not transformed direction vectors
  2250. * @param x define the x coordinate of the source vector
  2251. * @param y define the y coordinate of the source vector
  2252. * @param z define the z coordinate of the source vector
  2253. * @param transformation defines the transformation matrix
  2254. * @param result defines the Vector3 where to store the result
  2255. */
  2256. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2257. /**
  2258. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2259. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2260. * @param vector defines the Vector3 to transform
  2261. * @param transformation defines the transformation matrix
  2262. * @returns the new Vector3
  2263. */
  2264. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2265. /**
  2266. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2267. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2268. * @param vector defines the Vector3 to transform
  2269. * @param transformation defines the transformation matrix
  2270. * @param result defines the Vector3 where to store the result
  2271. */
  2272. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2273. /**
  2274. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2275. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2276. * @param x define the x coordinate of the source vector
  2277. * @param y define the y coordinate of the source vector
  2278. * @param z define the z coordinate of the source vector
  2279. * @param transformation defines the transformation matrix
  2280. * @param result defines the Vector3 where to store the result
  2281. */
  2282. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2283. /**
  2284. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2285. * @param value1 defines the first control point
  2286. * @param value2 defines the second control point
  2287. * @param value3 defines the third control point
  2288. * @param value4 defines the fourth control point
  2289. * @param amount defines the amount on the spline to use
  2290. * @returns the new Vector3
  2291. */
  2292. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2293. /**
  2294. * 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"
  2295. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2296. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2297. * @param value defines the current value
  2298. * @param min defines the lower range value
  2299. * @param max defines the upper range value
  2300. * @returns the new Vector3
  2301. */
  2302. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2303. /**
  2304. * 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"
  2305. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2306. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2307. * @param value defines the current value
  2308. * @param min defines the lower range value
  2309. * @param max defines the upper range value
  2310. * @param result defines the Vector3 where to store the result
  2311. */
  2312. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2313. /**
  2314. * Checks if a given vector is inside a specific range
  2315. * @param v defines the vector to test
  2316. * @param min defines the minimum range
  2317. * @param max defines the maximum range
  2318. */
  2319. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2320. /**
  2321. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2322. * @param value1 defines the first control point
  2323. * @param tangent1 defines the first tangent vector
  2324. * @param value2 defines the second control point
  2325. * @param tangent2 defines the second tangent vector
  2326. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2327. * @returns the new Vector3
  2328. */
  2329. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2330. /**
  2331. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2332. * @param start defines the start value
  2333. * @param end defines the end value
  2334. * @param amount max defines amount between both (between 0 and 1)
  2335. * @returns the new Vector3
  2336. */
  2337. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2338. /**
  2339. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2340. * @param start defines the start value
  2341. * @param end defines the end value
  2342. * @param amount max defines amount between both (between 0 and 1)
  2343. * @param result defines the Vector3 where to store the result
  2344. */
  2345. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2346. /**
  2347. * Returns the dot product (float) between the vectors "left" and "right"
  2348. * @param left defines the left operand
  2349. * @param right defines the right operand
  2350. * @returns the dot product
  2351. */
  2352. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2353. /**
  2354. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2355. * The cross product is then orthogonal to both "left" and "right"
  2356. * @param left defines the left operand
  2357. * @param right defines the right operand
  2358. * @returns the cross product
  2359. */
  2360. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2361. /**
  2362. * Sets the given vector "result" with the cross product of "left" and "right"
  2363. * The cross product is then orthogonal to both "left" and "right"
  2364. * @param left defines the left operand
  2365. * @param right defines the right operand
  2366. * @param result defines the Vector3 where to store the result
  2367. */
  2368. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2369. /**
  2370. * Returns a new Vector3 as the normalization of the given vector
  2371. * @param vector defines the Vector3 to normalize
  2372. * @returns the new Vector3
  2373. */
  2374. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2375. /**
  2376. * Sets the given vector "result" with the normalization of the given first vector
  2377. * @param vector defines the Vector3 to normalize
  2378. * @param result defines the Vector3 where to store the result
  2379. */
  2380. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2381. /**
  2382. * Project a Vector3 onto screen space
  2383. * @param vector defines the Vector3 to project
  2384. * @param world defines the world matrix to use
  2385. * @param transform defines the transform (view x projection) matrix to use
  2386. * @param viewport defines the screen viewport to use
  2387. * @returns the new Vector3
  2388. */
  2389. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2390. /** @hidden */
  2391. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2392. /**
  2393. * Unproject from screen space to object space
  2394. * @param source defines the screen space Vector3 to use
  2395. * @param viewportWidth defines the current width of the viewport
  2396. * @param viewportHeight defines the current height of the viewport
  2397. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2398. * @param transform defines the transform (view x projection) matrix to use
  2399. * @returns the new Vector3
  2400. */
  2401. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2402. /**
  2403. * Unproject from screen space to object space
  2404. * @param source defines the screen space Vector3 to use
  2405. * @param viewportWidth defines the current width of the viewport
  2406. * @param viewportHeight defines the current height of the viewport
  2407. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2408. * @param view defines the view matrix to use
  2409. * @param projection defines the projection matrix to use
  2410. * @returns the new Vector3
  2411. */
  2412. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2413. /**
  2414. * Unproject from screen space to object space
  2415. * @param source defines the screen space Vector3 to use
  2416. * @param viewportWidth defines the current width of the viewport
  2417. * @param viewportHeight defines the current height of the viewport
  2418. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2419. * @param view defines the view matrix to use
  2420. * @param projection defines the projection matrix to use
  2421. * @param result defines the Vector3 where to store the result
  2422. */
  2423. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2424. /**
  2425. * Unproject from screen space to object space
  2426. * @param sourceX defines the screen space x coordinate to use
  2427. * @param sourceY defines the screen space y coordinate to use
  2428. * @param sourceZ defines the screen space z coordinate to use
  2429. * @param viewportWidth defines the current width of the viewport
  2430. * @param viewportHeight defines the current height of the viewport
  2431. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2432. * @param view defines the view matrix to use
  2433. * @param projection defines the projection matrix to use
  2434. * @param result defines the Vector3 where to store the result
  2435. */
  2436. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2437. /**
  2438. * Gets the minimal coordinate values between two Vector3
  2439. * @param left defines the first operand
  2440. * @param right defines the second operand
  2441. * @returns the new Vector3
  2442. */
  2443. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2444. /**
  2445. * Gets the maximal coordinate values between two Vector3
  2446. * @param left defines the first operand
  2447. * @param right defines the second operand
  2448. * @returns the new Vector3
  2449. */
  2450. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2451. /**
  2452. * Returns the distance between the vectors "value1" and "value2"
  2453. * @param value1 defines the first operand
  2454. * @param value2 defines the second operand
  2455. * @returns the distance
  2456. */
  2457. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2458. /**
  2459. * Returns the squared distance between the vectors "value1" and "value2"
  2460. * @param value1 defines the first operand
  2461. * @param value2 defines the second operand
  2462. * @returns the squared distance
  2463. */
  2464. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2465. /**
  2466. * Returns a new Vector3 located at the center between "value1" and "value2"
  2467. * @param value1 defines the first operand
  2468. * @param value2 defines the second operand
  2469. * @returns the new Vector3
  2470. */
  2471. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2472. /**
  2473. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2474. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2475. * to something in order to rotate it from its local system to the given target system
  2476. * Note: axis1, axis2 and axis3 are normalized during this operation
  2477. * @param axis1 defines the first axis
  2478. * @param axis2 defines the second axis
  2479. * @param axis3 defines the third axis
  2480. * @returns a new Vector3
  2481. */
  2482. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2483. /**
  2484. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2485. * @param axis1 defines the first axis
  2486. * @param axis2 defines the second axis
  2487. * @param axis3 defines the third axis
  2488. * @param ref defines the Vector3 where to store the result
  2489. */
  2490. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2491. }
  2492. /**
  2493. * Vector4 class created for EulerAngle class conversion to Quaternion
  2494. */
  2495. export class Vector4 {
  2496. /** x value of the vector */
  2497. x: number;
  2498. /** y value of the vector */
  2499. y: number;
  2500. /** z value of the vector */
  2501. z: number;
  2502. /** w value of the vector */
  2503. w: number;
  2504. /**
  2505. * Creates a Vector4 object from the given floats.
  2506. * @param x x value of the vector
  2507. * @param y y value of the vector
  2508. * @param z z value of the vector
  2509. * @param w w value of the vector
  2510. */
  2511. constructor(
  2512. /** x value of the vector */
  2513. x: number,
  2514. /** y value of the vector */
  2515. y: number,
  2516. /** z value of the vector */
  2517. z: number,
  2518. /** w value of the vector */
  2519. w: number);
  2520. /**
  2521. * Returns the string with the Vector4 coordinates.
  2522. * @returns a string containing all the vector values
  2523. */
  2524. toString(): string;
  2525. /**
  2526. * Returns the string "Vector4".
  2527. * @returns "Vector4"
  2528. */
  2529. getClassName(): string;
  2530. /**
  2531. * Returns the Vector4 hash code.
  2532. * @returns a unique hash code
  2533. */
  2534. getHashCode(): number;
  2535. /**
  2536. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2537. * @returns the resulting array
  2538. */
  2539. asArray(): number[];
  2540. /**
  2541. * Populates the given array from the given index with the Vector4 coordinates.
  2542. * @param array array to populate
  2543. * @param index index of the array to start at (default: 0)
  2544. * @returns the Vector4.
  2545. */
  2546. toArray(array: FloatArray, index?: number): Vector4;
  2547. /**
  2548. * Adds the given vector to the current Vector4.
  2549. * @param otherVector the vector to add
  2550. * @returns the updated Vector4.
  2551. */
  2552. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2553. /**
  2554. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2555. * @param otherVector the vector to add
  2556. * @returns the resulting vector
  2557. */
  2558. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2559. /**
  2560. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2561. * @param otherVector the vector to add
  2562. * @param result the vector to store the result
  2563. * @returns the current Vector4.
  2564. */
  2565. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2566. /**
  2567. * Subtract in place the given vector from the current Vector4.
  2568. * @param otherVector the vector to subtract
  2569. * @returns the updated Vector4.
  2570. */
  2571. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2572. /**
  2573. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2574. * @param otherVector the vector to add
  2575. * @returns the new vector with the result
  2576. */
  2577. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2578. /**
  2579. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2580. * @param otherVector the vector to subtract
  2581. * @param result the vector to store the result
  2582. * @returns the current Vector4.
  2583. */
  2584. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2585. /**
  2586. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2587. */
  2588. /**
  2589. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2590. * @param x value to subtract
  2591. * @param y value to subtract
  2592. * @param z value to subtract
  2593. * @param w value to subtract
  2594. * @returns new vector containing the result
  2595. */
  2596. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2597. /**
  2598. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2599. * @param x value to subtract
  2600. * @param y value to subtract
  2601. * @param z value to subtract
  2602. * @param w value to subtract
  2603. * @param result the vector to store the result in
  2604. * @returns the current Vector4.
  2605. */
  2606. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2607. /**
  2608. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2609. * @returns a new vector with the negated values
  2610. */
  2611. negate(): Vector4;
  2612. /**
  2613. * Multiplies the current Vector4 coordinates by scale (float).
  2614. * @param scale the number to scale with
  2615. * @returns the updated Vector4.
  2616. */
  2617. scaleInPlace(scale: number): Vector4;
  2618. /**
  2619. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2620. * @param scale the number to scale with
  2621. * @returns a new vector with the result
  2622. */
  2623. scale(scale: number): Vector4;
  2624. /**
  2625. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2626. * @param scale the number to scale with
  2627. * @param result a vector to store the result in
  2628. * @returns the current Vector4.
  2629. */
  2630. scaleToRef(scale: number, result: Vector4): Vector4;
  2631. /**
  2632. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2633. * @param scale defines the scale factor
  2634. * @param result defines the Vector4 object where to store the result
  2635. * @returns the unmodified current Vector4
  2636. */
  2637. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2638. /**
  2639. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2640. * @param otherVector the vector to compare against
  2641. * @returns true if they are equal
  2642. */
  2643. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2644. /**
  2645. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2646. * @param otherVector vector to compare against
  2647. * @param epsilon (Default: very small number)
  2648. * @returns true if they are equal
  2649. */
  2650. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2651. /**
  2652. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2653. * @param x x value to compare against
  2654. * @param y y value to compare against
  2655. * @param z z value to compare against
  2656. * @param w w value to compare against
  2657. * @returns true if equal
  2658. */
  2659. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2660. /**
  2661. * Multiplies in place the current Vector4 by the given one.
  2662. * @param otherVector vector to multiple with
  2663. * @returns the updated Vector4.
  2664. */
  2665. multiplyInPlace(otherVector: Vector4): Vector4;
  2666. /**
  2667. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2668. * @param otherVector vector to multiple with
  2669. * @returns resulting new vector
  2670. */
  2671. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2672. /**
  2673. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2674. * @param otherVector vector to multiple with
  2675. * @param result vector to store the result
  2676. * @returns the current Vector4.
  2677. */
  2678. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2679. /**
  2680. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2681. * @param x x value multiply with
  2682. * @param y y value multiply with
  2683. * @param z z value multiply with
  2684. * @param w w value multiply with
  2685. * @returns resulting new vector
  2686. */
  2687. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2688. /**
  2689. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2690. * @param otherVector vector to devide with
  2691. * @returns resulting new vector
  2692. */
  2693. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2694. /**
  2695. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2696. * @param otherVector vector to devide with
  2697. * @param result vector to store the result
  2698. * @returns the current Vector4.
  2699. */
  2700. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2701. /**
  2702. * Divides the current Vector3 coordinates by the given ones.
  2703. * @param otherVector vector to devide with
  2704. * @returns the updated Vector3.
  2705. */
  2706. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2707. /**
  2708. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2709. * @param other defines the second operand
  2710. * @returns the current updated Vector4
  2711. */
  2712. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2713. /**
  2714. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2715. * @param other defines the second operand
  2716. * @returns the current updated Vector4
  2717. */
  2718. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2719. /**
  2720. * Gets a new Vector4 from current Vector4 floored values
  2721. * @returns a new Vector4
  2722. */
  2723. floor(): Vector4;
  2724. /**
  2725. * Gets a new Vector4 from current Vector3 floored values
  2726. * @returns a new Vector4
  2727. */
  2728. fract(): Vector4;
  2729. /**
  2730. * Returns the Vector4 length (float).
  2731. * @returns the length
  2732. */
  2733. length(): number;
  2734. /**
  2735. * Returns the Vector4 squared length (float).
  2736. * @returns the length squared
  2737. */
  2738. lengthSquared(): number;
  2739. /**
  2740. * Normalizes in place the Vector4.
  2741. * @returns the updated Vector4.
  2742. */
  2743. normalize(): Vector4;
  2744. /**
  2745. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2746. * @returns this converted to a new vector3
  2747. */
  2748. toVector3(): Vector3;
  2749. /**
  2750. * Returns a new Vector4 copied from the current one.
  2751. * @returns the new cloned vector
  2752. */
  2753. clone(): Vector4;
  2754. /**
  2755. * Updates the current Vector4 with the given one coordinates.
  2756. * @param source the source vector to copy from
  2757. * @returns the updated Vector4.
  2758. */
  2759. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2760. /**
  2761. * Updates the current Vector4 coordinates with the given floats.
  2762. * @param x float to copy from
  2763. * @param y float to copy from
  2764. * @param z float to copy from
  2765. * @param w float to copy from
  2766. * @returns the updated Vector4.
  2767. */
  2768. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2769. /**
  2770. * Updates the current Vector4 coordinates with the given floats.
  2771. * @param x float to set from
  2772. * @param y float to set from
  2773. * @param z float to set from
  2774. * @param w float to set from
  2775. * @returns the updated Vector4.
  2776. */
  2777. set(x: number, y: number, z: number, w: number): Vector4;
  2778. /**
  2779. * Copies the given float to the current Vector3 coordinates
  2780. * @param v defines the x, y, z and w coordinates of the operand
  2781. * @returns the current updated Vector3
  2782. */
  2783. setAll(v: number): Vector4;
  2784. /**
  2785. * Returns a new Vector4 set from the starting index of the given array.
  2786. * @param array the array to pull values from
  2787. * @param offset the offset into the array to start at
  2788. * @returns the new vector
  2789. */
  2790. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2791. /**
  2792. * Updates the given vector "result" from the starting index of the given array.
  2793. * @param array the array to pull values from
  2794. * @param offset the offset into the array to start at
  2795. * @param result the vector to store the result in
  2796. */
  2797. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2798. /**
  2799. * Updates the given vector "result" from the starting index of the given Float32Array.
  2800. * @param array the array to pull values from
  2801. * @param offset the offset into the array to start at
  2802. * @param result the vector to store the result in
  2803. */
  2804. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2805. /**
  2806. * Updates the given vector "result" coordinates from the given floats.
  2807. * @param x float to set from
  2808. * @param y float to set from
  2809. * @param z float to set from
  2810. * @param w float to set from
  2811. * @param result the vector to the floats in
  2812. */
  2813. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2814. /**
  2815. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2816. * @returns the new vector
  2817. */
  2818. static Zero(): Vector4;
  2819. /**
  2820. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2821. * @returns the new vector
  2822. */
  2823. static One(): Vector4;
  2824. /**
  2825. * Returns a new normalized Vector4 from the given one.
  2826. * @param vector the vector to normalize
  2827. * @returns the vector
  2828. */
  2829. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2830. /**
  2831. * Updates the given vector "result" from the normalization of the given one.
  2832. * @param vector the vector to normalize
  2833. * @param result the vector to store the result in
  2834. */
  2835. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2836. /**
  2837. * Returns a vector with the minimum values from the left and right vectors
  2838. * @param left left vector to minimize
  2839. * @param right right vector to minimize
  2840. * @returns a new vector with the minimum of the left and right vector values
  2841. */
  2842. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2843. /**
  2844. * Returns a vector with the maximum values from the left and right vectors
  2845. * @param left left vector to maximize
  2846. * @param right right vector to maximize
  2847. * @returns a new vector with the maximum of the left and right vector values
  2848. */
  2849. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2850. /**
  2851. * Returns the distance (float) between the vectors "value1" and "value2".
  2852. * @param value1 value to calulate the distance between
  2853. * @param value2 value to calulate the distance between
  2854. * @return the distance between the two vectors
  2855. */
  2856. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2857. /**
  2858. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2859. * @param value1 value to calulate the distance between
  2860. * @param value2 value to calulate the distance between
  2861. * @return the distance between the two vectors squared
  2862. */
  2863. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2864. /**
  2865. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2866. * @param value1 value to calulate the center between
  2867. * @param value2 value to calulate the center between
  2868. * @return the center between the two vectors
  2869. */
  2870. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2871. /**
  2872. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2873. * This methods computes transformed normalized direction vectors only.
  2874. * @param vector the vector to transform
  2875. * @param transformation the transformation matrix to apply
  2876. * @returns the new vector
  2877. */
  2878. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2879. /**
  2880. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2881. * This methods computes transformed normalized direction vectors only.
  2882. * @param vector the vector to transform
  2883. * @param transformation the transformation matrix to apply
  2884. * @param result the vector to store the result in
  2885. */
  2886. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2887. /**
  2888. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2889. * This methods computes transformed normalized direction vectors only.
  2890. * @param x value to transform
  2891. * @param y value to transform
  2892. * @param z value to transform
  2893. * @param w value to transform
  2894. * @param transformation the transformation matrix to apply
  2895. * @param result the vector to store the results in
  2896. */
  2897. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2898. /**
  2899. * Creates a new Vector4 from a Vector3
  2900. * @param source defines the source data
  2901. * @param w defines the 4th component (default is 0)
  2902. * @returns a new Vector4
  2903. */
  2904. static FromVector3(source: Vector3, w?: number): Vector4;
  2905. }
  2906. /**
  2907. * Class used to store quaternion data
  2908. * @see https://en.wikipedia.org/wiki/Quaternion
  2909. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2910. */
  2911. export class Quaternion {
  2912. /** defines the first component (0 by default) */
  2913. x: number;
  2914. /** defines the second component (0 by default) */
  2915. y: number;
  2916. /** defines the third component (0 by default) */
  2917. z: number;
  2918. /** defines the fourth component (1.0 by default) */
  2919. w: number;
  2920. /**
  2921. * Creates a new Quaternion from the given floats
  2922. * @param x defines the first component (0 by default)
  2923. * @param y defines the second component (0 by default)
  2924. * @param z defines the third component (0 by default)
  2925. * @param w defines the fourth component (1.0 by default)
  2926. */
  2927. constructor(
  2928. /** defines the first component (0 by default) */
  2929. x?: number,
  2930. /** defines the second component (0 by default) */
  2931. y?: number,
  2932. /** defines the third component (0 by default) */
  2933. z?: number,
  2934. /** defines the fourth component (1.0 by default) */
  2935. w?: number);
  2936. /**
  2937. * Gets a string representation for the current quaternion
  2938. * @returns a string with the Quaternion coordinates
  2939. */
  2940. toString(): string;
  2941. /**
  2942. * Gets the class name of the quaternion
  2943. * @returns the string "Quaternion"
  2944. */
  2945. getClassName(): string;
  2946. /**
  2947. * Gets a hash code for this quaternion
  2948. * @returns the quaternion hash code
  2949. */
  2950. getHashCode(): number;
  2951. /**
  2952. * Copy the quaternion to an array
  2953. * @returns a new array populated with 4 elements from the quaternion coordinates
  2954. */
  2955. asArray(): number[];
  2956. /**
  2957. * Check if two quaternions are equals
  2958. * @param otherQuaternion defines the second operand
  2959. * @return true if the current quaternion and the given one coordinates are strictly equals
  2960. */
  2961. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2962. /**
  2963. * Clone the current quaternion
  2964. * @returns a new quaternion copied from the current one
  2965. */
  2966. clone(): Quaternion;
  2967. /**
  2968. * Copy a quaternion to the current one
  2969. * @param other defines the other quaternion
  2970. * @returns the updated current quaternion
  2971. */
  2972. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2973. /**
  2974. * Updates the current quaternion with the given float coordinates
  2975. * @param x defines the x coordinate
  2976. * @param y defines the y coordinate
  2977. * @param z defines the z coordinate
  2978. * @param w defines the w coordinate
  2979. * @returns the updated current quaternion
  2980. */
  2981. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2982. /**
  2983. * Updates the current quaternion from the given float coordinates
  2984. * @param x defines the x coordinate
  2985. * @param y defines the y coordinate
  2986. * @param z defines the z coordinate
  2987. * @param w defines the w coordinate
  2988. * @returns the updated current quaternion
  2989. */
  2990. set(x: number, y: number, z: number, w: number): Quaternion;
  2991. /**
  2992. * Adds two quaternions
  2993. * @param other defines the second operand
  2994. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2995. */
  2996. add(other: DeepImmutable<Quaternion>): Quaternion;
  2997. /**
  2998. * Add a quaternion to the current one
  2999. * @param other defines the quaternion to add
  3000. * @returns the current quaternion
  3001. */
  3002. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3003. /**
  3004. * Subtract two quaternions
  3005. * @param other defines the second operand
  3006. * @returns a new quaternion as the subtraction result of the given one from the current one
  3007. */
  3008. subtract(other: Quaternion): Quaternion;
  3009. /**
  3010. * Multiplies the current quaternion by a scale factor
  3011. * @param value defines the scale factor
  3012. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3013. */
  3014. scale(value: number): Quaternion;
  3015. /**
  3016. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3017. * @param scale defines the scale factor
  3018. * @param result defines the Quaternion object where to store the result
  3019. * @returns the unmodified current quaternion
  3020. */
  3021. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3022. /**
  3023. * Multiplies in place the current quaternion by a scale factor
  3024. * @param value defines the scale factor
  3025. * @returns the current modified quaternion
  3026. */
  3027. scaleInPlace(value: number): Quaternion;
  3028. /**
  3029. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3030. * @param scale defines the scale factor
  3031. * @param result defines the Quaternion object where to store the result
  3032. * @returns the unmodified current quaternion
  3033. */
  3034. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3035. /**
  3036. * Multiplies two quaternions
  3037. * @param q1 defines the second operand
  3038. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3039. */
  3040. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3041. /**
  3042. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3043. * @param q1 defines the second operand
  3044. * @param result defines the target quaternion
  3045. * @returns the current quaternion
  3046. */
  3047. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3048. /**
  3049. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3050. * @param q1 defines the second operand
  3051. * @returns the currentupdated quaternion
  3052. */
  3053. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3054. /**
  3055. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3056. * @param ref defines the target quaternion
  3057. * @returns the current quaternion
  3058. */
  3059. conjugateToRef(ref: Quaternion): Quaternion;
  3060. /**
  3061. * Conjugates in place (1-q) the current quaternion
  3062. * @returns the current updated quaternion
  3063. */
  3064. conjugateInPlace(): Quaternion;
  3065. /**
  3066. * Conjugates in place (1-q) the current quaternion
  3067. * @returns a new quaternion
  3068. */
  3069. conjugate(): Quaternion;
  3070. /**
  3071. * Gets length of current quaternion
  3072. * @returns the quaternion length (float)
  3073. */
  3074. length(): number;
  3075. /**
  3076. * Normalize in place the current quaternion
  3077. * @returns the current updated quaternion
  3078. */
  3079. normalize(): Quaternion;
  3080. /**
  3081. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3082. * @param order is a reserved parameter and is ignore for now
  3083. * @returns a new Vector3 containing the Euler angles
  3084. */
  3085. toEulerAngles(order?: string): Vector3;
  3086. /**
  3087. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3088. * @param result defines the vector which will be filled with the Euler angles
  3089. * @param order is a reserved parameter and is ignore for now
  3090. * @returns the current unchanged quaternion
  3091. */
  3092. toEulerAnglesToRef(result: Vector3): Quaternion;
  3093. /**
  3094. * Updates the given rotation matrix with the current quaternion values
  3095. * @param result defines the target matrix
  3096. * @returns the current unchanged quaternion
  3097. */
  3098. toRotationMatrix(result: Matrix): Quaternion;
  3099. /**
  3100. * Updates the current quaternion from the given rotation matrix values
  3101. * @param matrix defines the source matrix
  3102. * @returns the current updated quaternion
  3103. */
  3104. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3105. /**
  3106. * Creates a new quaternion from a rotation matrix
  3107. * @param matrix defines the source matrix
  3108. * @returns a new quaternion created from the given rotation matrix values
  3109. */
  3110. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3111. /**
  3112. * Updates the given quaternion with the given rotation matrix values
  3113. * @param matrix defines the source matrix
  3114. * @param result defines the target quaternion
  3115. */
  3116. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3117. /**
  3118. * Returns the dot product (float) between the quaternions "left" and "right"
  3119. * @param left defines the left operand
  3120. * @param right defines the right operand
  3121. * @returns the dot product
  3122. */
  3123. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3124. /**
  3125. * Checks if the two quaternions are close to each other
  3126. * @param quat0 defines the first quaternion to check
  3127. * @param quat1 defines the second quaternion to check
  3128. * @returns true if the two quaternions are close to each other
  3129. */
  3130. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3131. /**
  3132. * Creates an empty quaternion
  3133. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3134. */
  3135. static Zero(): Quaternion;
  3136. /**
  3137. * Inverse a given quaternion
  3138. * @param q defines the source quaternion
  3139. * @returns a new quaternion as the inverted current quaternion
  3140. */
  3141. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3142. /**
  3143. * Inverse a given quaternion
  3144. * @param q defines the source quaternion
  3145. * @param result the quaternion the result will be stored in
  3146. * @returns the result quaternion
  3147. */
  3148. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3149. /**
  3150. * Creates an identity quaternion
  3151. * @returns the identity quaternion
  3152. */
  3153. static Identity(): Quaternion;
  3154. /**
  3155. * Gets a boolean indicating if the given quaternion is identity
  3156. * @param quaternion defines the quaternion to check
  3157. * @returns true if the quaternion is identity
  3158. */
  3159. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3160. /**
  3161. * Creates a quaternion from a rotation around an axis
  3162. * @param axis defines the axis to use
  3163. * @param angle defines the angle to use
  3164. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3165. */
  3166. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3167. /**
  3168. * Creates a rotation around an axis and stores it into the given quaternion
  3169. * @param axis defines the axis to use
  3170. * @param angle defines the angle to use
  3171. * @param result defines the target quaternion
  3172. * @returns the target quaternion
  3173. */
  3174. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3175. /**
  3176. * Creates a new quaternion from data stored into an array
  3177. * @param array defines the data source
  3178. * @param offset defines the offset in the source array where the data starts
  3179. * @returns a new quaternion
  3180. */
  3181. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3182. /**
  3183. * Create a quaternion from Euler rotation angles
  3184. * @param x Pitch
  3185. * @param y Yaw
  3186. * @param z Roll
  3187. * @returns the new Quaternion
  3188. */
  3189. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3190. /**
  3191. * Updates a quaternion from Euler rotation angles
  3192. * @param x Pitch
  3193. * @param y Yaw
  3194. * @param z Roll
  3195. * @param result the quaternion to store the result
  3196. * @returns the updated quaternion
  3197. */
  3198. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3199. /**
  3200. * Create a quaternion from Euler rotation vector
  3201. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3202. * @returns the new Quaternion
  3203. */
  3204. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3205. /**
  3206. * Updates a quaternion from Euler rotation vector
  3207. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3208. * @param result the quaternion to store the result
  3209. * @returns the updated quaternion
  3210. */
  3211. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3212. /**
  3213. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3214. * @param yaw defines the rotation around Y axis
  3215. * @param pitch defines the rotation around X axis
  3216. * @param roll defines the rotation around Z axis
  3217. * @returns the new quaternion
  3218. */
  3219. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3220. /**
  3221. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3222. * @param yaw defines the rotation around Y axis
  3223. * @param pitch defines the rotation around X axis
  3224. * @param roll defines the rotation around Z axis
  3225. * @param result defines the target quaternion
  3226. */
  3227. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3228. /**
  3229. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3230. * @param alpha defines the rotation around first axis
  3231. * @param beta defines the rotation around second axis
  3232. * @param gamma defines the rotation around third axis
  3233. * @returns the new quaternion
  3234. */
  3235. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3236. /**
  3237. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3238. * @param alpha defines the rotation around first axis
  3239. * @param beta defines the rotation around second axis
  3240. * @param gamma defines the rotation around third axis
  3241. * @param result defines the target quaternion
  3242. */
  3243. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3244. /**
  3245. * 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)
  3246. * @param axis1 defines the first axis
  3247. * @param axis2 defines the second axis
  3248. * @param axis3 defines the third axis
  3249. * @returns the new quaternion
  3250. */
  3251. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3252. /**
  3253. * 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
  3254. * @param axis1 defines the first axis
  3255. * @param axis2 defines the second axis
  3256. * @param axis3 defines the third axis
  3257. * @param ref defines the target quaternion
  3258. */
  3259. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3260. /**
  3261. * Interpolates between two quaternions
  3262. * @param left defines first quaternion
  3263. * @param right defines second quaternion
  3264. * @param amount defines the gradient to use
  3265. * @returns the new interpolated quaternion
  3266. */
  3267. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3268. /**
  3269. * Interpolates between two quaternions and stores it into a target quaternion
  3270. * @param left defines first quaternion
  3271. * @param right defines second quaternion
  3272. * @param amount defines the gradient to use
  3273. * @param result defines the target quaternion
  3274. */
  3275. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3276. /**
  3277. * Interpolate between two quaternions using Hermite interpolation
  3278. * @param value1 defines first quaternion
  3279. * @param tangent1 defines the incoming tangent
  3280. * @param value2 defines second quaternion
  3281. * @param tangent2 defines the outgoing tangent
  3282. * @param amount defines the target quaternion
  3283. * @returns the new interpolated quaternion
  3284. */
  3285. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3286. }
  3287. /**
  3288. * Class used to store matrix data (4x4)
  3289. */
  3290. export class Matrix {
  3291. private static _updateFlagSeed;
  3292. private static _identityReadOnly;
  3293. private _isIdentity;
  3294. private _isIdentityDirty;
  3295. private _isIdentity3x2;
  3296. private _isIdentity3x2Dirty;
  3297. /**
  3298. * Gets the update flag of the matrix which is an unique number for the matrix.
  3299. * It will be incremented every time the matrix data change.
  3300. * You can use it to speed the comparison between two versions of the same matrix.
  3301. */
  3302. updateFlag: number;
  3303. private readonly _m;
  3304. /**
  3305. * Gets the internal data of the matrix
  3306. */
  3307. readonly m: DeepImmutable<Float32Array>;
  3308. /** @hidden */
  3309. _markAsUpdated(): void;
  3310. /** @hidden */
  3311. private _updateIdentityStatus;
  3312. /**
  3313. * Creates an empty matrix (filled with zeros)
  3314. */
  3315. constructor();
  3316. /**
  3317. * Check if the current matrix is identity
  3318. * @returns true is the matrix is the identity matrix
  3319. */
  3320. isIdentity(): boolean;
  3321. /**
  3322. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3323. * @returns true is the matrix is the identity matrix
  3324. */
  3325. isIdentityAs3x2(): boolean;
  3326. /**
  3327. * Gets the determinant of the matrix
  3328. * @returns the matrix determinant
  3329. */
  3330. determinant(): number;
  3331. /**
  3332. * Returns the matrix as a Float32Array
  3333. * @returns the matrix underlying array
  3334. */
  3335. toArray(): DeepImmutable<Float32Array>;
  3336. /**
  3337. * Returns the matrix as a Float32Array
  3338. * @returns the matrix underlying array.
  3339. */
  3340. asArray(): DeepImmutable<Float32Array>;
  3341. /**
  3342. * Inverts the current matrix in place
  3343. * @returns the current inverted matrix
  3344. */
  3345. invert(): Matrix;
  3346. /**
  3347. * Sets all the matrix elements to zero
  3348. * @returns the current matrix
  3349. */
  3350. reset(): Matrix;
  3351. /**
  3352. * Adds the current matrix with a second one
  3353. * @param other defines the matrix to add
  3354. * @returns a new matrix as the addition of the current matrix and the given one
  3355. */
  3356. add(other: DeepImmutable<Matrix>): Matrix;
  3357. /**
  3358. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3359. * @param other defines the matrix to add
  3360. * @param result defines the target matrix
  3361. * @returns the current matrix
  3362. */
  3363. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3364. /**
  3365. * Adds in place the given matrix to the current matrix
  3366. * @param other defines the second operand
  3367. * @returns the current updated matrix
  3368. */
  3369. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3370. /**
  3371. * Sets the given matrix to the current inverted Matrix
  3372. * @param other defines the target matrix
  3373. * @returns the unmodified current matrix
  3374. */
  3375. invertToRef(other: Matrix): Matrix;
  3376. /**
  3377. * add a value at the specified position in the current Matrix
  3378. * @param index the index of the value within the matrix. between 0 and 15.
  3379. * @param value the value to be added
  3380. * @returns the current updated matrix
  3381. */
  3382. addAtIndex(index: number, value: number): Matrix;
  3383. /**
  3384. * mutiply the specified position in the current Matrix by a value
  3385. * @param index the index of the value within the matrix. between 0 and 15.
  3386. * @param value the value to be added
  3387. * @returns the current updated matrix
  3388. */
  3389. multiplyAtIndex(index: number, value: number): Matrix;
  3390. /**
  3391. * Inserts the translation vector (using 3 floats) in the current matrix
  3392. * @param x defines the 1st component of the translation
  3393. * @param y defines the 2nd component of the translation
  3394. * @param z defines the 3rd component of the translation
  3395. * @returns the current updated matrix
  3396. */
  3397. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3398. /**
  3399. * Adds the translation vector (using 3 floats) in the current matrix
  3400. * @param x defines the 1st component of the translation
  3401. * @param y defines the 2nd component of the translation
  3402. * @param z defines the 3rd component of the translation
  3403. * @returns the current updated matrix
  3404. */
  3405. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3406. /**
  3407. * Inserts the translation vector in the current matrix
  3408. * @param vector3 defines the translation to insert
  3409. * @returns the current updated matrix
  3410. */
  3411. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3412. /**
  3413. * Gets the translation value of the current matrix
  3414. * @returns a new Vector3 as the extracted translation from the matrix
  3415. */
  3416. getTranslation(): Vector3;
  3417. /**
  3418. * Fill a Vector3 with the extracted translation from the matrix
  3419. * @param result defines the Vector3 where to store the translation
  3420. * @returns the current matrix
  3421. */
  3422. getTranslationToRef(result: Vector3): Matrix;
  3423. /**
  3424. * Remove rotation and scaling part from the matrix
  3425. * @returns the updated matrix
  3426. */
  3427. removeRotationAndScaling(): Matrix;
  3428. /**
  3429. * Multiply two matrices
  3430. * @param other defines the second operand
  3431. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3432. */
  3433. multiply(other: DeepImmutable<Matrix>): Matrix;
  3434. /**
  3435. * Copy the current matrix from the given one
  3436. * @param other defines the source matrix
  3437. * @returns the current updated matrix
  3438. */
  3439. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3440. /**
  3441. * Populates the given array from the starting index with the current matrix values
  3442. * @param array defines the target array
  3443. * @param offset defines the offset in the target array where to start storing values
  3444. * @returns the current matrix
  3445. */
  3446. copyToArray(array: Float32Array, offset?: number): Matrix;
  3447. /**
  3448. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3449. * @param other defines the second operand
  3450. * @param result defines the matrix where to store the multiplication
  3451. * @returns the current matrix
  3452. */
  3453. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3454. /**
  3455. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3456. * @param other defines the second operand
  3457. * @param result defines the array where to store the multiplication
  3458. * @param offset defines the offset in the target array where to start storing values
  3459. * @returns the current matrix
  3460. */
  3461. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3462. /**
  3463. * Check equality between this matrix and a second one
  3464. * @param value defines the second matrix to compare
  3465. * @returns true is the current matrix and the given one values are strictly equal
  3466. */
  3467. equals(value: DeepImmutable<Matrix>): boolean;
  3468. /**
  3469. * Clone the current matrix
  3470. * @returns a new matrix from the current matrix
  3471. */
  3472. clone(): Matrix;
  3473. /**
  3474. * Returns the name of the current matrix class
  3475. * @returns the string "Matrix"
  3476. */
  3477. getClassName(): string;
  3478. /**
  3479. * Gets the hash code of the current matrix
  3480. * @returns the hash code
  3481. */
  3482. getHashCode(): number;
  3483. /**
  3484. * Decomposes the current Matrix into a translation, rotation and scaling components
  3485. * @param scale defines the scale vector3 given as a reference to update
  3486. * @param rotation defines the rotation quaternion given as a reference to update
  3487. * @param translation defines the translation vector3 given as a reference to update
  3488. * @returns true if operation was successful
  3489. */
  3490. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3491. /**
  3492. * Gets specific row of the matrix
  3493. * @param index defines the number of the row to get
  3494. * @returns the index-th row of the current matrix as a new Vector4
  3495. */
  3496. getRow(index: number): Nullable<Vector4>;
  3497. /**
  3498. * Sets the index-th row of the current matrix to the vector4 values
  3499. * @param index defines the number of the row to set
  3500. * @param row defines the target vector4
  3501. * @returns the updated current matrix
  3502. */
  3503. setRow(index: number, row: Vector4): Matrix;
  3504. /**
  3505. * Compute the transpose of the matrix
  3506. * @returns the new transposed matrix
  3507. */
  3508. transpose(): Matrix;
  3509. /**
  3510. * Compute the transpose of the matrix and store it in a given matrix
  3511. * @param result defines the target matrix
  3512. * @returns the current matrix
  3513. */
  3514. transposeToRef(result: Matrix): Matrix;
  3515. /**
  3516. * Sets the index-th row of the current matrix with the given 4 x float values
  3517. * @param index defines the row index
  3518. * @param x defines the x component to set
  3519. * @param y defines the y component to set
  3520. * @param z defines the z component to set
  3521. * @param w defines the w component to set
  3522. * @returns the updated current matrix
  3523. */
  3524. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3525. /**
  3526. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3527. * @param scale defines the scale factor
  3528. * @returns a new matrix
  3529. */
  3530. scale(scale: number): Matrix;
  3531. /**
  3532. * Scale the current matrix values by a factor to a given result matrix
  3533. * @param scale defines the scale factor
  3534. * @param result defines the matrix to store the result
  3535. * @returns the current matrix
  3536. */
  3537. scaleToRef(scale: number, result: Matrix): Matrix;
  3538. /**
  3539. * Scale the current matrix values by a factor and add the result to a given matrix
  3540. * @param scale defines the scale factor
  3541. * @param result defines the Matrix to store the result
  3542. * @returns the current matrix
  3543. */
  3544. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3545. /**
  3546. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3547. * @param ref matrix to store the result
  3548. */
  3549. toNormalMatrix(ref: Matrix): void;
  3550. /**
  3551. * Gets only rotation part of the current matrix
  3552. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3553. */
  3554. getRotationMatrix(): Matrix;
  3555. /**
  3556. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3557. * @param result defines the target matrix to store data to
  3558. * @returns the current matrix
  3559. */
  3560. getRotationMatrixToRef(result: Matrix): Matrix;
  3561. /**
  3562. * Toggles model matrix from being right handed to left handed in place and vice versa
  3563. */
  3564. toggleModelMatrixHandInPlace(): void;
  3565. /**
  3566. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3567. */
  3568. toggleProjectionMatrixHandInPlace(): void;
  3569. /**
  3570. * Creates a matrix from an array
  3571. * @param array defines the source array
  3572. * @param offset defines an offset in the source array
  3573. * @returns a new Matrix set from the starting index of the given array
  3574. */
  3575. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3576. /**
  3577. * Copy the content of an array into a given matrix
  3578. * @param array defines the source array
  3579. * @param offset defines an offset in the source array
  3580. * @param result defines the target matrix
  3581. */
  3582. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3583. /**
  3584. * Stores an array into a matrix after having multiplied each component by a given factor
  3585. * @param array defines the source array
  3586. * @param offset defines the offset in the source array
  3587. * @param scale defines the scaling factor
  3588. * @param result defines the target matrix
  3589. */
  3590. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3591. /**
  3592. * Gets an identity matrix that must not be updated
  3593. */
  3594. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3595. /**
  3596. * Stores a list of values (16) inside a given matrix
  3597. * @param initialM11 defines 1st value of 1st row
  3598. * @param initialM12 defines 2nd value of 1st row
  3599. * @param initialM13 defines 3rd value of 1st row
  3600. * @param initialM14 defines 4th value of 1st row
  3601. * @param initialM21 defines 1st value of 2nd row
  3602. * @param initialM22 defines 2nd value of 2nd row
  3603. * @param initialM23 defines 3rd value of 2nd row
  3604. * @param initialM24 defines 4th value of 2nd row
  3605. * @param initialM31 defines 1st value of 3rd row
  3606. * @param initialM32 defines 2nd value of 3rd row
  3607. * @param initialM33 defines 3rd value of 3rd row
  3608. * @param initialM34 defines 4th value of 3rd row
  3609. * @param initialM41 defines 1st value of 4th row
  3610. * @param initialM42 defines 2nd value of 4th row
  3611. * @param initialM43 defines 3rd value of 4th row
  3612. * @param initialM44 defines 4th value of 4th row
  3613. * @param result defines the target matrix
  3614. */
  3615. 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;
  3616. /**
  3617. * Creates new matrix from a list of values (16)
  3618. * @param initialM11 defines 1st value of 1st row
  3619. * @param initialM12 defines 2nd value of 1st row
  3620. * @param initialM13 defines 3rd value of 1st row
  3621. * @param initialM14 defines 4th value of 1st row
  3622. * @param initialM21 defines 1st value of 2nd row
  3623. * @param initialM22 defines 2nd value of 2nd row
  3624. * @param initialM23 defines 3rd value of 2nd row
  3625. * @param initialM24 defines 4th value of 2nd row
  3626. * @param initialM31 defines 1st value of 3rd row
  3627. * @param initialM32 defines 2nd value of 3rd row
  3628. * @param initialM33 defines 3rd value of 3rd row
  3629. * @param initialM34 defines 4th value of 3rd row
  3630. * @param initialM41 defines 1st value of 4th row
  3631. * @param initialM42 defines 2nd value of 4th row
  3632. * @param initialM43 defines 3rd value of 4th row
  3633. * @param initialM44 defines 4th value of 4th row
  3634. * @returns the new matrix
  3635. */
  3636. 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;
  3637. /**
  3638. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3639. * @param scale defines the scale vector3
  3640. * @param rotation defines the rotation quaternion
  3641. * @param translation defines the translation vector3
  3642. * @returns a new matrix
  3643. */
  3644. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3645. /**
  3646. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3647. * @param scale defines the scale vector3
  3648. * @param rotation defines the rotation quaternion
  3649. * @param translation defines the translation vector3
  3650. * @param result defines the target matrix
  3651. */
  3652. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3653. /**
  3654. * Creates a new identity matrix
  3655. * @returns a new identity matrix
  3656. */
  3657. static Identity(): Matrix;
  3658. /**
  3659. * Creates a new identity matrix and stores the result in a given matrix
  3660. * @param result defines the target matrix
  3661. */
  3662. static IdentityToRef(result: Matrix): void;
  3663. /**
  3664. * Creates a new zero matrix
  3665. * @returns a new zero matrix
  3666. */
  3667. static Zero(): Matrix;
  3668. /**
  3669. * Creates a new rotation matrix for "angle" radians around the X axis
  3670. * @param angle defines the angle (in radians) to use
  3671. * @return the new matrix
  3672. */
  3673. static RotationX(angle: number): Matrix;
  3674. /**
  3675. * Creates a new matrix as the invert of a given matrix
  3676. * @param source defines the source matrix
  3677. * @returns the new matrix
  3678. */
  3679. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3680. /**
  3681. * Creates a new rotation matrix for "angle" radians around the X 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 RotationXToRef(angle: number, result: Matrix): void;
  3686. /**
  3687. * Creates a new rotation matrix for "angle" radians around the Y axis
  3688. * @param angle defines the angle (in radians) to use
  3689. * @return the new matrix
  3690. */
  3691. static RotationY(angle: number): Matrix;
  3692. /**
  3693. * Creates a new rotation matrix for "angle" radians around the Y 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 RotationYToRef(angle: number, result: Matrix): void;
  3698. /**
  3699. * Creates a new rotation matrix for "angle" radians around the Z axis
  3700. * @param angle defines the angle (in radians) to use
  3701. * @return the new matrix
  3702. */
  3703. static RotationZ(angle: number): Matrix;
  3704. /**
  3705. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3706. * @param angle defines the angle (in radians) to use
  3707. * @param result defines the target matrix
  3708. */
  3709. static RotationZToRef(angle: number, result: Matrix): void;
  3710. /**
  3711. * Creates a new rotation matrix for "angle" radians around the given axis
  3712. * @param axis defines the axis to use
  3713. * @param angle defines the angle (in radians) to use
  3714. * @return the new matrix
  3715. */
  3716. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3717. /**
  3718. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3719. * @param axis defines the axis to use
  3720. * @param angle defines the angle (in radians) to use
  3721. * @param result defines the target matrix
  3722. */
  3723. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3724. /**
  3725. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3726. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3727. * @param from defines the vector to align
  3728. * @param to defines the vector to align to
  3729. * @param result defines the target matrix
  3730. */
  3731. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3732. /**
  3733. * Creates a rotation matrix
  3734. * @param yaw defines the yaw angle in radians (Y axis)
  3735. * @param pitch defines the pitch angle in radians (X axis)
  3736. * @param roll defines the roll angle in radians (X axis)
  3737. * @returns the new rotation matrix
  3738. */
  3739. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3740. /**
  3741. * Creates a rotation matrix and stores it in a given matrix
  3742. * @param yaw defines the yaw angle in radians (Y axis)
  3743. * @param pitch defines the pitch angle in radians (X axis)
  3744. * @param roll defines the roll angle in radians (X axis)
  3745. * @param result defines the target matrix
  3746. */
  3747. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3748. /**
  3749. * Creates a scaling matrix
  3750. * @param x defines the scale factor on X axis
  3751. * @param y defines the scale factor on Y axis
  3752. * @param z defines the scale factor on Z axis
  3753. * @returns the new matrix
  3754. */
  3755. static Scaling(x: number, y: number, z: number): Matrix;
  3756. /**
  3757. * Creates a scaling matrix and stores it in a given matrix
  3758. * @param x defines the scale factor on X axis
  3759. * @param y defines the scale factor on Y axis
  3760. * @param z defines the scale factor on Z axis
  3761. * @param result defines the target matrix
  3762. */
  3763. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3764. /**
  3765. * Creates a translation matrix
  3766. * @param x defines the translation on X axis
  3767. * @param y defines the translation on Y axis
  3768. * @param z defines the translationon Z axis
  3769. * @returns the new matrix
  3770. */
  3771. static Translation(x: number, y: number, z: number): Matrix;
  3772. /**
  3773. * Creates a translation matrix and stores it in a given matrix
  3774. * @param x defines the translation on X axis
  3775. * @param y defines the translation on Y axis
  3776. * @param z defines the translationon Z axis
  3777. * @param result defines the target matrix
  3778. */
  3779. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3780. /**
  3781. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3782. * @param startValue defines the start value
  3783. * @param endValue defines the end value
  3784. * @param gradient defines the gradient factor
  3785. * @returns the new matrix
  3786. */
  3787. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3788. /**
  3789. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3790. * @param startValue defines the start value
  3791. * @param endValue defines the end value
  3792. * @param gradient defines the gradient factor
  3793. * @param result defines the Matrix object where to store data
  3794. */
  3795. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3796. /**
  3797. * Builds a new matrix whose values are computed by:
  3798. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3799. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3800. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3801. * @param startValue defines the first matrix
  3802. * @param endValue defines the second matrix
  3803. * @param gradient defines the gradient between the two matrices
  3804. * @returns the new matrix
  3805. */
  3806. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3807. /**
  3808. * Update a matrix to values which are computed by:
  3809. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3810. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3811. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3812. * @param startValue defines the first matrix
  3813. * @param endValue defines the second matrix
  3814. * @param gradient defines the gradient between the two matrices
  3815. * @param result defines the target matrix
  3816. */
  3817. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3818. /**
  3819. * 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"
  3820. * This function works in left handed mode
  3821. * @param eye defines the final position of the entity
  3822. * @param target defines where the entity should look at
  3823. * @param up defines the up vector for the entity
  3824. * @returns the new matrix
  3825. */
  3826. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3827. /**
  3828. * 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".
  3829. * This function works in left handed mode
  3830. * @param eye defines the final position of the entity
  3831. * @param target defines where the entity should look at
  3832. * @param up defines the up vector for the entity
  3833. * @param result defines the target matrix
  3834. */
  3835. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3836. /**
  3837. * 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"
  3838. * This function works in right handed mode
  3839. * @param eye defines the final position of the entity
  3840. * @param target defines where the entity should look at
  3841. * @param up defines the up vector for the entity
  3842. * @returns the new matrix
  3843. */
  3844. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3845. /**
  3846. * 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".
  3847. * This function works in right handed mode
  3848. * @param eye defines the final position of the entity
  3849. * @param target defines where the entity should look at
  3850. * @param up defines the up vector for the entity
  3851. * @param result defines the target matrix
  3852. */
  3853. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3854. /**
  3855. * Create a left-handed orthographic projection matrix
  3856. * @param width defines the viewport width
  3857. * @param height defines the viewport height
  3858. * @param znear defines the near clip plane
  3859. * @param zfar defines the far clip plane
  3860. * @returns a new matrix as a left-handed orthographic projection matrix
  3861. */
  3862. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3863. /**
  3864. * Store a left-handed orthographic projection to a given matrix
  3865. * @param width defines the viewport width
  3866. * @param height defines the viewport height
  3867. * @param znear defines the near clip plane
  3868. * @param zfar defines the far clip plane
  3869. * @param result defines the target matrix
  3870. */
  3871. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3872. /**
  3873. * Create a left-handed orthographic projection matrix
  3874. * @param left defines the viewport left coordinate
  3875. * @param right defines the viewport right coordinate
  3876. * @param bottom defines the viewport bottom coordinate
  3877. * @param top defines the viewport top coordinate
  3878. * @param znear defines the near clip plane
  3879. * @param zfar defines the far clip plane
  3880. * @returns a new matrix as a left-handed orthographic projection matrix
  3881. */
  3882. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3883. /**
  3884. * Stores a left-handed orthographic projection into a given matrix
  3885. * @param left defines the viewport left coordinate
  3886. * @param right defines the viewport right coordinate
  3887. * @param bottom defines the viewport bottom coordinate
  3888. * @param top defines the viewport top coordinate
  3889. * @param znear defines the near clip plane
  3890. * @param zfar defines the far clip plane
  3891. * @param result defines the target matrix
  3892. */
  3893. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3894. /**
  3895. * Creates a right-handed orthographic projection matrix
  3896. * @param left defines the viewport left coordinate
  3897. * @param right defines the viewport right coordinate
  3898. * @param bottom defines the viewport bottom coordinate
  3899. * @param top defines the viewport top coordinate
  3900. * @param znear defines the near clip plane
  3901. * @param zfar defines the far clip plane
  3902. * @returns a new matrix as a right-handed orthographic projection matrix
  3903. */
  3904. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3905. /**
  3906. * Stores a right-handed orthographic projection into a given matrix
  3907. * @param left defines the viewport left coordinate
  3908. * @param right defines the viewport right coordinate
  3909. * @param bottom defines the viewport bottom coordinate
  3910. * @param top defines the viewport top coordinate
  3911. * @param znear defines the near clip plane
  3912. * @param zfar defines the far clip plane
  3913. * @param result defines the target matrix
  3914. */
  3915. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3916. /**
  3917. * Creates a left-handed perspective projection matrix
  3918. * @param width defines the viewport width
  3919. * @param height defines the viewport height
  3920. * @param znear defines the near clip plane
  3921. * @param zfar defines the far clip plane
  3922. * @returns a new matrix as a left-handed perspective projection matrix
  3923. */
  3924. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3925. /**
  3926. * Creates a left-handed perspective projection matrix
  3927. * @param fov defines the horizontal field of view
  3928. * @param aspect defines the aspect ratio
  3929. * @param znear defines the near clip plane
  3930. * @param zfar defines the far clip plane
  3931. * @returns a new matrix as a left-handed perspective projection matrix
  3932. */
  3933. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3934. /**
  3935. * Stores a left-handed perspective projection into a given matrix
  3936. * @param fov defines the horizontal field of view
  3937. * @param aspect defines the aspect ratio
  3938. * @param znear defines the near clip plane
  3939. * @param zfar defines the far clip plane
  3940. * @param result defines the target matrix
  3941. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3942. */
  3943. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3944. /**
  3945. * Creates a right-handed perspective projection matrix
  3946. * @param fov defines the horizontal field of view
  3947. * @param aspect defines the aspect ratio
  3948. * @param znear defines the near clip plane
  3949. * @param zfar defines the far clip plane
  3950. * @returns a new matrix as a right-handed perspective projection matrix
  3951. */
  3952. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3953. /**
  3954. * Stores a right-handed perspective projection into a given matrix
  3955. * @param fov defines the horizontal field of view
  3956. * @param aspect defines the aspect ratio
  3957. * @param znear defines the near clip plane
  3958. * @param zfar defines the far clip plane
  3959. * @param result defines the target matrix
  3960. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3961. */
  3962. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3963. /**
  3964. * Stores a perspective projection for WebVR info a given matrix
  3965. * @param fov defines the field of view
  3966. * @param znear defines the near clip plane
  3967. * @param zfar defines the far clip plane
  3968. * @param result defines the target matrix
  3969. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3970. */
  3971. static PerspectiveFovWebVRToRef(fov: {
  3972. upDegrees: number;
  3973. downDegrees: number;
  3974. leftDegrees: number;
  3975. rightDegrees: number;
  3976. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3977. /**
  3978. * Computes a complete transformation matrix
  3979. * @param viewport defines the viewport to use
  3980. * @param world defines the world matrix
  3981. * @param view defines the view matrix
  3982. * @param projection defines the projection matrix
  3983. * @param zmin defines the near clip plane
  3984. * @param zmax defines the far clip plane
  3985. * @returns the transformation matrix
  3986. */
  3987. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3988. /**
  3989. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3990. * @param matrix defines the matrix to use
  3991. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3992. */
  3993. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3994. /**
  3995. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3996. * @param matrix defines the matrix to use
  3997. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3998. */
  3999. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4000. /**
  4001. * Compute the transpose of a given matrix
  4002. * @param matrix defines the matrix to transpose
  4003. * @returns the new matrix
  4004. */
  4005. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4006. /**
  4007. * Compute the transpose of a matrix and store it in a target matrix
  4008. * @param matrix defines the matrix to transpose
  4009. * @param result defines the target matrix
  4010. */
  4011. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4012. /**
  4013. * Computes a reflection matrix from a plane
  4014. * @param plane defines the reflection plane
  4015. * @returns a new matrix
  4016. */
  4017. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4018. /**
  4019. * Computes a reflection matrix from a plane
  4020. * @param plane defines the reflection plane
  4021. * @param result defines the target matrix
  4022. */
  4023. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4024. /**
  4025. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4026. * @param xaxis defines the value of the 1st axis
  4027. * @param yaxis defines the value of the 2nd axis
  4028. * @param zaxis defines the value of the 3rd axis
  4029. * @param result defines the target matrix
  4030. */
  4031. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4032. /**
  4033. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4034. * @param quat defines the quaternion to use
  4035. * @param result defines the target matrix
  4036. */
  4037. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4038. }
  4039. /**
  4040. * @hidden
  4041. */
  4042. export class TmpVectors {
  4043. static Vector2: Vector2[];
  4044. static Vector3: Vector3[];
  4045. static Vector4: Vector4[];
  4046. static Quaternion: Quaternion[];
  4047. static Matrix: Matrix[];
  4048. }
  4049. }
  4050. declare module BABYLON {
  4051. /** Defines the cross module used constants to avoid circular dependncies */
  4052. export class Constants {
  4053. /** Defines that alpha blending is disabled */
  4054. static readonly ALPHA_DISABLE: number;
  4055. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4056. static readonly ALPHA_ADD: number;
  4057. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4058. static readonly ALPHA_COMBINE: number;
  4059. /** Defines that alpha blending to DEST - SRC * DEST */
  4060. static readonly ALPHA_SUBTRACT: number;
  4061. /** Defines that alpha blending to SRC * DEST */
  4062. static readonly ALPHA_MULTIPLY: number;
  4063. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4064. static readonly ALPHA_MAXIMIZED: number;
  4065. /** Defines that alpha blending to SRC + DEST */
  4066. static readonly ALPHA_ONEONE: number;
  4067. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4068. static readonly ALPHA_PREMULTIPLIED: number;
  4069. /**
  4070. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4071. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4072. */
  4073. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4074. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4075. static readonly ALPHA_INTERPOLATE: number;
  4076. /**
  4077. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4078. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4079. */
  4080. static readonly ALPHA_SCREENMODE: number;
  4081. /** Defines that the ressource is not delayed*/
  4082. static readonly DELAYLOADSTATE_NONE: number;
  4083. /** Defines that the ressource was successfully delay loaded */
  4084. static readonly DELAYLOADSTATE_LOADED: number;
  4085. /** Defines that the ressource is currently delay loading */
  4086. static readonly DELAYLOADSTATE_LOADING: number;
  4087. /** Defines that the ressource is delayed and has not started loading */
  4088. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4089. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4090. static readonly NEVER: number;
  4091. /** 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 */
  4092. static readonly ALWAYS: number;
  4093. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4094. static readonly LESS: number;
  4095. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4096. static readonly EQUAL: number;
  4097. /** 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 */
  4098. static readonly LEQUAL: number;
  4099. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4100. static readonly GREATER: number;
  4101. /** 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 */
  4102. static readonly GEQUAL: number;
  4103. /** 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 */
  4104. static readonly NOTEQUAL: number;
  4105. /** Passed to stencilOperation to specify that stencil value must be kept */
  4106. static readonly KEEP: number;
  4107. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4108. static readonly REPLACE: number;
  4109. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4110. static readonly INCR: number;
  4111. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4112. static readonly DECR: number;
  4113. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4114. static readonly INVERT: number;
  4115. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4116. static readonly INCR_WRAP: number;
  4117. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4118. static readonly DECR_WRAP: number;
  4119. /** Texture is not repeating outside of 0..1 UVs */
  4120. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4121. /** Texture is repeating outside of 0..1 UVs */
  4122. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4123. /** Texture is repeating and mirrored */
  4124. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4125. /** ALPHA */
  4126. static readonly TEXTUREFORMAT_ALPHA: number;
  4127. /** LUMINANCE */
  4128. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4129. /** LUMINANCE_ALPHA */
  4130. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4131. /** RGB */
  4132. static readonly TEXTUREFORMAT_RGB: number;
  4133. /** RGBA */
  4134. static readonly TEXTUREFORMAT_RGBA: number;
  4135. /** RED */
  4136. static readonly TEXTUREFORMAT_RED: number;
  4137. /** RED (2nd reference) */
  4138. static readonly TEXTUREFORMAT_R: number;
  4139. /** RG */
  4140. static readonly TEXTUREFORMAT_RG: number;
  4141. /** RED_INTEGER */
  4142. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4143. /** RED_INTEGER (2nd reference) */
  4144. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4145. /** RG_INTEGER */
  4146. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4147. /** RGB_INTEGER */
  4148. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4149. /** RGBA_INTEGER */
  4150. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4151. /** UNSIGNED_BYTE */
  4152. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4153. /** UNSIGNED_BYTE (2nd reference) */
  4154. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4155. /** FLOAT */
  4156. static readonly TEXTURETYPE_FLOAT: number;
  4157. /** HALF_FLOAT */
  4158. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4159. /** BYTE */
  4160. static readonly TEXTURETYPE_BYTE: number;
  4161. /** SHORT */
  4162. static readonly TEXTURETYPE_SHORT: number;
  4163. /** UNSIGNED_SHORT */
  4164. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4165. /** INT */
  4166. static readonly TEXTURETYPE_INT: number;
  4167. /** UNSIGNED_INT */
  4168. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4169. /** UNSIGNED_SHORT_4_4_4_4 */
  4170. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4171. /** UNSIGNED_SHORT_5_5_5_1 */
  4172. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4173. /** UNSIGNED_SHORT_5_6_5 */
  4174. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4175. /** UNSIGNED_INT_2_10_10_10_REV */
  4176. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4177. /** UNSIGNED_INT_24_8 */
  4178. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4179. /** UNSIGNED_INT_10F_11F_11F_REV */
  4180. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4181. /** UNSIGNED_INT_5_9_9_9_REV */
  4182. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4183. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4184. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4185. /** nearest is mag = nearest and min = nearest and mip = linear */
  4186. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4187. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4188. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4189. /** Trilinear is mag = linear and min = linear and mip = linear */
  4190. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4191. /** nearest is mag = nearest and min = nearest and mip = linear */
  4192. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4193. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4194. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4195. /** Trilinear is mag = linear and min = linear and mip = linear */
  4196. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4197. /** mag = nearest and min = nearest and mip = nearest */
  4198. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4199. /** mag = nearest and min = linear and mip = nearest */
  4200. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4201. /** mag = nearest and min = linear and mip = linear */
  4202. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4203. /** mag = nearest and min = linear and mip = none */
  4204. static readonly TEXTURE_NEAREST_LINEAR: number;
  4205. /** mag = nearest and min = nearest and mip = none */
  4206. static readonly TEXTURE_NEAREST_NEAREST: number;
  4207. /** mag = linear and min = nearest and mip = nearest */
  4208. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4209. /** mag = linear and min = nearest and mip = linear */
  4210. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4211. /** mag = linear and min = linear and mip = none */
  4212. static readonly TEXTURE_LINEAR_LINEAR: number;
  4213. /** mag = linear and min = nearest and mip = none */
  4214. static readonly TEXTURE_LINEAR_NEAREST: number;
  4215. /** Explicit coordinates mode */
  4216. static readonly TEXTURE_EXPLICIT_MODE: number;
  4217. /** Spherical coordinates mode */
  4218. static readonly TEXTURE_SPHERICAL_MODE: number;
  4219. /** Planar coordinates mode */
  4220. static readonly TEXTURE_PLANAR_MODE: number;
  4221. /** Cubic coordinates mode */
  4222. static readonly TEXTURE_CUBIC_MODE: number;
  4223. /** Projection coordinates mode */
  4224. static readonly TEXTURE_PROJECTION_MODE: number;
  4225. /** Skybox coordinates mode */
  4226. static readonly TEXTURE_SKYBOX_MODE: number;
  4227. /** Inverse Cubic coordinates mode */
  4228. static readonly TEXTURE_INVCUBIC_MODE: number;
  4229. /** Equirectangular coordinates mode */
  4230. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4231. /** Equirectangular Fixed coordinates mode */
  4232. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4233. /** Equirectangular Fixed Mirrored coordinates mode */
  4234. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4235. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4236. static readonly SCALEMODE_FLOOR: number;
  4237. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4238. static readonly SCALEMODE_NEAREST: number;
  4239. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4240. static readonly SCALEMODE_CEILING: number;
  4241. /**
  4242. * The dirty texture flag value
  4243. */
  4244. static readonly MATERIAL_TextureDirtyFlag: number;
  4245. /**
  4246. * The dirty light flag value
  4247. */
  4248. static readonly MATERIAL_LightDirtyFlag: number;
  4249. /**
  4250. * The dirty fresnel flag value
  4251. */
  4252. static readonly MATERIAL_FresnelDirtyFlag: number;
  4253. /**
  4254. * The dirty attribute flag value
  4255. */
  4256. static readonly MATERIAL_AttributesDirtyFlag: number;
  4257. /**
  4258. * The dirty misc flag value
  4259. */
  4260. static readonly MATERIAL_MiscDirtyFlag: number;
  4261. /**
  4262. * The all dirty flag value
  4263. */
  4264. static readonly MATERIAL_AllDirtyFlag: number;
  4265. /**
  4266. * Returns the triangle fill mode
  4267. */
  4268. static readonly MATERIAL_TriangleFillMode: number;
  4269. /**
  4270. * Returns the wireframe mode
  4271. */
  4272. static readonly MATERIAL_WireFrameFillMode: number;
  4273. /**
  4274. * Returns the point fill mode
  4275. */
  4276. static readonly MATERIAL_PointFillMode: number;
  4277. /**
  4278. * Returns the point list draw mode
  4279. */
  4280. static readonly MATERIAL_PointListDrawMode: number;
  4281. /**
  4282. * Returns the line list draw mode
  4283. */
  4284. static readonly MATERIAL_LineListDrawMode: number;
  4285. /**
  4286. * Returns the line loop draw mode
  4287. */
  4288. static readonly MATERIAL_LineLoopDrawMode: number;
  4289. /**
  4290. * Returns the line strip draw mode
  4291. */
  4292. static readonly MATERIAL_LineStripDrawMode: number;
  4293. /**
  4294. * Returns the triangle strip draw mode
  4295. */
  4296. static readonly MATERIAL_TriangleStripDrawMode: number;
  4297. /**
  4298. * Returns the triangle fan draw mode
  4299. */
  4300. static readonly MATERIAL_TriangleFanDrawMode: number;
  4301. /**
  4302. * Stores the clock-wise side orientation
  4303. */
  4304. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4305. /**
  4306. * Stores the counter clock-wise side orientation
  4307. */
  4308. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4309. /**
  4310. * Nothing
  4311. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4312. */
  4313. static readonly ACTION_NothingTrigger: number;
  4314. /**
  4315. * On pick
  4316. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4317. */
  4318. static readonly ACTION_OnPickTrigger: number;
  4319. /**
  4320. * On left pick
  4321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4322. */
  4323. static readonly ACTION_OnLeftPickTrigger: number;
  4324. /**
  4325. * On right pick
  4326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4327. */
  4328. static readonly ACTION_OnRightPickTrigger: number;
  4329. /**
  4330. * On center pick
  4331. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4332. */
  4333. static readonly ACTION_OnCenterPickTrigger: number;
  4334. /**
  4335. * On pick down
  4336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4337. */
  4338. static readonly ACTION_OnPickDownTrigger: number;
  4339. /**
  4340. * On double pick
  4341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4342. */
  4343. static readonly ACTION_OnDoublePickTrigger: number;
  4344. /**
  4345. * On pick up
  4346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4347. */
  4348. static readonly ACTION_OnPickUpTrigger: number;
  4349. /**
  4350. * On pick out.
  4351. * This trigger will only be raised if you also declared a OnPickDown
  4352. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4353. */
  4354. static readonly ACTION_OnPickOutTrigger: number;
  4355. /**
  4356. * On long press
  4357. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4358. */
  4359. static readonly ACTION_OnLongPressTrigger: number;
  4360. /**
  4361. * On pointer over
  4362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4363. */
  4364. static readonly ACTION_OnPointerOverTrigger: number;
  4365. /**
  4366. * On pointer out
  4367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4368. */
  4369. static readonly ACTION_OnPointerOutTrigger: number;
  4370. /**
  4371. * On every frame
  4372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4373. */
  4374. static readonly ACTION_OnEveryFrameTrigger: number;
  4375. /**
  4376. * On intersection enter
  4377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4378. */
  4379. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4380. /**
  4381. * On intersection exit
  4382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4383. */
  4384. static readonly ACTION_OnIntersectionExitTrigger: number;
  4385. /**
  4386. * On key down
  4387. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4388. */
  4389. static readonly ACTION_OnKeyDownTrigger: number;
  4390. /**
  4391. * On key up
  4392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4393. */
  4394. static readonly ACTION_OnKeyUpTrigger: number;
  4395. /**
  4396. * Billboard mode will only apply to Y axis
  4397. */
  4398. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4399. /**
  4400. * Billboard mode will apply to all axes
  4401. */
  4402. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4403. /**
  4404. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4405. */
  4406. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4407. /**
  4408. * Gets or sets base Assets URL
  4409. */
  4410. static PARTICLES_BaseAssetsUrl: string;
  4411. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4412. * Test order :
  4413. * Is the bounding sphere outside the frustum ?
  4414. * If not, are the bounding box vertices outside the frustum ?
  4415. * It not, then the cullable object is in the frustum.
  4416. */
  4417. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4418. /** Culling strategy : Bounding Sphere Only.
  4419. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4420. * It's also less accurate than the standard because some not visible objects can still be selected.
  4421. * Test : is the bounding sphere outside the frustum ?
  4422. * If not, then the cullable object is in the frustum.
  4423. */
  4424. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4425. /** Culling strategy : Optimistic Inclusion.
  4426. * This in an inclusion test first, then the standard exclusion test.
  4427. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4428. * 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.
  4429. * Anyway, it's as accurate as the standard strategy.
  4430. * Test :
  4431. * Is the cullable object bounding sphere center in the frustum ?
  4432. * If not, apply the default culling strategy.
  4433. */
  4434. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4435. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4436. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4437. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4438. * 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.
  4439. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4440. * Test :
  4441. * Is the cullable object bounding sphere center in the frustum ?
  4442. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4443. */
  4444. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4445. /**
  4446. * No logging while loading
  4447. */
  4448. static readonly SCENELOADER_NO_LOGGING: number;
  4449. /**
  4450. * Minimal logging while loading
  4451. */
  4452. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4453. /**
  4454. * Summary logging while loading
  4455. */
  4456. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4457. /**
  4458. * Detailled logging while loading
  4459. */
  4460. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4461. }
  4462. }
  4463. declare module BABYLON {
  4464. /**
  4465. * Class used to store and describe the pipeline context associated with an effect
  4466. */
  4467. export interface IPipelineContext {
  4468. /**
  4469. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4470. */
  4471. isAsync: boolean;
  4472. /**
  4473. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4474. */
  4475. isReady: boolean;
  4476. /** @hidden */
  4477. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4478. }
  4479. }
  4480. declare module BABYLON {
  4481. /** @hidden */
  4482. export interface IShaderProcessor {
  4483. attributeProcessor?: (attribute: string) => string;
  4484. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4485. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4486. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4487. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4488. lineProcessor?: (line: string, isFragment: boolean) => string;
  4489. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4490. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4491. }
  4492. }
  4493. declare module BABYLON {
  4494. /** @hidden */
  4495. export interface ProcessingOptions {
  4496. defines: string[];
  4497. indexParameters: any;
  4498. isFragment: boolean;
  4499. shouldUseHighPrecisionShader: boolean;
  4500. supportsUniformBuffers: boolean;
  4501. shadersRepository: string;
  4502. includesShadersStore: {
  4503. [key: string]: string;
  4504. };
  4505. processor?: IShaderProcessor;
  4506. version: string;
  4507. platformName: string;
  4508. lookForClosingBracketForUniformBuffer?: boolean;
  4509. }
  4510. }
  4511. declare module BABYLON {
  4512. /**
  4513. * Helper to manipulate strings
  4514. */
  4515. export class StringTools {
  4516. /**
  4517. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4518. * @param str Source string
  4519. * @param suffix Suffix to search for in the source string
  4520. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4521. */
  4522. static EndsWith(str: string, suffix: string): boolean;
  4523. /**
  4524. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4525. * @param str Source string
  4526. * @param suffix Suffix to search for in the source string
  4527. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4528. */
  4529. static StartsWith(str: string, suffix: string): boolean;
  4530. }
  4531. }
  4532. declare module BABYLON {
  4533. /** @hidden */
  4534. export class ShaderCodeNode {
  4535. line: string;
  4536. children: ShaderCodeNode[];
  4537. additionalDefineKey?: string;
  4538. additionalDefineValue?: string;
  4539. isValid(preprocessors: {
  4540. [key: string]: string;
  4541. }): boolean;
  4542. process(preprocessors: {
  4543. [key: string]: string;
  4544. }, options: ProcessingOptions): string;
  4545. }
  4546. }
  4547. declare module BABYLON {
  4548. /** @hidden */
  4549. export class ShaderCodeCursor {
  4550. private _lines;
  4551. lineIndex: number;
  4552. readonly currentLine: string;
  4553. readonly canRead: boolean;
  4554. lines: string[];
  4555. }
  4556. }
  4557. declare module BABYLON {
  4558. /** @hidden */
  4559. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4560. process(preprocessors: {
  4561. [key: string]: string;
  4562. }, options: ProcessingOptions): string;
  4563. }
  4564. }
  4565. declare module BABYLON {
  4566. /** @hidden */
  4567. export class ShaderDefineExpression {
  4568. isTrue(preprocessors: {
  4569. [key: string]: string;
  4570. }): boolean;
  4571. }
  4572. }
  4573. declare module BABYLON {
  4574. /** @hidden */
  4575. export class ShaderCodeTestNode extends ShaderCodeNode {
  4576. testExpression: ShaderDefineExpression;
  4577. isValid(preprocessors: {
  4578. [key: string]: string;
  4579. }): boolean;
  4580. }
  4581. }
  4582. declare module BABYLON {
  4583. /** @hidden */
  4584. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4585. define: string;
  4586. not: boolean;
  4587. constructor(define: string, not?: boolean);
  4588. isTrue(preprocessors: {
  4589. [key: string]: string;
  4590. }): boolean;
  4591. }
  4592. }
  4593. declare module BABYLON {
  4594. /** @hidden */
  4595. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4596. leftOperand: ShaderDefineExpression;
  4597. rightOperand: ShaderDefineExpression;
  4598. isTrue(preprocessors: {
  4599. [key: string]: string;
  4600. }): boolean;
  4601. }
  4602. }
  4603. declare module BABYLON {
  4604. /** @hidden */
  4605. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4606. leftOperand: ShaderDefineExpression;
  4607. rightOperand: ShaderDefineExpression;
  4608. isTrue(preprocessors: {
  4609. [key: string]: string;
  4610. }): boolean;
  4611. }
  4612. }
  4613. declare module BABYLON {
  4614. /** @hidden */
  4615. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4616. define: string;
  4617. operand: string;
  4618. testValue: string;
  4619. constructor(define: string, operand: string, testValue: string);
  4620. isTrue(preprocessors: {
  4621. [key: string]: string;
  4622. }): boolean;
  4623. }
  4624. }
  4625. declare module BABYLON {
  4626. /**
  4627. * @ignore
  4628. * Application error to support additional information when loading a file
  4629. */
  4630. export class LoadFileError extends Error {
  4631. /** defines the optional web request */
  4632. request?: WebRequest | undefined;
  4633. private static _setPrototypeOf;
  4634. /**
  4635. * Creates a new LoadFileError
  4636. * @param message defines the message of the error
  4637. * @param request defines the optional web request
  4638. */
  4639. constructor(message: string,
  4640. /** defines the optional web request */
  4641. request?: WebRequest | undefined);
  4642. }
  4643. }
  4644. declare module BABYLON {
  4645. /**
  4646. * Class used to enable access to offline support
  4647. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4648. */
  4649. export interface IOfflineProvider {
  4650. /**
  4651. * Gets a boolean indicating if scene must be saved in the database
  4652. */
  4653. enableSceneOffline: boolean;
  4654. /**
  4655. * Gets a boolean indicating if textures must be saved in the database
  4656. */
  4657. enableTexturesOffline: boolean;
  4658. /**
  4659. * Open the offline support and make it available
  4660. * @param successCallback defines the callback to call on success
  4661. * @param errorCallback defines the callback to call on error
  4662. */
  4663. open(successCallback: () => void, errorCallback: () => void): void;
  4664. /**
  4665. * Loads an image from the offline support
  4666. * @param url defines the url to load from
  4667. * @param image defines the target DOM image
  4668. */
  4669. loadImage(url: string, image: HTMLImageElement): void;
  4670. /**
  4671. * Loads a file from offline support
  4672. * @param url defines the URL to load from
  4673. * @param sceneLoaded defines a callback to call on success
  4674. * @param progressCallBack defines a callback to call when progress changed
  4675. * @param errorCallback defines a callback to call on error
  4676. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4677. */
  4678. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4679. }
  4680. }
  4681. declare module BABYLON {
  4682. /**
  4683. * Class used to help managing file picking and drag'n'drop
  4684. * File Storage
  4685. */
  4686. export class FilesInputStore {
  4687. /**
  4688. * List of files ready to be loaded
  4689. */
  4690. static FilesToLoad: {
  4691. [key: string]: File;
  4692. };
  4693. }
  4694. }
  4695. declare module BABYLON {
  4696. /**
  4697. * Class used to define a retry strategy when error happens while loading assets
  4698. */
  4699. export class RetryStrategy {
  4700. /**
  4701. * Function used to defines an exponential back off strategy
  4702. * @param maxRetries defines the maximum number of retries (3 by default)
  4703. * @param baseInterval defines the interval between retries
  4704. * @returns the strategy function to use
  4705. */
  4706. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4707. }
  4708. }
  4709. declare module BABYLON {
  4710. /**
  4711. * @hidden
  4712. */
  4713. export class FileTools {
  4714. /**
  4715. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4716. */
  4717. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4718. /**
  4719. * Gets or sets the base URL to use to load assets
  4720. */
  4721. static BaseUrl: string;
  4722. /**
  4723. * Default behaviour for cors in the application.
  4724. * It can be a string if the expected behavior is identical in the entire app.
  4725. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4726. */
  4727. static CorsBehavior: string | ((url: string | string[]) => string);
  4728. /**
  4729. * Gets or sets a function used to pre-process url before using them to load assets
  4730. */
  4731. static PreprocessUrl: (url: string) => string;
  4732. /**
  4733. * Removes unwanted characters from an url
  4734. * @param url defines the url to clean
  4735. * @returns the cleaned url
  4736. */
  4737. private static _CleanUrl;
  4738. /**
  4739. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4740. * @param url define the url we are trying
  4741. * @param element define the dom element where to configure the cors policy
  4742. */
  4743. static SetCorsBehavior(url: string | string[], element: {
  4744. crossOrigin: string | null;
  4745. }): void;
  4746. /**
  4747. * Loads an image as an HTMLImageElement.
  4748. * @param input url string, ArrayBuffer, or Blob to load
  4749. * @param onLoad callback called when the image successfully loads
  4750. * @param onError callback called when the image fails to load
  4751. * @param offlineProvider offline provider for caching
  4752. * @returns the HTMLImageElement of the loaded image
  4753. */
  4754. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4755. /**
  4756. * Loads a file
  4757. * @param fileToLoad defines the file to load
  4758. * @param callback defines the callback to call when data is loaded
  4759. * @param progressCallBack defines the callback to call during loading process
  4760. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4761. * @returns a file request object
  4762. */
  4763. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4764. /**
  4765. * Loads a file
  4766. * @param url url string, ArrayBuffer, or Blob to load
  4767. * @param onSuccess callback called when the file successfully loads
  4768. * @param onProgress callback called while file is loading (if the server supports this mode)
  4769. * @param offlineProvider defines the offline provider for caching
  4770. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4771. * @param onError callback called when the file fails to load
  4772. * @returns a file request object
  4773. */
  4774. 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;
  4775. /**
  4776. * Checks if the loaded document was accessed via `file:`-Protocol.
  4777. * @returns boolean
  4778. */
  4779. static IsFileURL(): boolean;
  4780. }
  4781. }
  4782. declare module BABYLON {
  4783. /** @hidden */
  4784. export class ShaderProcessor {
  4785. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4786. private static _ProcessPrecision;
  4787. private static _ExtractOperation;
  4788. private static _BuildSubExpression;
  4789. private static _BuildExpression;
  4790. private static _MoveCursorWithinIf;
  4791. private static _MoveCursor;
  4792. private static _EvaluatePreProcessors;
  4793. private static _PreparePreProcessors;
  4794. private static _ProcessShaderConversion;
  4795. private static _ProcessIncludes;
  4796. }
  4797. }
  4798. declare module BABYLON {
  4799. /**
  4800. * Class used to hold a RBG color
  4801. */
  4802. export class Color3 {
  4803. /**
  4804. * Defines the red component (between 0 and 1, default is 0)
  4805. */
  4806. r: number;
  4807. /**
  4808. * Defines the green component (between 0 and 1, default is 0)
  4809. */
  4810. g: number;
  4811. /**
  4812. * Defines the blue component (between 0 and 1, default is 0)
  4813. */
  4814. b: number;
  4815. /**
  4816. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4817. * @param r defines the red component (between 0 and 1, default is 0)
  4818. * @param g defines the green component (between 0 and 1, default is 0)
  4819. * @param b defines the blue component (between 0 and 1, default is 0)
  4820. */
  4821. constructor(
  4822. /**
  4823. * Defines the red component (between 0 and 1, default is 0)
  4824. */
  4825. r?: number,
  4826. /**
  4827. * Defines the green component (between 0 and 1, default is 0)
  4828. */
  4829. g?: number,
  4830. /**
  4831. * Defines the blue component (between 0 and 1, default is 0)
  4832. */
  4833. b?: number);
  4834. /**
  4835. * Creates a string with the Color3 current values
  4836. * @returns the string representation of the Color3 object
  4837. */
  4838. toString(): string;
  4839. /**
  4840. * Returns the string "Color3"
  4841. * @returns "Color3"
  4842. */
  4843. getClassName(): string;
  4844. /**
  4845. * Compute the Color3 hash code
  4846. * @returns an unique number that can be used to hash Color3 objects
  4847. */
  4848. getHashCode(): number;
  4849. /**
  4850. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4851. * @param array defines the array where to store the r,g,b components
  4852. * @param index defines an optional index in the target array to define where to start storing values
  4853. * @returns the current Color3 object
  4854. */
  4855. toArray(array: FloatArray, index?: number): Color3;
  4856. /**
  4857. * Returns a new Color4 object from the current Color3 and the given alpha
  4858. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4859. * @returns a new Color4 object
  4860. */
  4861. toColor4(alpha?: number): Color4;
  4862. /**
  4863. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4864. * @returns the new array
  4865. */
  4866. asArray(): number[];
  4867. /**
  4868. * Returns the luminance value
  4869. * @returns a float value
  4870. */
  4871. toLuminance(): number;
  4872. /**
  4873. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4874. * @param otherColor defines the second operand
  4875. * @returns the new Color3 object
  4876. */
  4877. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4878. /**
  4879. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4880. * @param otherColor defines the second operand
  4881. * @param result defines the Color3 object where to store the result
  4882. * @returns the current Color3
  4883. */
  4884. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4885. /**
  4886. * Determines equality between Color3 objects
  4887. * @param otherColor defines the second operand
  4888. * @returns true if the rgb values are equal to the given ones
  4889. */
  4890. equals(otherColor: DeepImmutable<Color3>): boolean;
  4891. /**
  4892. * Determines equality between the current Color3 object and a set of r,b,g values
  4893. * @param r defines the red component to check
  4894. * @param g defines the green component to check
  4895. * @param b defines the blue component to check
  4896. * @returns true if the rgb values are equal to the given ones
  4897. */
  4898. equalsFloats(r: number, g: number, b: number): boolean;
  4899. /**
  4900. * Multiplies in place each rgb value by scale
  4901. * @param scale defines the scaling factor
  4902. * @returns the updated Color3
  4903. */
  4904. scale(scale: number): Color3;
  4905. /**
  4906. * Multiplies the rgb values by scale and stores the result into "result"
  4907. * @param scale defines the scaling factor
  4908. * @param result defines the Color3 object where to store the result
  4909. * @returns the unmodified current Color3
  4910. */
  4911. scaleToRef(scale: number, result: Color3): Color3;
  4912. /**
  4913. * Scale the current Color3 values by a factor and add the result to a given Color3
  4914. * @param scale defines the scale factor
  4915. * @param result defines color to store the result into
  4916. * @returns the unmodified current Color3
  4917. */
  4918. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4919. /**
  4920. * Clamps the rgb values by the min and max values and stores the result into "result"
  4921. * @param min defines minimum clamping value (default is 0)
  4922. * @param max defines maximum clamping value (default is 1)
  4923. * @param result defines color to store the result into
  4924. * @returns the original Color3
  4925. */
  4926. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4927. /**
  4928. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4929. * @param otherColor defines the second operand
  4930. * @returns the new Color3
  4931. */
  4932. add(otherColor: DeepImmutable<Color3>): Color3;
  4933. /**
  4934. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4935. * @param otherColor defines the second operand
  4936. * @param result defines Color3 object to store the result into
  4937. * @returns the unmodified current Color3
  4938. */
  4939. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4940. /**
  4941. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4942. * @param otherColor defines the second operand
  4943. * @returns the new Color3
  4944. */
  4945. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4946. /**
  4947. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4948. * @param otherColor defines the second operand
  4949. * @param result defines Color3 object to store the result into
  4950. * @returns the unmodified current Color3
  4951. */
  4952. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4953. /**
  4954. * Copy the current object
  4955. * @returns a new Color3 copied the current one
  4956. */
  4957. clone(): Color3;
  4958. /**
  4959. * Copies the rgb values from the source in the current Color3
  4960. * @param source defines the source Color3 object
  4961. * @returns the updated Color3 object
  4962. */
  4963. copyFrom(source: DeepImmutable<Color3>): Color3;
  4964. /**
  4965. * Updates the Color3 rgb values from the given floats
  4966. * @param r defines the red component to read from
  4967. * @param g defines the green component to read from
  4968. * @param b defines the blue component to read from
  4969. * @returns the current Color3 object
  4970. */
  4971. copyFromFloats(r: number, g: number, b: number): Color3;
  4972. /**
  4973. * Updates the Color3 rgb values from the given floats
  4974. * @param r defines the red component to read from
  4975. * @param g defines the green component to read from
  4976. * @param b defines the blue component to read from
  4977. * @returns the current Color3 object
  4978. */
  4979. set(r: number, g: number, b: number): Color3;
  4980. /**
  4981. * Compute the Color3 hexadecimal code as a string
  4982. * @returns a string containing the hexadecimal representation of the Color3 object
  4983. */
  4984. toHexString(): string;
  4985. /**
  4986. * Computes a new Color3 converted from the current one to linear space
  4987. * @returns a new Color3 object
  4988. */
  4989. toLinearSpace(): Color3;
  4990. /**
  4991. * Converts current color in rgb space to HSV values
  4992. * @returns a new color3 representing the HSV values
  4993. */
  4994. toHSV(): Color3;
  4995. /**
  4996. * Converts current color in rgb space to HSV values
  4997. * @param result defines the Color3 where to store the HSV values
  4998. */
  4999. toHSVToRef(result: Color3): void;
  5000. /**
  5001. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5002. * @param convertedColor defines the Color3 object where to store the linear space version
  5003. * @returns the unmodified Color3
  5004. */
  5005. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5006. /**
  5007. * Computes a new Color3 converted from the current one to gamma space
  5008. * @returns a new Color3 object
  5009. */
  5010. toGammaSpace(): Color3;
  5011. /**
  5012. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5013. * @param convertedColor defines the Color3 object where to store the gamma space version
  5014. * @returns the unmodified Color3
  5015. */
  5016. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5017. private static _BlackReadOnly;
  5018. /**
  5019. * Convert Hue, saturation and value to a Color3 (RGB)
  5020. * @param hue defines the hue
  5021. * @param saturation defines the saturation
  5022. * @param value defines the value
  5023. * @param result defines the Color3 where to store the RGB values
  5024. */
  5025. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5026. /**
  5027. * Creates a new Color3 from the string containing valid hexadecimal values
  5028. * @param hex defines a string containing valid hexadecimal values
  5029. * @returns a new Color3 object
  5030. */
  5031. static FromHexString(hex: string): Color3;
  5032. /**
  5033. * Creates a new Color3 from the starting index of the given array
  5034. * @param array defines the source array
  5035. * @param offset defines an offset in the source array
  5036. * @returns a new Color3 object
  5037. */
  5038. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5039. /**
  5040. * Creates a new Color3 from integer values (< 256)
  5041. * @param r defines the red component to read from (value between 0 and 255)
  5042. * @param g defines the green component to read from (value between 0 and 255)
  5043. * @param b defines the blue component to read from (value between 0 and 255)
  5044. * @returns a new Color3 object
  5045. */
  5046. static FromInts(r: number, g: number, b: number): Color3;
  5047. /**
  5048. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5049. * @param start defines the start Color3 value
  5050. * @param end defines the end Color3 value
  5051. * @param amount defines the gradient value between start and end
  5052. * @returns a new Color3 object
  5053. */
  5054. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5055. /**
  5056. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5057. * @param left defines the start value
  5058. * @param right defines the end value
  5059. * @param amount defines the gradient factor
  5060. * @param result defines the Color3 object where to store the result
  5061. */
  5062. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5063. /**
  5064. * Returns a Color3 value containing a red color
  5065. * @returns a new Color3 object
  5066. */
  5067. static Red(): Color3;
  5068. /**
  5069. * Returns a Color3 value containing a green color
  5070. * @returns a new Color3 object
  5071. */
  5072. static Green(): Color3;
  5073. /**
  5074. * Returns a Color3 value containing a blue color
  5075. * @returns a new Color3 object
  5076. */
  5077. static Blue(): Color3;
  5078. /**
  5079. * Returns a Color3 value containing a black color
  5080. * @returns a new Color3 object
  5081. */
  5082. static Black(): Color3;
  5083. /**
  5084. * Gets a Color3 value containing a black color that must not be updated
  5085. */
  5086. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5087. /**
  5088. * Returns a Color3 value containing a white color
  5089. * @returns a new Color3 object
  5090. */
  5091. static White(): Color3;
  5092. /**
  5093. * Returns a Color3 value containing a purple color
  5094. * @returns a new Color3 object
  5095. */
  5096. static Purple(): Color3;
  5097. /**
  5098. * Returns a Color3 value containing a magenta color
  5099. * @returns a new Color3 object
  5100. */
  5101. static Magenta(): Color3;
  5102. /**
  5103. * Returns a Color3 value containing a yellow color
  5104. * @returns a new Color3 object
  5105. */
  5106. static Yellow(): Color3;
  5107. /**
  5108. * Returns a Color3 value containing a gray color
  5109. * @returns a new Color3 object
  5110. */
  5111. static Gray(): Color3;
  5112. /**
  5113. * Returns a Color3 value containing a teal color
  5114. * @returns a new Color3 object
  5115. */
  5116. static Teal(): Color3;
  5117. /**
  5118. * Returns a Color3 value containing a random color
  5119. * @returns a new Color3 object
  5120. */
  5121. static Random(): Color3;
  5122. }
  5123. /**
  5124. * Class used to hold a RBGA color
  5125. */
  5126. export class Color4 {
  5127. /**
  5128. * Defines the red component (between 0 and 1, default is 0)
  5129. */
  5130. r: number;
  5131. /**
  5132. * Defines the green component (between 0 and 1, default is 0)
  5133. */
  5134. g: number;
  5135. /**
  5136. * Defines the blue component (between 0 and 1, default is 0)
  5137. */
  5138. b: number;
  5139. /**
  5140. * Defines the alpha component (between 0 and 1, default is 1)
  5141. */
  5142. a: number;
  5143. /**
  5144. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5145. * @param r defines the red component (between 0 and 1, default is 0)
  5146. * @param g defines the green component (between 0 and 1, default is 0)
  5147. * @param b defines the blue component (between 0 and 1, default is 0)
  5148. * @param a defines the alpha component (between 0 and 1, default is 1)
  5149. */
  5150. constructor(
  5151. /**
  5152. * Defines the red component (between 0 and 1, default is 0)
  5153. */
  5154. r?: number,
  5155. /**
  5156. * Defines the green component (between 0 and 1, default is 0)
  5157. */
  5158. g?: number,
  5159. /**
  5160. * Defines the blue component (between 0 and 1, default is 0)
  5161. */
  5162. b?: number,
  5163. /**
  5164. * Defines the alpha component (between 0 and 1, default is 1)
  5165. */
  5166. a?: number);
  5167. /**
  5168. * Adds in place the given Color4 values to the current Color4 object
  5169. * @param right defines the second operand
  5170. * @returns the current updated Color4 object
  5171. */
  5172. addInPlace(right: DeepImmutable<Color4>): Color4;
  5173. /**
  5174. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5175. * @returns the new array
  5176. */
  5177. asArray(): number[];
  5178. /**
  5179. * Stores from the starting index in the given array the Color4 successive values
  5180. * @param array defines the array where to store the r,g,b components
  5181. * @param index defines an optional index in the target array to define where to start storing values
  5182. * @returns the current Color4 object
  5183. */
  5184. toArray(array: number[], index?: number): Color4;
  5185. /**
  5186. * Determines equality between Color4 objects
  5187. * @param otherColor defines the second operand
  5188. * @returns true if the rgba values are equal to the given ones
  5189. */
  5190. equals(otherColor: DeepImmutable<Color4>): boolean;
  5191. /**
  5192. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5193. * @param right defines the second operand
  5194. * @returns a new Color4 object
  5195. */
  5196. add(right: DeepImmutable<Color4>): Color4;
  5197. /**
  5198. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5199. * @param right defines the second operand
  5200. * @returns a new Color4 object
  5201. */
  5202. subtract(right: DeepImmutable<Color4>): Color4;
  5203. /**
  5204. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5205. * @param right defines the second operand
  5206. * @param result defines the Color4 object where to store the result
  5207. * @returns the current Color4 object
  5208. */
  5209. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5210. /**
  5211. * Creates a new Color4 with the current Color4 values multiplied by scale
  5212. * @param scale defines the scaling factor to apply
  5213. * @returns a new Color4 object
  5214. */
  5215. scale(scale: number): Color4;
  5216. /**
  5217. * Multiplies the current Color4 values by scale and stores the result in "result"
  5218. * @param scale defines the scaling factor to apply
  5219. * @param result defines the Color4 object where to store the result
  5220. * @returns the current unmodified Color4
  5221. */
  5222. scaleToRef(scale: number, result: Color4): Color4;
  5223. /**
  5224. * Scale the current Color4 values by a factor and add the result to a given Color4
  5225. * @param scale defines the scale factor
  5226. * @param result defines the Color4 object where to store the result
  5227. * @returns the unmodified current Color4
  5228. */
  5229. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5230. /**
  5231. * Clamps the rgb values by the min and max values and stores the result into "result"
  5232. * @param min defines minimum clamping value (default is 0)
  5233. * @param max defines maximum clamping value (default is 1)
  5234. * @param result defines color to store the result into.
  5235. * @returns the cuurent Color4
  5236. */
  5237. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5238. /**
  5239. * Multipy an Color4 value by another and return a new Color4 object
  5240. * @param color defines the Color4 value to multiply by
  5241. * @returns a new Color4 object
  5242. */
  5243. multiply(color: Color4): Color4;
  5244. /**
  5245. * Multipy a Color4 value by another and push the result in a reference value
  5246. * @param color defines the Color4 value to multiply by
  5247. * @param result defines the Color4 to fill the result in
  5248. * @returns the result Color4
  5249. */
  5250. multiplyToRef(color: Color4, result: Color4): Color4;
  5251. /**
  5252. * Creates a string with the Color4 current values
  5253. * @returns the string representation of the Color4 object
  5254. */
  5255. toString(): string;
  5256. /**
  5257. * Returns the string "Color4"
  5258. * @returns "Color4"
  5259. */
  5260. getClassName(): string;
  5261. /**
  5262. * Compute the Color4 hash code
  5263. * @returns an unique number that can be used to hash Color4 objects
  5264. */
  5265. getHashCode(): number;
  5266. /**
  5267. * Creates a new Color4 copied from the current one
  5268. * @returns a new Color4 object
  5269. */
  5270. clone(): Color4;
  5271. /**
  5272. * Copies the given Color4 values into the current one
  5273. * @param source defines the source Color4 object
  5274. * @returns the current updated Color4 object
  5275. */
  5276. copyFrom(source: Color4): Color4;
  5277. /**
  5278. * Copies the given float values into the current one
  5279. * @param r defines the red component to read from
  5280. * @param g defines the green component to read from
  5281. * @param b defines the blue component to read from
  5282. * @param a defines the alpha component to read from
  5283. * @returns the current updated Color4 object
  5284. */
  5285. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5286. /**
  5287. * Copies the given float values into the current one
  5288. * @param r defines the red component to read from
  5289. * @param g defines the green component to read from
  5290. * @param b defines the blue component to read from
  5291. * @param a defines the alpha component to read from
  5292. * @returns the current updated Color4 object
  5293. */
  5294. set(r: number, g: number, b: number, a: number): Color4;
  5295. /**
  5296. * Compute the Color4 hexadecimal code as a string
  5297. * @returns a string containing the hexadecimal representation of the Color4 object
  5298. */
  5299. toHexString(): string;
  5300. /**
  5301. * Computes a new Color4 converted from the current one to linear space
  5302. * @returns a new Color4 object
  5303. */
  5304. toLinearSpace(): Color4;
  5305. /**
  5306. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5307. * @param convertedColor defines the Color4 object where to store the linear space version
  5308. * @returns the unmodified Color4
  5309. */
  5310. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5311. /**
  5312. * Computes a new Color4 converted from the current one to gamma space
  5313. * @returns a new Color4 object
  5314. */
  5315. toGammaSpace(): Color4;
  5316. /**
  5317. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5318. * @param convertedColor defines the Color4 object where to store the gamma space version
  5319. * @returns the unmodified Color4
  5320. */
  5321. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5322. /**
  5323. * Creates a new Color4 from the string containing valid hexadecimal values
  5324. * @param hex defines a string containing valid hexadecimal values
  5325. * @returns a new Color4 object
  5326. */
  5327. static FromHexString(hex: string): Color4;
  5328. /**
  5329. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5330. * @param left defines the start value
  5331. * @param right defines the end value
  5332. * @param amount defines the gradient factor
  5333. * @returns a new Color4 object
  5334. */
  5335. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5336. /**
  5337. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5338. * @param left defines the start value
  5339. * @param right defines the end value
  5340. * @param amount defines the gradient factor
  5341. * @param result defines the Color4 object where to store data
  5342. */
  5343. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5344. /**
  5345. * Creates a new Color4 from a Color3 and an alpha value
  5346. * @param color3 defines the source Color3 to read from
  5347. * @param alpha defines the alpha component (1.0 by default)
  5348. * @returns a new Color4 object
  5349. */
  5350. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5351. /**
  5352. * Creates a new Color4 from the starting index element of the given array
  5353. * @param array defines the source array to read from
  5354. * @param offset defines the offset in the source array
  5355. * @returns a new Color4 object
  5356. */
  5357. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5358. /**
  5359. * Creates a new Color3 from integer values (< 256)
  5360. * @param r defines the red component to read from (value between 0 and 255)
  5361. * @param g defines the green component to read from (value between 0 and 255)
  5362. * @param b defines the blue component to read from (value between 0 and 255)
  5363. * @param a defines the alpha component to read from (value between 0 and 255)
  5364. * @returns a new Color3 object
  5365. */
  5366. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5367. /**
  5368. * Check the content of a given array and convert it to an array containing RGBA data
  5369. * If the original array was already containing count * 4 values then it is returned directly
  5370. * @param colors defines the array to check
  5371. * @param count defines the number of RGBA data to expect
  5372. * @returns an array containing count * 4 values (RGBA)
  5373. */
  5374. static CheckColors4(colors: number[], count: number): number[];
  5375. }
  5376. /**
  5377. * @hidden
  5378. */
  5379. export class TmpColors {
  5380. static Color3: Color3[];
  5381. static Color4: Color4[];
  5382. }
  5383. }
  5384. declare module BABYLON {
  5385. /**
  5386. * Class representing spherical harmonics coefficients to the 3rd degree
  5387. */
  5388. export class SphericalHarmonics {
  5389. /**
  5390. * Defines whether or not the harmonics have been prescaled for rendering.
  5391. */
  5392. preScaled: boolean;
  5393. /**
  5394. * The l0,0 coefficients of the spherical harmonics
  5395. */
  5396. l00: Vector3;
  5397. /**
  5398. * The l1,-1 coefficients of the spherical harmonics
  5399. */
  5400. l1_1: Vector3;
  5401. /**
  5402. * The l1,0 coefficients of the spherical harmonics
  5403. */
  5404. l10: Vector3;
  5405. /**
  5406. * The l1,1 coefficients of the spherical harmonics
  5407. */
  5408. l11: Vector3;
  5409. /**
  5410. * The l2,-2 coefficients of the spherical harmonics
  5411. */
  5412. l2_2: Vector3;
  5413. /**
  5414. * The l2,-1 coefficients of the spherical harmonics
  5415. */
  5416. l2_1: Vector3;
  5417. /**
  5418. * The l2,0 coefficients of the spherical harmonics
  5419. */
  5420. l20: Vector3;
  5421. /**
  5422. * The l2,1 coefficients of the spherical harmonics
  5423. */
  5424. l21: Vector3;
  5425. /**
  5426. * The l2,2 coefficients of the spherical harmonics
  5427. */
  5428. l22: Vector3;
  5429. /**
  5430. * Adds a light to the spherical harmonics
  5431. * @param direction the direction of the light
  5432. * @param color the color of the light
  5433. * @param deltaSolidAngle the delta solid angle of the light
  5434. */
  5435. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5436. /**
  5437. * Scales the spherical harmonics by the given amount
  5438. * @param scale the amount to scale
  5439. */
  5440. scaleInPlace(scale: number): void;
  5441. /**
  5442. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5443. *
  5444. * ```
  5445. * E_lm = A_l * L_lm
  5446. * ```
  5447. *
  5448. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5449. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5450. * the scaling factors are given in equation 9.
  5451. */
  5452. convertIncidentRadianceToIrradiance(): void;
  5453. /**
  5454. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5455. *
  5456. * ```
  5457. * L = (1/pi) * E * rho
  5458. * ```
  5459. *
  5460. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5461. */
  5462. convertIrradianceToLambertianRadiance(): void;
  5463. /**
  5464. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5465. * required operations at run time.
  5466. *
  5467. * This is simply done by scaling back the SH with Ylm constants parameter.
  5468. * The trigonometric part being applied by the shader at run time.
  5469. */
  5470. preScaleForRendering(): void;
  5471. /**
  5472. * Constructs a spherical harmonics from an array.
  5473. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5474. * @returns the spherical harmonics
  5475. */
  5476. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5477. /**
  5478. * Gets the spherical harmonics from polynomial
  5479. * @param polynomial the spherical polynomial
  5480. * @returns the spherical harmonics
  5481. */
  5482. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5483. }
  5484. /**
  5485. * Class representing spherical polynomial coefficients to the 3rd degree
  5486. */
  5487. export class SphericalPolynomial {
  5488. private _harmonics;
  5489. /**
  5490. * The spherical harmonics used to create the polynomials.
  5491. */
  5492. readonly preScaledHarmonics: SphericalHarmonics;
  5493. /**
  5494. * The x coefficients of the spherical polynomial
  5495. */
  5496. x: Vector3;
  5497. /**
  5498. * The y coefficients of the spherical polynomial
  5499. */
  5500. y: Vector3;
  5501. /**
  5502. * The z coefficients of the spherical polynomial
  5503. */
  5504. z: Vector3;
  5505. /**
  5506. * The xx coefficients of the spherical polynomial
  5507. */
  5508. xx: Vector3;
  5509. /**
  5510. * The yy coefficients of the spherical polynomial
  5511. */
  5512. yy: Vector3;
  5513. /**
  5514. * The zz coefficients of the spherical polynomial
  5515. */
  5516. zz: Vector3;
  5517. /**
  5518. * The xy coefficients of the spherical polynomial
  5519. */
  5520. xy: Vector3;
  5521. /**
  5522. * The yz coefficients of the spherical polynomial
  5523. */
  5524. yz: Vector3;
  5525. /**
  5526. * The zx coefficients of the spherical polynomial
  5527. */
  5528. zx: Vector3;
  5529. /**
  5530. * Adds an ambient color to the spherical polynomial
  5531. * @param color the color to add
  5532. */
  5533. addAmbient(color: Color3): void;
  5534. /**
  5535. * Scales the spherical polynomial by the given amount
  5536. * @param scale the amount to scale
  5537. */
  5538. scaleInPlace(scale: number): void;
  5539. /**
  5540. * Gets the spherical polynomial from harmonics
  5541. * @param harmonics the spherical harmonics
  5542. * @returns the spherical polynomial
  5543. */
  5544. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5545. /**
  5546. * Constructs a spherical polynomial from an array.
  5547. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5548. * @returns the spherical polynomial
  5549. */
  5550. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5551. }
  5552. }
  5553. declare module BABYLON {
  5554. /**
  5555. * Define options used to create a render target texture
  5556. */
  5557. export class RenderTargetCreationOptions {
  5558. /**
  5559. * Specifies is mipmaps must be generated
  5560. */
  5561. generateMipMaps?: boolean;
  5562. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5563. generateDepthBuffer?: boolean;
  5564. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5565. generateStencilBuffer?: boolean;
  5566. /** Defines texture type (int by default) */
  5567. type?: number;
  5568. /** Defines sampling mode (trilinear by default) */
  5569. samplingMode?: number;
  5570. /** Defines format (RGBA by default) */
  5571. format?: number;
  5572. }
  5573. }
  5574. declare module BABYLON {
  5575. /**
  5576. * @hidden
  5577. **/
  5578. export class _AlphaState {
  5579. private _isAlphaBlendDirty;
  5580. private _isBlendFunctionParametersDirty;
  5581. private _isBlendEquationParametersDirty;
  5582. private _isBlendConstantsDirty;
  5583. private _alphaBlend;
  5584. private _blendFunctionParameters;
  5585. private _blendEquationParameters;
  5586. private _blendConstants;
  5587. /**
  5588. * Initializes the state.
  5589. */
  5590. constructor();
  5591. readonly isDirty: boolean;
  5592. alphaBlend: boolean;
  5593. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5594. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5595. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5596. reset(): void;
  5597. apply(gl: WebGLRenderingContext): void;
  5598. }
  5599. }
  5600. declare module BABYLON {
  5601. /**
  5602. * @hidden
  5603. **/
  5604. export class _DepthCullingState {
  5605. private _isDepthTestDirty;
  5606. private _isDepthMaskDirty;
  5607. private _isDepthFuncDirty;
  5608. private _isCullFaceDirty;
  5609. private _isCullDirty;
  5610. private _isZOffsetDirty;
  5611. private _isFrontFaceDirty;
  5612. private _depthTest;
  5613. private _depthMask;
  5614. private _depthFunc;
  5615. private _cull;
  5616. private _cullFace;
  5617. private _zOffset;
  5618. private _frontFace;
  5619. /**
  5620. * Initializes the state.
  5621. */
  5622. constructor();
  5623. readonly isDirty: boolean;
  5624. zOffset: number;
  5625. cullFace: Nullable<number>;
  5626. cull: Nullable<boolean>;
  5627. depthFunc: Nullable<number>;
  5628. depthMask: boolean;
  5629. depthTest: boolean;
  5630. frontFace: Nullable<number>;
  5631. reset(): void;
  5632. apply(gl: WebGLRenderingContext): void;
  5633. }
  5634. }
  5635. declare module BABYLON {
  5636. /**
  5637. * @hidden
  5638. **/
  5639. export class _StencilState {
  5640. /** 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 */
  5641. static readonly ALWAYS: number;
  5642. /** Passed to stencilOperation to specify that stencil value must be kept */
  5643. static readonly KEEP: number;
  5644. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5645. static readonly REPLACE: number;
  5646. private _isStencilTestDirty;
  5647. private _isStencilMaskDirty;
  5648. private _isStencilFuncDirty;
  5649. private _isStencilOpDirty;
  5650. private _stencilTest;
  5651. private _stencilMask;
  5652. private _stencilFunc;
  5653. private _stencilFuncRef;
  5654. private _stencilFuncMask;
  5655. private _stencilOpStencilFail;
  5656. private _stencilOpDepthFail;
  5657. private _stencilOpStencilDepthPass;
  5658. readonly isDirty: boolean;
  5659. stencilFunc: number;
  5660. stencilFuncRef: number;
  5661. stencilFuncMask: number;
  5662. stencilOpStencilFail: number;
  5663. stencilOpDepthFail: number;
  5664. stencilOpStencilDepthPass: number;
  5665. stencilMask: number;
  5666. stencilTest: boolean;
  5667. constructor();
  5668. reset(): void;
  5669. apply(gl: WebGLRenderingContext): void;
  5670. }
  5671. }
  5672. declare module BABYLON {
  5673. /**
  5674. * @hidden
  5675. **/
  5676. export class _TimeToken {
  5677. _startTimeQuery: Nullable<WebGLQuery>;
  5678. _endTimeQuery: Nullable<WebGLQuery>;
  5679. _timeElapsedQuery: Nullable<WebGLQuery>;
  5680. _timeElapsedQueryEnded: boolean;
  5681. }
  5682. }
  5683. declare module BABYLON {
  5684. /**
  5685. * Class used to evalaute queries containing `and` and `or` operators
  5686. */
  5687. export class AndOrNotEvaluator {
  5688. /**
  5689. * Evaluate a query
  5690. * @param query defines the query to evaluate
  5691. * @param evaluateCallback defines the callback used to filter result
  5692. * @returns true if the query matches
  5693. */
  5694. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5695. private static _HandleParenthesisContent;
  5696. private static _SimplifyNegation;
  5697. }
  5698. }
  5699. declare module BABYLON {
  5700. /**
  5701. * Class used to store custom tags
  5702. */
  5703. export class Tags {
  5704. /**
  5705. * Adds support for tags on the given object
  5706. * @param obj defines the object to use
  5707. */
  5708. static EnableFor(obj: any): void;
  5709. /**
  5710. * Removes tags support
  5711. * @param obj defines the object to use
  5712. */
  5713. static DisableFor(obj: any): void;
  5714. /**
  5715. * Gets a boolean indicating if the given object has tags
  5716. * @param obj defines the object to use
  5717. * @returns a boolean
  5718. */
  5719. static HasTags(obj: any): boolean;
  5720. /**
  5721. * Gets the tags available on a given object
  5722. * @param obj defines the object to use
  5723. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5724. * @returns the tags
  5725. */
  5726. static GetTags(obj: any, asString?: boolean): any;
  5727. /**
  5728. * Adds tags to an object
  5729. * @param obj defines the object to use
  5730. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5731. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5732. */
  5733. static AddTagsTo(obj: any, tagsString: string): void;
  5734. /**
  5735. * @hidden
  5736. */
  5737. static _AddTagTo(obj: any, tag: string): void;
  5738. /**
  5739. * Removes specific tags from a specific object
  5740. * @param obj defines the object to use
  5741. * @param tagsString defines the tags to remove
  5742. */
  5743. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5744. /**
  5745. * @hidden
  5746. */
  5747. static _RemoveTagFrom(obj: any, tag: string): void;
  5748. /**
  5749. * Defines if tags hosted on an object match a given query
  5750. * @param obj defines the object to use
  5751. * @param tagsQuery defines the tag query
  5752. * @returns a boolean
  5753. */
  5754. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5755. }
  5756. }
  5757. declare module BABYLON {
  5758. /**
  5759. * Defines potential orientation for back face culling
  5760. */
  5761. export enum Orientation {
  5762. /**
  5763. * Clockwise
  5764. */
  5765. CW = 0,
  5766. /** Counter clockwise */
  5767. CCW = 1
  5768. }
  5769. /** Class used to represent a Bezier curve */
  5770. export class BezierCurve {
  5771. /**
  5772. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5773. * @param t defines the time
  5774. * @param x1 defines the left coordinate on X axis
  5775. * @param y1 defines the left coordinate on Y axis
  5776. * @param x2 defines the right coordinate on X axis
  5777. * @param y2 defines the right coordinate on Y axis
  5778. * @returns the interpolated value
  5779. */
  5780. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5781. }
  5782. /**
  5783. * Defines angle representation
  5784. */
  5785. export class Angle {
  5786. private _radians;
  5787. /**
  5788. * Creates an Angle object of "radians" radians (float).
  5789. * @param radians the angle in radians
  5790. */
  5791. constructor(radians: number);
  5792. /**
  5793. * Get value in degrees
  5794. * @returns the Angle value in degrees (float)
  5795. */
  5796. degrees(): number;
  5797. /**
  5798. * Get value in radians
  5799. * @returns the Angle value in radians (float)
  5800. */
  5801. radians(): number;
  5802. /**
  5803. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5804. * @param a defines first vector
  5805. * @param b defines second vector
  5806. * @returns a new Angle
  5807. */
  5808. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5809. /**
  5810. * Gets a new Angle object from the given float in radians
  5811. * @param radians defines the angle value in radians
  5812. * @returns a new Angle
  5813. */
  5814. static FromRadians(radians: number): Angle;
  5815. /**
  5816. * Gets a new Angle object from the given float in degrees
  5817. * @param degrees defines the angle value in degrees
  5818. * @returns a new Angle
  5819. */
  5820. static FromDegrees(degrees: number): Angle;
  5821. }
  5822. /**
  5823. * This represents an arc in a 2d space.
  5824. */
  5825. export class Arc2 {
  5826. /** Defines the start point of the arc */
  5827. startPoint: Vector2;
  5828. /** Defines the mid point of the arc */
  5829. midPoint: Vector2;
  5830. /** Defines the end point of the arc */
  5831. endPoint: Vector2;
  5832. /**
  5833. * Defines the center point of the arc.
  5834. */
  5835. centerPoint: Vector2;
  5836. /**
  5837. * Defines the radius of the arc.
  5838. */
  5839. radius: number;
  5840. /**
  5841. * Defines the angle of the arc (from mid point to end point).
  5842. */
  5843. angle: Angle;
  5844. /**
  5845. * Defines the start angle of the arc (from start point to middle point).
  5846. */
  5847. startAngle: Angle;
  5848. /**
  5849. * Defines the orientation of the arc (clock wise/counter clock wise).
  5850. */
  5851. orientation: Orientation;
  5852. /**
  5853. * Creates an Arc object from the three given points : start, middle and end.
  5854. * @param startPoint Defines the start point of the arc
  5855. * @param midPoint Defines the midlle point of the arc
  5856. * @param endPoint Defines the end point of the arc
  5857. */
  5858. constructor(
  5859. /** Defines the start point of the arc */
  5860. startPoint: Vector2,
  5861. /** Defines the mid point of the arc */
  5862. midPoint: Vector2,
  5863. /** Defines the end point of the arc */
  5864. endPoint: Vector2);
  5865. }
  5866. /**
  5867. * Represents a 2D path made up of multiple 2D points
  5868. */
  5869. export class Path2 {
  5870. private _points;
  5871. private _length;
  5872. /**
  5873. * If the path start and end point are the same
  5874. */
  5875. closed: boolean;
  5876. /**
  5877. * Creates a Path2 object from the starting 2D coordinates x and y.
  5878. * @param x the starting points x value
  5879. * @param y the starting points y value
  5880. */
  5881. constructor(x: number, y: number);
  5882. /**
  5883. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5884. * @param x the added points x value
  5885. * @param y the added points y value
  5886. * @returns the updated Path2.
  5887. */
  5888. addLineTo(x: number, y: number): Path2;
  5889. /**
  5890. * 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.
  5891. * @param midX middle point x value
  5892. * @param midY middle point y value
  5893. * @param endX end point x value
  5894. * @param endY end point y value
  5895. * @param numberOfSegments (default: 36)
  5896. * @returns the updated Path2.
  5897. */
  5898. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5899. /**
  5900. * Closes the Path2.
  5901. * @returns the Path2.
  5902. */
  5903. close(): Path2;
  5904. /**
  5905. * Gets the sum of the distance between each sequential point in the path
  5906. * @returns the Path2 total length (float).
  5907. */
  5908. length(): number;
  5909. /**
  5910. * Gets the points which construct the path
  5911. * @returns the Path2 internal array of points.
  5912. */
  5913. getPoints(): Vector2[];
  5914. /**
  5915. * Retreives the point at the distance aways from the starting point
  5916. * @param normalizedLengthPosition the length along the path to retreive the point from
  5917. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5918. */
  5919. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5920. /**
  5921. * Creates a new path starting from an x and y position
  5922. * @param x starting x value
  5923. * @param y starting y value
  5924. * @returns a new Path2 starting at the coordinates (x, y).
  5925. */
  5926. static StartingAt(x: number, y: number): Path2;
  5927. }
  5928. /**
  5929. * Represents a 3D path made up of multiple 3D points
  5930. */
  5931. export class Path3D {
  5932. /**
  5933. * an array of Vector3, the curve axis of the Path3D
  5934. */
  5935. path: Vector3[];
  5936. private _curve;
  5937. private _distances;
  5938. private _tangents;
  5939. private _normals;
  5940. private _binormals;
  5941. private _raw;
  5942. /**
  5943. * new Path3D(path, normal, raw)
  5944. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5945. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5946. * @param path an array of Vector3, the curve axis of the Path3D
  5947. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5948. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5949. */
  5950. constructor(
  5951. /**
  5952. * an array of Vector3, the curve axis of the Path3D
  5953. */
  5954. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5955. /**
  5956. * Returns the Path3D array of successive Vector3 designing its curve.
  5957. * @returns the Path3D array of successive Vector3 designing its curve.
  5958. */
  5959. getCurve(): Vector3[];
  5960. /**
  5961. * Returns an array populated with tangent vectors on each Path3D curve point.
  5962. * @returns an array populated with tangent vectors on each Path3D curve point.
  5963. */
  5964. getTangents(): Vector3[];
  5965. /**
  5966. * Returns an array populated with normal vectors on each Path3D curve point.
  5967. * @returns an array populated with normal vectors on each Path3D curve point.
  5968. */
  5969. getNormals(): Vector3[];
  5970. /**
  5971. * Returns an array populated with binormal vectors on each Path3D curve point.
  5972. * @returns an array populated with binormal vectors on each Path3D curve point.
  5973. */
  5974. getBinormals(): Vector3[];
  5975. /**
  5976. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5977. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5978. */
  5979. getDistances(): number[];
  5980. /**
  5981. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5982. * @param path path which all values are copied into the curves points
  5983. * @param firstNormal which should be projected onto the curve
  5984. * @returns the same object updated.
  5985. */
  5986. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5987. private _compute;
  5988. private _getFirstNonNullVector;
  5989. private _getLastNonNullVector;
  5990. private _normalVector;
  5991. }
  5992. /**
  5993. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5994. * A Curve3 is designed from a series of successive Vector3.
  5995. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5996. */
  5997. export class Curve3 {
  5998. private _points;
  5999. private _length;
  6000. /**
  6001. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6002. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6003. * @param v1 (Vector3) the control point
  6004. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6005. * @param nbPoints (integer) the wanted number of points in the curve
  6006. * @returns the created Curve3
  6007. */
  6008. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6009. /**
  6010. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6011. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6012. * @param v1 (Vector3) the first control point
  6013. * @param v2 (Vector3) the second control point
  6014. * @param v3 (Vector3) the end point of the Cubic Bezier
  6015. * @param nbPoints (integer) the wanted number of points in the curve
  6016. * @returns the created Curve3
  6017. */
  6018. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6019. /**
  6020. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6021. * @param p1 (Vector3) the origin point of the Hermite Spline
  6022. * @param t1 (Vector3) the tangent vector at the origin point
  6023. * @param p2 (Vector3) the end point of the Hermite Spline
  6024. * @param t2 (Vector3) the tangent vector at the end point
  6025. * @param nbPoints (integer) the wanted number of points in the curve
  6026. * @returns the created Curve3
  6027. */
  6028. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6029. /**
  6030. * Returns a Curve3 object along a CatmullRom Spline curve :
  6031. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6032. * @param nbPoints (integer) the wanted number of points between each curve control points
  6033. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6034. * @returns the created Curve3
  6035. */
  6036. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6037. /**
  6038. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6039. * A Curve3 is designed from a series of successive Vector3.
  6040. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6041. * @param points points which make up the curve
  6042. */
  6043. constructor(points: Vector3[]);
  6044. /**
  6045. * @returns the Curve3 stored array of successive Vector3
  6046. */
  6047. getPoints(): Vector3[];
  6048. /**
  6049. * @returns the computed length (float) of the curve.
  6050. */
  6051. length(): number;
  6052. /**
  6053. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6054. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6055. * curveA and curveB keep unchanged.
  6056. * @param curve the curve to continue from this curve
  6057. * @returns the newly constructed curve
  6058. */
  6059. continue(curve: DeepImmutable<Curve3>): Curve3;
  6060. private _computeLength;
  6061. }
  6062. }
  6063. declare module BABYLON {
  6064. /**
  6065. * This represents the main contract an easing function should follow.
  6066. * Easing functions are used throughout the animation system.
  6067. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6068. */
  6069. export interface IEasingFunction {
  6070. /**
  6071. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6072. * of the easing function.
  6073. * The link below provides some of the most common examples of easing functions.
  6074. * @see https://easings.net/
  6075. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6076. * @returns the corresponding value on the curve defined by the easing function
  6077. */
  6078. ease(gradient: number): number;
  6079. }
  6080. /**
  6081. * Base class used for every default easing function.
  6082. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6083. */
  6084. export class EasingFunction implements IEasingFunction {
  6085. /**
  6086. * Interpolation follows the mathematical formula associated with the easing function.
  6087. */
  6088. static readonly EASINGMODE_EASEIN: number;
  6089. /**
  6090. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6091. */
  6092. static readonly EASINGMODE_EASEOUT: number;
  6093. /**
  6094. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6095. */
  6096. static readonly EASINGMODE_EASEINOUT: number;
  6097. private _easingMode;
  6098. /**
  6099. * Sets the easing mode of the current function.
  6100. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6101. */
  6102. setEasingMode(easingMode: number): void;
  6103. /**
  6104. * Gets the current easing mode.
  6105. * @returns the easing mode
  6106. */
  6107. getEasingMode(): number;
  6108. /**
  6109. * @hidden
  6110. */
  6111. easeInCore(gradient: number): number;
  6112. /**
  6113. * Given an input gradient between 0 and 1, this returns the corresponding value
  6114. * of the easing function.
  6115. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6116. * @returns the corresponding value on the curve defined by the easing function
  6117. */
  6118. ease(gradient: number): number;
  6119. }
  6120. /**
  6121. * Easing function with a circle shape (see link below).
  6122. * @see https://easings.net/#easeInCirc
  6123. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6124. */
  6125. export class CircleEase extends EasingFunction implements IEasingFunction {
  6126. /** @hidden */
  6127. easeInCore(gradient: number): number;
  6128. }
  6129. /**
  6130. * Easing function with a ease back shape (see link below).
  6131. * @see https://easings.net/#easeInBack
  6132. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6133. */
  6134. export class BackEase extends EasingFunction implements IEasingFunction {
  6135. /** Defines the amplitude of the function */
  6136. amplitude: number;
  6137. /**
  6138. * Instantiates a back ease easing
  6139. * @see https://easings.net/#easeInBack
  6140. * @param amplitude Defines the amplitude of the function
  6141. */
  6142. constructor(
  6143. /** Defines the amplitude of the function */
  6144. amplitude?: number);
  6145. /** @hidden */
  6146. easeInCore(gradient: number): number;
  6147. }
  6148. /**
  6149. * Easing function with a bouncing shape (see link below).
  6150. * @see https://easings.net/#easeInBounce
  6151. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6152. */
  6153. export class BounceEase extends EasingFunction implements IEasingFunction {
  6154. /** Defines the number of bounces */
  6155. bounces: number;
  6156. /** Defines the amplitude of the bounce */
  6157. bounciness: number;
  6158. /**
  6159. * Instantiates a bounce easing
  6160. * @see https://easings.net/#easeInBounce
  6161. * @param bounces Defines the number of bounces
  6162. * @param bounciness Defines the amplitude of the bounce
  6163. */
  6164. constructor(
  6165. /** Defines the number of bounces */
  6166. bounces?: number,
  6167. /** Defines the amplitude of the bounce */
  6168. bounciness?: number);
  6169. /** @hidden */
  6170. easeInCore(gradient: number): number;
  6171. }
  6172. /**
  6173. * Easing function with a power of 3 shape (see link below).
  6174. * @see https://easings.net/#easeInCubic
  6175. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6176. */
  6177. export class CubicEase extends EasingFunction implements IEasingFunction {
  6178. /** @hidden */
  6179. easeInCore(gradient: number): number;
  6180. }
  6181. /**
  6182. * Easing function with an elastic shape (see link below).
  6183. * @see https://easings.net/#easeInElastic
  6184. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6185. */
  6186. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6187. /** Defines the number of oscillations*/
  6188. oscillations: number;
  6189. /** Defines the amplitude of the oscillations*/
  6190. springiness: number;
  6191. /**
  6192. * Instantiates an elastic easing function
  6193. * @see https://easings.net/#easeInElastic
  6194. * @param oscillations Defines the number of oscillations
  6195. * @param springiness Defines the amplitude of the oscillations
  6196. */
  6197. constructor(
  6198. /** Defines the number of oscillations*/
  6199. oscillations?: number,
  6200. /** Defines the amplitude of the oscillations*/
  6201. springiness?: number);
  6202. /** @hidden */
  6203. easeInCore(gradient: number): number;
  6204. }
  6205. /**
  6206. * Easing function with an exponential shape (see link below).
  6207. * @see https://easings.net/#easeInExpo
  6208. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6209. */
  6210. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6211. /** Defines the exponent of the function */
  6212. exponent: number;
  6213. /**
  6214. * Instantiates an exponential easing function
  6215. * @see https://easings.net/#easeInExpo
  6216. * @param exponent Defines the exponent of the function
  6217. */
  6218. constructor(
  6219. /** Defines the exponent of the function */
  6220. exponent?: number);
  6221. /** @hidden */
  6222. easeInCore(gradient: number): number;
  6223. }
  6224. /**
  6225. * Easing function with a power shape (see link below).
  6226. * @see https://easings.net/#easeInQuad
  6227. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6228. */
  6229. export class PowerEase extends EasingFunction implements IEasingFunction {
  6230. /** Defines the power of the function */
  6231. power: number;
  6232. /**
  6233. * Instantiates an power base easing function
  6234. * @see https://easings.net/#easeInQuad
  6235. * @param power Defines the power of the function
  6236. */
  6237. constructor(
  6238. /** Defines the power of the function */
  6239. power?: number);
  6240. /** @hidden */
  6241. easeInCore(gradient: number): number;
  6242. }
  6243. /**
  6244. * Easing function with a power of 2 shape (see link below).
  6245. * @see https://easings.net/#easeInQuad
  6246. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6247. */
  6248. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6249. /** @hidden */
  6250. easeInCore(gradient: number): number;
  6251. }
  6252. /**
  6253. * Easing function with a power of 4 shape (see link below).
  6254. * @see https://easings.net/#easeInQuart
  6255. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6256. */
  6257. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6258. /** @hidden */
  6259. easeInCore(gradient: number): number;
  6260. }
  6261. /**
  6262. * Easing function with a power of 5 shape (see link below).
  6263. * @see https://easings.net/#easeInQuint
  6264. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6265. */
  6266. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6267. /** @hidden */
  6268. easeInCore(gradient: number): number;
  6269. }
  6270. /**
  6271. * Easing function with a sin shape (see link below).
  6272. * @see https://easings.net/#easeInSine
  6273. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6274. */
  6275. export class SineEase extends EasingFunction implements IEasingFunction {
  6276. /** @hidden */
  6277. easeInCore(gradient: number): number;
  6278. }
  6279. /**
  6280. * Easing function with a bezier shape (see link below).
  6281. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6283. */
  6284. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6285. /** Defines the x component of the start tangent in the bezier curve */
  6286. x1: number;
  6287. /** Defines the y component of the start tangent in the bezier curve */
  6288. y1: number;
  6289. /** Defines the x component of the end tangent in the bezier curve */
  6290. x2: number;
  6291. /** Defines the y component of the end tangent in the bezier curve */
  6292. y2: number;
  6293. /**
  6294. * Instantiates a bezier function
  6295. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6296. * @param x1 Defines the x component of the start tangent in the bezier curve
  6297. * @param y1 Defines the y component of the start tangent in the bezier curve
  6298. * @param x2 Defines the x component of the end tangent in the bezier curve
  6299. * @param y2 Defines the y component of the end tangent in the bezier curve
  6300. */
  6301. constructor(
  6302. /** Defines the x component of the start tangent in the bezier curve */
  6303. x1?: number,
  6304. /** Defines the y component of the start tangent in the bezier curve */
  6305. y1?: number,
  6306. /** Defines the x component of the end tangent in the bezier curve */
  6307. x2?: number,
  6308. /** Defines the y component of the end tangent in the bezier curve */
  6309. y2?: number);
  6310. /** @hidden */
  6311. easeInCore(gradient: number): number;
  6312. }
  6313. }
  6314. declare module BABYLON {
  6315. /**
  6316. * Defines an interface which represents an animation key frame
  6317. */
  6318. export interface IAnimationKey {
  6319. /**
  6320. * Frame of the key frame
  6321. */
  6322. frame: number;
  6323. /**
  6324. * Value at the specifies key frame
  6325. */
  6326. value: any;
  6327. /**
  6328. * The input tangent for the cubic hermite spline
  6329. */
  6330. inTangent?: any;
  6331. /**
  6332. * The output tangent for the cubic hermite spline
  6333. */
  6334. outTangent?: any;
  6335. /**
  6336. * The animation interpolation type
  6337. */
  6338. interpolation?: AnimationKeyInterpolation;
  6339. }
  6340. /**
  6341. * Enum for the animation key frame interpolation type
  6342. */
  6343. export enum AnimationKeyInterpolation {
  6344. /**
  6345. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6346. */
  6347. STEP = 1
  6348. }
  6349. }
  6350. declare module BABYLON {
  6351. /**
  6352. * Represents the range of an animation
  6353. */
  6354. export class AnimationRange {
  6355. /**The name of the animation range**/
  6356. name: string;
  6357. /**The starting frame of the animation */
  6358. from: number;
  6359. /**The ending frame of the animation*/
  6360. to: number;
  6361. /**
  6362. * Initializes the range of an animation
  6363. * @param name The name of the animation range
  6364. * @param from The starting frame of the animation
  6365. * @param to The ending frame of the animation
  6366. */
  6367. constructor(
  6368. /**The name of the animation range**/
  6369. name: string,
  6370. /**The starting frame of the animation */
  6371. from: number,
  6372. /**The ending frame of the animation*/
  6373. to: number);
  6374. /**
  6375. * Makes a copy of the animation range
  6376. * @returns A copy of the animation range
  6377. */
  6378. clone(): AnimationRange;
  6379. }
  6380. }
  6381. declare module BABYLON {
  6382. /**
  6383. * Composed of a frame, and an action function
  6384. */
  6385. export class AnimationEvent {
  6386. /** The frame for which the event is triggered **/
  6387. frame: number;
  6388. /** The event to perform when triggered **/
  6389. action: (currentFrame: number) => void;
  6390. /** Specifies if the event should be triggered only once**/
  6391. onlyOnce?: boolean | undefined;
  6392. /**
  6393. * Specifies if the animation event is done
  6394. */
  6395. isDone: boolean;
  6396. /**
  6397. * Initializes the animation event
  6398. * @param frame The frame for which the event is triggered
  6399. * @param action The event to perform when triggered
  6400. * @param onlyOnce Specifies if the event should be triggered only once
  6401. */
  6402. constructor(
  6403. /** The frame for which the event is triggered **/
  6404. frame: number,
  6405. /** The event to perform when triggered **/
  6406. action: (currentFrame: number) => void,
  6407. /** Specifies if the event should be triggered only once**/
  6408. onlyOnce?: boolean | undefined);
  6409. /** @hidden */
  6410. _clone(): AnimationEvent;
  6411. }
  6412. }
  6413. declare module BABYLON {
  6414. /**
  6415. * Interface used to define a behavior
  6416. */
  6417. export interface Behavior<T> {
  6418. /** gets or sets behavior's name */
  6419. name: string;
  6420. /**
  6421. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6422. */
  6423. init(): void;
  6424. /**
  6425. * Called when the behavior is attached to a target
  6426. * @param target defines the target where the behavior is attached to
  6427. */
  6428. attach(target: T): void;
  6429. /**
  6430. * Called when the behavior is detached from its target
  6431. */
  6432. detach(): void;
  6433. }
  6434. /**
  6435. * Interface implemented by classes supporting behaviors
  6436. */
  6437. export interface IBehaviorAware<T> {
  6438. /**
  6439. * Attach a behavior
  6440. * @param behavior defines the behavior to attach
  6441. * @returns the current host
  6442. */
  6443. addBehavior(behavior: Behavior<T>): T;
  6444. /**
  6445. * Remove a behavior from the current object
  6446. * @param behavior defines the behavior to detach
  6447. * @returns the current host
  6448. */
  6449. removeBehavior(behavior: Behavior<T>): T;
  6450. /**
  6451. * Gets a behavior using its name to search
  6452. * @param name defines the name to search
  6453. * @returns the behavior or null if not found
  6454. */
  6455. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6456. }
  6457. }
  6458. declare module BABYLON {
  6459. /**
  6460. * Defines an array and its length.
  6461. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6462. */
  6463. export interface ISmartArrayLike<T> {
  6464. /**
  6465. * The data of the array.
  6466. */
  6467. data: Array<T>;
  6468. /**
  6469. * The active length of the array.
  6470. */
  6471. length: number;
  6472. }
  6473. /**
  6474. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6475. */
  6476. export class SmartArray<T> implements ISmartArrayLike<T> {
  6477. /**
  6478. * The full set of data from the array.
  6479. */
  6480. data: Array<T>;
  6481. /**
  6482. * The active length of the array.
  6483. */
  6484. length: number;
  6485. protected _id: number;
  6486. /**
  6487. * Instantiates a Smart Array.
  6488. * @param capacity defines the default capacity of the array.
  6489. */
  6490. constructor(capacity: number);
  6491. /**
  6492. * Pushes a value at the end of the active data.
  6493. * @param value defines the object to push in the array.
  6494. */
  6495. push(value: T): void;
  6496. /**
  6497. * Iterates over the active data and apply the lambda to them.
  6498. * @param func defines the action to apply on each value.
  6499. */
  6500. forEach(func: (content: T) => void): void;
  6501. /**
  6502. * Sorts the full sets of data.
  6503. * @param compareFn defines the comparison function to apply.
  6504. */
  6505. sort(compareFn: (a: T, b: T) => number): void;
  6506. /**
  6507. * Resets the active data to an empty array.
  6508. */
  6509. reset(): void;
  6510. /**
  6511. * Releases all the data from the array as well as the array.
  6512. */
  6513. dispose(): void;
  6514. /**
  6515. * Concats the active data with a given array.
  6516. * @param array defines the data to concatenate with.
  6517. */
  6518. concat(array: any): void;
  6519. /**
  6520. * Returns the position of a value in the active data.
  6521. * @param value defines the value to find the index for
  6522. * @returns the index if found in the active data otherwise -1
  6523. */
  6524. indexOf(value: T): number;
  6525. /**
  6526. * Returns whether an element is part of the active data.
  6527. * @param value defines the value to look for
  6528. * @returns true if found in the active data otherwise false
  6529. */
  6530. contains(value: T): boolean;
  6531. private static _GlobalId;
  6532. }
  6533. /**
  6534. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6535. * The data in this array can only be present once
  6536. */
  6537. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6538. private _duplicateId;
  6539. /**
  6540. * Pushes a value at the end of the active data.
  6541. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6542. * @param value defines the object to push in the array.
  6543. */
  6544. push(value: T): void;
  6545. /**
  6546. * Pushes a value at the end of the active data.
  6547. * If the data is already present, it won t be added again
  6548. * @param value defines the object to push in the array.
  6549. * @returns true if added false if it was already present
  6550. */
  6551. pushNoDuplicate(value: T): boolean;
  6552. /**
  6553. * Resets the active data to an empty array.
  6554. */
  6555. reset(): void;
  6556. /**
  6557. * Concats the active data with a given array.
  6558. * This ensures no dupplicate will be present in the result.
  6559. * @param array defines the data to concatenate with.
  6560. */
  6561. concatWithNoDuplicate(array: any): void;
  6562. }
  6563. }
  6564. declare module BABYLON {
  6565. /**
  6566. * @ignore
  6567. * This is a list of all the different input types that are available in the application.
  6568. * Fo instance: ArcRotateCameraGamepadInput...
  6569. */
  6570. export var CameraInputTypes: {};
  6571. /**
  6572. * This is the contract to implement in order to create a new input class.
  6573. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6574. */
  6575. export interface ICameraInput<TCamera extends Camera> {
  6576. /**
  6577. * Defines the camera the input is attached to.
  6578. */
  6579. camera: Nullable<TCamera>;
  6580. /**
  6581. * Gets the class name of the current intput.
  6582. * @returns the class name
  6583. */
  6584. getClassName(): string;
  6585. /**
  6586. * Get the friendly name associated with the input class.
  6587. * @returns the input friendly name
  6588. */
  6589. getSimpleName(): string;
  6590. /**
  6591. * Attach the input controls to a specific dom element to get the input from.
  6592. * @param element Defines the element the controls should be listened from
  6593. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6594. */
  6595. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6596. /**
  6597. * Detach the current controls from the specified dom element.
  6598. * @param element Defines the element to stop listening the inputs from
  6599. */
  6600. detachControl(element: Nullable<HTMLElement>): void;
  6601. /**
  6602. * Update the current camera state depending on the inputs that have been used this frame.
  6603. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6604. */
  6605. checkInputs?: () => void;
  6606. }
  6607. /**
  6608. * Represents a map of input types to input instance or input index to input instance.
  6609. */
  6610. export interface CameraInputsMap<TCamera extends Camera> {
  6611. /**
  6612. * Accessor to the input by input type.
  6613. */
  6614. [name: string]: ICameraInput<TCamera>;
  6615. /**
  6616. * Accessor to the input by input index.
  6617. */
  6618. [idx: number]: ICameraInput<TCamera>;
  6619. }
  6620. /**
  6621. * This represents the input manager used within a camera.
  6622. * It helps dealing with all the different kind of input attached to a camera.
  6623. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6624. */
  6625. export class CameraInputsManager<TCamera extends Camera> {
  6626. /**
  6627. * Defines the list of inputs attahed to the camera.
  6628. */
  6629. attached: CameraInputsMap<TCamera>;
  6630. /**
  6631. * Defines the dom element the camera is collecting inputs from.
  6632. * This is null if the controls have not been attached.
  6633. */
  6634. attachedElement: Nullable<HTMLElement>;
  6635. /**
  6636. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6637. */
  6638. noPreventDefault: boolean;
  6639. /**
  6640. * Defined the camera the input manager belongs to.
  6641. */
  6642. camera: TCamera;
  6643. /**
  6644. * Update the current camera state depending on the inputs that have been used this frame.
  6645. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6646. */
  6647. checkInputs: () => void;
  6648. /**
  6649. * Instantiate a new Camera Input Manager.
  6650. * @param camera Defines the camera the input manager blongs to
  6651. */
  6652. constructor(camera: TCamera);
  6653. /**
  6654. * Add an input method to a camera
  6655. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6656. * @param input camera input method
  6657. */
  6658. add(input: ICameraInput<TCamera>): void;
  6659. /**
  6660. * Remove a specific input method from a camera
  6661. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6662. * @param inputToRemove camera input method
  6663. */
  6664. remove(inputToRemove: ICameraInput<TCamera>): void;
  6665. /**
  6666. * Remove a specific input type from a camera
  6667. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6668. * @param inputType the type of the input to remove
  6669. */
  6670. removeByType(inputType: string): void;
  6671. private _addCheckInputs;
  6672. /**
  6673. * Attach the input controls to the currently attached dom element to listen the events from.
  6674. * @param input Defines the input to attach
  6675. */
  6676. attachInput(input: ICameraInput<TCamera>): void;
  6677. /**
  6678. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6679. * @param element Defines the dom element to collect the events from
  6680. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6681. */
  6682. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6683. /**
  6684. * Detach the current manager inputs controls from a specific dom element.
  6685. * @param element Defines the dom element to collect the events from
  6686. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6687. */
  6688. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6689. /**
  6690. * Rebuild the dynamic inputCheck function from the current list of
  6691. * defined inputs in the manager.
  6692. */
  6693. rebuildInputCheck(): void;
  6694. /**
  6695. * Remove all attached input methods from a camera
  6696. */
  6697. clear(): void;
  6698. /**
  6699. * Serialize the current input manager attached to a camera.
  6700. * This ensures than once parsed,
  6701. * the input associated to the camera will be identical to the current ones
  6702. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6703. */
  6704. serialize(serializedCamera: any): void;
  6705. /**
  6706. * Parses an input manager serialized JSON to restore the previous list of inputs
  6707. * and states associated to a camera.
  6708. * @param parsedCamera Defines the JSON to parse
  6709. */
  6710. parse(parsedCamera: any): void;
  6711. }
  6712. }
  6713. declare module BABYLON {
  6714. /**
  6715. * @hidden
  6716. */
  6717. export class IntersectionInfo {
  6718. bu: Nullable<number>;
  6719. bv: Nullable<number>;
  6720. distance: number;
  6721. faceId: number;
  6722. subMeshId: number;
  6723. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6724. }
  6725. }
  6726. declare module BABYLON {
  6727. /**
  6728. * Represens a plane by the equation ax + by + cz + d = 0
  6729. */
  6730. export class Plane {
  6731. private static _TmpMatrix;
  6732. /**
  6733. * Normal of the plane (a,b,c)
  6734. */
  6735. normal: Vector3;
  6736. /**
  6737. * d component of the plane
  6738. */
  6739. d: number;
  6740. /**
  6741. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6742. * @param a a component of the plane
  6743. * @param b b component of the plane
  6744. * @param c c component of the plane
  6745. * @param d d component of the plane
  6746. */
  6747. constructor(a: number, b: number, c: number, d: number);
  6748. /**
  6749. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6750. */
  6751. asArray(): number[];
  6752. /**
  6753. * @returns a new plane copied from the current Plane.
  6754. */
  6755. clone(): Plane;
  6756. /**
  6757. * @returns the string "Plane".
  6758. */
  6759. getClassName(): string;
  6760. /**
  6761. * @returns the Plane hash code.
  6762. */
  6763. getHashCode(): number;
  6764. /**
  6765. * Normalize the current Plane in place.
  6766. * @returns the updated Plane.
  6767. */
  6768. normalize(): Plane;
  6769. /**
  6770. * Applies a transformation the plane and returns the result
  6771. * @param transformation the transformation matrix to be applied to the plane
  6772. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6773. */
  6774. transform(transformation: DeepImmutable<Matrix>): Plane;
  6775. /**
  6776. * Calcualtte the dot product between the point and the plane normal
  6777. * @param point point to calculate the dot product with
  6778. * @returns the dot product (float) of the point coordinates and the plane normal.
  6779. */
  6780. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6781. /**
  6782. * Updates the current Plane from the plane defined by the three given points.
  6783. * @param point1 one of the points used to contruct the plane
  6784. * @param point2 one of the points used to contruct the plane
  6785. * @param point3 one of the points used to contruct the plane
  6786. * @returns the updated Plane.
  6787. */
  6788. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6789. /**
  6790. * Checks if the plane is facing a given direction
  6791. * @param direction the direction to check if the plane is facing
  6792. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6793. * @returns True is the vector "direction" is the same side than the plane normal.
  6794. */
  6795. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6796. /**
  6797. * Calculates the distance to a point
  6798. * @param point point to calculate distance to
  6799. * @returns the signed distance (float) from the given point to the Plane.
  6800. */
  6801. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6802. /**
  6803. * Creates a plane from an array
  6804. * @param array the array to create a plane from
  6805. * @returns a new Plane from the given array.
  6806. */
  6807. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6808. /**
  6809. * Creates a plane from three points
  6810. * @param point1 point used to create the plane
  6811. * @param point2 point used to create the plane
  6812. * @param point3 point used to create the plane
  6813. * @returns a new Plane defined by the three given points.
  6814. */
  6815. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6816. /**
  6817. * Creates a plane from an origin point and a normal
  6818. * @param origin origin of the plane to be constructed
  6819. * @param normal normal of the plane to be constructed
  6820. * @returns a new Plane the normal vector to this plane at the given origin point.
  6821. * Note : the vector "normal" is updated because normalized.
  6822. */
  6823. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6824. /**
  6825. * Calculates the distance from a plane and a point
  6826. * @param origin origin of the plane to be constructed
  6827. * @param normal normal of the plane to be constructed
  6828. * @param point point to calculate distance to
  6829. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6830. */
  6831. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6832. }
  6833. }
  6834. declare module BABYLON {
  6835. /**
  6836. * Class used to store bounding sphere information
  6837. */
  6838. export class BoundingSphere {
  6839. /**
  6840. * Gets the center of the bounding sphere in local space
  6841. */
  6842. readonly center: Vector3;
  6843. /**
  6844. * Radius of the bounding sphere in local space
  6845. */
  6846. radius: number;
  6847. /**
  6848. * Gets the center of the bounding sphere in world space
  6849. */
  6850. readonly centerWorld: Vector3;
  6851. /**
  6852. * Radius of the bounding sphere in world space
  6853. */
  6854. radiusWorld: number;
  6855. /**
  6856. * Gets the minimum vector in local space
  6857. */
  6858. readonly minimum: Vector3;
  6859. /**
  6860. * Gets the maximum vector in local space
  6861. */
  6862. readonly maximum: Vector3;
  6863. private _worldMatrix;
  6864. private static readonly TmpVector3;
  6865. /**
  6866. * Creates a new bounding sphere
  6867. * @param min defines the minimum vector (in local space)
  6868. * @param max defines the maximum vector (in local space)
  6869. * @param worldMatrix defines the new world matrix
  6870. */
  6871. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6872. /**
  6873. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6874. * @param min defines the new minimum vector (in local space)
  6875. * @param max defines the new maximum vector (in local space)
  6876. * @param worldMatrix defines the new world matrix
  6877. */
  6878. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6879. /**
  6880. * Scale the current bounding sphere by applying a scale factor
  6881. * @param factor defines the scale factor to apply
  6882. * @returns the current bounding box
  6883. */
  6884. scale(factor: number): BoundingSphere;
  6885. /**
  6886. * Gets the world matrix of the bounding box
  6887. * @returns a matrix
  6888. */
  6889. getWorldMatrix(): DeepImmutable<Matrix>;
  6890. /** @hidden */
  6891. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6892. /**
  6893. * Tests if the bounding sphere is intersecting the frustum planes
  6894. * @param frustumPlanes defines the frustum planes to test
  6895. * @returns true if there is an intersection
  6896. */
  6897. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6898. /**
  6899. * Tests if the bounding sphere center is in between the frustum planes.
  6900. * Used for optimistic fast inclusion.
  6901. * @param frustumPlanes defines the frustum planes to test
  6902. * @returns true if the sphere center is in between the frustum planes
  6903. */
  6904. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6905. /**
  6906. * Tests if a point is inside the bounding sphere
  6907. * @param point defines the point to test
  6908. * @returns true if the point is inside the bounding sphere
  6909. */
  6910. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6911. /**
  6912. * Checks if two sphere intersct
  6913. * @param sphere0 sphere 0
  6914. * @param sphere1 sphere 1
  6915. * @returns true if the speres intersect
  6916. */
  6917. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6918. }
  6919. }
  6920. declare module BABYLON {
  6921. /**
  6922. * Class used to store bounding box information
  6923. */
  6924. export class BoundingBox implements ICullable {
  6925. /**
  6926. * Gets the 8 vectors representing the bounding box in local space
  6927. */
  6928. readonly vectors: Vector3[];
  6929. /**
  6930. * Gets the center of the bounding box in local space
  6931. */
  6932. readonly center: Vector3;
  6933. /**
  6934. * Gets the center of the bounding box in world space
  6935. */
  6936. readonly centerWorld: Vector3;
  6937. /**
  6938. * Gets the extend size in local space
  6939. */
  6940. readonly extendSize: Vector3;
  6941. /**
  6942. * Gets the extend size in world space
  6943. */
  6944. readonly extendSizeWorld: Vector3;
  6945. /**
  6946. * Gets the OBB (object bounding box) directions
  6947. */
  6948. readonly directions: Vector3[];
  6949. /**
  6950. * Gets the 8 vectors representing the bounding box in world space
  6951. */
  6952. readonly vectorsWorld: Vector3[];
  6953. /**
  6954. * Gets the minimum vector in world space
  6955. */
  6956. readonly minimumWorld: Vector3;
  6957. /**
  6958. * Gets the maximum vector in world space
  6959. */
  6960. readonly maximumWorld: Vector3;
  6961. /**
  6962. * Gets the minimum vector in local space
  6963. */
  6964. readonly minimum: Vector3;
  6965. /**
  6966. * Gets the maximum vector in local space
  6967. */
  6968. readonly maximum: Vector3;
  6969. private _worldMatrix;
  6970. private static readonly TmpVector3;
  6971. /**
  6972. * @hidden
  6973. */
  6974. _tag: number;
  6975. /**
  6976. * Creates a new bounding box
  6977. * @param min defines the minimum vector (in local space)
  6978. * @param max defines the maximum vector (in local space)
  6979. * @param worldMatrix defines the new world matrix
  6980. */
  6981. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6982. /**
  6983. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6984. * @param min defines the new minimum vector (in local space)
  6985. * @param max defines the new maximum vector (in local space)
  6986. * @param worldMatrix defines the new world matrix
  6987. */
  6988. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6989. /**
  6990. * Scale the current bounding box by applying a scale factor
  6991. * @param factor defines the scale factor to apply
  6992. * @returns the current bounding box
  6993. */
  6994. scale(factor: number): BoundingBox;
  6995. /**
  6996. * Gets the world matrix of the bounding box
  6997. * @returns a matrix
  6998. */
  6999. getWorldMatrix(): DeepImmutable<Matrix>;
  7000. /** @hidden */
  7001. _update(world: DeepImmutable<Matrix>): void;
  7002. /**
  7003. * Tests if the bounding box is intersecting the frustum planes
  7004. * @param frustumPlanes defines the frustum planes to test
  7005. * @returns true if there is an intersection
  7006. */
  7007. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7008. /**
  7009. * Tests if the bounding box is entirely inside the frustum planes
  7010. * @param frustumPlanes defines the frustum planes to test
  7011. * @returns true if there is an inclusion
  7012. */
  7013. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7014. /**
  7015. * Tests if a point is inside the bounding box
  7016. * @param point defines the point to test
  7017. * @returns true if the point is inside the bounding box
  7018. */
  7019. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7020. /**
  7021. * Tests if the bounding box intersects with a bounding sphere
  7022. * @param sphere defines the sphere to test
  7023. * @returns true if there is an intersection
  7024. */
  7025. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7026. /**
  7027. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7028. * @param min defines the min vector to use
  7029. * @param max defines the max vector to use
  7030. * @returns true if there is an intersection
  7031. */
  7032. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7033. /**
  7034. * Tests if two bounding boxes are intersections
  7035. * @param box0 defines the first box to test
  7036. * @param box1 defines the second box to test
  7037. * @returns true if there is an intersection
  7038. */
  7039. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7040. /**
  7041. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7042. * @param minPoint defines the minimum vector of the bounding box
  7043. * @param maxPoint defines the maximum vector of the bounding box
  7044. * @param sphereCenter defines the sphere center
  7045. * @param sphereRadius defines the sphere radius
  7046. * @returns true if there is an intersection
  7047. */
  7048. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7049. /**
  7050. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7051. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7052. * @param frustumPlanes defines the frustum planes to test
  7053. * @return true if there is an inclusion
  7054. */
  7055. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7056. /**
  7057. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7058. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7059. * @param frustumPlanes defines the frustum planes to test
  7060. * @return true if there is an intersection
  7061. */
  7062. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7063. }
  7064. }
  7065. declare module BABYLON {
  7066. /** @hidden */
  7067. export class Collider {
  7068. /** Define if a collision was found */
  7069. collisionFound: boolean;
  7070. /**
  7071. * Define last intersection point in local space
  7072. */
  7073. intersectionPoint: Vector3;
  7074. /**
  7075. * Define last collided mesh
  7076. */
  7077. collidedMesh: Nullable<AbstractMesh>;
  7078. private _collisionPoint;
  7079. private _planeIntersectionPoint;
  7080. private _tempVector;
  7081. private _tempVector2;
  7082. private _tempVector3;
  7083. private _tempVector4;
  7084. private _edge;
  7085. private _baseToVertex;
  7086. private _destinationPoint;
  7087. private _slidePlaneNormal;
  7088. private _displacementVector;
  7089. /** @hidden */
  7090. _radius: Vector3;
  7091. /** @hidden */
  7092. _retry: number;
  7093. private _velocity;
  7094. private _basePoint;
  7095. private _epsilon;
  7096. /** @hidden */
  7097. _velocityWorldLength: number;
  7098. /** @hidden */
  7099. _basePointWorld: Vector3;
  7100. private _velocityWorld;
  7101. private _normalizedVelocity;
  7102. /** @hidden */
  7103. _initialVelocity: Vector3;
  7104. /** @hidden */
  7105. _initialPosition: Vector3;
  7106. private _nearestDistance;
  7107. private _collisionMask;
  7108. collisionMask: number;
  7109. /**
  7110. * Gets the plane normal used to compute the sliding response (in local space)
  7111. */
  7112. readonly slidePlaneNormal: Vector3;
  7113. /** @hidden */
  7114. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7115. /** @hidden */
  7116. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7117. /** @hidden */
  7118. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7119. /** @hidden */
  7120. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7121. /** @hidden */
  7122. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7123. /** @hidden */
  7124. _getResponse(pos: Vector3, vel: Vector3): void;
  7125. }
  7126. }
  7127. declare module BABYLON {
  7128. /**
  7129. * Interface for cullable objects
  7130. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7131. */
  7132. export interface ICullable {
  7133. /**
  7134. * Checks if the object or part of the object is in the frustum
  7135. * @param frustumPlanes Camera near/planes
  7136. * @returns true if the object is in frustum otherwise false
  7137. */
  7138. isInFrustum(frustumPlanes: Plane[]): boolean;
  7139. /**
  7140. * Checks if a cullable object (mesh...) is in the camera frustum
  7141. * Unlike isInFrustum this cheks the full bounding box
  7142. * @param frustumPlanes Camera near/planes
  7143. * @returns true if the object is in frustum otherwise false
  7144. */
  7145. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7146. }
  7147. /**
  7148. * Info for a bounding data of a mesh
  7149. */
  7150. export class BoundingInfo implements ICullable {
  7151. /**
  7152. * Bounding box for the mesh
  7153. */
  7154. readonly boundingBox: BoundingBox;
  7155. /**
  7156. * Bounding sphere for the mesh
  7157. */
  7158. readonly boundingSphere: BoundingSphere;
  7159. private _isLocked;
  7160. private static readonly TmpVector3;
  7161. /**
  7162. * Constructs bounding info
  7163. * @param minimum min vector of the bounding box/sphere
  7164. * @param maximum max vector of the bounding box/sphere
  7165. * @param worldMatrix defines the new world matrix
  7166. */
  7167. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7168. /**
  7169. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7170. * @param min defines the new minimum vector (in local space)
  7171. * @param max defines the new maximum vector (in local space)
  7172. * @param worldMatrix defines the new world matrix
  7173. */
  7174. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7175. /**
  7176. * min vector of the bounding box/sphere
  7177. */
  7178. readonly minimum: Vector3;
  7179. /**
  7180. * max vector of the bounding box/sphere
  7181. */
  7182. readonly maximum: Vector3;
  7183. /**
  7184. * If the info is locked and won't be updated to avoid perf overhead
  7185. */
  7186. isLocked: boolean;
  7187. /**
  7188. * Updates the bounding sphere and box
  7189. * @param world world matrix to be used to update
  7190. */
  7191. update(world: DeepImmutable<Matrix>): void;
  7192. /**
  7193. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7194. * @param center New center of the bounding info
  7195. * @param extend New extend of the bounding info
  7196. * @returns the current bounding info
  7197. */
  7198. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7199. /**
  7200. * Scale the current bounding info by applying a scale factor
  7201. * @param factor defines the scale factor to apply
  7202. * @returns the current bounding info
  7203. */
  7204. scale(factor: number): BoundingInfo;
  7205. /**
  7206. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7207. * @param frustumPlanes defines the frustum to test
  7208. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7209. * @returns true if the bounding info is in the frustum planes
  7210. */
  7211. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7212. /**
  7213. * Gets the world distance between the min and max points of the bounding box
  7214. */
  7215. readonly diagonalLength: number;
  7216. /**
  7217. * Checks if a cullable object (mesh...) is in the camera frustum
  7218. * Unlike isInFrustum this cheks the full bounding box
  7219. * @param frustumPlanes Camera near/planes
  7220. * @returns true if the object is in frustum otherwise false
  7221. */
  7222. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7223. /** @hidden */
  7224. _checkCollision(collider: Collider): boolean;
  7225. /**
  7226. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7227. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7228. * @param point the point to check intersection with
  7229. * @returns if the point intersects
  7230. */
  7231. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7232. /**
  7233. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7234. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7235. * @param boundingInfo the bounding info to check intersection with
  7236. * @param precise if the intersection should be done using OBB
  7237. * @returns if the bounding info intersects
  7238. */
  7239. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7240. }
  7241. }
  7242. declare module BABYLON {
  7243. /**
  7244. * Extracts minimum and maximum values from a list of indexed positions
  7245. * @param positions defines the positions to use
  7246. * @param indices defines the indices to the positions
  7247. * @param indexStart defines the start index
  7248. * @param indexCount defines the end index
  7249. * @param bias defines bias value to add to the result
  7250. * @return minimum and maximum values
  7251. */
  7252. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7253. minimum: Vector3;
  7254. maximum: Vector3;
  7255. };
  7256. /**
  7257. * Extracts minimum and maximum values from a list of positions
  7258. * @param positions defines the positions to use
  7259. * @param start defines the start index in the positions array
  7260. * @param count defines the number of positions to handle
  7261. * @param bias defines bias value to add to the result
  7262. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7263. * @return minimum and maximum values
  7264. */
  7265. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7266. minimum: Vector3;
  7267. maximum: Vector3;
  7268. };
  7269. }
  7270. declare module BABYLON {
  7271. /**
  7272. * Enum that determines the text-wrapping mode to use.
  7273. */
  7274. export enum InspectableType {
  7275. /**
  7276. * Checkbox for booleans
  7277. */
  7278. Checkbox = 0,
  7279. /**
  7280. * Sliders for numbers
  7281. */
  7282. Slider = 1,
  7283. /**
  7284. * Vector3
  7285. */
  7286. Vector3 = 2,
  7287. /**
  7288. * Quaternions
  7289. */
  7290. Quaternion = 3,
  7291. /**
  7292. * Color3
  7293. */
  7294. Color3 = 4,
  7295. /**
  7296. * String
  7297. */
  7298. String = 5
  7299. }
  7300. /**
  7301. * Interface used to define custom inspectable properties.
  7302. * This interface is used by the inspector to display custom property grids
  7303. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7304. */
  7305. export interface IInspectable {
  7306. /**
  7307. * Gets the label to display
  7308. */
  7309. label: string;
  7310. /**
  7311. * Gets the name of the property to edit
  7312. */
  7313. propertyName: string;
  7314. /**
  7315. * Gets the type of the editor to use
  7316. */
  7317. type: InspectableType;
  7318. /**
  7319. * Gets the minimum value of the property when using in "slider" mode
  7320. */
  7321. min?: number;
  7322. /**
  7323. * Gets the maximum value of the property when using in "slider" mode
  7324. */
  7325. max?: number;
  7326. /**
  7327. * Gets the setp to use when using in "slider" mode
  7328. */
  7329. step?: number;
  7330. }
  7331. }
  7332. declare module BABYLON {
  7333. /**
  7334. * Class used to provide helper for timing
  7335. */
  7336. export class TimingTools {
  7337. /**
  7338. * Polyfill for setImmediate
  7339. * @param action defines the action to execute after the current execution block
  7340. */
  7341. static SetImmediate(action: () => void): void;
  7342. }
  7343. }
  7344. declare module BABYLON {
  7345. /**
  7346. * Class used to enable instatition of objects by class name
  7347. */
  7348. export class InstantiationTools {
  7349. /**
  7350. * Use this object to register external classes like custom textures or material
  7351. * to allow the laoders to instantiate them
  7352. */
  7353. static RegisteredExternalClasses: {
  7354. [key: string]: Object;
  7355. };
  7356. /**
  7357. * Tries to instantiate a new object from a given class name
  7358. * @param className defines the class name to instantiate
  7359. * @returns the new object or null if the system was not able to do the instantiation
  7360. */
  7361. static Instantiate(className: string): any;
  7362. }
  7363. }
  7364. declare module BABYLON {
  7365. /**
  7366. * This represents the required contract to create a new type of texture loader.
  7367. */
  7368. export interface IInternalTextureLoader {
  7369. /**
  7370. * Defines wether the loader supports cascade loading the different faces.
  7371. */
  7372. supportCascades: boolean;
  7373. /**
  7374. * This returns if the loader support the current file information.
  7375. * @param extension defines the file extension of the file being loaded
  7376. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7377. * @param fallback defines the fallback internal texture if any
  7378. * @param isBase64 defines whether the texture is encoded as a base64
  7379. * @param isBuffer defines whether the texture data are stored as a buffer
  7380. * @returns true if the loader can load the specified file
  7381. */
  7382. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7383. /**
  7384. * Transform the url before loading if required.
  7385. * @param rootUrl the url of the texture
  7386. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7387. * @returns the transformed texture
  7388. */
  7389. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7390. /**
  7391. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7392. * @param rootUrl the url of the texture
  7393. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7394. * @returns the fallback texture
  7395. */
  7396. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7397. /**
  7398. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7399. * @param data contains the texture data
  7400. * @param texture defines the BabylonJS internal texture
  7401. * @param createPolynomials will be true if polynomials have been requested
  7402. * @param onLoad defines the callback to trigger once the texture is ready
  7403. * @param onError defines the callback to trigger in case of error
  7404. */
  7405. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7406. /**
  7407. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7408. * @param data contains the texture data
  7409. * @param texture defines the BabylonJS internal texture
  7410. * @param callback defines the method to call once ready to upload
  7411. */
  7412. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7413. }
  7414. }
  7415. declare module BABYLON {
  7416. interface Engine {
  7417. /**
  7418. * Creates a depth stencil cube texture.
  7419. * This is only available in WebGL 2.
  7420. * @param size The size of face edge in the cube texture.
  7421. * @param options The options defining the cube texture.
  7422. * @returns The cube texture
  7423. */
  7424. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7425. /**
  7426. * Creates a cube texture
  7427. * @param rootUrl defines the url where the files to load is located
  7428. * @param scene defines the current scene
  7429. * @param files defines the list of files to load (1 per face)
  7430. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7431. * @param onLoad defines an optional callback raised when the texture is loaded
  7432. * @param onError defines an optional callback raised if there is an issue to load the texture
  7433. * @param format defines the format of the data
  7434. * @param forcedExtension defines the extension to use to pick the right loader
  7435. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7436. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7437. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7438. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7439. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7440. * @returns the cube texture as an InternalTexture
  7441. */
  7442. 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;
  7443. /**
  7444. * Creates a cube texture
  7445. * @param rootUrl defines the url where the files to load is located
  7446. * @param scene defines the current scene
  7447. * @param files defines the list of files to load (1 per face)
  7448. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7449. * @param onLoad defines an optional callback raised when the texture is loaded
  7450. * @param onError defines an optional callback raised if there is an issue to load the texture
  7451. * @param format defines the format of the data
  7452. * @param forcedExtension defines the extension to use to pick the right loader
  7453. * @returns the cube texture as an InternalTexture
  7454. */
  7455. 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;
  7456. /**
  7457. * Creates a cube texture
  7458. * @param rootUrl defines the url where the files to load is located
  7459. * @param scene defines the current scene
  7460. * @param files defines the list of files to load (1 per face)
  7461. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7462. * @param onLoad defines an optional callback raised when the texture is loaded
  7463. * @param onError defines an optional callback raised if there is an issue to load the texture
  7464. * @param format defines the format of the data
  7465. * @param forcedExtension defines the extension to use to pick the right loader
  7466. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7467. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7468. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7469. * @returns the cube texture as an InternalTexture
  7470. */
  7471. 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;
  7472. /** @hidden */
  7473. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7474. /** @hidden */
  7475. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7476. /** @hidden */
  7477. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7478. /** @hidden */
  7479. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7480. }
  7481. }
  7482. declare module BABYLON {
  7483. /**
  7484. * Class for creating a cube texture
  7485. */
  7486. export class CubeTexture extends BaseTexture {
  7487. private _delayedOnLoad;
  7488. /**
  7489. * The url of the texture
  7490. */
  7491. url: string;
  7492. /**
  7493. * Gets or sets the center of the bounding box associated with the cube texture.
  7494. * It must define where the camera used to render the texture was set
  7495. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7496. */
  7497. boundingBoxPosition: Vector3;
  7498. private _boundingBoxSize;
  7499. /**
  7500. * Gets or sets the size of the bounding box associated with the cube texture
  7501. * When defined, the cubemap will switch to local mode
  7502. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7503. * @example https://www.babylonjs-playground.com/#RNASML
  7504. */
  7505. /**
  7506. * Returns the bounding box size
  7507. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7508. */
  7509. boundingBoxSize: Vector3;
  7510. protected _rotationY: number;
  7511. /**
  7512. * Sets texture matrix rotation angle around Y axis in radians.
  7513. */
  7514. /**
  7515. * Gets texture matrix rotation angle around Y axis radians.
  7516. */
  7517. rotationY: number;
  7518. /**
  7519. * Are mip maps generated for this texture or not.
  7520. */
  7521. readonly noMipmap: boolean;
  7522. private _noMipmap;
  7523. private _files;
  7524. private _extensions;
  7525. private _textureMatrix;
  7526. private _format;
  7527. private _createPolynomials;
  7528. /** @hidden */
  7529. _prefiltered: boolean;
  7530. /**
  7531. * Creates a cube texture from an array of image urls
  7532. * @param files defines an array of image urls
  7533. * @param scene defines the hosting scene
  7534. * @param noMipmap specifies if mip maps are not used
  7535. * @returns a cube texture
  7536. */
  7537. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7538. /**
  7539. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7540. * @param url defines the url of the prefiltered texture
  7541. * @param scene defines the scene the texture is attached to
  7542. * @param forcedExtension defines the extension of the file if different from the url
  7543. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7544. * @return the prefiltered texture
  7545. */
  7546. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7547. /**
  7548. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7549. * as prefiltered data.
  7550. * @param rootUrl defines the url of the texture or the root name of the six images
  7551. * @param scene defines the scene the texture is attached to
  7552. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7553. * @param noMipmap defines if mipmaps should be created or not
  7554. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7555. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7556. * @param onError defines a callback triggered in case of error during load
  7557. * @param format defines the internal format to use for the texture once loaded
  7558. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7559. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7560. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7561. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7562. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7563. * @return the cube texture
  7564. */
  7565. 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);
  7566. /**
  7567. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7568. */
  7569. readonly isPrefiltered: boolean;
  7570. /**
  7571. * Get the current class name of the texture useful for serialization or dynamic coding.
  7572. * @returns "CubeTexture"
  7573. */
  7574. getClassName(): string;
  7575. /**
  7576. * Update the url (and optional buffer) of this texture if url was null during construction.
  7577. * @param url the url of the texture
  7578. * @param forcedExtension defines the extension to use
  7579. * @param onLoad callback called when the texture is loaded (defaults to null)
  7580. */
  7581. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7582. /**
  7583. * Delays loading of the cube texture
  7584. * @param forcedExtension defines the extension to use
  7585. */
  7586. delayLoad(forcedExtension?: string): void;
  7587. /**
  7588. * Returns the reflection texture matrix
  7589. * @returns the reflection texture matrix
  7590. */
  7591. getReflectionTextureMatrix(): Matrix;
  7592. /**
  7593. * Sets the reflection texture matrix
  7594. * @param value Reflection texture matrix
  7595. */
  7596. setReflectionTextureMatrix(value: Matrix): void;
  7597. /**
  7598. * Parses text to create a cube texture
  7599. * @param parsedTexture define the serialized text to read from
  7600. * @param scene defines the hosting scene
  7601. * @param rootUrl defines the root url of the cube texture
  7602. * @returns a cube texture
  7603. */
  7604. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7605. /**
  7606. * Makes a clone, or deep copy, of the cube texture
  7607. * @returns a new cube texture
  7608. */
  7609. clone(): CubeTexture;
  7610. }
  7611. }
  7612. declare module BABYLON {
  7613. /**
  7614. * Manages the defines for the Material
  7615. */
  7616. export class MaterialDefines {
  7617. /** @hidden */
  7618. protected _keys: string[];
  7619. private _isDirty;
  7620. /** @hidden */
  7621. _renderId: number;
  7622. /** @hidden */
  7623. _areLightsDirty: boolean;
  7624. /** @hidden */
  7625. _areLightsDisposed: boolean;
  7626. /** @hidden */
  7627. _areAttributesDirty: boolean;
  7628. /** @hidden */
  7629. _areTexturesDirty: boolean;
  7630. /** @hidden */
  7631. _areFresnelDirty: boolean;
  7632. /** @hidden */
  7633. _areMiscDirty: boolean;
  7634. /** @hidden */
  7635. _areImageProcessingDirty: boolean;
  7636. /** @hidden */
  7637. _normals: boolean;
  7638. /** @hidden */
  7639. _uvs: boolean;
  7640. /** @hidden */
  7641. _needNormals: boolean;
  7642. /** @hidden */
  7643. _needUVs: boolean;
  7644. [id: string]: any;
  7645. /**
  7646. * Specifies if the material needs to be re-calculated
  7647. */
  7648. readonly isDirty: boolean;
  7649. /**
  7650. * Marks the material to indicate that it has been re-calculated
  7651. */
  7652. markAsProcessed(): void;
  7653. /**
  7654. * Marks the material to indicate that it needs to be re-calculated
  7655. */
  7656. markAsUnprocessed(): void;
  7657. /**
  7658. * Marks the material to indicate all of its defines need to be re-calculated
  7659. */
  7660. markAllAsDirty(): void;
  7661. /**
  7662. * Marks the material to indicate that image processing needs to be re-calculated
  7663. */
  7664. markAsImageProcessingDirty(): void;
  7665. /**
  7666. * Marks the material to indicate the lights need to be re-calculated
  7667. * @param disposed Defines whether the light is dirty due to dispose or not
  7668. */
  7669. markAsLightDirty(disposed?: boolean): void;
  7670. /**
  7671. * Marks the attribute state as changed
  7672. */
  7673. markAsAttributesDirty(): void;
  7674. /**
  7675. * Marks the texture state as changed
  7676. */
  7677. markAsTexturesDirty(): void;
  7678. /**
  7679. * Marks the fresnel state as changed
  7680. */
  7681. markAsFresnelDirty(): void;
  7682. /**
  7683. * Marks the misc state as changed
  7684. */
  7685. markAsMiscDirty(): void;
  7686. /**
  7687. * Rebuilds the material defines
  7688. */
  7689. rebuild(): void;
  7690. /**
  7691. * Specifies if two material defines are equal
  7692. * @param other - A material define instance to compare to
  7693. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7694. */
  7695. isEqual(other: MaterialDefines): boolean;
  7696. /**
  7697. * Clones this instance's defines to another instance
  7698. * @param other - material defines to clone values to
  7699. */
  7700. cloneTo(other: MaterialDefines): void;
  7701. /**
  7702. * Resets the material define values
  7703. */
  7704. reset(): void;
  7705. /**
  7706. * Converts the material define values to a string
  7707. * @returns - String of material define information
  7708. */
  7709. toString(): string;
  7710. }
  7711. }
  7712. declare module BABYLON {
  7713. /**
  7714. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7715. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7716. * 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;
  7717. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7718. */
  7719. export class ColorCurves {
  7720. private _dirty;
  7721. private _tempColor;
  7722. private _globalCurve;
  7723. private _highlightsCurve;
  7724. private _midtonesCurve;
  7725. private _shadowsCurve;
  7726. private _positiveCurve;
  7727. private _negativeCurve;
  7728. private _globalHue;
  7729. private _globalDensity;
  7730. private _globalSaturation;
  7731. private _globalExposure;
  7732. /**
  7733. * Gets the global Hue value.
  7734. * 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).
  7735. */
  7736. /**
  7737. * Sets the global Hue value.
  7738. * 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).
  7739. */
  7740. globalHue: number;
  7741. /**
  7742. * Gets the global Density value.
  7743. * 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.
  7744. * Values less than zero provide a filter of opposite hue.
  7745. */
  7746. /**
  7747. * Sets the global Density value.
  7748. * 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.
  7749. * Values less than zero provide a filter of opposite hue.
  7750. */
  7751. globalDensity: number;
  7752. /**
  7753. * Gets the global Saturation value.
  7754. * 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.
  7755. */
  7756. /**
  7757. * Sets the global Saturation value.
  7758. * 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.
  7759. */
  7760. globalSaturation: number;
  7761. /**
  7762. * Gets the global Exposure value.
  7763. * 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.
  7764. */
  7765. /**
  7766. * Sets the global Exposure value.
  7767. * 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.
  7768. */
  7769. globalExposure: number;
  7770. private _highlightsHue;
  7771. private _highlightsDensity;
  7772. private _highlightsSaturation;
  7773. private _highlightsExposure;
  7774. /**
  7775. * Gets the highlights Hue value.
  7776. * 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).
  7777. */
  7778. /**
  7779. * Sets the highlights Hue value.
  7780. * 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).
  7781. */
  7782. highlightsHue: number;
  7783. /**
  7784. * Gets the highlights Density value.
  7785. * 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.
  7786. * Values less than zero provide a filter of opposite hue.
  7787. */
  7788. /**
  7789. * Sets the highlights Density value.
  7790. * 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.
  7791. * Values less than zero provide a filter of opposite hue.
  7792. */
  7793. highlightsDensity: number;
  7794. /**
  7795. * Gets the highlights Saturation value.
  7796. * 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.
  7797. */
  7798. /**
  7799. * Sets the highlights Saturation value.
  7800. * 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.
  7801. */
  7802. highlightsSaturation: number;
  7803. /**
  7804. * Gets the highlights Exposure value.
  7805. * 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.
  7806. */
  7807. /**
  7808. * Sets the highlights Exposure value.
  7809. * 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.
  7810. */
  7811. highlightsExposure: number;
  7812. private _midtonesHue;
  7813. private _midtonesDensity;
  7814. private _midtonesSaturation;
  7815. private _midtonesExposure;
  7816. /**
  7817. * Gets the midtones Hue value.
  7818. * 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).
  7819. */
  7820. /**
  7821. * Sets the midtones Hue value.
  7822. * 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).
  7823. */
  7824. midtonesHue: number;
  7825. /**
  7826. * Gets the midtones Density value.
  7827. * 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.
  7828. * Values less than zero provide a filter of opposite hue.
  7829. */
  7830. /**
  7831. * Sets the midtones Density value.
  7832. * 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.
  7833. * Values less than zero provide a filter of opposite hue.
  7834. */
  7835. midtonesDensity: number;
  7836. /**
  7837. * Gets the midtones Saturation value.
  7838. * 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.
  7839. */
  7840. /**
  7841. * Sets the midtones Saturation value.
  7842. * 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.
  7843. */
  7844. midtonesSaturation: number;
  7845. /**
  7846. * Gets the midtones Exposure value.
  7847. * 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.
  7848. */
  7849. /**
  7850. * Sets the midtones Exposure value.
  7851. * 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.
  7852. */
  7853. midtonesExposure: number;
  7854. private _shadowsHue;
  7855. private _shadowsDensity;
  7856. private _shadowsSaturation;
  7857. private _shadowsExposure;
  7858. /**
  7859. * Gets the shadows Hue value.
  7860. * 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).
  7861. */
  7862. /**
  7863. * Sets the shadows Hue value.
  7864. * 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).
  7865. */
  7866. shadowsHue: number;
  7867. /**
  7868. * Gets the shadows Density value.
  7869. * 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.
  7870. * Values less than zero provide a filter of opposite hue.
  7871. */
  7872. /**
  7873. * Sets the shadows Density value.
  7874. * 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.
  7875. * Values less than zero provide a filter of opposite hue.
  7876. */
  7877. shadowsDensity: number;
  7878. /**
  7879. * Gets the shadows Saturation value.
  7880. * 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.
  7881. */
  7882. /**
  7883. * Sets the shadows Saturation value.
  7884. * 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.
  7885. */
  7886. shadowsSaturation: number;
  7887. /**
  7888. * Gets the shadows Exposure value.
  7889. * 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.
  7890. */
  7891. /**
  7892. * Sets the shadows Exposure value.
  7893. * 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.
  7894. */
  7895. shadowsExposure: number;
  7896. /**
  7897. * Returns the class name
  7898. * @returns The class name
  7899. */
  7900. getClassName(): string;
  7901. /**
  7902. * Binds the color curves to the shader.
  7903. * @param colorCurves The color curve to bind
  7904. * @param effect The effect to bind to
  7905. * @param positiveUniform The positive uniform shader parameter
  7906. * @param neutralUniform The neutral uniform shader parameter
  7907. * @param negativeUniform The negative uniform shader parameter
  7908. */
  7909. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7910. /**
  7911. * Prepare the list of uniforms associated with the ColorCurves effects.
  7912. * @param uniformsList The list of uniforms used in the effect
  7913. */
  7914. static PrepareUniforms(uniformsList: string[]): void;
  7915. /**
  7916. * Returns color grading data based on a hue, density, saturation and exposure value.
  7917. * @param filterHue The hue of the color filter.
  7918. * @param filterDensity The density of the color filter.
  7919. * @param saturation The saturation.
  7920. * @param exposure The exposure.
  7921. * @param result The result data container.
  7922. */
  7923. private getColorGradingDataToRef;
  7924. /**
  7925. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7926. * @param value The input slider value in range [-100,100].
  7927. * @returns Adjusted value.
  7928. */
  7929. private static applyColorGradingSliderNonlinear;
  7930. /**
  7931. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7932. * @param hue The hue (H) input.
  7933. * @param saturation The saturation (S) input.
  7934. * @param brightness The brightness (B) input.
  7935. * @result An RGBA color represented as Vector4.
  7936. */
  7937. private static fromHSBToRef;
  7938. /**
  7939. * Returns a value clamped between min and max
  7940. * @param value The value to clamp
  7941. * @param min The minimum of value
  7942. * @param max The maximum of value
  7943. * @returns The clamped value.
  7944. */
  7945. private static clamp;
  7946. /**
  7947. * Clones the current color curve instance.
  7948. * @return The cloned curves
  7949. */
  7950. clone(): ColorCurves;
  7951. /**
  7952. * Serializes the current color curve instance to a json representation.
  7953. * @return a JSON representation
  7954. */
  7955. serialize(): any;
  7956. /**
  7957. * Parses the color curve from a json representation.
  7958. * @param source the JSON source to parse
  7959. * @return The parsed curves
  7960. */
  7961. static Parse(source: any): ColorCurves;
  7962. }
  7963. }
  7964. declare module BABYLON {
  7965. /**
  7966. * Interface to follow in your material defines to integrate easily the
  7967. * Image proccessing functions.
  7968. * @hidden
  7969. */
  7970. export interface IImageProcessingConfigurationDefines {
  7971. IMAGEPROCESSING: boolean;
  7972. VIGNETTE: boolean;
  7973. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7974. VIGNETTEBLENDMODEOPAQUE: boolean;
  7975. TONEMAPPING: boolean;
  7976. TONEMAPPING_ACES: boolean;
  7977. CONTRAST: boolean;
  7978. EXPOSURE: boolean;
  7979. COLORCURVES: boolean;
  7980. COLORGRADING: boolean;
  7981. COLORGRADING3D: boolean;
  7982. SAMPLER3DGREENDEPTH: boolean;
  7983. SAMPLER3DBGRMAP: boolean;
  7984. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7985. }
  7986. /**
  7987. * @hidden
  7988. */
  7989. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7990. IMAGEPROCESSING: boolean;
  7991. VIGNETTE: boolean;
  7992. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7993. VIGNETTEBLENDMODEOPAQUE: boolean;
  7994. TONEMAPPING: boolean;
  7995. TONEMAPPING_ACES: boolean;
  7996. CONTRAST: boolean;
  7997. COLORCURVES: boolean;
  7998. COLORGRADING: boolean;
  7999. COLORGRADING3D: boolean;
  8000. SAMPLER3DGREENDEPTH: boolean;
  8001. SAMPLER3DBGRMAP: boolean;
  8002. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8003. EXPOSURE: boolean;
  8004. constructor();
  8005. }
  8006. /**
  8007. * This groups together the common properties used for image processing either in direct forward pass
  8008. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8009. * or not.
  8010. */
  8011. export class ImageProcessingConfiguration {
  8012. /**
  8013. * Default tone mapping applied in BabylonJS.
  8014. */
  8015. static readonly TONEMAPPING_STANDARD: number;
  8016. /**
  8017. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8018. * to other engines rendering to increase portability.
  8019. */
  8020. static readonly TONEMAPPING_ACES: number;
  8021. /**
  8022. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8023. */
  8024. colorCurves: Nullable<ColorCurves>;
  8025. private _colorCurvesEnabled;
  8026. /**
  8027. * Gets wether the color curves effect is enabled.
  8028. */
  8029. /**
  8030. * Sets wether the color curves effect is enabled.
  8031. */
  8032. colorCurvesEnabled: boolean;
  8033. private _colorGradingTexture;
  8034. /**
  8035. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8036. */
  8037. /**
  8038. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8039. */
  8040. colorGradingTexture: Nullable<BaseTexture>;
  8041. private _colorGradingEnabled;
  8042. /**
  8043. * Gets wether the color grading effect is enabled.
  8044. */
  8045. /**
  8046. * Sets wether the color grading effect is enabled.
  8047. */
  8048. colorGradingEnabled: boolean;
  8049. private _colorGradingWithGreenDepth;
  8050. /**
  8051. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8052. */
  8053. /**
  8054. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8055. */
  8056. colorGradingWithGreenDepth: boolean;
  8057. private _colorGradingBGR;
  8058. /**
  8059. * Gets wether the color grading texture contains BGR values.
  8060. */
  8061. /**
  8062. * Sets wether the color grading texture contains BGR values.
  8063. */
  8064. colorGradingBGR: boolean;
  8065. /** @hidden */
  8066. _exposure: number;
  8067. /**
  8068. * Gets the Exposure used in the effect.
  8069. */
  8070. /**
  8071. * Sets the Exposure used in the effect.
  8072. */
  8073. exposure: number;
  8074. private _toneMappingEnabled;
  8075. /**
  8076. * Gets wether the tone mapping effect is enabled.
  8077. */
  8078. /**
  8079. * Sets wether the tone mapping effect is enabled.
  8080. */
  8081. toneMappingEnabled: boolean;
  8082. private _toneMappingType;
  8083. /**
  8084. * Gets the type of tone mapping effect.
  8085. */
  8086. /**
  8087. * Sets the type of tone mapping effect used in BabylonJS.
  8088. */
  8089. toneMappingType: number;
  8090. protected _contrast: number;
  8091. /**
  8092. * Gets the contrast used in the effect.
  8093. */
  8094. /**
  8095. * Sets the contrast used in the effect.
  8096. */
  8097. contrast: number;
  8098. /**
  8099. * Vignette stretch size.
  8100. */
  8101. vignetteStretch: number;
  8102. /**
  8103. * Vignette centre X Offset.
  8104. */
  8105. vignetteCentreX: number;
  8106. /**
  8107. * Vignette centre Y Offset.
  8108. */
  8109. vignetteCentreY: number;
  8110. /**
  8111. * Vignette weight or intensity of the vignette effect.
  8112. */
  8113. vignetteWeight: number;
  8114. /**
  8115. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8116. * if vignetteEnabled is set to true.
  8117. */
  8118. vignetteColor: Color4;
  8119. /**
  8120. * Camera field of view used by the Vignette effect.
  8121. */
  8122. vignetteCameraFov: number;
  8123. private _vignetteBlendMode;
  8124. /**
  8125. * Gets the vignette blend mode allowing different kind of effect.
  8126. */
  8127. /**
  8128. * Sets the vignette blend mode allowing different kind of effect.
  8129. */
  8130. vignetteBlendMode: number;
  8131. private _vignetteEnabled;
  8132. /**
  8133. * Gets wether the vignette effect is enabled.
  8134. */
  8135. /**
  8136. * Sets wether the vignette effect is enabled.
  8137. */
  8138. vignetteEnabled: boolean;
  8139. private _applyByPostProcess;
  8140. /**
  8141. * Gets wether the image processing is applied through a post process or not.
  8142. */
  8143. /**
  8144. * Sets wether the image processing is applied through a post process or not.
  8145. */
  8146. applyByPostProcess: boolean;
  8147. private _isEnabled;
  8148. /**
  8149. * Gets wether the image processing is enabled or not.
  8150. */
  8151. /**
  8152. * Sets wether the image processing is enabled or not.
  8153. */
  8154. isEnabled: boolean;
  8155. /**
  8156. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8157. */
  8158. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8159. /**
  8160. * Method called each time the image processing information changes requires to recompile the effect.
  8161. */
  8162. protected _updateParameters(): void;
  8163. /**
  8164. * Gets the current class name.
  8165. * @return "ImageProcessingConfiguration"
  8166. */
  8167. getClassName(): string;
  8168. /**
  8169. * Prepare the list of uniforms associated with the Image Processing effects.
  8170. * @param uniforms The list of uniforms used in the effect
  8171. * @param defines the list of defines currently in use
  8172. */
  8173. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8174. /**
  8175. * Prepare the list of samplers associated with the Image Processing effects.
  8176. * @param samplersList The list of uniforms used in the effect
  8177. * @param defines the list of defines currently in use
  8178. */
  8179. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8180. /**
  8181. * Prepare the list of defines associated to the shader.
  8182. * @param defines the list of defines to complete
  8183. * @param forPostProcess Define if we are currently in post process mode or not
  8184. */
  8185. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8186. /**
  8187. * Returns true if all the image processing information are ready.
  8188. * @returns True if ready, otherwise, false
  8189. */
  8190. isReady(): boolean;
  8191. /**
  8192. * Binds the image processing to the shader.
  8193. * @param effect The effect to bind to
  8194. * @param aspectRatio Define the current aspect ratio of the effect
  8195. */
  8196. bind(effect: Effect, aspectRatio?: number): void;
  8197. /**
  8198. * Clones the current image processing instance.
  8199. * @return The cloned image processing
  8200. */
  8201. clone(): ImageProcessingConfiguration;
  8202. /**
  8203. * Serializes the current image processing instance to a json representation.
  8204. * @return a JSON representation
  8205. */
  8206. serialize(): any;
  8207. /**
  8208. * Parses the image processing from a json representation.
  8209. * @param source the JSON source to parse
  8210. * @return The parsed image processing
  8211. */
  8212. static Parse(source: any): ImageProcessingConfiguration;
  8213. private static _VIGNETTEMODE_MULTIPLY;
  8214. private static _VIGNETTEMODE_OPAQUE;
  8215. /**
  8216. * Used to apply the vignette as a mix with the pixel color.
  8217. */
  8218. static readonly VIGNETTEMODE_MULTIPLY: number;
  8219. /**
  8220. * Used to apply the vignette as a replacement of the pixel color.
  8221. */
  8222. static readonly VIGNETTEMODE_OPAQUE: number;
  8223. }
  8224. }
  8225. declare module BABYLON {
  8226. /** @hidden */
  8227. export var postprocessVertexShader: {
  8228. name: string;
  8229. shader: string;
  8230. };
  8231. }
  8232. declare module BABYLON {
  8233. /** Defines supported spaces */
  8234. export enum Space {
  8235. /** Local (object) space */
  8236. LOCAL = 0,
  8237. /** World space */
  8238. WORLD = 1,
  8239. /** Bone space */
  8240. BONE = 2
  8241. }
  8242. /** Defines the 3 main axes */
  8243. export class Axis {
  8244. /** X axis */
  8245. static X: Vector3;
  8246. /** Y axis */
  8247. static Y: Vector3;
  8248. /** Z axis */
  8249. static Z: Vector3;
  8250. }
  8251. }
  8252. declare module BABYLON {
  8253. /**
  8254. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8255. * This is the base of the follow, arc rotate cameras and Free camera
  8256. * @see http://doc.babylonjs.com/features/cameras
  8257. */
  8258. export class TargetCamera extends Camera {
  8259. private static _RigCamTransformMatrix;
  8260. private static _TargetTransformMatrix;
  8261. private static _TargetFocalPoint;
  8262. /**
  8263. * Define the current direction the camera is moving to
  8264. */
  8265. cameraDirection: Vector3;
  8266. /**
  8267. * Define the current rotation the camera is rotating to
  8268. */
  8269. cameraRotation: Vector2;
  8270. /**
  8271. * When set, the up vector of the camera will be updated by the rotation of the camera
  8272. */
  8273. updateUpVectorFromRotation: boolean;
  8274. private _tmpQuaternion;
  8275. /**
  8276. * Define the current rotation of the camera
  8277. */
  8278. rotation: Vector3;
  8279. /**
  8280. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8281. */
  8282. rotationQuaternion: Quaternion;
  8283. /**
  8284. * Define the current speed of the camera
  8285. */
  8286. speed: number;
  8287. /**
  8288. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8289. * around all axis.
  8290. */
  8291. noRotationConstraint: boolean;
  8292. /**
  8293. * Define the current target of the camera as an object or a position.
  8294. */
  8295. lockedTarget: any;
  8296. /** @hidden */
  8297. _currentTarget: Vector3;
  8298. /** @hidden */
  8299. _initialFocalDistance: number;
  8300. /** @hidden */
  8301. _viewMatrix: Matrix;
  8302. /** @hidden */
  8303. _camMatrix: Matrix;
  8304. /** @hidden */
  8305. _cameraTransformMatrix: Matrix;
  8306. /** @hidden */
  8307. _cameraRotationMatrix: Matrix;
  8308. /** @hidden */
  8309. _referencePoint: Vector3;
  8310. /** @hidden */
  8311. _transformedReferencePoint: Vector3;
  8312. protected _globalCurrentTarget: Vector3;
  8313. protected _globalCurrentUpVector: Vector3;
  8314. /** @hidden */
  8315. _reset: () => void;
  8316. private _defaultUp;
  8317. /**
  8318. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8319. * This is the base of the follow, arc rotate cameras and Free camera
  8320. * @see http://doc.babylonjs.com/features/cameras
  8321. * @param name Defines the name of the camera in the scene
  8322. * @param position Defines the start position of the camera in the scene
  8323. * @param scene Defines the scene the camera belongs to
  8324. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8325. */
  8326. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8327. /**
  8328. * Gets the position in front of the camera at a given distance.
  8329. * @param distance The distance from the camera we want the position to be
  8330. * @returns the position
  8331. */
  8332. getFrontPosition(distance: number): Vector3;
  8333. /** @hidden */
  8334. _getLockedTargetPosition(): Nullable<Vector3>;
  8335. private _storedPosition;
  8336. private _storedRotation;
  8337. private _storedRotationQuaternion;
  8338. /**
  8339. * Store current camera state of the camera (fov, position, rotation, etc..)
  8340. * @returns the camera
  8341. */
  8342. storeState(): Camera;
  8343. /**
  8344. * Restored camera state. You must call storeState() first
  8345. * @returns whether it was successful or not
  8346. * @hidden
  8347. */
  8348. _restoreStateValues(): boolean;
  8349. /** @hidden */
  8350. _initCache(): void;
  8351. /** @hidden */
  8352. _updateCache(ignoreParentClass?: boolean): void;
  8353. /** @hidden */
  8354. _isSynchronizedViewMatrix(): boolean;
  8355. /** @hidden */
  8356. _computeLocalCameraSpeed(): number;
  8357. /**
  8358. * Defines the target the camera should look at.
  8359. * @param target Defines the new target as a Vector or a mesh
  8360. */
  8361. setTarget(target: Vector3): void;
  8362. /**
  8363. * Return the current target position of the camera. This value is expressed in local space.
  8364. * @returns the target position
  8365. */
  8366. getTarget(): Vector3;
  8367. /** @hidden */
  8368. _decideIfNeedsToMove(): boolean;
  8369. /** @hidden */
  8370. _updatePosition(): void;
  8371. /** @hidden */
  8372. _checkInputs(): void;
  8373. protected _updateCameraRotationMatrix(): void;
  8374. /**
  8375. * 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)
  8376. * @returns the current camera
  8377. */
  8378. private _rotateUpVectorWithCameraRotationMatrix;
  8379. private _cachedRotationZ;
  8380. private _cachedQuaternionRotationZ;
  8381. /** @hidden */
  8382. _getViewMatrix(): Matrix;
  8383. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8384. /**
  8385. * @hidden
  8386. */
  8387. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8388. /**
  8389. * @hidden
  8390. */
  8391. _updateRigCameras(): void;
  8392. private _getRigCamPositionAndTarget;
  8393. /**
  8394. * Gets the current object class name.
  8395. * @return the class name
  8396. */
  8397. getClassName(): string;
  8398. }
  8399. }
  8400. declare module BABYLON {
  8401. /**
  8402. * Gather the list of keyboard event types as constants.
  8403. */
  8404. export class KeyboardEventTypes {
  8405. /**
  8406. * The keydown event is fired when a key becomes active (pressed).
  8407. */
  8408. static readonly KEYDOWN: number;
  8409. /**
  8410. * The keyup event is fired when a key has been released.
  8411. */
  8412. static readonly KEYUP: number;
  8413. }
  8414. /**
  8415. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8416. */
  8417. export class KeyboardInfo {
  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. * Instantiates a new keyboard info.
  8428. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8429. * @param type Defines the type of event (KeyboardEventTypes)
  8430. * @param event Defines the related dom event
  8431. */
  8432. constructor(
  8433. /**
  8434. * Defines the type of event (KeyboardEventTypes)
  8435. */
  8436. type: number,
  8437. /**
  8438. * Defines the related dom event
  8439. */
  8440. event: KeyboardEvent);
  8441. }
  8442. /**
  8443. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8444. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8445. */
  8446. export class KeyboardInfoPre extends KeyboardInfo {
  8447. /**
  8448. * Defines the type of event (KeyboardEventTypes)
  8449. */
  8450. type: number;
  8451. /**
  8452. * Defines the related dom event
  8453. */
  8454. event: KeyboardEvent;
  8455. /**
  8456. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8457. */
  8458. skipOnPointerObservable: boolean;
  8459. /**
  8460. * Instantiates a new keyboard pre info.
  8461. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8462. * @param type Defines the type of event (KeyboardEventTypes)
  8463. * @param event Defines the related dom event
  8464. */
  8465. constructor(
  8466. /**
  8467. * Defines the type of event (KeyboardEventTypes)
  8468. */
  8469. type: number,
  8470. /**
  8471. * Defines the related dom event
  8472. */
  8473. event: KeyboardEvent);
  8474. }
  8475. }
  8476. declare module BABYLON {
  8477. /**
  8478. * Manage the keyboard inputs to control the movement of a free camera.
  8479. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8480. */
  8481. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8482. /**
  8483. * Defines the camera the input is attached to.
  8484. */
  8485. camera: FreeCamera;
  8486. /**
  8487. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8488. */
  8489. keysUp: number[];
  8490. /**
  8491. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8492. */
  8493. keysDown: number[];
  8494. /**
  8495. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8496. */
  8497. keysLeft: number[];
  8498. /**
  8499. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8500. */
  8501. keysRight: number[];
  8502. private _keys;
  8503. private _onCanvasBlurObserver;
  8504. private _onKeyboardObserver;
  8505. private _engine;
  8506. private _scene;
  8507. /**
  8508. * Attach the input controls to a specific dom element to get the input from.
  8509. * @param element Defines the element the controls should be listened from
  8510. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8511. */
  8512. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8513. /**
  8514. * Detach the current controls from the specified dom element.
  8515. * @param element Defines the element to stop listening the inputs from
  8516. */
  8517. detachControl(element: Nullable<HTMLElement>): void;
  8518. /**
  8519. * Update the current camera state depending on the inputs that have been used this frame.
  8520. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8521. */
  8522. checkInputs(): void;
  8523. /**
  8524. * Gets the class name of the current intput.
  8525. * @returns the class name
  8526. */
  8527. getClassName(): string;
  8528. /** @hidden */
  8529. _onLostFocus(): void;
  8530. /**
  8531. * Get the friendly name associated with the input class.
  8532. * @returns the input friendly name
  8533. */
  8534. getSimpleName(): string;
  8535. }
  8536. }
  8537. declare module BABYLON {
  8538. /**
  8539. * Interface describing all the common properties and methods a shadow light needs to implement.
  8540. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8541. * as well as binding the different shadow properties to the effects.
  8542. */
  8543. export interface IShadowLight extends Light {
  8544. /**
  8545. * The light id in the scene (used in scene.findLighById for instance)
  8546. */
  8547. id: string;
  8548. /**
  8549. * The position the shdow will be casted from.
  8550. */
  8551. position: Vector3;
  8552. /**
  8553. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8554. */
  8555. direction: Vector3;
  8556. /**
  8557. * The transformed position. Position of the light in world space taking parenting in account.
  8558. */
  8559. transformedPosition: Vector3;
  8560. /**
  8561. * The transformed direction. Direction of the light in world space taking parenting in account.
  8562. */
  8563. transformedDirection: Vector3;
  8564. /**
  8565. * The friendly name of the light in the scene.
  8566. */
  8567. name: string;
  8568. /**
  8569. * Defines the shadow projection clipping minimum z value.
  8570. */
  8571. shadowMinZ: number;
  8572. /**
  8573. * Defines the shadow projection clipping maximum z value.
  8574. */
  8575. shadowMaxZ: number;
  8576. /**
  8577. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8578. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8579. */
  8580. computeTransformedInformation(): boolean;
  8581. /**
  8582. * Gets the scene the light belongs to.
  8583. * @returns The scene
  8584. */
  8585. getScene(): Scene;
  8586. /**
  8587. * Callback defining a custom Projection Matrix Builder.
  8588. * This can be used to override the default projection matrix computation.
  8589. */
  8590. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8591. /**
  8592. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8593. * @param matrix The materix to updated with the projection information
  8594. * @param viewMatrix The transform matrix of the light
  8595. * @param renderList The list of mesh to render in the map
  8596. * @returns The current light
  8597. */
  8598. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8599. /**
  8600. * Gets the current depth scale used in ESM.
  8601. * @returns The scale
  8602. */
  8603. getDepthScale(): number;
  8604. /**
  8605. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8606. * @returns true if a cube texture needs to be use
  8607. */
  8608. needCube(): boolean;
  8609. /**
  8610. * Detects if the projection matrix requires to be recomputed this frame.
  8611. * @returns true if it requires to be recomputed otherwise, false.
  8612. */
  8613. needProjectionMatrixCompute(): boolean;
  8614. /**
  8615. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8616. */
  8617. forceProjectionMatrixCompute(): void;
  8618. /**
  8619. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8620. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8621. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8622. */
  8623. getShadowDirection(faceIndex?: number): Vector3;
  8624. /**
  8625. * Gets the minZ used for shadow according to both the scene and the light.
  8626. * @param activeCamera The camera we are returning the min for
  8627. * @returns the depth min z
  8628. */
  8629. getDepthMinZ(activeCamera: Camera): number;
  8630. /**
  8631. * Gets the maxZ used for shadow according to both the scene and the light.
  8632. * @param activeCamera The camera we are returning the max for
  8633. * @returns the depth max z
  8634. */
  8635. getDepthMaxZ(activeCamera: Camera): number;
  8636. }
  8637. /**
  8638. * Base implementation IShadowLight
  8639. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8640. */
  8641. export abstract class ShadowLight extends Light implements IShadowLight {
  8642. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8643. protected _position: Vector3;
  8644. protected _setPosition(value: Vector3): void;
  8645. /**
  8646. * Sets the position the shadow will be casted from. Also use as the light position for both
  8647. * point and spot lights.
  8648. */
  8649. /**
  8650. * Sets the position the shadow will be casted from. Also use as the light position for both
  8651. * point and spot lights.
  8652. */
  8653. position: Vector3;
  8654. protected _direction: Vector3;
  8655. protected _setDirection(value: Vector3): void;
  8656. /**
  8657. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8658. * Also use as the light direction on spot and directional lights.
  8659. */
  8660. /**
  8661. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8662. * Also use as the light direction on spot and directional lights.
  8663. */
  8664. direction: Vector3;
  8665. private _shadowMinZ;
  8666. /**
  8667. * Gets the shadow projection clipping minimum z value.
  8668. */
  8669. /**
  8670. * Sets the shadow projection clipping minimum z value.
  8671. */
  8672. shadowMinZ: number;
  8673. private _shadowMaxZ;
  8674. /**
  8675. * Sets the shadow projection clipping maximum z value.
  8676. */
  8677. /**
  8678. * Gets the shadow projection clipping maximum z value.
  8679. */
  8680. shadowMaxZ: number;
  8681. /**
  8682. * Callback defining a custom Projection Matrix Builder.
  8683. * This can be used to override the default projection matrix computation.
  8684. */
  8685. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8686. /**
  8687. * The transformed position. Position of the light in world space taking parenting in account.
  8688. */
  8689. transformedPosition: Vector3;
  8690. /**
  8691. * The transformed direction. Direction of the light in world space taking parenting in account.
  8692. */
  8693. transformedDirection: Vector3;
  8694. private _needProjectionMatrixCompute;
  8695. /**
  8696. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8697. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8698. */
  8699. computeTransformedInformation(): boolean;
  8700. /**
  8701. * Return the depth scale used for the shadow map.
  8702. * @returns the depth scale.
  8703. */
  8704. getDepthScale(): number;
  8705. /**
  8706. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8707. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8708. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8709. */
  8710. getShadowDirection(faceIndex?: number): Vector3;
  8711. /**
  8712. * Returns the ShadowLight absolute position in the World.
  8713. * @returns the position vector in world space
  8714. */
  8715. getAbsolutePosition(): Vector3;
  8716. /**
  8717. * Sets the ShadowLight direction toward the passed target.
  8718. * @param target The point to target in local space
  8719. * @returns the updated ShadowLight direction
  8720. */
  8721. setDirectionToTarget(target: Vector3): Vector3;
  8722. /**
  8723. * Returns the light rotation in euler definition.
  8724. * @returns the x y z rotation in local space.
  8725. */
  8726. getRotation(): Vector3;
  8727. /**
  8728. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8729. * @returns true if a cube texture needs to be use
  8730. */
  8731. needCube(): boolean;
  8732. /**
  8733. * Detects if the projection matrix requires to be recomputed this frame.
  8734. * @returns true if it requires to be recomputed otherwise, false.
  8735. */
  8736. needProjectionMatrixCompute(): boolean;
  8737. /**
  8738. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8739. */
  8740. forceProjectionMatrixCompute(): void;
  8741. /** @hidden */
  8742. _initCache(): void;
  8743. /** @hidden */
  8744. _isSynchronized(): boolean;
  8745. /**
  8746. * Computes the world matrix of the node
  8747. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8748. * @returns the world matrix
  8749. */
  8750. computeWorldMatrix(force?: boolean): Matrix;
  8751. /**
  8752. * Gets the minZ used for shadow according to both the scene and the light.
  8753. * @param activeCamera The camera we are returning the min for
  8754. * @returns the depth min z
  8755. */
  8756. getDepthMinZ(activeCamera: Camera): number;
  8757. /**
  8758. * Gets the maxZ used for shadow according to both the scene and the light.
  8759. * @param activeCamera The camera we are returning the max for
  8760. * @returns the depth max z
  8761. */
  8762. getDepthMaxZ(activeCamera: Camera): number;
  8763. /**
  8764. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8765. * @param matrix The materix to updated with the projection information
  8766. * @param viewMatrix The transform matrix of the light
  8767. * @param renderList The list of mesh to render in the map
  8768. * @returns The current light
  8769. */
  8770. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8771. }
  8772. }
  8773. declare module BABYLON {
  8774. /**
  8775. * "Static Class" containing the most commonly used helper while dealing with material for
  8776. * rendering purpose.
  8777. *
  8778. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8779. *
  8780. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8781. */
  8782. export class MaterialHelper {
  8783. /**
  8784. * Bind the current view position to an effect.
  8785. * @param effect The effect to be bound
  8786. * @param scene The scene the eyes position is used from
  8787. */
  8788. static BindEyePosition(effect: Effect, scene: Scene): void;
  8789. /**
  8790. * Helps preparing the defines values about the UVs in used in the effect.
  8791. * UVs are shared as much as we can accross channels in the shaders.
  8792. * @param texture The texture we are preparing the UVs for
  8793. * @param defines The defines to update
  8794. * @param key The channel key "diffuse", "specular"... used in the shader
  8795. */
  8796. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8797. /**
  8798. * Binds a texture matrix value to its corrsponding uniform
  8799. * @param texture The texture to bind the matrix for
  8800. * @param uniformBuffer The uniform buffer receivin the data
  8801. * @param key The channel key "diffuse", "specular"... used in the shader
  8802. */
  8803. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8804. /**
  8805. * Gets the current status of the fog (should it be enabled?)
  8806. * @param mesh defines the mesh to evaluate for fog support
  8807. * @param scene defines the hosting scene
  8808. * @returns true if fog must be enabled
  8809. */
  8810. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8811. /**
  8812. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8813. * @param mesh defines the current mesh
  8814. * @param scene defines the current scene
  8815. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8816. * @param pointsCloud defines if point cloud rendering has to be turned on
  8817. * @param fogEnabled defines if fog has to be turned on
  8818. * @param alphaTest defines if alpha testing has to be turned on
  8819. * @param defines defines the current list of defines
  8820. */
  8821. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8822. /**
  8823. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8824. * @param scene defines the current scene
  8825. * @param engine defines the current engine
  8826. * @param defines specifies the list of active defines
  8827. * @param useInstances defines if instances have to be turned on
  8828. * @param useClipPlane defines if clip plane have to be turned on
  8829. */
  8830. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8831. /**
  8832. * Prepares the defines for bones
  8833. * @param mesh The mesh containing the geometry data we will draw
  8834. * @param defines The defines to update
  8835. */
  8836. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8837. /**
  8838. * Prepares the defines for morph targets
  8839. * @param mesh The mesh containing the geometry data we will draw
  8840. * @param defines The defines to update
  8841. */
  8842. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8843. /**
  8844. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8845. * @param mesh The mesh containing the geometry data we will draw
  8846. * @param defines The defines to update
  8847. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8848. * @param useBones Precise whether bones should be used or not (override mesh info)
  8849. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8850. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8851. * @returns false if defines are considered not dirty and have not been checked
  8852. */
  8853. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8854. /**
  8855. * Prepares the defines related to multiview
  8856. * @param scene The scene we are intending to draw
  8857. * @param defines The defines to update
  8858. */
  8859. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8860. /**
  8861. * Prepares the defines related to the light information passed in parameter
  8862. * @param scene The scene we are intending to draw
  8863. * @param mesh The mesh the effect is compiling for
  8864. * @param light The light the effect is compiling for
  8865. * @param lightIndex The index of the light
  8866. * @param defines The defines to update
  8867. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8868. * @param state Defines the current state regarding what is needed (normals, etc...)
  8869. */
  8870. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8871. needNormals: boolean;
  8872. needRebuild: boolean;
  8873. shadowEnabled: boolean;
  8874. specularEnabled: boolean;
  8875. lightmapMode: boolean;
  8876. }): void;
  8877. /**
  8878. * Prepares the defines related to the light information passed in parameter
  8879. * @param scene The scene we are intending to draw
  8880. * @param mesh The mesh the effect is compiling for
  8881. * @param defines The defines to update
  8882. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8883. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8884. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8885. * @returns true if normals will be required for the rest of the effect
  8886. */
  8887. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8888. /**
  8889. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8890. * @param lightIndex defines the light index
  8891. * @param uniformsList The uniform list
  8892. * @param samplersList The sampler list
  8893. * @param projectedLightTexture defines if projected texture must be used
  8894. * @param uniformBuffersList defines an optional list of uniform buffers
  8895. */
  8896. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8897. /**
  8898. * Prepares the uniforms and samplers list to be used in the effect
  8899. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8900. * @param samplersList The sampler list
  8901. * @param defines The defines helping in the list generation
  8902. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8903. */
  8904. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8905. /**
  8906. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8907. * @param defines The defines to update while falling back
  8908. * @param fallbacks The authorized effect fallbacks
  8909. * @param maxSimultaneousLights The maximum number of lights allowed
  8910. * @param rank the current rank of the Effect
  8911. * @returns The newly affected rank
  8912. */
  8913. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8914. private static _TmpMorphInfluencers;
  8915. /**
  8916. * Prepares the list of attributes required for morph targets according to the effect defines.
  8917. * @param attribs The current list of supported attribs
  8918. * @param mesh The mesh to prepare the morph targets attributes for
  8919. * @param influencers The number of influencers
  8920. */
  8921. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8922. /**
  8923. * Prepares the list of attributes required for morph targets according to the effect defines.
  8924. * @param attribs The current list of supported attribs
  8925. * @param mesh The mesh to prepare the morph targets attributes for
  8926. * @param defines The current Defines of the effect
  8927. */
  8928. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8929. /**
  8930. * Prepares the list of attributes required for bones according to the effect defines.
  8931. * @param attribs The current list of supported attribs
  8932. * @param mesh The mesh to prepare the bones attributes for
  8933. * @param defines The current Defines of the effect
  8934. * @param fallbacks The current efffect fallback strategy
  8935. */
  8936. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8937. /**
  8938. * Check and prepare the list of attributes required for instances according to the effect defines.
  8939. * @param attribs The current list of supported attribs
  8940. * @param defines The current MaterialDefines of the effect
  8941. */
  8942. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8943. /**
  8944. * Add the list of attributes required for instances to the attribs array.
  8945. * @param attribs The current list of supported attribs
  8946. */
  8947. static PushAttributesForInstances(attribs: string[]): void;
  8948. /**
  8949. * Binds the light shadow information to the effect for the given mesh.
  8950. * @param light The light containing the generator
  8951. * @param scene The scene the lights belongs to
  8952. * @param mesh The mesh we are binding the information to render
  8953. * @param lightIndex The light index in the effect used to render the mesh
  8954. * @param effect The effect we are binding the data to
  8955. */
  8956. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8957. /**
  8958. * Binds the light information to the effect.
  8959. * @param light The light containing the generator
  8960. * @param effect The effect we are binding the data to
  8961. * @param lightIndex The light index in the effect used to render
  8962. */
  8963. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8964. /**
  8965. * Binds the lights information from the scene to the effect for the given mesh.
  8966. * @param light Light to bind
  8967. * @param lightIndex Light index
  8968. * @param scene The scene where the light belongs to
  8969. * @param mesh The mesh we are binding the information to render
  8970. * @param effect The effect we are binding the data to
  8971. * @param useSpecular Defines if specular is supported
  8972. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8973. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8974. */
  8975. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8976. /**
  8977. * Binds the lights information from the scene to the effect for the given mesh.
  8978. * @param scene The scene the lights belongs to
  8979. * @param mesh The mesh we are binding the information to render
  8980. * @param effect The effect we are binding the data to
  8981. * @param defines The generated defines for the effect
  8982. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8983. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8984. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8985. */
  8986. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8987. private static _tempFogColor;
  8988. /**
  8989. * Binds the fog information from the scene to the effect for the given mesh.
  8990. * @param scene The scene the lights belongs to
  8991. * @param mesh The mesh we are binding the information to render
  8992. * @param effect The effect we are binding the data to
  8993. * @param linearSpace Defines if the fog effect is applied in linear space
  8994. */
  8995. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8996. /**
  8997. * Binds the bones information from the mesh to the effect.
  8998. * @param mesh The mesh we are binding the information to render
  8999. * @param effect The effect we are binding the data to
  9000. */
  9001. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9002. /**
  9003. * Binds the morph targets information from the mesh to the effect.
  9004. * @param abstractMesh The mesh we are binding the information to render
  9005. * @param effect The effect we are binding the data to
  9006. */
  9007. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9008. /**
  9009. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9010. * @param defines The generated defines used in the effect
  9011. * @param effect The effect we are binding the data to
  9012. * @param scene The scene we are willing to render with logarithmic scale for
  9013. */
  9014. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9015. /**
  9016. * Binds the clip plane information from the scene to the effect.
  9017. * @param scene The scene the clip plane information are extracted from
  9018. * @param effect The effect we are binding the data to
  9019. */
  9020. static BindClipPlane(effect: Effect, scene: Scene): void;
  9021. }
  9022. }
  9023. declare module BABYLON {
  9024. /** @hidden */
  9025. export var packingFunctions: {
  9026. name: string;
  9027. shader: string;
  9028. };
  9029. }
  9030. declare module BABYLON {
  9031. /** @hidden */
  9032. export var shadowMapPixelShader: {
  9033. name: string;
  9034. shader: string;
  9035. };
  9036. }
  9037. declare module BABYLON {
  9038. /** @hidden */
  9039. export var bonesDeclaration: {
  9040. name: string;
  9041. shader: string;
  9042. };
  9043. }
  9044. declare module BABYLON {
  9045. /** @hidden */
  9046. export var morphTargetsVertexGlobalDeclaration: {
  9047. name: string;
  9048. shader: string;
  9049. };
  9050. }
  9051. declare module BABYLON {
  9052. /** @hidden */
  9053. export var morphTargetsVertexDeclaration: {
  9054. name: string;
  9055. shader: string;
  9056. };
  9057. }
  9058. declare module BABYLON {
  9059. /** @hidden */
  9060. export var instancesDeclaration: {
  9061. name: string;
  9062. shader: string;
  9063. };
  9064. }
  9065. declare module BABYLON {
  9066. /** @hidden */
  9067. export var helperFunctions: {
  9068. name: string;
  9069. shader: string;
  9070. };
  9071. }
  9072. declare module BABYLON {
  9073. /** @hidden */
  9074. export var morphTargetsVertex: {
  9075. name: string;
  9076. shader: string;
  9077. };
  9078. }
  9079. declare module BABYLON {
  9080. /** @hidden */
  9081. export var instancesVertex: {
  9082. name: string;
  9083. shader: string;
  9084. };
  9085. }
  9086. declare module BABYLON {
  9087. /** @hidden */
  9088. export var bonesVertex: {
  9089. name: string;
  9090. shader: string;
  9091. };
  9092. }
  9093. declare module BABYLON {
  9094. /** @hidden */
  9095. export var shadowMapVertexShader: {
  9096. name: string;
  9097. shader: string;
  9098. };
  9099. }
  9100. declare module BABYLON {
  9101. /** @hidden */
  9102. export var depthBoxBlurPixelShader: {
  9103. name: string;
  9104. shader: string;
  9105. };
  9106. }
  9107. declare module BABYLON {
  9108. /**
  9109. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9110. */
  9111. export interface ICustomShaderOptions {
  9112. /**
  9113. * Gets or sets the custom shader name to use
  9114. */
  9115. shaderName: string;
  9116. /**
  9117. * The list of attribute names used in the shader
  9118. */
  9119. attributes?: string[];
  9120. /**
  9121. * The list of unifrom names used in the shader
  9122. */
  9123. uniforms?: string[];
  9124. /**
  9125. * The list of sampler names used in the shader
  9126. */
  9127. samplers?: string[];
  9128. /**
  9129. * The list of defines used in the shader
  9130. */
  9131. defines?: string[];
  9132. }
  9133. /**
  9134. * Interface to implement to create a shadow generator compatible with BJS.
  9135. */
  9136. export interface IShadowGenerator {
  9137. /**
  9138. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9139. * @returns The render target texture if present otherwise, null
  9140. */
  9141. getShadowMap(): Nullable<RenderTargetTexture>;
  9142. /**
  9143. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9144. * @returns The render target texture if the shadow map is present otherwise, null
  9145. */
  9146. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9147. /**
  9148. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9149. * @param subMesh The submesh we want to render in the shadow map
  9150. * @param useInstances Defines wether will draw in the map using instances
  9151. * @returns true if ready otherwise, false
  9152. */
  9153. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9154. /**
  9155. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9156. * @param defines Defines of the material we want to update
  9157. * @param lightIndex Index of the light in the enabled light list of the material
  9158. */
  9159. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9160. /**
  9161. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9162. * defined in the generator but impacting the effect).
  9163. * It implies the unifroms available on the materials are the standard BJS ones.
  9164. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9165. * @param effect The effect we are binfing the information for
  9166. */
  9167. bindShadowLight(lightIndex: string, effect: Effect): void;
  9168. /**
  9169. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9170. * (eq to shadow prjection matrix * light transform matrix)
  9171. * @returns The transform matrix used to create the shadow map
  9172. */
  9173. getTransformMatrix(): Matrix;
  9174. /**
  9175. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9176. * Cube and 2D textures for instance.
  9177. */
  9178. recreateShadowMap(): void;
  9179. /**
  9180. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9181. * @param onCompiled Callback triggered at the and of the effects compilation
  9182. * @param options Sets of optional options forcing the compilation with different modes
  9183. */
  9184. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9185. useInstances: boolean;
  9186. }>): void;
  9187. /**
  9188. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9189. * @param options Sets of optional options forcing the compilation with different modes
  9190. * @returns A promise that resolves when the compilation completes
  9191. */
  9192. forceCompilationAsync(options?: Partial<{
  9193. useInstances: boolean;
  9194. }>): Promise<void>;
  9195. /**
  9196. * Serializes the shadow generator setup to a json object.
  9197. * @returns The serialized JSON object
  9198. */
  9199. serialize(): any;
  9200. /**
  9201. * Disposes the Shadow map and related Textures and effects.
  9202. */
  9203. dispose(): void;
  9204. }
  9205. /**
  9206. * Default implementation IShadowGenerator.
  9207. * This is the main object responsible of generating shadows in the framework.
  9208. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9209. */
  9210. export class ShadowGenerator implements IShadowGenerator {
  9211. /**
  9212. * Shadow generator mode None: no filtering applied.
  9213. */
  9214. static readonly FILTER_NONE: number;
  9215. /**
  9216. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9217. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9218. */
  9219. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9220. /**
  9221. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9222. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9223. */
  9224. static readonly FILTER_POISSONSAMPLING: number;
  9225. /**
  9226. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9227. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9228. */
  9229. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9230. /**
  9231. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9232. * edge artifacts on steep falloff.
  9233. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9234. */
  9235. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9236. /**
  9237. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9238. * edge artifacts on steep falloff.
  9239. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9240. */
  9241. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9242. /**
  9243. * Shadow generator mode PCF: Percentage Closer Filtering
  9244. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9245. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9246. */
  9247. static readonly FILTER_PCF: number;
  9248. /**
  9249. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9250. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9251. * Contact Hardening
  9252. */
  9253. static readonly FILTER_PCSS: number;
  9254. /**
  9255. * Reserved for PCF and PCSS
  9256. * Highest Quality.
  9257. *
  9258. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9259. *
  9260. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9261. */
  9262. static readonly QUALITY_HIGH: number;
  9263. /**
  9264. * Reserved for PCF and PCSS
  9265. * Good tradeoff for quality/perf cross devices
  9266. *
  9267. * Execute PCF on a 3*3 kernel.
  9268. *
  9269. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9270. */
  9271. static readonly QUALITY_MEDIUM: number;
  9272. /**
  9273. * Reserved for PCF and PCSS
  9274. * The lowest quality but the fastest.
  9275. *
  9276. * Execute PCF on a 1*1 kernel.
  9277. *
  9278. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9279. */
  9280. static readonly QUALITY_LOW: number;
  9281. /** Gets or sets the custom shader name to use */
  9282. customShaderOptions: ICustomShaderOptions;
  9283. /**
  9284. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9285. */
  9286. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9287. /**
  9288. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9289. */
  9290. onAfterShadowMapRenderObservable: Observable<Effect>;
  9291. /**
  9292. * Observable triggered before a mesh is rendered in the shadow map.
  9293. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9294. */
  9295. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9296. /**
  9297. * Observable triggered after a mesh is rendered in the shadow map.
  9298. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9299. */
  9300. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9301. private _bias;
  9302. /**
  9303. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9304. */
  9305. /**
  9306. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9307. */
  9308. bias: number;
  9309. private _normalBias;
  9310. /**
  9311. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9312. */
  9313. /**
  9314. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9315. */
  9316. normalBias: number;
  9317. private _blurBoxOffset;
  9318. /**
  9319. * Gets the blur box offset: offset applied during the blur pass.
  9320. * Only useful if useKernelBlur = false
  9321. */
  9322. /**
  9323. * Sets the blur box offset: offset applied during the blur pass.
  9324. * Only useful if useKernelBlur = false
  9325. */
  9326. blurBoxOffset: number;
  9327. private _blurScale;
  9328. /**
  9329. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9330. * 2 means half of the size.
  9331. */
  9332. /**
  9333. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9334. * 2 means half of the size.
  9335. */
  9336. blurScale: number;
  9337. private _blurKernel;
  9338. /**
  9339. * Gets the blur kernel: kernel size of the blur pass.
  9340. * Only useful if useKernelBlur = true
  9341. */
  9342. /**
  9343. * Sets the blur kernel: kernel size of the blur pass.
  9344. * Only useful if useKernelBlur = true
  9345. */
  9346. blurKernel: number;
  9347. private _useKernelBlur;
  9348. /**
  9349. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9350. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9351. */
  9352. /**
  9353. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9354. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9355. */
  9356. useKernelBlur: boolean;
  9357. private _depthScale;
  9358. /**
  9359. * Gets the depth scale used in ESM mode.
  9360. */
  9361. /**
  9362. * Sets the depth scale used in ESM mode.
  9363. * This can override the scale stored on the light.
  9364. */
  9365. depthScale: number;
  9366. private _filter;
  9367. /**
  9368. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9369. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9370. */
  9371. /**
  9372. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9373. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9374. */
  9375. filter: number;
  9376. /**
  9377. * Gets if the current filter is set to Poisson Sampling.
  9378. */
  9379. /**
  9380. * Sets the current filter to Poisson Sampling.
  9381. */
  9382. usePoissonSampling: boolean;
  9383. /**
  9384. * Gets if the current filter is set to ESM.
  9385. */
  9386. /**
  9387. * Sets the current filter is to ESM.
  9388. */
  9389. useExponentialShadowMap: boolean;
  9390. /**
  9391. * Gets if the current filter is set to filtered ESM.
  9392. */
  9393. /**
  9394. * Gets if the current filter is set to filtered ESM.
  9395. */
  9396. useBlurExponentialShadowMap: boolean;
  9397. /**
  9398. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9399. * exponential to prevent steep falloff artifacts).
  9400. */
  9401. /**
  9402. * Sets the current filter to "close ESM" (using the inverse of the
  9403. * exponential to prevent steep falloff artifacts).
  9404. */
  9405. useCloseExponentialShadowMap: boolean;
  9406. /**
  9407. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9408. * exponential to prevent steep falloff artifacts).
  9409. */
  9410. /**
  9411. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9412. * exponential to prevent steep falloff artifacts).
  9413. */
  9414. useBlurCloseExponentialShadowMap: boolean;
  9415. /**
  9416. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9417. */
  9418. /**
  9419. * Sets the current filter to "PCF" (percentage closer filtering).
  9420. */
  9421. usePercentageCloserFiltering: boolean;
  9422. private _filteringQuality;
  9423. /**
  9424. * Gets the PCF or PCSS Quality.
  9425. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9426. */
  9427. /**
  9428. * Sets the PCF or PCSS Quality.
  9429. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9430. */
  9431. filteringQuality: number;
  9432. /**
  9433. * Gets if the current filter is set to "PCSS" (contact hardening).
  9434. */
  9435. /**
  9436. * Sets the current filter to "PCSS" (contact hardening).
  9437. */
  9438. useContactHardeningShadow: boolean;
  9439. private _contactHardeningLightSizeUVRatio;
  9440. /**
  9441. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9442. * Using a ratio helps keeping shape stability independently of the map size.
  9443. *
  9444. * It does not account for the light projection as it was having too much
  9445. * instability during the light setup or during light position changes.
  9446. *
  9447. * Only valid if useContactHardeningShadow is true.
  9448. */
  9449. /**
  9450. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9451. * Using a ratio helps keeping shape stability independently of the map size.
  9452. *
  9453. * It does not account for the light projection as it was having too much
  9454. * instability during the light setup or during light position changes.
  9455. *
  9456. * Only valid if useContactHardeningShadow is true.
  9457. */
  9458. contactHardeningLightSizeUVRatio: number;
  9459. private _darkness;
  9460. /** Gets or sets the actual darkness of a shadow */
  9461. darkness: number;
  9462. /**
  9463. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9464. * 0 means strongest and 1 would means no shadow.
  9465. * @returns the darkness.
  9466. */
  9467. getDarkness(): number;
  9468. /**
  9469. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9470. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9471. * @returns the shadow generator allowing fluent coding.
  9472. */
  9473. setDarkness(darkness: number): ShadowGenerator;
  9474. private _transparencyShadow;
  9475. /** Gets or sets the ability to have transparent shadow */
  9476. transparencyShadow: boolean;
  9477. /**
  9478. * Sets the ability to have transparent shadow (boolean).
  9479. * @param transparent True if transparent else False
  9480. * @returns the shadow generator allowing fluent coding
  9481. */
  9482. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9483. private _shadowMap;
  9484. private _shadowMap2;
  9485. /**
  9486. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9487. * @returns The render target texture if present otherwise, null
  9488. */
  9489. getShadowMap(): Nullable<RenderTargetTexture>;
  9490. /**
  9491. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9492. * @returns The render target texture if the shadow map is present otherwise, null
  9493. */
  9494. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9495. /**
  9496. * Gets the class name of that object
  9497. * @returns "ShadowGenerator"
  9498. */
  9499. getClassName(): string;
  9500. /**
  9501. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9502. * @param mesh Mesh to add
  9503. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9504. * @returns the Shadow Generator itself
  9505. */
  9506. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9507. /**
  9508. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9509. * @param mesh Mesh to remove
  9510. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9511. * @returns the Shadow Generator itself
  9512. */
  9513. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9514. /**
  9515. * Controls the extent to which the shadows fade out at the edge of the frustum
  9516. * Used only by directionals and spots
  9517. */
  9518. frustumEdgeFalloff: number;
  9519. private _light;
  9520. /**
  9521. * Returns the associated light object.
  9522. * @returns the light generating the shadow
  9523. */
  9524. getLight(): IShadowLight;
  9525. /**
  9526. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9527. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9528. * It might on the other hand introduce peter panning.
  9529. */
  9530. forceBackFacesOnly: boolean;
  9531. private _scene;
  9532. private _lightDirection;
  9533. private _effect;
  9534. private _viewMatrix;
  9535. private _projectionMatrix;
  9536. private _transformMatrix;
  9537. private _cachedPosition;
  9538. private _cachedDirection;
  9539. private _cachedDefines;
  9540. private _currentRenderID;
  9541. private _boxBlurPostprocess;
  9542. private _kernelBlurXPostprocess;
  9543. private _kernelBlurYPostprocess;
  9544. private _blurPostProcesses;
  9545. private _mapSize;
  9546. private _currentFaceIndex;
  9547. private _currentFaceIndexCache;
  9548. private _textureType;
  9549. private _defaultTextureMatrix;
  9550. /** @hidden */
  9551. static _SceneComponentInitialization: (scene: Scene) => void;
  9552. /**
  9553. * Creates a ShadowGenerator object.
  9554. * A ShadowGenerator is the required tool to use the shadows.
  9555. * Each light casting shadows needs to use its own ShadowGenerator.
  9556. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9557. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9558. * @param light The light object generating the shadows.
  9559. * @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.
  9560. */
  9561. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9562. private _initializeGenerator;
  9563. private _initializeShadowMap;
  9564. private _initializeBlurRTTAndPostProcesses;
  9565. private _renderForShadowMap;
  9566. private _renderSubMeshForShadowMap;
  9567. private _applyFilterValues;
  9568. /**
  9569. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9570. * @param onCompiled Callback triggered at the and of the effects compilation
  9571. * @param options Sets of optional options forcing the compilation with different modes
  9572. */
  9573. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9574. useInstances: boolean;
  9575. }>): void;
  9576. /**
  9577. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9578. * @param options Sets of optional options forcing the compilation with different modes
  9579. * @returns A promise that resolves when the compilation completes
  9580. */
  9581. forceCompilationAsync(options?: Partial<{
  9582. useInstances: boolean;
  9583. }>): Promise<void>;
  9584. /**
  9585. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9586. * @param subMesh The submesh we want to render in the shadow map
  9587. * @param useInstances Defines wether will draw in the map using instances
  9588. * @returns true if ready otherwise, false
  9589. */
  9590. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9591. /**
  9592. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9593. * @param defines Defines of the material we want to update
  9594. * @param lightIndex Index of the light in the enabled light list of the material
  9595. */
  9596. prepareDefines(defines: any, lightIndex: number): void;
  9597. /**
  9598. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9599. * defined in the generator but impacting the effect).
  9600. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9601. * @param effect The effect we are binfing the information for
  9602. */
  9603. bindShadowLight(lightIndex: string, effect: Effect): void;
  9604. /**
  9605. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9606. * (eq to shadow prjection matrix * light transform matrix)
  9607. * @returns The transform matrix used to create the shadow map
  9608. */
  9609. getTransformMatrix(): Matrix;
  9610. /**
  9611. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9612. * Cube and 2D textures for instance.
  9613. */
  9614. recreateShadowMap(): void;
  9615. private _disposeBlurPostProcesses;
  9616. private _disposeRTTandPostProcesses;
  9617. /**
  9618. * Disposes the ShadowGenerator.
  9619. * Returns nothing.
  9620. */
  9621. dispose(): void;
  9622. /**
  9623. * Serializes the shadow generator setup to a json object.
  9624. * @returns The serialized JSON object
  9625. */
  9626. serialize(): any;
  9627. /**
  9628. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9629. * @param parsedShadowGenerator The JSON object to parse
  9630. * @param scene The scene to create the shadow map for
  9631. * @returns The parsed shadow generator
  9632. */
  9633. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9634. }
  9635. }
  9636. declare module BABYLON {
  9637. /**
  9638. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9639. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9640. * 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.
  9641. */
  9642. export abstract class Light extends Node {
  9643. /**
  9644. * Falloff Default: light is falling off following the material specification:
  9645. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9646. */
  9647. static readonly FALLOFF_DEFAULT: number;
  9648. /**
  9649. * Falloff Physical: light is falling off following the inverse squared distance law.
  9650. */
  9651. static readonly FALLOFF_PHYSICAL: number;
  9652. /**
  9653. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9654. * to enhance interoperability with other engines.
  9655. */
  9656. static readonly FALLOFF_GLTF: number;
  9657. /**
  9658. * Falloff Standard: light is falling off like in the standard material
  9659. * to enhance interoperability with other materials.
  9660. */
  9661. static readonly FALLOFF_STANDARD: number;
  9662. /**
  9663. * If every light affecting the material is in this lightmapMode,
  9664. * material.lightmapTexture adds or multiplies
  9665. * (depends on material.useLightmapAsShadowmap)
  9666. * after every other light calculations.
  9667. */
  9668. static readonly LIGHTMAP_DEFAULT: number;
  9669. /**
  9670. * material.lightmapTexture as only diffuse lighting from this light
  9671. * adds only specular lighting from this light
  9672. * adds dynamic shadows
  9673. */
  9674. static readonly LIGHTMAP_SPECULAR: number;
  9675. /**
  9676. * material.lightmapTexture as only lighting
  9677. * no light calculation from this light
  9678. * only adds dynamic shadows from this light
  9679. */
  9680. static readonly LIGHTMAP_SHADOWSONLY: number;
  9681. /**
  9682. * Each light type uses the default quantity according to its type:
  9683. * point/spot lights use luminous intensity
  9684. * directional lights use illuminance
  9685. */
  9686. static readonly INTENSITYMODE_AUTOMATIC: number;
  9687. /**
  9688. * lumen (lm)
  9689. */
  9690. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9691. /**
  9692. * candela (lm/sr)
  9693. */
  9694. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9695. /**
  9696. * lux (lm/m^2)
  9697. */
  9698. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9699. /**
  9700. * nit (cd/m^2)
  9701. */
  9702. static readonly INTENSITYMODE_LUMINANCE: number;
  9703. /**
  9704. * Light type const id of the point light.
  9705. */
  9706. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9707. /**
  9708. * Light type const id of the directional light.
  9709. */
  9710. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9711. /**
  9712. * Light type const id of the spot light.
  9713. */
  9714. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9715. /**
  9716. * Light type const id of the hemispheric light.
  9717. */
  9718. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9719. /**
  9720. * Diffuse gives the basic color to an object.
  9721. */
  9722. diffuse: Color3;
  9723. /**
  9724. * Specular produces a highlight color on an object.
  9725. * Note: This is note affecting PBR materials.
  9726. */
  9727. specular: Color3;
  9728. /**
  9729. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9730. * falling off base on range or angle.
  9731. * This can be set to any values in Light.FALLOFF_x.
  9732. *
  9733. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9734. * other types of materials.
  9735. */
  9736. falloffType: number;
  9737. /**
  9738. * Strength of the light.
  9739. * Note: By default it is define in the framework own unit.
  9740. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9741. */
  9742. intensity: number;
  9743. private _range;
  9744. protected _inverseSquaredRange: number;
  9745. /**
  9746. * Defines how far from the source the light is impacting in scene units.
  9747. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9748. */
  9749. /**
  9750. * Defines how far from the source the light is impacting in scene units.
  9751. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9752. */
  9753. range: number;
  9754. /**
  9755. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9756. * of light.
  9757. */
  9758. private _photometricScale;
  9759. private _intensityMode;
  9760. /**
  9761. * Gets the photometric scale used to interpret the intensity.
  9762. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9763. */
  9764. /**
  9765. * Sets the photometric scale used to interpret the intensity.
  9766. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9767. */
  9768. intensityMode: number;
  9769. private _radius;
  9770. /**
  9771. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9772. */
  9773. /**
  9774. * sets the light radius used by PBR Materials to simulate soft area lights.
  9775. */
  9776. radius: number;
  9777. private _renderPriority;
  9778. /**
  9779. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9780. * exceeding the number allowed of the materials.
  9781. */
  9782. renderPriority: number;
  9783. private _shadowEnabled;
  9784. /**
  9785. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9786. * the current shadow generator.
  9787. */
  9788. /**
  9789. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9790. * the current shadow generator.
  9791. */
  9792. shadowEnabled: boolean;
  9793. private _includedOnlyMeshes;
  9794. /**
  9795. * Gets the only meshes impacted by this light.
  9796. */
  9797. /**
  9798. * Sets the only meshes impacted by this light.
  9799. */
  9800. includedOnlyMeshes: AbstractMesh[];
  9801. private _excludedMeshes;
  9802. /**
  9803. * Gets the meshes not impacted by this light.
  9804. */
  9805. /**
  9806. * Sets the meshes not impacted by this light.
  9807. */
  9808. excludedMeshes: AbstractMesh[];
  9809. private _excludeWithLayerMask;
  9810. /**
  9811. * Gets the layer id use to find what meshes are not impacted by the light.
  9812. * Inactive if 0
  9813. */
  9814. /**
  9815. * Sets the layer id use to find what meshes are not impacted by the light.
  9816. * Inactive if 0
  9817. */
  9818. excludeWithLayerMask: number;
  9819. private _includeOnlyWithLayerMask;
  9820. /**
  9821. * Gets the layer id use to find what meshes are impacted by the light.
  9822. * Inactive if 0
  9823. */
  9824. /**
  9825. * Sets the layer id use to find what meshes are impacted by the light.
  9826. * Inactive if 0
  9827. */
  9828. includeOnlyWithLayerMask: number;
  9829. private _lightmapMode;
  9830. /**
  9831. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9832. */
  9833. /**
  9834. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9835. */
  9836. lightmapMode: number;
  9837. /**
  9838. * Shadow generator associted to the light.
  9839. * @hidden Internal use only.
  9840. */
  9841. _shadowGenerator: Nullable<IShadowGenerator>;
  9842. /**
  9843. * @hidden Internal use only.
  9844. */
  9845. _excludedMeshesIds: string[];
  9846. /**
  9847. * @hidden Internal use only.
  9848. */
  9849. _includedOnlyMeshesIds: string[];
  9850. /**
  9851. * The current light unifom buffer.
  9852. * @hidden Internal use only.
  9853. */
  9854. _uniformBuffer: UniformBuffer;
  9855. /**
  9856. * Creates a Light object in the scene.
  9857. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9858. * @param name The firendly name of the light
  9859. * @param scene The scene the light belongs too
  9860. */
  9861. constructor(name: string, scene: Scene);
  9862. protected abstract _buildUniformLayout(): void;
  9863. /**
  9864. * Sets the passed Effect "effect" with the Light information.
  9865. * @param effect The effect to update
  9866. * @param lightIndex The index of the light in the effect to update
  9867. * @returns The light
  9868. */
  9869. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9870. /**
  9871. * Sets the passed Effect "effect" with the Light information.
  9872. * @param effect The effect to update
  9873. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9874. * @returns The light
  9875. */
  9876. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9877. /**
  9878. * Returns the string "Light".
  9879. * @returns the class name
  9880. */
  9881. getClassName(): string;
  9882. /** @hidden */
  9883. readonly _isLight: boolean;
  9884. /**
  9885. * Converts the light information to a readable string for debug purpose.
  9886. * @param fullDetails Supports for multiple levels of logging within scene loading
  9887. * @returns the human readable light info
  9888. */
  9889. toString(fullDetails?: boolean): string;
  9890. /** @hidden */
  9891. protected _syncParentEnabledState(): void;
  9892. /**
  9893. * Set the enabled state of this node.
  9894. * @param value - the new enabled state
  9895. */
  9896. setEnabled(value: boolean): void;
  9897. /**
  9898. * Returns the Light associated shadow generator if any.
  9899. * @return the associated shadow generator.
  9900. */
  9901. getShadowGenerator(): Nullable<IShadowGenerator>;
  9902. /**
  9903. * Returns a Vector3, the absolute light position in the World.
  9904. * @returns the world space position of the light
  9905. */
  9906. getAbsolutePosition(): Vector3;
  9907. /**
  9908. * Specifies if the light will affect the passed mesh.
  9909. * @param mesh The mesh to test against the light
  9910. * @return true the mesh is affected otherwise, false.
  9911. */
  9912. canAffectMesh(mesh: AbstractMesh): boolean;
  9913. /**
  9914. * Sort function to order lights for rendering.
  9915. * @param a First Light object to compare to second.
  9916. * @param b Second Light object to compare first.
  9917. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9918. */
  9919. static CompareLightsPriority(a: Light, b: Light): number;
  9920. /**
  9921. * Releases resources associated with this node.
  9922. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9923. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9924. */
  9925. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9926. /**
  9927. * Returns the light type ID (integer).
  9928. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9929. */
  9930. getTypeID(): number;
  9931. /**
  9932. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9933. * @returns the scaled intensity in intensity mode unit
  9934. */
  9935. getScaledIntensity(): number;
  9936. /**
  9937. * Returns a new Light object, named "name", from the current one.
  9938. * @param name The name of the cloned light
  9939. * @returns the new created light
  9940. */
  9941. clone(name: string): Nullable<Light>;
  9942. /**
  9943. * Serializes the current light into a Serialization object.
  9944. * @returns the serialized object.
  9945. */
  9946. serialize(): any;
  9947. /**
  9948. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9949. * This new light is named "name" and added to the passed scene.
  9950. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9951. * @param name The friendly name of the light
  9952. * @param scene The scene the new light will belong to
  9953. * @returns the constructor function
  9954. */
  9955. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9956. /**
  9957. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9958. * @param parsedLight The JSON representation of the light
  9959. * @param scene The scene to create the parsed light in
  9960. * @returns the created light after parsing
  9961. */
  9962. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9963. private _hookArrayForExcluded;
  9964. private _hookArrayForIncludedOnly;
  9965. private _resyncMeshes;
  9966. /**
  9967. * Forces the meshes to update their light related information in their rendering used effects
  9968. * @hidden Internal Use Only
  9969. */
  9970. _markMeshesAsLightDirty(): void;
  9971. /**
  9972. * Recomputes the cached photometric scale if needed.
  9973. */
  9974. private _computePhotometricScale;
  9975. /**
  9976. * Returns the Photometric Scale according to the light type and intensity mode.
  9977. */
  9978. private _getPhotometricScale;
  9979. /**
  9980. * Reorder the light in the scene according to their defined priority.
  9981. * @hidden Internal Use Only
  9982. */
  9983. _reorderLightsInScene(): void;
  9984. /**
  9985. * Prepares the list of defines specific to the light type.
  9986. * @param defines the list of defines
  9987. * @param lightIndex defines the index of the light for the effect
  9988. */
  9989. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9990. }
  9991. }
  9992. declare module BABYLON {
  9993. /**
  9994. * Interface used to define Action
  9995. */
  9996. export interface IAction {
  9997. /**
  9998. * Trigger for the action
  9999. */
  10000. trigger: number;
  10001. /** Options of the trigger */
  10002. triggerOptions: any;
  10003. /**
  10004. * Gets the trigger parameters
  10005. * @returns the trigger parameters
  10006. */
  10007. getTriggerParameter(): any;
  10008. /**
  10009. * Internal only - executes current action event
  10010. * @hidden
  10011. */
  10012. _executeCurrent(evt?: ActionEvent): void;
  10013. /**
  10014. * Serialize placeholder for child classes
  10015. * @param parent of child
  10016. * @returns the serialized object
  10017. */
  10018. serialize(parent: any): any;
  10019. /**
  10020. * Internal only
  10021. * @hidden
  10022. */
  10023. _prepare(): void;
  10024. /**
  10025. * Internal only - manager for action
  10026. * @hidden
  10027. */
  10028. _actionManager: AbstractActionManager;
  10029. /**
  10030. * Adds action to chain of actions, may be a DoNothingAction
  10031. * @param action defines the next action to execute
  10032. * @returns The action passed in
  10033. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10034. */
  10035. then(action: IAction): IAction;
  10036. }
  10037. /**
  10038. * The action to be carried out following a trigger
  10039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10040. */
  10041. export class Action implements IAction {
  10042. /** the trigger, with or without parameters, for the action */
  10043. triggerOptions: any;
  10044. /**
  10045. * Trigger for the action
  10046. */
  10047. trigger: number;
  10048. /**
  10049. * Internal only - manager for action
  10050. * @hidden
  10051. */
  10052. _actionManager: ActionManager;
  10053. private _nextActiveAction;
  10054. private _child;
  10055. private _condition?;
  10056. private _triggerParameter;
  10057. /**
  10058. * An event triggered prior to action being executed.
  10059. */
  10060. onBeforeExecuteObservable: Observable<Action>;
  10061. /**
  10062. * Creates a new Action
  10063. * @param triggerOptions the trigger, with or without parameters, for the action
  10064. * @param condition an optional determinant of action
  10065. */
  10066. constructor(
  10067. /** the trigger, with or without parameters, for the action */
  10068. triggerOptions: any, condition?: Condition);
  10069. /**
  10070. * Internal only
  10071. * @hidden
  10072. */
  10073. _prepare(): void;
  10074. /**
  10075. * Gets the trigger parameters
  10076. * @returns the trigger parameters
  10077. */
  10078. getTriggerParameter(): any;
  10079. /**
  10080. * Internal only - executes current action event
  10081. * @hidden
  10082. */
  10083. _executeCurrent(evt?: ActionEvent): void;
  10084. /**
  10085. * Execute placeholder for child classes
  10086. * @param evt optional action event
  10087. */
  10088. execute(evt?: ActionEvent): void;
  10089. /**
  10090. * Skips to next active action
  10091. */
  10092. skipToNextActiveAction(): void;
  10093. /**
  10094. * Adds action to chain of actions, may be a DoNothingAction
  10095. * @param action defines the next action to execute
  10096. * @returns The action passed in
  10097. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10098. */
  10099. then(action: Action): Action;
  10100. /**
  10101. * Internal only
  10102. * @hidden
  10103. */
  10104. _getProperty(propertyPath: string): string;
  10105. /**
  10106. * Internal only
  10107. * @hidden
  10108. */
  10109. _getEffectiveTarget(target: any, propertyPath: string): any;
  10110. /**
  10111. * Serialize placeholder for child classes
  10112. * @param parent of child
  10113. * @returns the serialized object
  10114. */
  10115. serialize(parent: any): any;
  10116. /**
  10117. * Internal only called by serialize
  10118. * @hidden
  10119. */
  10120. protected _serialize(serializedAction: any, parent?: any): any;
  10121. /**
  10122. * Internal only
  10123. * @hidden
  10124. */
  10125. static _SerializeValueAsString: (value: any) => string;
  10126. /**
  10127. * Internal only
  10128. * @hidden
  10129. */
  10130. static _GetTargetProperty: (target: Node | Scene) => {
  10131. name: string;
  10132. targetType: string;
  10133. value: string;
  10134. };
  10135. }
  10136. }
  10137. declare module BABYLON {
  10138. /**
  10139. * A Condition applied to an Action
  10140. */
  10141. export class Condition {
  10142. /**
  10143. * Internal only - manager for action
  10144. * @hidden
  10145. */
  10146. _actionManager: ActionManager;
  10147. /**
  10148. * Internal only
  10149. * @hidden
  10150. */
  10151. _evaluationId: number;
  10152. /**
  10153. * Internal only
  10154. * @hidden
  10155. */
  10156. _currentResult: boolean;
  10157. /**
  10158. * Creates a new Condition
  10159. * @param actionManager the manager of the action the condition is applied to
  10160. */
  10161. constructor(actionManager: ActionManager);
  10162. /**
  10163. * Check if the current condition is valid
  10164. * @returns a boolean
  10165. */
  10166. isValid(): boolean;
  10167. /**
  10168. * Internal only
  10169. * @hidden
  10170. */
  10171. _getProperty(propertyPath: string): string;
  10172. /**
  10173. * Internal only
  10174. * @hidden
  10175. */
  10176. _getEffectiveTarget(target: any, propertyPath: string): any;
  10177. /**
  10178. * Serialize placeholder for child classes
  10179. * @returns the serialized object
  10180. */
  10181. serialize(): any;
  10182. /**
  10183. * Internal only
  10184. * @hidden
  10185. */
  10186. protected _serialize(serializedCondition: any): any;
  10187. }
  10188. /**
  10189. * Defines specific conditional operators as extensions of Condition
  10190. */
  10191. export class ValueCondition extends Condition {
  10192. /** path to specify the property of the target the conditional operator uses */
  10193. propertyPath: string;
  10194. /** the value compared by the conditional operator against the current value of the property */
  10195. value: any;
  10196. /** the conditional operator, default ValueCondition.IsEqual */
  10197. operator: number;
  10198. /**
  10199. * Internal only
  10200. * @hidden
  10201. */
  10202. private static _IsEqual;
  10203. /**
  10204. * Internal only
  10205. * @hidden
  10206. */
  10207. private static _IsDifferent;
  10208. /**
  10209. * Internal only
  10210. * @hidden
  10211. */
  10212. private static _IsGreater;
  10213. /**
  10214. * Internal only
  10215. * @hidden
  10216. */
  10217. private static _IsLesser;
  10218. /**
  10219. * returns the number for IsEqual
  10220. */
  10221. static readonly IsEqual: number;
  10222. /**
  10223. * Returns the number for IsDifferent
  10224. */
  10225. static readonly IsDifferent: number;
  10226. /**
  10227. * Returns the number for IsGreater
  10228. */
  10229. static readonly IsGreater: number;
  10230. /**
  10231. * Returns the number for IsLesser
  10232. */
  10233. static readonly IsLesser: number;
  10234. /**
  10235. * Internal only The action manager for the condition
  10236. * @hidden
  10237. */
  10238. _actionManager: ActionManager;
  10239. /**
  10240. * Internal only
  10241. * @hidden
  10242. */
  10243. private _target;
  10244. /**
  10245. * Internal only
  10246. * @hidden
  10247. */
  10248. private _effectiveTarget;
  10249. /**
  10250. * Internal only
  10251. * @hidden
  10252. */
  10253. private _property;
  10254. /**
  10255. * Creates a new ValueCondition
  10256. * @param actionManager manager for the action the condition applies to
  10257. * @param target for the action
  10258. * @param propertyPath path to specify the property of the target the conditional operator uses
  10259. * @param value the value compared by the conditional operator against the current value of the property
  10260. * @param operator the conditional operator, default ValueCondition.IsEqual
  10261. */
  10262. constructor(actionManager: ActionManager, target: any,
  10263. /** path to specify the property of the target the conditional operator uses */
  10264. propertyPath: string,
  10265. /** the value compared by the conditional operator against the current value of the property */
  10266. value: any,
  10267. /** the conditional operator, default ValueCondition.IsEqual */
  10268. operator?: number);
  10269. /**
  10270. * Compares the given value with the property value for the specified conditional operator
  10271. * @returns the result of the comparison
  10272. */
  10273. isValid(): boolean;
  10274. /**
  10275. * Serialize the ValueCondition into a JSON compatible object
  10276. * @returns serialization object
  10277. */
  10278. serialize(): any;
  10279. /**
  10280. * Gets the name of the conditional operator for the ValueCondition
  10281. * @param operator the conditional operator
  10282. * @returns the name
  10283. */
  10284. static GetOperatorName(operator: number): string;
  10285. }
  10286. /**
  10287. * Defines a predicate condition as an extension of Condition
  10288. */
  10289. export class PredicateCondition extends Condition {
  10290. /** defines the predicate function used to validate the condition */
  10291. predicate: () => boolean;
  10292. /**
  10293. * Internal only - manager for action
  10294. * @hidden
  10295. */
  10296. _actionManager: ActionManager;
  10297. /**
  10298. * Creates a new PredicateCondition
  10299. * @param actionManager manager for the action the condition applies to
  10300. * @param predicate defines the predicate function used to validate the condition
  10301. */
  10302. constructor(actionManager: ActionManager,
  10303. /** defines the predicate function used to validate the condition */
  10304. predicate: () => boolean);
  10305. /**
  10306. * @returns the validity of the predicate condition
  10307. */
  10308. isValid(): boolean;
  10309. }
  10310. /**
  10311. * Defines a state condition as an extension of Condition
  10312. */
  10313. export class StateCondition extends Condition {
  10314. /** Value to compare with target state */
  10315. value: string;
  10316. /**
  10317. * Internal only - manager for action
  10318. * @hidden
  10319. */
  10320. _actionManager: ActionManager;
  10321. /**
  10322. * Internal only
  10323. * @hidden
  10324. */
  10325. private _target;
  10326. /**
  10327. * Creates a new StateCondition
  10328. * @param actionManager manager for the action the condition applies to
  10329. * @param target of the condition
  10330. * @param value to compare with target state
  10331. */
  10332. constructor(actionManager: ActionManager, target: any,
  10333. /** Value to compare with target state */
  10334. value: string);
  10335. /**
  10336. * Gets a boolean indicating if the current condition is met
  10337. * @returns the validity of the state
  10338. */
  10339. isValid(): boolean;
  10340. /**
  10341. * Serialize the StateCondition into a JSON compatible object
  10342. * @returns serialization object
  10343. */
  10344. serialize(): any;
  10345. }
  10346. }
  10347. declare module BABYLON {
  10348. /**
  10349. * This defines an action responsible to toggle a boolean once triggered.
  10350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10351. */
  10352. export class SwitchBooleanAction extends Action {
  10353. /**
  10354. * The path to the boolean property in the target object
  10355. */
  10356. propertyPath: string;
  10357. private _target;
  10358. private _effectiveTarget;
  10359. private _property;
  10360. /**
  10361. * Instantiate the action
  10362. * @param triggerOptions defines the trigger options
  10363. * @param target defines the object containing the boolean
  10364. * @param propertyPath defines the path to the boolean property in the target object
  10365. * @param condition defines the trigger related conditions
  10366. */
  10367. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10368. /** @hidden */
  10369. _prepare(): void;
  10370. /**
  10371. * Execute the action toggle the boolean value.
  10372. */
  10373. execute(): void;
  10374. /**
  10375. * Serializes the actions and its related information.
  10376. * @param parent defines the object to serialize in
  10377. * @returns the serialized object
  10378. */
  10379. serialize(parent: any): any;
  10380. }
  10381. /**
  10382. * This defines an action responsible to set a the state field of the target
  10383. * to a desired value once triggered.
  10384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10385. */
  10386. export class SetStateAction extends Action {
  10387. /**
  10388. * The value to store in the state field.
  10389. */
  10390. value: string;
  10391. private _target;
  10392. /**
  10393. * Instantiate the action
  10394. * @param triggerOptions defines the trigger options
  10395. * @param target defines the object containing the state property
  10396. * @param value defines the value to store in the state field
  10397. * @param condition defines the trigger related conditions
  10398. */
  10399. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10400. /**
  10401. * Execute the action and store the value on the target state property.
  10402. */
  10403. execute(): void;
  10404. /**
  10405. * Serializes the actions and its related information.
  10406. * @param parent defines the object to serialize in
  10407. * @returns the serialized object
  10408. */
  10409. serialize(parent: any): any;
  10410. }
  10411. /**
  10412. * This defines an action responsible to set a property of the target
  10413. * to a desired value once triggered.
  10414. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10415. */
  10416. export class SetValueAction extends Action {
  10417. /**
  10418. * The path of the property to set in the target.
  10419. */
  10420. propertyPath: string;
  10421. /**
  10422. * The value to set in the property
  10423. */
  10424. value: any;
  10425. private _target;
  10426. private _effectiveTarget;
  10427. private _property;
  10428. /**
  10429. * Instantiate the action
  10430. * @param triggerOptions defines the trigger options
  10431. * @param target defines the object containing the property
  10432. * @param propertyPath defines the path of the property to set in the target
  10433. * @param value defines the value to set in the property
  10434. * @param condition defines the trigger related conditions
  10435. */
  10436. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10437. /** @hidden */
  10438. _prepare(): void;
  10439. /**
  10440. * Execute the action and set the targetted property to the desired value.
  10441. */
  10442. execute(): void;
  10443. /**
  10444. * Serializes the actions and its related information.
  10445. * @param parent defines the object to serialize in
  10446. * @returns the serialized object
  10447. */
  10448. serialize(parent: any): any;
  10449. }
  10450. /**
  10451. * This defines an action responsible to increment the target value
  10452. * to a desired value once triggered.
  10453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10454. */
  10455. export class IncrementValueAction extends Action {
  10456. /**
  10457. * The path of the property to increment in the target.
  10458. */
  10459. propertyPath: string;
  10460. /**
  10461. * The value we should increment the property by.
  10462. */
  10463. value: any;
  10464. private _target;
  10465. private _effectiveTarget;
  10466. private _property;
  10467. /**
  10468. * Instantiate the action
  10469. * @param triggerOptions defines the trigger options
  10470. * @param target defines the object containing the property
  10471. * @param propertyPath defines the path of the property to increment in the target
  10472. * @param value defines the value value we should increment the property by
  10473. * @param condition defines the trigger related conditions
  10474. */
  10475. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10476. /** @hidden */
  10477. _prepare(): void;
  10478. /**
  10479. * Execute the action and increment the target of the value amount.
  10480. */
  10481. execute(): void;
  10482. /**
  10483. * Serializes the actions and its related information.
  10484. * @param parent defines the object to serialize in
  10485. * @returns the serialized object
  10486. */
  10487. serialize(parent: any): any;
  10488. }
  10489. /**
  10490. * This defines an action responsible to start an animation once triggered.
  10491. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10492. */
  10493. export class PlayAnimationAction extends Action {
  10494. /**
  10495. * Where the animation should start (animation frame)
  10496. */
  10497. from: number;
  10498. /**
  10499. * Where the animation should stop (animation frame)
  10500. */
  10501. to: number;
  10502. /**
  10503. * Define if the animation should loop or stop after the first play.
  10504. */
  10505. loop?: boolean;
  10506. private _target;
  10507. /**
  10508. * Instantiate the action
  10509. * @param triggerOptions defines the trigger options
  10510. * @param target defines the target animation or animation name
  10511. * @param from defines from where the animation should start (animation frame)
  10512. * @param end defines where the animation should stop (animation frame)
  10513. * @param loop defines if the animation should loop or stop after the first play
  10514. * @param condition defines the trigger related conditions
  10515. */
  10516. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10517. /** @hidden */
  10518. _prepare(): void;
  10519. /**
  10520. * Execute the action and play the animation.
  10521. */
  10522. execute(): void;
  10523. /**
  10524. * Serializes the actions and its related information.
  10525. * @param parent defines the object to serialize in
  10526. * @returns the serialized object
  10527. */
  10528. serialize(parent: any): any;
  10529. }
  10530. /**
  10531. * This defines an action responsible to stop an animation once triggered.
  10532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10533. */
  10534. export class StopAnimationAction extends Action {
  10535. private _target;
  10536. /**
  10537. * Instantiate the action
  10538. * @param triggerOptions defines the trigger options
  10539. * @param target defines the target animation or animation name
  10540. * @param condition defines the trigger related conditions
  10541. */
  10542. constructor(triggerOptions: any, target: any, condition?: Condition);
  10543. /** @hidden */
  10544. _prepare(): void;
  10545. /**
  10546. * Execute the action and stop the animation.
  10547. */
  10548. execute(): void;
  10549. /**
  10550. * Serializes the actions and its related information.
  10551. * @param parent defines the object to serialize in
  10552. * @returns the serialized object
  10553. */
  10554. serialize(parent: any): any;
  10555. }
  10556. /**
  10557. * This defines an action responsible that does nothing once triggered.
  10558. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10559. */
  10560. export class DoNothingAction extends Action {
  10561. /**
  10562. * Instantiate the action
  10563. * @param triggerOptions defines the trigger options
  10564. * @param condition defines the trigger related conditions
  10565. */
  10566. constructor(triggerOptions?: any, condition?: Condition);
  10567. /**
  10568. * Execute the action and do nothing.
  10569. */
  10570. execute(): void;
  10571. /**
  10572. * Serializes the actions and its related information.
  10573. * @param parent defines the object to serialize in
  10574. * @returns the serialized object
  10575. */
  10576. serialize(parent: any): any;
  10577. }
  10578. /**
  10579. * This defines an action responsible to trigger several actions once triggered.
  10580. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10581. */
  10582. export class CombineAction extends Action {
  10583. /**
  10584. * The list of aggregated animations to run.
  10585. */
  10586. children: Action[];
  10587. /**
  10588. * Instantiate the action
  10589. * @param triggerOptions defines the trigger options
  10590. * @param children defines the list of aggregated animations to run
  10591. * @param condition defines the trigger related conditions
  10592. */
  10593. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10594. /** @hidden */
  10595. _prepare(): void;
  10596. /**
  10597. * Execute the action and executes all the aggregated actions.
  10598. */
  10599. execute(evt: ActionEvent): void;
  10600. /**
  10601. * Serializes the actions and its related information.
  10602. * @param parent defines the object to serialize in
  10603. * @returns the serialized object
  10604. */
  10605. serialize(parent: any): any;
  10606. }
  10607. /**
  10608. * This defines an action responsible to run code (external event) once triggered.
  10609. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10610. */
  10611. export class ExecuteCodeAction extends Action {
  10612. /**
  10613. * The callback function to run.
  10614. */
  10615. func: (evt: ActionEvent) => void;
  10616. /**
  10617. * Instantiate the action
  10618. * @param triggerOptions defines the trigger options
  10619. * @param func defines the callback function to run
  10620. * @param condition defines the trigger related conditions
  10621. */
  10622. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10623. /**
  10624. * Execute the action and run the attached code.
  10625. */
  10626. execute(evt: ActionEvent): void;
  10627. }
  10628. /**
  10629. * This defines an action responsible to set the parent property of the target once triggered.
  10630. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10631. */
  10632. export class SetParentAction extends Action {
  10633. private _parent;
  10634. private _target;
  10635. /**
  10636. * Instantiate the action
  10637. * @param triggerOptions defines the trigger options
  10638. * @param target defines the target containing the parent property
  10639. * @param parent defines from where the animation should start (animation frame)
  10640. * @param condition defines the trigger related conditions
  10641. */
  10642. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10643. /** @hidden */
  10644. _prepare(): void;
  10645. /**
  10646. * Execute the action and set the parent property.
  10647. */
  10648. execute(): void;
  10649. /**
  10650. * Serializes the actions and its related information.
  10651. * @param parent defines the object to serialize in
  10652. * @returns the serialized object
  10653. */
  10654. serialize(parent: any): any;
  10655. }
  10656. }
  10657. declare module BABYLON {
  10658. /**
  10659. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10660. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10662. */
  10663. export class ActionManager extends AbstractActionManager {
  10664. /**
  10665. * Nothing
  10666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10667. */
  10668. static readonly NothingTrigger: number;
  10669. /**
  10670. * On pick
  10671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10672. */
  10673. static readonly OnPickTrigger: number;
  10674. /**
  10675. * On left pick
  10676. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10677. */
  10678. static readonly OnLeftPickTrigger: number;
  10679. /**
  10680. * On right pick
  10681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10682. */
  10683. static readonly OnRightPickTrigger: number;
  10684. /**
  10685. * On center pick
  10686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10687. */
  10688. static readonly OnCenterPickTrigger: number;
  10689. /**
  10690. * On pick down
  10691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10692. */
  10693. static readonly OnPickDownTrigger: number;
  10694. /**
  10695. * On double pick
  10696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10697. */
  10698. static readonly OnDoublePickTrigger: number;
  10699. /**
  10700. * On pick up
  10701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10702. */
  10703. static readonly OnPickUpTrigger: number;
  10704. /**
  10705. * On pick out.
  10706. * This trigger will only be raised if you also declared a OnPickDown
  10707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10708. */
  10709. static readonly OnPickOutTrigger: number;
  10710. /**
  10711. * On long press
  10712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10713. */
  10714. static readonly OnLongPressTrigger: number;
  10715. /**
  10716. * On pointer over
  10717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10718. */
  10719. static readonly OnPointerOverTrigger: number;
  10720. /**
  10721. * On pointer out
  10722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10723. */
  10724. static readonly OnPointerOutTrigger: number;
  10725. /**
  10726. * On every frame
  10727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10728. */
  10729. static readonly OnEveryFrameTrigger: number;
  10730. /**
  10731. * On intersection enter
  10732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10733. */
  10734. static readonly OnIntersectionEnterTrigger: number;
  10735. /**
  10736. * On intersection exit
  10737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10738. */
  10739. static readonly OnIntersectionExitTrigger: number;
  10740. /**
  10741. * On key down
  10742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10743. */
  10744. static readonly OnKeyDownTrigger: number;
  10745. /**
  10746. * On key up
  10747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10748. */
  10749. static readonly OnKeyUpTrigger: number;
  10750. private _scene;
  10751. /**
  10752. * Creates a new action manager
  10753. * @param scene defines the hosting scene
  10754. */
  10755. constructor(scene: Scene);
  10756. /**
  10757. * Releases all associated resources
  10758. */
  10759. dispose(): void;
  10760. /**
  10761. * Gets hosting scene
  10762. * @returns the hosting scene
  10763. */
  10764. getScene(): Scene;
  10765. /**
  10766. * Does this action manager handles actions of any of the given triggers
  10767. * @param triggers defines the triggers to be tested
  10768. * @return a boolean indicating whether one (or more) of the triggers is handled
  10769. */
  10770. hasSpecificTriggers(triggers: number[]): boolean;
  10771. /**
  10772. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10773. * speed.
  10774. * @param triggerA defines the trigger to be tested
  10775. * @param triggerB defines the trigger to be tested
  10776. * @return a boolean indicating whether one (or more) of the triggers is handled
  10777. */
  10778. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10779. /**
  10780. * Does this action manager handles actions of a given trigger
  10781. * @param trigger defines the trigger to be tested
  10782. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10783. * @return whether the trigger is handled
  10784. */
  10785. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10786. /**
  10787. * Does this action manager has pointer triggers
  10788. */
  10789. readonly hasPointerTriggers: boolean;
  10790. /**
  10791. * Does this action manager has pick triggers
  10792. */
  10793. readonly hasPickTriggers: boolean;
  10794. /**
  10795. * Registers an action to this action manager
  10796. * @param action defines the action to be registered
  10797. * @return the action amended (prepared) after registration
  10798. */
  10799. registerAction(action: IAction): Nullable<IAction>;
  10800. /**
  10801. * Unregisters an action to this action manager
  10802. * @param action defines the action to be unregistered
  10803. * @return a boolean indicating whether the action has been unregistered
  10804. */
  10805. unregisterAction(action: IAction): Boolean;
  10806. /**
  10807. * Process a specific trigger
  10808. * @param trigger defines the trigger to process
  10809. * @param evt defines the event details to be processed
  10810. */
  10811. processTrigger(trigger: number, evt?: IActionEvent): void;
  10812. /** @hidden */
  10813. _getEffectiveTarget(target: any, propertyPath: string): any;
  10814. /** @hidden */
  10815. _getProperty(propertyPath: string): string;
  10816. /**
  10817. * Serialize this manager to a JSON object
  10818. * @param name defines the property name to store this manager
  10819. * @returns a JSON representation of this manager
  10820. */
  10821. serialize(name: string): any;
  10822. /**
  10823. * Creates a new ActionManager from a JSON data
  10824. * @param parsedActions defines the JSON data to read from
  10825. * @param object defines the hosting mesh
  10826. * @param scene defines the hosting scene
  10827. */
  10828. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10829. /**
  10830. * Get a trigger name by index
  10831. * @param trigger defines the trigger index
  10832. * @returns a trigger name
  10833. */
  10834. static GetTriggerName(trigger: number): string;
  10835. }
  10836. }
  10837. declare module BABYLON {
  10838. /**
  10839. * Class representing a ray with position and direction
  10840. */
  10841. export class Ray {
  10842. /** origin point */
  10843. origin: Vector3;
  10844. /** direction */
  10845. direction: Vector3;
  10846. /** length of the ray */
  10847. length: number;
  10848. private static readonly TmpVector3;
  10849. private _tmpRay;
  10850. /**
  10851. * Creates a new ray
  10852. * @param origin origin point
  10853. * @param direction direction
  10854. * @param length length of the ray
  10855. */
  10856. constructor(
  10857. /** origin point */
  10858. origin: Vector3,
  10859. /** direction */
  10860. direction: Vector3,
  10861. /** length of the ray */
  10862. length?: number);
  10863. /**
  10864. * Checks if the ray intersects a box
  10865. * @param minimum bound of the box
  10866. * @param maximum bound of the box
  10867. * @param intersectionTreshold extra extend to be added to the box in all direction
  10868. * @returns if the box was hit
  10869. */
  10870. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10871. /**
  10872. * Checks if the ray intersects a box
  10873. * @param box the bounding box to check
  10874. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10875. * @returns if the box was hit
  10876. */
  10877. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10878. /**
  10879. * If the ray hits a sphere
  10880. * @param sphere the bounding sphere to check
  10881. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10882. * @returns true if it hits the sphere
  10883. */
  10884. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10885. /**
  10886. * If the ray hits a triange
  10887. * @param vertex0 triangle vertex
  10888. * @param vertex1 triangle vertex
  10889. * @param vertex2 triangle vertex
  10890. * @returns intersection information if hit
  10891. */
  10892. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10893. /**
  10894. * Checks if ray intersects a plane
  10895. * @param plane the plane to check
  10896. * @returns the distance away it was hit
  10897. */
  10898. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10899. /**
  10900. * Calculate the intercept of a ray on a given axis
  10901. * @param axis to check 'x' | 'y' | 'z'
  10902. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10903. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10904. */
  10905. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10906. /**
  10907. * Checks if ray intersects a mesh
  10908. * @param mesh the mesh to check
  10909. * @param fastCheck if only the bounding box should checked
  10910. * @returns picking info of the intersecton
  10911. */
  10912. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10913. /**
  10914. * Checks if ray intersects a mesh
  10915. * @param meshes the meshes to check
  10916. * @param fastCheck if only the bounding box should checked
  10917. * @param results array to store result in
  10918. * @returns Array of picking infos
  10919. */
  10920. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10921. private _comparePickingInfo;
  10922. private static smallnum;
  10923. private static rayl;
  10924. /**
  10925. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10926. * @param sega the first point of the segment to test the intersection against
  10927. * @param segb the second point of the segment to test the intersection against
  10928. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10929. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10930. */
  10931. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10932. /**
  10933. * Update the ray from viewport position
  10934. * @param x position
  10935. * @param y y position
  10936. * @param viewportWidth viewport width
  10937. * @param viewportHeight viewport height
  10938. * @param world world matrix
  10939. * @param view view matrix
  10940. * @param projection projection matrix
  10941. * @returns this ray updated
  10942. */
  10943. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10944. /**
  10945. * Creates a ray with origin and direction of 0,0,0
  10946. * @returns the new ray
  10947. */
  10948. static Zero(): Ray;
  10949. /**
  10950. * Creates a new ray from screen space and viewport
  10951. * @param x position
  10952. * @param y y position
  10953. * @param viewportWidth viewport width
  10954. * @param viewportHeight viewport height
  10955. * @param world world matrix
  10956. * @param view view matrix
  10957. * @param projection projection matrix
  10958. * @returns new ray
  10959. */
  10960. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10961. /**
  10962. * 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
  10963. * transformed to the given world matrix.
  10964. * @param origin The origin point
  10965. * @param end The end point
  10966. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10967. * @returns the new ray
  10968. */
  10969. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10970. /**
  10971. * Transforms a ray by a matrix
  10972. * @param ray ray to transform
  10973. * @param matrix matrix to apply
  10974. * @returns the resulting new ray
  10975. */
  10976. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10977. /**
  10978. * Transforms a ray by a matrix
  10979. * @param ray ray to transform
  10980. * @param matrix matrix to apply
  10981. * @param result ray to store result in
  10982. */
  10983. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10984. /**
  10985. * Unproject a ray from screen space to object space
  10986. * @param sourceX defines the screen space x coordinate to use
  10987. * @param sourceY defines the screen space y coordinate to use
  10988. * @param viewportWidth defines the current width of the viewport
  10989. * @param viewportHeight defines the current height of the viewport
  10990. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10991. * @param view defines the view matrix to use
  10992. * @param projection defines the projection matrix to use
  10993. */
  10994. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10995. }
  10996. /**
  10997. * Type used to define predicate used to select faces when a mesh intersection is detected
  10998. */
  10999. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11000. interface Scene {
  11001. /** @hidden */
  11002. _tempPickingRay: Nullable<Ray>;
  11003. /** @hidden */
  11004. _cachedRayForTransform: Ray;
  11005. /** @hidden */
  11006. _pickWithRayInverseMatrix: Matrix;
  11007. /** @hidden */
  11008. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11009. /** @hidden */
  11010. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11011. }
  11012. }
  11013. declare module BABYLON {
  11014. /**
  11015. * Groups all the scene component constants in one place to ease maintenance.
  11016. * @hidden
  11017. */
  11018. export class SceneComponentConstants {
  11019. static readonly NAME_EFFECTLAYER: string;
  11020. static readonly NAME_LAYER: string;
  11021. static readonly NAME_LENSFLARESYSTEM: string;
  11022. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11023. static readonly NAME_PARTICLESYSTEM: string;
  11024. static readonly NAME_GAMEPAD: string;
  11025. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11026. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11027. static readonly NAME_DEPTHRENDERER: string;
  11028. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11029. static readonly NAME_SPRITE: string;
  11030. static readonly NAME_OUTLINERENDERER: string;
  11031. static readonly NAME_PROCEDURALTEXTURE: string;
  11032. static readonly NAME_SHADOWGENERATOR: string;
  11033. static readonly NAME_OCTREE: string;
  11034. static readonly NAME_PHYSICSENGINE: string;
  11035. static readonly NAME_AUDIO: string;
  11036. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11037. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11038. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11039. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11040. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11041. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11042. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11043. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11044. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11045. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11046. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11047. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11048. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11049. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11050. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11051. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11052. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11053. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11054. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11055. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11056. static readonly STEP_AFTERRENDER_AUDIO: number;
  11057. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11058. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11059. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11060. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11061. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11062. static readonly STEP_POINTERMOVE_SPRITE: number;
  11063. static readonly STEP_POINTERDOWN_SPRITE: number;
  11064. static readonly STEP_POINTERUP_SPRITE: number;
  11065. }
  11066. /**
  11067. * This represents a scene component.
  11068. *
  11069. * This is used to decouple the dependency the scene is having on the different workloads like
  11070. * layers, post processes...
  11071. */
  11072. export interface ISceneComponent {
  11073. /**
  11074. * The name of the component. Each component must have a unique name.
  11075. */
  11076. name: string;
  11077. /**
  11078. * The scene the component belongs to.
  11079. */
  11080. scene: Scene;
  11081. /**
  11082. * Register the component to one instance of a scene.
  11083. */
  11084. register(): void;
  11085. /**
  11086. * Rebuilds the elements related to this component in case of
  11087. * context lost for instance.
  11088. */
  11089. rebuild(): void;
  11090. /**
  11091. * Disposes the component and the associated ressources.
  11092. */
  11093. dispose(): void;
  11094. }
  11095. /**
  11096. * This represents a SERIALIZABLE scene component.
  11097. *
  11098. * This extends Scene Component to add Serialization methods on top.
  11099. */
  11100. export interface ISceneSerializableComponent extends ISceneComponent {
  11101. /**
  11102. * Adds all the elements from the container to the scene
  11103. * @param container the container holding the elements
  11104. */
  11105. addFromContainer(container: AbstractScene): void;
  11106. /**
  11107. * Removes all the elements in the container from the scene
  11108. * @param container contains the elements to remove
  11109. * @param dispose if the removed element should be disposed (default: false)
  11110. */
  11111. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11112. /**
  11113. * Serializes the component data to the specified json object
  11114. * @param serializationObject The object to serialize to
  11115. */
  11116. serialize(serializationObject: any): void;
  11117. }
  11118. /**
  11119. * Strong typing of a Mesh related stage step action
  11120. */
  11121. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11122. /**
  11123. * Strong typing of a Evaluate Sub Mesh related stage step action
  11124. */
  11125. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11126. /**
  11127. * Strong typing of a Active Mesh related stage step action
  11128. */
  11129. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11130. /**
  11131. * Strong typing of a Camera related stage step action
  11132. */
  11133. export type CameraStageAction = (camera: Camera) => void;
  11134. /**
  11135. * Strong typing of a Camera Frame buffer related stage step action
  11136. */
  11137. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11138. /**
  11139. * Strong typing of a Render Target related stage step action
  11140. */
  11141. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11142. /**
  11143. * Strong typing of a RenderingGroup related stage step action
  11144. */
  11145. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11146. /**
  11147. * Strong typing of a Mesh Render related stage step action
  11148. */
  11149. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11150. /**
  11151. * Strong typing of a simple stage step action
  11152. */
  11153. export type SimpleStageAction = () => void;
  11154. /**
  11155. * Strong typing of a render target action.
  11156. */
  11157. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11158. /**
  11159. * Strong typing of a pointer move action.
  11160. */
  11161. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11162. /**
  11163. * Strong typing of a pointer up/down action.
  11164. */
  11165. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11166. /**
  11167. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11168. * @hidden
  11169. */
  11170. export class Stage<T extends Function> extends Array<{
  11171. index: number;
  11172. component: ISceneComponent;
  11173. action: T;
  11174. }> {
  11175. /**
  11176. * Hide ctor from the rest of the world.
  11177. * @param items The items to add.
  11178. */
  11179. private constructor();
  11180. /**
  11181. * Creates a new Stage.
  11182. * @returns A new instance of a Stage
  11183. */
  11184. static Create<T extends Function>(): Stage<T>;
  11185. /**
  11186. * Registers a step in an ordered way in the targeted stage.
  11187. * @param index Defines the position to register the step in
  11188. * @param component Defines the component attached to the step
  11189. * @param action Defines the action to launch during the step
  11190. */
  11191. registerStep(index: number, component: ISceneComponent, action: T): void;
  11192. /**
  11193. * Clears all the steps from the stage.
  11194. */
  11195. clear(): void;
  11196. }
  11197. }
  11198. declare module BABYLON {
  11199. interface Scene {
  11200. /** @hidden */
  11201. _pointerOverSprite: Nullable<Sprite>;
  11202. /** @hidden */
  11203. _pickedDownSprite: Nullable<Sprite>;
  11204. /** @hidden */
  11205. _tempSpritePickingRay: Nullable<Ray>;
  11206. /**
  11207. * All of the sprite managers added to this scene
  11208. * @see http://doc.babylonjs.com/babylon101/sprites
  11209. */
  11210. spriteManagers: Array<ISpriteManager>;
  11211. /**
  11212. * An event triggered when sprites rendering is about to start
  11213. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11214. */
  11215. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11216. /**
  11217. * An event triggered when sprites rendering is done
  11218. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11219. */
  11220. onAfterSpritesRenderingObservable: Observable<Scene>;
  11221. /** @hidden */
  11222. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11223. /** Launch a ray to try to pick a sprite in the scene
  11224. * @param x position on screen
  11225. * @param y position on screen
  11226. * @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
  11227. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11228. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11229. * @returns a PickingInfo
  11230. */
  11231. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11232. /** Use the given ray to pick a sprite in the scene
  11233. * @param ray The ray (in world space) to use to pick meshes
  11234. * @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
  11235. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11236. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11237. * @returns a PickingInfo
  11238. */
  11239. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11240. /** @hidden */
  11241. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11242. /** Launch a ray to try to pick sprites in the scene
  11243. * @param x position on screen
  11244. * @param y position on screen
  11245. * @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
  11246. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11247. * @returns a PickingInfo array
  11248. */
  11249. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11250. /** Use the given ray to pick sprites in the scene
  11251. * @param ray The ray (in world space) to use to pick meshes
  11252. * @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
  11253. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11254. * @returns a PickingInfo array
  11255. */
  11256. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11257. /**
  11258. * Force the sprite under the pointer
  11259. * @param sprite defines the sprite to use
  11260. */
  11261. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11262. /**
  11263. * Gets the sprite under the pointer
  11264. * @returns a Sprite or null if no sprite is under the pointer
  11265. */
  11266. getPointerOverSprite(): Nullable<Sprite>;
  11267. }
  11268. /**
  11269. * Defines the sprite scene component responsible to manage sprites
  11270. * in a given scene.
  11271. */
  11272. export class SpriteSceneComponent implements ISceneComponent {
  11273. /**
  11274. * The component name helpfull to identify the component in the list of scene components.
  11275. */
  11276. readonly name: string;
  11277. /**
  11278. * The scene the component belongs to.
  11279. */
  11280. scene: Scene;
  11281. /** @hidden */
  11282. private _spritePredicate;
  11283. /**
  11284. * Creates a new instance of the component for the given scene
  11285. * @param scene Defines the scene to register the component in
  11286. */
  11287. constructor(scene: Scene);
  11288. /**
  11289. * Registers the component in a given scene
  11290. */
  11291. register(): void;
  11292. /**
  11293. * Rebuilds the elements related to this component in case of
  11294. * context lost for instance.
  11295. */
  11296. rebuild(): void;
  11297. /**
  11298. * Disposes the component and the associated ressources.
  11299. */
  11300. dispose(): void;
  11301. private _pickSpriteButKeepRay;
  11302. private _pointerMove;
  11303. private _pointerDown;
  11304. private _pointerUp;
  11305. }
  11306. }
  11307. declare module BABYLON {
  11308. /** @hidden */
  11309. export var fogFragmentDeclaration: {
  11310. name: string;
  11311. shader: string;
  11312. };
  11313. }
  11314. declare module BABYLON {
  11315. /** @hidden */
  11316. export var fogFragment: {
  11317. name: string;
  11318. shader: string;
  11319. };
  11320. }
  11321. declare module BABYLON {
  11322. /** @hidden */
  11323. export var spritesPixelShader: {
  11324. name: string;
  11325. shader: string;
  11326. };
  11327. }
  11328. declare module BABYLON {
  11329. /** @hidden */
  11330. export var fogVertexDeclaration: {
  11331. name: string;
  11332. shader: string;
  11333. };
  11334. }
  11335. declare module BABYLON {
  11336. /** @hidden */
  11337. export var spritesVertexShader: {
  11338. name: string;
  11339. shader: string;
  11340. };
  11341. }
  11342. declare module BABYLON {
  11343. /**
  11344. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11345. */
  11346. export interface ISpriteManager extends IDisposable {
  11347. /**
  11348. * Restricts the camera to viewing objects with the same layerMask.
  11349. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11350. */
  11351. layerMask: number;
  11352. /**
  11353. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11354. */
  11355. isPickable: boolean;
  11356. /**
  11357. * Specifies the rendering group id for this mesh (0 by default)
  11358. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11359. */
  11360. renderingGroupId: number;
  11361. /**
  11362. * Defines the list of sprites managed by the manager.
  11363. */
  11364. sprites: Array<Sprite>;
  11365. /**
  11366. * Tests the intersection of a sprite with a specific ray.
  11367. * @param ray The ray we are sending to test the collision
  11368. * @param camera The camera space we are sending rays in
  11369. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11370. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11371. * @returns picking info or null.
  11372. */
  11373. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11374. /**
  11375. * Intersects the sprites with a ray
  11376. * @param ray defines the ray to intersect with
  11377. * @param camera defines the current active camera
  11378. * @param predicate defines a predicate used to select candidate sprites
  11379. * @returns null if no hit or a PickingInfo array
  11380. */
  11381. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11382. /**
  11383. * Renders the list of sprites on screen.
  11384. */
  11385. render(): void;
  11386. }
  11387. /**
  11388. * Class used to manage multiple sprites on the same spritesheet
  11389. * @see http://doc.babylonjs.com/babylon101/sprites
  11390. */
  11391. export class SpriteManager implements ISpriteManager {
  11392. /** defines the manager's name */
  11393. name: string;
  11394. /** Gets the list of sprites */
  11395. sprites: Sprite[];
  11396. /** Gets or sets the rendering group id (0 by default) */
  11397. renderingGroupId: number;
  11398. /** Gets or sets camera layer mask */
  11399. layerMask: number;
  11400. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11401. fogEnabled: boolean;
  11402. /** Gets or sets a boolean indicating if the sprites are pickable */
  11403. isPickable: boolean;
  11404. /** Defines the default width of a cell in the spritesheet */
  11405. cellWidth: number;
  11406. /** Defines the default height of a cell in the spritesheet */
  11407. cellHeight: number;
  11408. /** Associative array from JSON sprite data file */
  11409. private _cellData;
  11410. /** Array of sprite names from JSON sprite data file */
  11411. private _spriteMap;
  11412. /** True when packed cell data from JSON file is ready*/
  11413. private _packedAndReady;
  11414. /**
  11415. * An event triggered when the manager is disposed.
  11416. */
  11417. onDisposeObservable: Observable<SpriteManager>;
  11418. private _onDisposeObserver;
  11419. /**
  11420. * Callback called when the manager is disposed
  11421. */
  11422. onDispose: () => void;
  11423. private _capacity;
  11424. private _fromPacked;
  11425. private _spriteTexture;
  11426. private _epsilon;
  11427. private _scene;
  11428. private _vertexData;
  11429. private _buffer;
  11430. private _vertexBuffers;
  11431. private _indexBuffer;
  11432. private _effectBase;
  11433. private _effectFog;
  11434. /**
  11435. * Gets or sets the spritesheet texture
  11436. */
  11437. texture: Texture;
  11438. /**
  11439. * Creates a new sprite manager
  11440. * @param name defines the manager's name
  11441. * @param imgUrl defines the sprite sheet url
  11442. * @param capacity defines the maximum allowed number of sprites
  11443. * @param cellSize defines the size of a sprite cell
  11444. * @param scene defines the hosting scene
  11445. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11446. * @param samplingMode defines the smapling mode to use with spritesheet
  11447. * @param fromPacked set to false; do not alter
  11448. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11449. */
  11450. constructor(
  11451. /** defines the manager's name */
  11452. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11453. private _makePacked;
  11454. private _appendSpriteVertex;
  11455. /**
  11456. * Intersects the sprites with a ray
  11457. * @param ray defines the ray to intersect with
  11458. * @param camera defines the current active camera
  11459. * @param predicate defines a predicate used to select candidate sprites
  11460. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11461. * @returns null if no hit or a PickingInfo
  11462. */
  11463. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11464. /**
  11465. * Intersects the sprites with a ray
  11466. * @param ray defines the ray to intersect with
  11467. * @param camera defines the current active camera
  11468. * @param predicate defines a predicate used to select candidate sprites
  11469. * @returns null if no hit or a PickingInfo array
  11470. */
  11471. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11472. /**
  11473. * Render all child sprites
  11474. */
  11475. render(): void;
  11476. /**
  11477. * Release associated resources
  11478. */
  11479. dispose(): void;
  11480. }
  11481. }
  11482. declare module BABYLON {
  11483. /**
  11484. * Class used to represent a sprite
  11485. * @see http://doc.babylonjs.com/babylon101/sprites
  11486. */
  11487. export class Sprite {
  11488. /** defines the name */
  11489. name: string;
  11490. /** Gets or sets the current world position */
  11491. position: Vector3;
  11492. /** Gets or sets the main color */
  11493. color: Color4;
  11494. /** Gets or sets the width */
  11495. width: number;
  11496. /** Gets or sets the height */
  11497. height: number;
  11498. /** Gets or sets rotation angle */
  11499. angle: number;
  11500. /** Gets or sets the cell index in the sprite sheet */
  11501. cellIndex: number;
  11502. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11503. cellRef: string;
  11504. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11505. invertU: number;
  11506. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11507. invertV: number;
  11508. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11509. disposeWhenFinishedAnimating: boolean;
  11510. /** Gets the list of attached animations */
  11511. animations: Animation[];
  11512. /** Gets or sets a boolean indicating if the sprite can be picked */
  11513. isPickable: boolean;
  11514. /**
  11515. * Gets or sets the associated action manager
  11516. */
  11517. actionManager: Nullable<ActionManager>;
  11518. private _animationStarted;
  11519. private _loopAnimation;
  11520. private _fromIndex;
  11521. private _toIndex;
  11522. private _delay;
  11523. private _direction;
  11524. private _manager;
  11525. private _time;
  11526. private _onAnimationEnd;
  11527. /**
  11528. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11529. */
  11530. isVisible: boolean;
  11531. /**
  11532. * Gets or sets the sprite size
  11533. */
  11534. size: number;
  11535. /**
  11536. * Creates a new Sprite
  11537. * @param name defines the name
  11538. * @param manager defines the manager
  11539. */
  11540. constructor(
  11541. /** defines the name */
  11542. name: string, manager: ISpriteManager);
  11543. /**
  11544. * Starts an animation
  11545. * @param from defines the initial key
  11546. * @param to defines the end key
  11547. * @param loop defines if the animation must loop
  11548. * @param delay defines the start delay (in ms)
  11549. * @param onAnimationEnd defines a callback to call when animation ends
  11550. */
  11551. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11552. /** Stops current animation (if any) */
  11553. stopAnimation(): void;
  11554. /** @hidden */
  11555. _animate(deltaTime: number): void;
  11556. /** Release associated resources */
  11557. dispose(): void;
  11558. }
  11559. }
  11560. declare module BABYLON {
  11561. /**
  11562. * Information about the result of picking within a scene
  11563. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11564. */
  11565. export class PickingInfo {
  11566. /** @hidden */
  11567. _pickingUnavailable: boolean;
  11568. /**
  11569. * If the pick collided with an object
  11570. */
  11571. hit: boolean;
  11572. /**
  11573. * Distance away where the pick collided
  11574. */
  11575. distance: number;
  11576. /**
  11577. * The location of pick collision
  11578. */
  11579. pickedPoint: Nullable<Vector3>;
  11580. /**
  11581. * The mesh corresponding the the pick collision
  11582. */
  11583. pickedMesh: Nullable<AbstractMesh>;
  11584. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11585. bu: number;
  11586. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11587. bv: number;
  11588. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11589. faceId: number;
  11590. /** Id of the the submesh that was picked */
  11591. subMeshId: number;
  11592. /** If a sprite was picked, this will be the sprite the pick collided with */
  11593. pickedSprite: Nullable<Sprite>;
  11594. /**
  11595. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11596. */
  11597. originMesh: Nullable<AbstractMesh>;
  11598. /**
  11599. * The ray that was used to perform the picking.
  11600. */
  11601. ray: Nullable<Ray>;
  11602. /**
  11603. * Gets the normal correspodning to the face the pick collided with
  11604. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11605. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11606. * @returns The normal correspodning to the face the pick collided with
  11607. */
  11608. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11609. /**
  11610. * Gets the texture coordinates of where the pick occured
  11611. * @returns the vector containing the coordnates of the texture
  11612. */
  11613. getTextureCoordinates(): Nullable<Vector2>;
  11614. }
  11615. }
  11616. declare module BABYLON {
  11617. /**
  11618. * Gather the list of pointer event types as constants.
  11619. */
  11620. export class PointerEventTypes {
  11621. /**
  11622. * 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.
  11623. */
  11624. static readonly POINTERDOWN: number;
  11625. /**
  11626. * The pointerup event is fired when a pointer is no longer active.
  11627. */
  11628. static readonly POINTERUP: number;
  11629. /**
  11630. * The pointermove event is fired when a pointer changes coordinates.
  11631. */
  11632. static readonly POINTERMOVE: number;
  11633. /**
  11634. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11635. */
  11636. static readonly POINTERWHEEL: number;
  11637. /**
  11638. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11639. */
  11640. static readonly POINTERPICK: number;
  11641. /**
  11642. * The pointertap event is fired when a the object has been touched and released without drag.
  11643. */
  11644. static readonly POINTERTAP: number;
  11645. /**
  11646. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11647. */
  11648. static readonly POINTERDOUBLETAP: number;
  11649. }
  11650. /**
  11651. * Base class of pointer info types.
  11652. */
  11653. export class PointerInfoBase {
  11654. /**
  11655. * Defines the type of event (PointerEventTypes)
  11656. */
  11657. type: number;
  11658. /**
  11659. * Defines the related dom event
  11660. */
  11661. event: PointerEvent | MouseWheelEvent;
  11662. /**
  11663. * Instantiates the base class of pointers info.
  11664. * @param type Defines the type of event (PointerEventTypes)
  11665. * @param event Defines the related dom event
  11666. */
  11667. constructor(
  11668. /**
  11669. * Defines the type of event (PointerEventTypes)
  11670. */
  11671. type: number,
  11672. /**
  11673. * Defines the related dom event
  11674. */
  11675. event: PointerEvent | MouseWheelEvent);
  11676. }
  11677. /**
  11678. * This class is used to store pointer related info for the onPrePointerObservable event.
  11679. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11680. */
  11681. export class PointerInfoPre extends PointerInfoBase {
  11682. /**
  11683. * Ray from a pointer if availible (eg. 6dof controller)
  11684. */
  11685. ray: Nullable<Ray>;
  11686. /**
  11687. * Defines the local position of the pointer on the canvas.
  11688. */
  11689. localPosition: Vector2;
  11690. /**
  11691. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11692. */
  11693. skipOnPointerObservable: boolean;
  11694. /**
  11695. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11696. * @param type Defines the type of event (PointerEventTypes)
  11697. * @param event Defines the related dom event
  11698. * @param localX Defines the local x coordinates of the pointer when the event occured
  11699. * @param localY Defines the local y coordinates of the pointer when the event occured
  11700. */
  11701. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11702. }
  11703. /**
  11704. * This type contains all the data related to a pointer event in Babylon.js.
  11705. * 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.
  11706. */
  11707. export class PointerInfo extends PointerInfoBase {
  11708. /**
  11709. * Defines the picking info associated to the info (if any)\
  11710. */
  11711. pickInfo: Nullable<PickingInfo>;
  11712. /**
  11713. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11714. * @param type Defines the type of event (PointerEventTypes)
  11715. * @param event Defines the related dom event
  11716. * @param pickInfo Defines the picking info associated to the info (if any)\
  11717. */
  11718. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11719. /**
  11720. * Defines the picking info associated to the info (if any)\
  11721. */
  11722. pickInfo: Nullable<PickingInfo>);
  11723. }
  11724. /**
  11725. * Data relating to a touch event on the screen.
  11726. */
  11727. export interface PointerTouch {
  11728. /**
  11729. * X coordinate of touch.
  11730. */
  11731. x: number;
  11732. /**
  11733. * Y coordinate of touch.
  11734. */
  11735. y: number;
  11736. /**
  11737. * Id of touch. Unique for each finger.
  11738. */
  11739. pointerId: number;
  11740. /**
  11741. * Event type passed from DOM.
  11742. */
  11743. type: any;
  11744. }
  11745. }
  11746. declare module BABYLON {
  11747. /**
  11748. * Manage the mouse inputs to control the movement of a free camera.
  11749. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11750. */
  11751. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11752. /**
  11753. * Define if touch is enabled in the mouse input
  11754. */
  11755. touchEnabled: boolean;
  11756. /**
  11757. * Defines the camera the input is attached to.
  11758. */
  11759. camera: FreeCamera;
  11760. /**
  11761. * Defines the buttons associated with the input to handle camera move.
  11762. */
  11763. buttons: number[];
  11764. /**
  11765. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11766. */
  11767. angularSensibility: number;
  11768. private _pointerInput;
  11769. private _onMouseMove;
  11770. private _observer;
  11771. private previousPosition;
  11772. /**
  11773. * Observable for when a pointer move event occurs containing the move offset
  11774. */
  11775. onPointerMovedObservable: Observable<{
  11776. offsetX: number;
  11777. offsetY: number;
  11778. }>;
  11779. /**
  11780. * @hidden
  11781. * If the camera should be rotated automatically based on pointer movement
  11782. */
  11783. _allowCameraRotation: boolean;
  11784. /**
  11785. * Manage the mouse inputs to control the movement of a free camera.
  11786. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11787. * @param touchEnabled Defines if touch is enabled or not
  11788. */
  11789. constructor(
  11790. /**
  11791. * Define if touch is enabled in the mouse input
  11792. */
  11793. touchEnabled?: boolean);
  11794. /**
  11795. * Attach the input controls to a specific dom element to get the input from.
  11796. * @param element Defines the element the controls should be listened from
  11797. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11798. */
  11799. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11800. /**
  11801. * Called on JS contextmenu event.
  11802. * Override this method to provide functionality.
  11803. */
  11804. protected onContextMenu(evt: PointerEvent): void;
  11805. /**
  11806. * Detach the current controls from the specified dom element.
  11807. * @param element Defines the element to stop listening the inputs from
  11808. */
  11809. detachControl(element: Nullable<HTMLElement>): void;
  11810. /**
  11811. * Gets the class name of the current intput.
  11812. * @returns the class name
  11813. */
  11814. getClassName(): string;
  11815. /**
  11816. * Get the friendly name associated with the input class.
  11817. * @returns the input friendly name
  11818. */
  11819. getSimpleName(): string;
  11820. }
  11821. }
  11822. declare module BABYLON {
  11823. /**
  11824. * Manage the touch inputs to control the movement of a free camera.
  11825. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11826. */
  11827. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11828. /**
  11829. * Defines the camera the input is attached to.
  11830. */
  11831. camera: FreeCamera;
  11832. /**
  11833. * Defines the touch sensibility for rotation.
  11834. * The higher the faster.
  11835. */
  11836. touchAngularSensibility: number;
  11837. /**
  11838. * Defines the touch sensibility for move.
  11839. * The higher the faster.
  11840. */
  11841. touchMoveSensibility: number;
  11842. private _offsetX;
  11843. private _offsetY;
  11844. private _pointerPressed;
  11845. private _pointerInput;
  11846. private _observer;
  11847. private _onLostFocus;
  11848. /**
  11849. * Attach the input controls to a specific dom element to get the input from.
  11850. * @param element Defines the element the controls should be listened from
  11851. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11852. */
  11853. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11854. /**
  11855. * Detach the current controls from the specified dom element.
  11856. * @param element Defines the element to stop listening the inputs from
  11857. */
  11858. detachControl(element: Nullable<HTMLElement>): void;
  11859. /**
  11860. * Update the current camera state depending on the inputs that have been used this frame.
  11861. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11862. */
  11863. checkInputs(): void;
  11864. /**
  11865. * Gets the class name of the current intput.
  11866. * @returns the class name
  11867. */
  11868. getClassName(): string;
  11869. /**
  11870. * Get the friendly name associated with the input class.
  11871. * @returns the input friendly name
  11872. */
  11873. getSimpleName(): string;
  11874. }
  11875. }
  11876. declare module BABYLON {
  11877. /**
  11878. * Default Inputs manager for the FreeCamera.
  11879. * It groups all the default supported inputs for ease of use.
  11880. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11881. */
  11882. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11883. /**
  11884. * @hidden
  11885. */
  11886. _mouseInput: Nullable<FreeCameraMouseInput>;
  11887. /**
  11888. * Instantiates a new FreeCameraInputsManager.
  11889. * @param camera Defines the camera the inputs belong to
  11890. */
  11891. constructor(camera: FreeCamera);
  11892. /**
  11893. * Add keyboard input support to the input manager.
  11894. * @returns the current input manager
  11895. */
  11896. addKeyboard(): FreeCameraInputsManager;
  11897. /**
  11898. * Add mouse input support to the input manager.
  11899. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11900. * @returns the current input manager
  11901. */
  11902. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11903. /**
  11904. * Removes the mouse input support from the manager
  11905. * @returns the current input manager
  11906. */
  11907. removeMouse(): FreeCameraInputsManager;
  11908. /**
  11909. * Add touch input support to the input manager.
  11910. * @returns the current input manager
  11911. */
  11912. addTouch(): FreeCameraInputsManager;
  11913. /**
  11914. * Remove all attached input methods from a camera
  11915. */
  11916. clear(): void;
  11917. }
  11918. }
  11919. declare module BABYLON {
  11920. /**
  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 the gamepad.
  11923. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11924. */
  11925. export class FreeCamera extends TargetCamera {
  11926. /**
  11927. * Define the collision ellipsoid of the camera.
  11928. * This is helpful to simulate a camera body like the player body around the camera
  11929. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11930. */
  11931. ellipsoid: Vector3;
  11932. /**
  11933. * Define an offset for the position of the ellipsoid around the camera.
  11934. * This can be helpful to determine the center of the body near the gravity center of the body
  11935. * instead of its head.
  11936. */
  11937. ellipsoidOffset: Vector3;
  11938. /**
  11939. * Enable or disable collisions of the camera with the rest of the scene objects.
  11940. */
  11941. checkCollisions: boolean;
  11942. /**
  11943. * Enable or disable gravity on the camera.
  11944. */
  11945. applyGravity: boolean;
  11946. /**
  11947. * Define the input manager associated to the camera.
  11948. */
  11949. inputs: FreeCameraInputsManager;
  11950. /**
  11951. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11952. * Higher values reduce sensitivity.
  11953. */
  11954. /**
  11955. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11956. * Higher values reduce sensitivity.
  11957. */
  11958. angularSensibility: number;
  11959. /**
  11960. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11961. */
  11962. keysUp: number[];
  11963. /**
  11964. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11965. */
  11966. keysDown: number[];
  11967. /**
  11968. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11969. */
  11970. keysLeft: number[];
  11971. /**
  11972. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11973. */
  11974. keysRight: number[];
  11975. /**
  11976. * Event raised when the camera collide with a mesh in the scene.
  11977. */
  11978. onCollide: (collidedMesh: AbstractMesh) => void;
  11979. private _collider;
  11980. private _needMoveForGravity;
  11981. private _oldPosition;
  11982. private _diffPosition;
  11983. private _newPosition;
  11984. /** @hidden */
  11985. _localDirection: Vector3;
  11986. /** @hidden */
  11987. _transformedDirection: Vector3;
  11988. /**
  11989. * Instantiates a Free Camera.
  11990. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11991. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11992. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11993. * @param name Define the name of the camera in the scene
  11994. * @param position Define the start position of the camera in the scene
  11995. * @param scene Define the scene the camera belongs to
  11996. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11997. */
  11998. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11999. /**
  12000. * Attached controls to the current camera.
  12001. * @param element Defines the element the controls should be listened from
  12002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12003. */
  12004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12005. /**
  12006. * Detach the current controls from the camera.
  12007. * The camera will stop reacting to inputs.
  12008. * @param element Defines the element to stop listening the inputs from
  12009. */
  12010. detachControl(element: HTMLElement): void;
  12011. private _collisionMask;
  12012. /**
  12013. * Define a collision mask to limit the list of object the camera can collide with
  12014. */
  12015. collisionMask: number;
  12016. /** @hidden */
  12017. _collideWithWorld(displacement: Vector3): void;
  12018. private _onCollisionPositionChange;
  12019. /** @hidden */
  12020. _checkInputs(): void;
  12021. /** @hidden */
  12022. _decideIfNeedsToMove(): boolean;
  12023. /** @hidden */
  12024. _updatePosition(): void;
  12025. /**
  12026. * Destroy the camera and release the current resources hold by it.
  12027. */
  12028. dispose(): void;
  12029. /**
  12030. * Gets the current object class name.
  12031. * @return the class name
  12032. */
  12033. getClassName(): string;
  12034. }
  12035. }
  12036. declare module BABYLON {
  12037. /**
  12038. * Represents a gamepad control stick position
  12039. */
  12040. export class StickValues {
  12041. /**
  12042. * The x component of the control stick
  12043. */
  12044. x: number;
  12045. /**
  12046. * The y component of the control stick
  12047. */
  12048. y: number;
  12049. /**
  12050. * Initializes the gamepad x and y control stick values
  12051. * @param x The x component of the gamepad control stick value
  12052. * @param y The y component of the gamepad control stick value
  12053. */
  12054. constructor(
  12055. /**
  12056. * The x component of the control stick
  12057. */
  12058. x: number,
  12059. /**
  12060. * The y component of the control stick
  12061. */
  12062. y: number);
  12063. }
  12064. /**
  12065. * An interface which manages callbacks for gamepad button changes
  12066. */
  12067. export interface GamepadButtonChanges {
  12068. /**
  12069. * Called when a gamepad has been changed
  12070. */
  12071. changed: boolean;
  12072. /**
  12073. * Called when a gamepad press event has been triggered
  12074. */
  12075. pressChanged: boolean;
  12076. /**
  12077. * Called when a touch event has been triggered
  12078. */
  12079. touchChanged: boolean;
  12080. /**
  12081. * Called when a value has changed
  12082. */
  12083. valueChanged: boolean;
  12084. }
  12085. /**
  12086. * Represents a gamepad
  12087. */
  12088. export class Gamepad {
  12089. /**
  12090. * The id of the gamepad
  12091. */
  12092. id: string;
  12093. /**
  12094. * The index of the gamepad
  12095. */
  12096. index: number;
  12097. /**
  12098. * The browser gamepad
  12099. */
  12100. browserGamepad: any;
  12101. /**
  12102. * Specifies what type of gamepad this represents
  12103. */
  12104. type: number;
  12105. private _leftStick;
  12106. private _rightStick;
  12107. /** @hidden */
  12108. _isConnected: boolean;
  12109. private _leftStickAxisX;
  12110. private _leftStickAxisY;
  12111. private _rightStickAxisX;
  12112. private _rightStickAxisY;
  12113. /**
  12114. * Triggered when the left control stick has been changed
  12115. */
  12116. private _onleftstickchanged;
  12117. /**
  12118. * Triggered when the right control stick has been changed
  12119. */
  12120. private _onrightstickchanged;
  12121. /**
  12122. * Represents a gamepad controller
  12123. */
  12124. static GAMEPAD: number;
  12125. /**
  12126. * Represents a generic controller
  12127. */
  12128. static GENERIC: number;
  12129. /**
  12130. * Represents an XBox controller
  12131. */
  12132. static XBOX: number;
  12133. /**
  12134. * Represents a pose-enabled controller
  12135. */
  12136. static POSE_ENABLED: number;
  12137. /**
  12138. * Represents an Dual Shock controller
  12139. */
  12140. static DUALSHOCK: number;
  12141. /**
  12142. * Specifies whether the left control stick should be Y-inverted
  12143. */
  12144. protected _invertLeftStickY: boolean;
  12145. /**
  12146. * Specifies if the gamepad has been connected
  12147. */
  12148. readonly isConnected: boolean;
  12149. /**
  12150. * Initializes the gamepad
  12151. * @param id The id of the gamepad
  12152. * @param index The index of the gamepad
  12153. * @param browserGamepad The browser gamepad
  12154. * @param leftStickX The x component of the left joystick
  12155. * @param leftStickY The y component of the left joystick
  12156. * @param rightStickX The x component of the right joystick
  12157. * @param rightStickY The y component of the right joystick
  12158. */
  12159. constructor(
  12160. /**
  12161. * The id of the gamepad
  12162. */
  12163. id: string,
  12164. /**
  12165. * The index of the gamepad
  12166. */
  12167. index: number,
  12168. /**
  12169. * The browser gamepad
  12170. */
  12171. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12172. /**
  12173. * Callback triggered when the left joystick has changed
  12174. * @param callback
  12175. */
  12176. onleftstickchanged(callback: (values: StickValues) => void): void;
  12177. /**
  12178. * Callback triggered when the right joystick has changed
  12179. * @param callback
  12180. */
  12181. onrightstickchanged(callback: (values: StickValues) => void): void;
  12182. /**
  12183. * Gets the left joystick
  12184. */
  12185. /**
  12186. * Sets the left joystick values
  12187. */
  12188. leftStick: StickValues;
  12189. /**
  12190. * Gets the right joystick
  12191. */
  12192. /**
  12193. * Sets the right joystick value
  12194. */
  12195. rightStick: StickValues;
  12196. /**
  12197. * Updates the gamepad joystick positions
  12198. */
  12199. update(): void;
  12200. /**
  12201. * Disposes the gamepad
  12202. */
  12203. dispose(): void;
  12204. }
  12205. /**
  12206. * Represents a generic gamepad
  12207. */
  12208. export class GenericPad extends Gamepad {
  12209. private _buttons;
  12210. private _onbuttondown;
  12211. private _onbuttonup;
  12212. /**
  12213. * Observable triggered when a button has been pressed
  12214. */
  12215. onButtonDownObservable: Observable<number>;
  12216. /**
  12217. * Observable triggered when a button has been released
  12218. */
  12219. onButtonUpObservable: Observable<number>;
  12220. /**
  12221. * Callback triggered when a button has been pressed
  12222. * @param callback Called when a button has been pressed
  12223. */
  12224. onbuttondown(callback: (buttonPressed: number) => void): void;
  12225. /**
  12226. * Callback triggered when a button has been released
  12227. * @param callback Called when a button has been released
  12228. */
  12229. onbuttonup(callback: (buttonReleased: number) => void): void;
  12230. /**
  12231. * Initializes the generic gamepad
  12232. * @param id The id of the generic gamepad
  12233. * @param index The index of the generic gamepad
  12234. * @param browserGamepad The browser gamepad
  12235. */
  12236. constructor(id: string, index: number, browserGamepad: any);
  12237. private _setButtonValue;
  12238. /**
  12239. * Updates the generic gamepad
  12240. */
  12241. update(): void;
  12242. /**
  12243. * Disposes the generic gamepad
  12244. */
  12245. dispose(): void;
  12246. }
  12247. }
  12248. declare module BABYLON {
  12249. interface Engine {
  12250. /**
  12251. * Creates a raw texture
  12252. * @param data defines the data to store in the texture
  12253. * @param width defines the width of the texture
  12254. * @param height defines the height of the texture
  12255. * @param format defines the format of the data
  12256. * @param generateMipMaps defines if the engine should generate the mip levels
  12257. * @param invertY defines if data must be stored with Y axis inverted
  12258. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12259. * @param compression defines the compression used (null by default)
  12260. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12261. * @returns the raw texture inside an InternalTexture
  12262. */
  12263. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12264. /**
  12265. * Update a raw texture
  12266. * @param texture defines the texture to update
  12267. * @param data defines the data to store in the texture
  12268. * @param format defines the format of the data
  12269. * @param invertY defines if data must be stored with Y axis inverted
  12270. */
  12271. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12272. /**
  12273. * Update a raw texture
  12274. * @param texture defines the texture to update
  12275. * @param data defines the data to store in the texture
  12276. * @param format defines the format of the data
  12277. * @param invertY defines if data must be stored with Y axis inverted
  12278. * @param compression defines the compression used (null by default)
  12279. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12280. */
  12281. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12282. /**
  12283. * Creates a new raw cube texture
  12284. * @param data defines the array of data to use to create each face
  12285. * @param size defines the size of the textures
  12286. * @param format defines the format of the data
  12287. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12288. * @param generateMipMaps defines if the engine should generate the mip levels
  12289. * @param invertY defines if data must be stored with Y axis inverted
  12290. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12291. * @param compression defines the compression used (null by default)
  12292. * @returns the cube texture as an InternalTexture
  12293. */
  12294. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12295. /**
  12296. * Update a raw cube texture
  12297. * @param texture defines the texture to udpdate
  12298. * @param data defines the data to store
  12299. * @param format defines the data format
  12300. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12301. * @param invertY defines if data must be stored with Y axis inverted
  12302. */
  12303. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12304. /**
  12305. * Update a raw cube texture
  12306. * @param texture defines the texture to udpdate
  12307. * @param data defines the data to store
  12308. * @param format defines the data format
  12309. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12310. * @param invertY defines if data must be stored with Y axis inverted
  12311. * @param compression defines the compression used (null by default)
  12312. */
  12313. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12314. /**
  12315. * Update a raw cube texture
  12316. * @param texture defines the texture to udpdate
  12317. * @param data defines the data to store
  12318. * @param format defines the data format
  12319. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12320. * @param invertY defines if data must be stored with Y axis inverted
  12321. * @param compression defines the compression used (null by default)
  12322. * @param level defines which level of the texture to update
  12323. */
  12324. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12325. /**
  12326. * Creates a new raw cube texture from a specified url
  12327. * @param url defines the url where the data is located
  12328. * @param scene defines the current scene
  12329. * @param size defines the size of the textures
  12330. * @param format defines the format of the data
  12331. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12332. * @param noMipmap defines if the engine should avoid generating the mip levels
  12333. * @param callback defines a callback used to extract texture data from loaded data
  12334. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12335. * @param onLoad defines a callback called when texture is loaded
  12336. * @param onError defines a callback called if there is an error
  12337. * @returns the cube texture as an InternalTexture
  12338. */
  12339. 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;
  12340. /**
  12341. * Creates a new raw cube texture from a specified url
  12342. * @param url defines the url where the data is located
  12343. * @param scene defines the current scene
  12344. * @param size defines the size of the textures
  12345. * @param format defines the format of the data
  12346. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12347. * @param noMipmap defines if the engine should avoid generating the mip levels
  12348. * @param callback defines a callback used to extract texture data from loaded data
  12349. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12350. * @param onLoad defines a callback called when texture is loaded
  12351. * @param onError defines a callback called if there is an error
  12352. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12353. * @param invertY defines if data must be stored with Y axis inverted
  12354. * @returns the cube texture as an InternalTexture
  12355. */
  12356. 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;
  12357. /**
  12358. * Creates a new raw 3D texture
  12359. * @param data defines the data used to create the texture
  12360. * @param width defines the width of the texture
  12361. * @param height defines the height of the texture
  12362. * @param depth defines the depth of the texture
  12363. * @param format defines the format of the texture
  12364. * @param generateMipMaps defines if the engine must generate mip levels
  12365. * @param invertY defines if data must be stored with Y axis inverted
  12366. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12367. * @param compression defines the compressed used (can be null)
  12368. * @param textureType defines the compressed used (can be null)
  12369. * @returns a new raw 3D texture (stored in an InternalTexture)
  12370. */
  12371. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12372. /**
  12373. * Update a raw 3D texture
  12374. * @param texture defines the texture to update
  12375. * @param data defines the data to store
  12376. * @param format defines the data format
  12377. * @param invertY defines if data must be stored with Y axis inverted
  12378. */
  12379. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12380. /**
  12381. * Update a raw 3D texture
  12382. * @param texture defines the texture to update
  12383. * @param data defines the data to store
  12384. * @param format defines the data format
  12385. * @param invertY defines if data must be stored with Y axis inverted
  12386. * @param compression defines the used compression (can be null)
  12387. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12388. */
  12389. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12390. }
  12391. }
  12392. declare module BABYLON {
  12393. /**
  12394. * Raw texture can help creating a texture directly from an array of data.
  12395. * This can be super useful if you either get the data from an uncompressed source or
  12396. * if you wish to create your texture pixel by pixel.
  12397. */
  12398. export class RawTexture extends Texture {
  12399. /**
  12400. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12401. */
  12402. format: number;
  12403. private _engine;
  12404. /**
  12405. * Instantiates a new RawTexture.
  12406. * Raw texture can help creating a texture directly from an array of data.
  12407. * This can be super useful if you either get the data from an uncompressed source or
  12408. * if you wish to create your texture pixel by pixel.
  12409. * @param data define the array of data to use to create the texture
  12410. * @param width define the width of the texture
  12411. * @param height define the height of the texture
  12412. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12413. * @param scene define the scene the texture belongs to
  12414. * @param generateMipMaps define whether mip maps should be generated or not
  12415. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12416. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12417. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12418. */
  12419. constructor(data: ArrayBufferView, width: number, height: number,
  12420. /**
  12421. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12422. */
  12423. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12424. /**
  12425. * Updates the texture underlying data.
  12426. * @param data Define the new data of the texture
  12427. */
  12428. update(data: ArrayBufferView): void;
  12429. /**
  12430. * Creates a luminance texture from some data.
  12431. * @param data Define the texture data
  12432. * @param width Define the width of the texture
  12433. * @param height Define the height of the texture
  12434. * @param scene Define the scene the texture belongs to
  12435. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12436. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12437. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12438. * @returns the luminance texture
  12439. */
  12440. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12441. /**
  12442. * Creates a luminance alpha texture from some data.
  12443. * @param data Define the texture data
  12444. * @param width Define the width of the texture
  12445. * @param height Define the height of the texture
  12446. * @param scene Define the scene the texture belongs to
  12447. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12448. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12449. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12450. * @returns the luminance alpha texture
  12451. */
  12452. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12453. /**
  12454. * Creates an alpha texture from some data.
  12455. * @param data Define the texture data
  12456. * @param width Define the width of the texture
  12457. * @param height Define the height of the texture
  12458. * @param scene Define the scene the texture belongs to
  12459. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12460. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12461. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12462. * @returns the alpha texture
  12463. */
  12464. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12465. /**
  12466. * Creates a RGB texture from some data.
  12467. * @param data Define the texture data
  12468. * @param width Define the width of the texture
  12469. * @param height Define the height of the texture
  12470. * @param scene Define the scene the texture belongs to
  12471. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12472. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12473. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12474. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12475. * @returns the RGB alpha texture
  12476. */
  12477. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12478. /**
  12479. * Creates a RGBA texture from some data.
  12480. * @param data Define the texture data
  12481. * @param width Define the width of the texture
  12482. * @param height Define the height of the texture
  12483. * @param scene Define the scene the texture belongs to
  12484. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12485. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12486. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12487. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12488. * @returns the RGBA texture
  12489. */
  12490. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12491. /**
  12492. * Creates a R texture from some data.
  12493. * @param data Define the texture data
  12494. * @param width Define the width of the texture
  12495. * @param height Define the height of the texture
  12496. * @param scene Define the scene the texture belongs to
  12497. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12498. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12499. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12500. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12501. * @returns the R texture
  12502. */
  12503. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12504. }
  12505. }
  12506. declare module BABYLON {
  12507. /**
  12508. * Interface for the size containing width and height
  12509. */
  12510. export interface ISize {
  12511. /**
  12512. * Width
  12513. */
  12514. width: number;
  12515. /**
  12516. * Heighht
  12517. */
  12518. height: number;
  12519. }
  12520. /**
  12521. * Size containing widht and height
  12522. */
  12523. export class Size implements ISize {
  12524. /**
  12525. * Width
  12526. */
  12527. width: number;
  12528. /**
  12529. * Height
  12530. */
  12531. height: number;
  12532. /**
  12533. * Creates a Size object from the given width and height (floats).
  12534. * @param width width of the new size
  12535. * @param height height of the new size
  12536. */
  12537. constructor(width: number, height: number);
  12538. /**
  12539. * Returns a string with the Size width and height
  12540. * @returns a string with the Size width and height
  12541. */
  12542. toString(): string;
  12543. /**
  12544. * "Size"
  12545. * @returns the string "Size"
  12546. */
  12547. getClassName(): string;
  12548. /**
  12549. * Returns the Size hash code.
  12550. * @returns a hash code for a unique width and height
  12551. */
  12552. getHashCode(): number;
  12553. /**
  12554. * Updates the current size from the given one.
  12555. * @param src the given size
  12556. */
  12557. copyFrom(src: Size): void;
  12558. /**
  12559. * Updates in place the current Size from the given floats.
  12560. * @param width width of the new size
  12561. * @param height height of the new size
  12562. * @returns the updated Size.
  12563. */
  12564. copyFromFloats(width: number, height: number): Size;
  12565. /**
  12566. * Updates in place the current Size from the given floats.
  12567. * @param width width to set
  12568. * @param height height to set
  12569. * @returns the updated Size.
  12570. */
  12571. set(width: number, height: number): Size;
  12572. /**
  12573. * Multiplies the width and height by numbers
  12574. * @param w factor to multiple the width by
  12575. * @param h factor to multiple the height by
  12576. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12577. */
  12578. multiplyByFloats(w: number, h: number): Size;
  12579. /**
  12580. * Clones the size
  12581. * @returns a new Size copied from the given one.
  12582. */
  12583. clone(): Size;
  12584. /**
  12585. * True if the current Size and the given one width and height are strictly equal.
  12586. * @param other the other size to compare against
  12587. * @returns True if the current Size and the given one width and height are strictly equal.
  12588. */
  12589. equals(other: Size): boolean;
  12590. /**
  12591. * The surface of the Size : width * height (float).
  12592. */
  12593. readonly surface: number;
  12594. /**
  12595. * Create a new size of zero
  12596. * @returns a new Size set to (0.0, 0.0)
  12597. */
  12598. static Zero(): Size;
  12599. /**
  12600. * Sums the width and height of two sizes
  12601. * @param otherSize size to add to this size
  12602. * @returns a new Size set as the addition result of the current Size and the given one.
  12603. */
  12604. add(otherSize: Size): Size;
  12605. /**
  12606. * Subtracts the width and height of two
  12607. * @param otherSize size to subtract to this size
  12608. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12609. */
  12610. subtract(otherSize: Size): Size;
  12611. /**
  12612. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12613. * @param start starting size to lerp between
  12614. * @param end end size to lerp between
  12615. * @param amount amount to lerp between the start and end values
  12616. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12617. */
  12618. static Lerp(start: Size, end: Size, amount: number): Size;
  12619. }
  12620. }
  12621. declare module BABYLON {
  12622. /**
  12623. * Defines a runtime animation
  12624. */
  12625. export class RuntimeAnimation {
  12626. private _events;
  12627. /**
  12628. * The current frame of the runtime animation
  12629. */
  12630. private _currentFrame;
  12631. /**
  12632. * The animation used by the runtime animation
  12633. */
  12634. private _animation;
  12635. /**
  12636. * The target of the runtime animation
  12637. */
  12638. private _target;
  12639. /**
  12640. * The initiating animatable
  12641. */
  12642. private _host;
  12643. /**
  12644. * The original value of the runtime animation
  12645. */
  12646. private _originalValue;
  12647. /**
  12648. * The original blend value of the runtime animation
  12649. */
  12650. private _originalBlendValue;
  12651. /**
  12652. * The offsets cache of the runtime animation
  12653. */
  12654. private _offsetsCache;
  12655. /**
  12656. * The high limits cache of the runtime animation
  12657. */
  12658. private _highLimitsCache;
  12659. /**
  12660. * Specifies if the runtime animation has been stopped
  12661. */
  12662. private _stopped;
  12663. /**
  12664. * The blending factor of the runtime animation
  12665. */
  12666. private _blendingFactor;
  12667. /**
  12668. * The BabylonJS scene
  12669. */
  12670. private _scene;
  12671. /**
  12672. * The current value of the runtime animation
  12673. */
  12674. private _currentValue;
  12675. /** @hidden */
  12676. _animationState: _IAnimationState;
  12677. /**
  12678. * The active target of the runtime animation
  12679. */
  12680. private _activeTargets;
  12681. private _currentActiveTarget;
  12682. private _directTarget;
  12683. /**
  12684. * The target path of the runtime animation
  12685. */
  12686. private _targetPath;
  12687. /**
  12688. * The weight of the runtime animation
  12689. */
  12690. private _weight;
  12691. /**
  12692. * The ratio offset of the runtime animation
  12693. */
  12694. private _ratioOffset;
  12695. /**
  12696. * The previous delay of the runtime animation
  12697. */
  12698. private _previousDelay;
  12699. /**
  12700. * The previous ratio of the runtime animation
  12701. */
  12702. private _previousRatio;
  12703. private _enableBlending;
  12704. private _keys;
  12705. private _minFrame;
  12706. private _maxFrame;
  12707. private _minValue;
  12708. private _maxValue;
  12709. private _targetIsArray;
  12710. /**
  12711. * Gets the current frame of the runtime animation
  12712. */
  12713. readonly currentFrame: number;
  12714. /**
  12715. * Gets the weight of the runtime animation
  12716. */
  12717. readonly weight: number;
  12718. /**
  12719. * Gets the current value of the runtime animation
  12720. */
  12721. readonly currentValue: any;
  12722. /**
  12723. * Gets the target path of the runtime animation
  12724. */
  12725. readonly targetPath: string;
  12726. /**
  12727. * Gets the actual target of the runtime animation
  12728. */
  12729. readonly target: any;
  12730. /** @hidden */
  12731. _onLoop: () => void;
  12732. /**
  12733. * Create a new RuntimeAnimation object
  12734. * @param target defines the target of the animation
  12735. * @param animation defines the source animation object
  12736. * @param scene defines the hosting scene
  12737. * @param host defines the initiating Animatable
  12738. */
  12739. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12740. private _preparePath;
  12741. /**
  12742. * Gets the animation from the runtime animation
  12743. */
  12744. readonly animation: Animation;
  12745. /**
  12746. * Resets the runtime animation to the beginning
  12747. * @param restoreOriginal defines whether to restore the target property to the original value
  12748. */
  12749. reset(restoreOriginal?: boolean): void;
  12750. /**
  12751. * Specifies if the runtime animation is stopped
  12752. * @returns Boolean specifying if the runtime animation is stopped
  12753. */
  12754. isStopped(): boolean;
  12755. /**
  12756. * Disposes of the runtime animation
  12757. */
  12758. dispose(): void;
  12759. /**
  12760. * Apply the interpolated value to the target
  12761. * @param currentValue defines the value computed by the animation
  12762. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12763. */
  12764. setValue(currentValue: any, weight: number): void;
  12765. private _getOriginalValues;
  12766. private _setValue;
  12767. /**
  12768. * Gets the loop pmode of the runtime animation
  12769. * @returns Loop Mode
  12770. */
  12771. private _getCorrectLoopMode;
  12772. /**
  12773. * Move the current animation to a given frame
  12774. * @param frame defines the frame to move to
  12775. */
  12776. goToFrame(frame: number): void;
  12777. /**
  12778. * @hidden Internal use only
  12779. */
  12780. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12781. /**
  12782. * Execute the current animation
  12783. * @param delay defines the delay to add to the current frame
  12784. * @param from defines the lower bound of the animation range
  12785. * @param to defines the upper bound of the animation range
  12786. * @param loop defines if the current animation must loop
  12787. * @param speedRatio defines the current speed ratio
  12788. * @param weight defines the weight of the animation (default is -1 so no weight)
  12789. * @param onLoop optional callback called when animation loops
  12790. * @returns a boolean indicating if the animation is running
  12791. */
  12792. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12793. }
  12794. }
  12795. declare module BABYLON {
  12796. /**
  12797. * Class used to store an actual running animation
  12798. */
  12799. export class Animatable {
  12800. /** defines the target object */
  12801. target: any;
  12802. /** defines the starting frame number (default is 0) */
  12803. fromFrame: number;
  12804. /** defines the ending frame number (default is 100) */
  12805. toFrame: number;
  12806. /** defines if the animation must loop (default is false) */
  12807. loopAnimation: boolean;
  12808. /** defines a callback to call when animation ends if it is not looping */
  12809. onAnimationEnd?: (() => void) | null | undefined;
  12810. /** defines a callback to call when animation loops */
  12811. onAnimationLoop?: (() => void) | null | undefined;
  12812. private _localDelayOffset;
  12813. private _pausedDelay;
  12814. private _runtimeAnimations;
  12815. private _paused;
  12816. private _scene;
  12817. private _speedRatio;
  12818. private _weight;
  12819. private _syncRoot;
  12820. /**
  12821. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12822. * This will only apply for non looping animation (default is true)
  12823. */
  12824. disposeOnEnd: boolean;
  12825. /**
  12826. * Gets a boolean indicating if the animation has started
  12827. */
  12828. animationStarted: boolean;
  12829. /**
  12830. * Observer raised when the animation ends
  12831. */
  12832. onAnimationEndObservable: Observable<Animatable>;
  12833. /**
  12834. * Observer raised when the animation loops
  12835. */
  12836. onAnimationLoopObservable: Observable<Animatable>;
  12837. /**
  12838. * Gets the root Animatable used to synchronize and normalize animations
  12839. */
  12840. readonly syncRoot: Nullable<Animatable>;
  12841. /**
  12842. * Gets the current frame of the first RuntimeAnimation
  12843. * Used to synchronize Animatables
  12844. */
  12845. readonly masterFrame: number;
  12846. /**
  12847. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12848. */
  12849. weight: number;
  12850. /**
  12851. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12852. */
  12853. speedRatio: number;
  12854. /**
  12855. * Creates a new Animatable
  12856. * @param scene defines the hosting scene
  12857. * @param target defines the target object
  12858. * @param fromFrame defines the starting frame number (default is 0)
  12859. * @param toFrame defines the ending frame number (default is 100)
  12860. * @param loopAnimation defines if the animation must loop (default is false)
  12861. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12862. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12863. * @param animations defines a group of animation to add to the new Animatable
  12864. * @param onAnimationLoop defines a callback to call when animation loops
  12865. */
  12866. constructor(scene: Scene,
  12867. /** defines the target object */
  12868. target: any,
  12869. /** defines the starting frame number (default is 0) */
  12870. fromFrame?: number,
  12871. /** defines the ending frame number (default is 100) */
  12872. toFrame?: number,
  12873. /** defines if the animation must loop (default is false) */
  12874. loopAnimation?: boolean, speedRatio?: number,
  12875. /** defines a callback to call when animation ends if it is not looping */
  12876. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12877. /** defines a callback to call when animation loops */
  12878. onAnimationLoop?: (() => void) | null | undefined);
  12879. /**
  12880. * Synchronize and normalize current Animatable with a source Animatable
  12881. * This is useful when using animation weights and when animations are not of the same length
  12882. * @param root defines the root Animatable to synchronize with
  12883. * @returns the current Animatable
  12884. */
  12885. syncWith(root: Animatable): Animatable;
  12886. /**
  12887. * Gets the list of runtime animations
  12888. * @returns an array of RuntimeAnimation
  12889. */
  12890. getAnimations(): RuntimeAnimation[];
  12891. /**
  12892. * Adds more animations to the current animatable
  12893. * @param target defines the target of the animations
  12894. * @param animations defines the new animations to add
  12895. */
  12896. appendAnimations(target: any, animations: Animation[]): void;
  12897. /**
  12898. * Gets the source animation for a specific property
  12899. * @param property defines the propertyu to look for
  12900. * @returns null or the source animation for the given property
  12901. */
  12902. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12903. /**
  12904. * Gets the runtime animation for a specific property
  12905. * @param property defines the propertyu to look for
  12906. * @returns null or the runtime animation for the given property
  12907. */
  12908. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12909. /**
  12910. * Resets the animatable to its original state
  12911. */
  12912. reset(): void;
  12913. /**
  12914. * Allows the animatable to blend with current running animations
  12915. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12916. * @param blendingSpeed defines the blending speed to use
  12917. */
  12918. enableBlending(blendingSpeed: number): void;
  12919. /**
  12920. * Disable animation blending
  12921. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12922. */
  12923. disableBlending(): void;
  12924. /**
  12925. * Jump directly to a given frame
  12926. * @param frame defines the frame to jump to
  12927. */
  12928. goToFrame(frame: number): void;
  12929. /**
  12930. * Pause the animation
  12931. */
  12932. pause(): void;
  12933. /**
  12934. * Restart the animation
  12935. */
  12936. restart(): void;
  12937. private _raiseOnAnimationEnd;
  12938. /**
  12939. * Stop and delete the current animation
  12940. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12941. * @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)
  12942. */
  12943. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12944. /**
  12945. * Wait asynchronously for the animation to end
  12946. * @returns a promise which will be fullfilled when the animation ends
  12947. */
  12948. waitAsync(): Promise<Animatable>;
  12949. /** @hidden */
  12950. _animate(delay: number): boolean;
  12951. }
  12952. interface Scene {
  12953. /** @hidden */
  12954. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12955. /** @hidden */
  12956. _processLateAnimationBindingsForMatrices(holder: {
  12957. totalWeight: number;
  12958. animations: RuntimeAnimation[];
  12959. originalValue: Matrix;
  12960. }): any;
  12961. /** @hidden */
  12962. _processLateAnimationBindingsForQuaternions(holder: {
  12963. totalWeight: number;
  12964. animations: RuntimeAnimation[];
  12965. originalValue: Quaternion;
  12966. }, refQuaternion: Quaternion): Quaternion;
  12967. /** @hidden */
  12968. _processLateAnimationBindings(): void;
  12969. /**
  12970. * Will start the animation sequence of a given target
  12971. * @param target defines the target
  12972. * @param from defines from which frame should animation start
  12973. * @param to defines until which frame should animation run.
  12974. * @param weight defines the weight to apply to the animation (1.0 by default)
  12975. * @param loop defines if the animation loops
  12976. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12977. * @param onAnimationEnd defines the function to be executed when the animation ends
  12978. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12979. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12980. * @param onAnimationLoop defines the callback to call when an animation loops
  12981. * @returns the animatable object created for this animation
  12982. */
  12983. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12984. /**
  12985. * Will start the animation sequence of a given target
  12986. * @param target defines the target
  12987. * @param from defines from which frame should animation start
  12988. * @param to defines until which frame should animation run.
  12989. * @param loop defines if the animation loops
  12990. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12991. * @param onAnimationEnd defines the function to be executed when the animation ends
  12992. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12993. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12994. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  12995. * @param onAnimationLoop defines the callback to call when an animation loops
  12996. * @returns the animatable object created for this animation
  12997. */
  12998. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12999. /**
  13000. * Will start the animation sequence of a given target and its hierarchy
  13001. * @param target defines the target
  13002. * @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.
  13003. * @param from defines from which frame should animation start
  13004. * @param to defines until which frame should animation run.
  13005. * @param loop defines if the animation loops
  13006. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13007. * @param onAnimationEnd defines the function to be executed when the animation ends
  13008. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13009. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13010. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13011. * @param onAnimationLoop defines the callback to call when an animation loops
  13012. * @returns the list of created animatables
  13013. */
  13014. 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[];
  13015. /**
  13016. * Begin a new animation on a given node
  13017. * @param target defines the target where the animation will take place
  13018. * @param animations defines the list of animations to start
  13019. * @param from defines the initial value
  13020. * @param to defines the final value
  13021. * @param loop defines if you want animation to loop (off by default)
  13022. * @param speedRatio defines the speed ratio to apply to all animations
  13023. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13024. * @param onAnimationLoop defines the callback to call when an animation loops
  13025. * @returns the list of created animatables
  13026. */
  13027. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13028. /**
  13029. * Begin a new animation on a given node and its hierarchy
  13030. * @param target defines the root node where the animation will take place
  13031. * @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.
  13032. * @param animations defines the list of animations to start
  13033. * @param from defines the initial value
  13034. * @param to defines the final value
  13035. * @param loop defines if you want animation to loop (off by default)
  13036. * @param speedRatio defines the speed ratio to apply to all animations
  13037. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13038. * @param onAnimationLoop defines the callback to call when an animation loops
  13039. * @returns the list of animatables created for all nodes
  13040. */
  13041. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13042. /**
  13043. * Gets the animatable associated with a specific target
  13044. * @param target defines the target of the animatable
  13045. * @returns the required animatable if found
  13046. */
  13047. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13048. /**
  13049. * Gets all animatables associated with a given target
  13050. * @param target defines the target to look animatables for
  13051. * @returns an array of Animatables
  13052. */
  13053. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13054. /**
  13055. * Stops and removes all animations that have been applied to the scene
  13056. */
  13057. stopAllAnimations(): void;
  13058. }
  13059. interface Bone {
  13060. /**
  13061. * Copy an animation range from another bone
  13062. * @param source defines the source bone
  13063. * @param rangeName defines the range name to copy
  13064. * @param frameOffset defines the frame offset
  13065. * @param rescaleAsRequired defines if rescaling must be applied if required
  13066. * @param skelDimensionsRatio defines the scaling ratio
  13067. * @returns true if operation was successful
  13068. */
  13069. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13070. }
  13071. }
  13072. declare module BABYLON {
  13073. /**
  13074. * Class used to override all child animations of a given target
  13075. */
  13076. export class AnimationPropertiesOverride {
  13077. /**
  13078. * Gets or sets a value indicating if animation blending must be used
  13079. */
  13080. enableBlending: boolean;
  13081. /**
  13082. * Gets or sets the blending speed to use when enableBlending is true
  13083. */
  13084. blendingSpeed: number;
  13085. /**
  13086. * Gets or sets the default loop mode to use
  13087. */
  13088. loopMode: number;
  13089. }
  13090. }
  13091. declare module BABYLON {
  13092. /**
  13093. * Class used to handle skinning animations
  13094. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13095. */
  13096. export class Skeleton implements IAnimatable {
  13097. /** defines the skeleton name */
  13098. name: string;
  13099. /** defines the skeleton Id */
  13100. id: string;
  13101. /**
  13102. * Defines the list of child bones
  13103. */
  13104. bones: Bone[];
  13105. /**
  13106. * Defines an estimate of the dimension of the skeleton at rest
  13107. */
  13108. dimensionsAtRest: Vector3;
  13109. /**
  13110. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13111. */
  13112. needInitialSkinMatrix: boolean;
  13113. /**
  13114. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13115. */
  13116. overrideMesh: Nullable<AbstractMesh>;
  13117. /**
  13118. * Gets the list of animations attached to this skeleton
  13119. */
  13120. animations: Array<Animation>;
  13121. private _scene;
  13122. private _isDirty;
  13123. private _transformMatrices;
  13124. private _transformMatrixTexture;
  13125. private _meshesWithPoseMatrix;
  13126. private _animatables;
  13127. private _identity;
  13128. private _synchronizedWithMesh;
  13129. private _ranges;
  13130. private _lastAbsoluteTransformsUpdateId;
  13131. private _canUseTextureForBones;
  13132. private _uniqueId;
  13133. /** @hidden */
  13134. _numBonesWithLinkedTransformNode: number;
  13135. /** @hidden */
  13136. _hasWaitingData: Nullable<boolean>;
  13137. /**
  13138. * Specifies if the skeleton should be serialized
  13139. */
  13140. doNotSerialize: boolean;
  13141. private _useTextureToStoreBoneMatrices;
  13142. /**
  13143. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13144. * Please note that this option is not available if the hardware does not support it
  13145. */
  13146. useTextureToStoreBoneMatrices: boolean;
  13147. private _animationPropertiesOverride;
  13148. /**
  13149. * Gets or sets the animation properties override
  13150. */
  13151. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13152. /**
  13153. * List of inspectable custom properties (used by the Inspector)
  13154. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13155. */
  13156. inspectableCustomProperties: IInspectable[];
  13157. /**
  13158. * An observable triggered before computing the skeleton's matrices
  13159. */
  13160. onBeforeComputeObservable: Observable<Skeleton>;
  13161. /**
  13162. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13163. */
  13164. readonly isUsingTextureForMatrices: boolean;
  13165. /**
  13166. * Gets the unique ID of this skeleton
  13167. */
  13168. readonly uniqueId: number;
  13169. /**
  13170. * Creates a new skeleton
  13171. * @param name defines the skeleton name
  13172. * @param id defines the skeleton Id
  13173. * @param scene defines the hosting scene
  13174. */
  13175. constructor(
  13176. /** defines the skeleton name */
  13177. name: string,
  13178. /** defines the skeleton Id */
  13179. id: string, scene: Scene);
  13180. /**
  13181. * Gets the current object class name.
  13182. * @return the class name
  13183. */
  13184. getClassName(): string;
  13185. /**
  13186. * Returns an array containing the root bones
  13187. * @returns an array containing the root bones
  13188. */
  13189. getChildren(): Array<Bone>;
  13190. /**
  13191. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13192. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13193. * @returns a Float32Array containing matrices data
  13194. */
  13195. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13196. /**
  13197. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13198. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13199. * @returns a raw texture containing the data
  13200. */
  13201. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13202. /**
  13203. * Gets the current hosting scene
  13204. * @returns a scene object
  13205. */
  13206. getScene(): Scene;
  13207. /**
  13208. * Gets a string representing the current skeleton data
  13209. * @param fullDetails defines a boolean indicating if we want a verbose version
  13210. * @returns a string representing the current skeleton data
  13211. */
  13212. toString(fullDetails?: boolean): string;
  13213. /**
  13214. * Get bone's index searching by name
  13215. * @param name defines bone's name to search for
  13216. * @return the indice of the bone. Returns -1 if not found
  13217. */
  13218. getBoneIndexByName(name: string): number;
  13219. /**
  13220. * Creater a new animation range
  13221. * @param name defines the name of the range
  13222. * @param from defines the start key
  13223. * @param to defines the end key
  13224. */
  13225. createAnimationRange(name: string, from: number, to: number): void;
  13226. /**
  13227. * Delete a specific animation range
  13228. * @param name defines the name of the range
  13229. * @param deleteFrames defines if frames must be removed as well
  13230. */
  13231. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13232. /**
  13233. * Gets a specific animation range
  13234. * @param name defines the name of the range to look for
  13235. * @returns the requested animation range or null if not found
  13236. */
  13237. getAnimationRange(name: string): Nullable<AnimationRange>;
  13238. /**
  13239. * Gets the list of all animation ranges defined on this skeleton
  13240. * @returns an array
  13241. */
  13242. getAnimationRanges(): Nullable<AnimationRange>[];
  13243. /**
  13244. * Copy animation range from a source skeleton.
  13245. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13246. * @param source defines the source skeleton
  13247. * @param name defines the name of the range to copy
  13248. * @param rescaleAsRequired defines if rescaling must be applied if required
  13249. * @returns true if operation was successful
  13250. */
  13251. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13252. /**
  13253. * Forces the skeleton to go to rest pose
  13254. */
  13255. returnToRest(): void;
  13256. private _getHighestAnimationFrame;
  13257. /**
  13258. * Begin a specific animation range
  13259. * @param name defines the name of the range to start
  13260. * @param loop defines if looping must be turned on (false by default)
  13261. * @param speedRatio defines the speed ratio to apply (1 by default)
  13262. * @param onAnimationEnd defines a callback which will be called when animation will end
  13263. * @returns a new animatable
  13264. */
  13265. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13266. /** @hidden */
  13267. _markAsDirty(): void;
  13268. /** @hidden */
  13269. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13270. /** @hidden */
  13271. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13272. private _computeTransformMatrices;
  13273. /**
  13274. * Build all resources required to render a skeleton
  13275. */
  13276. prepare(): void;
  13277. /**
  13278. * Gets the list of animatables currently running for this skeleton
  13279. * @returns an array of animatables
  13280. */
  13281. getAnimatables(): IAnimatable[];
  13282. /**
  13283. * Clone the current skeleton
  13284. * @param name defines the name of the new skeleton
  13285. * @param id defines the id of the new skeleton
  13286. * @returns the new skeleton
  13287. */
  13288. clone(name: string, id: string): Skeleton;
  13289. /**
  13290. * Enable animation blending for this skeleton
  13291. * @param blendingSpeed defines the blending speed to apply
  13292. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13293. */
  13294. enableBlending(blendingSpeed?: number): void;
  13295. /**
  13296. * Releases all resources associated with the current skeleton
  13297. */
  13298. dispose(): void;
  13299. /**
  13300. * Serialize the skeleton in a JSON object
  13301. * @returns a JSON object
  13302. */
  13303. serialize(): any;
  13304. /**
  13305. * Creates a new skeleton from serialized data
  13306. * @param parsedSkeleton defines the serialized data
  13307. * @param scene defines the hosting scene
  13308. * @returns a new skeleton
  13309. */
  13310. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13311. /**
  13312. * Compute all node absolute transforms
  13313. * @param forceUpdate defines if computation must be done even if cache is up to date
  13314. */
  13315. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13316. /**
  13317. * Gets the root pose matrix
  13318. * @returns a matrix
  13319. */
  13320. getPoseMatrix(): Nullable<Matrix>;
  13321. /**
  13322. * Sorts bones per internal index
  13323. */
  13324. sortBones(): void;
  13325. private _sortBones;
  13326. }
  13327. }
  13328. declare module BABYLON {
  13329. /**
  13330. * Class used to store bone information
  13331. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13332. */
  13333. export class Bone extends Node {
  13334. /**
  13335. * defines the bone name
  13336. */
  13337. name: string;
  13338. private static _tmpVecs;
  13339. private static _tmpQuat;
  13340. private static _tmpMats;
  13341. /**
  13342. * Gets the list of child bones
  13343. */
  13344. children: Bone[];
  13345. /** Gets the animations associated with this bone */
  13346. animations: Animation[];
  13347. /**
  13348. * Gets or sets bone length
  13349. */
  13350. length: number;
  13351. /**
  13352. * @hidden Internal only
  13353. * Set this value to map this bone to a different index in the transform matrices
  13354. * Set this value to -1 to exclude the bone from the transform matrices
  13355. */
  13356. _index: Nullable<number>;
  13357. private _skeleton;
  13358. private _localMatrix;
  13359. private _restPose;
  13360. private _baseMatrix;
  13361. private _absoluteTransform;
  13362. private _invertedAbsoluteTransform;
  13363. private _parent;
  13364. private _scalingDeterminant;
  13365. private _worldTransform;
  13366. private _localScaling;
  13367. private _localRotation;
  13368. private _localPosition;
  13369. private _needToDecompose;
  13370. private _needToCompose;
  13371. /** @hidden */
  13372. _linkedTransformNode: Nullable<TransformNode>;
  13373. /** @hidden */
  13374. _waitingTransformNodeId: Nullable<string>;
  13375. /** @hidden */
  13376. /** @hidden */
  13377. _matrix: Matrix;
  13378. /**
  13379. * Create a new bone
  13380. * @param name defines the bone name
  13381. * @param skeleton defines the parent skeleton
  13382. * @param parentBone defines the parent (can be null if the bone is the root)
  13383. * @param localMatrix defines the local matrix
  13384. * @param restPose defines the rest pose matrix
  13385. * @param baseMatrix defines the base matrix
  13386. * @param index defines index of the bone in the hiearchy
  13387. */
  13388. constructor(
  13389. /**
  13390. * defines the bone name
  13391. */
  13392. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13393. /**
  13394. * Gets the current object class name.
  13395. * @return the class name
  13396. */
  13397. getClassName(): string;
  13398. /**
  13399. * Gets the parent skeleton
  13400. * @returns a skeleton
  13401. */
  13402. getSkeleton(): Skeleton;
  13403. /**
  13404. * Gets parent bone
  13405. * @returns a bone or null if the bone is the root of the bone hierarchy
  13406. */
  13407. getParent(): Nullable<Bone>;
  13408. /**
  13409. * Returns an array containing the root bones
  13410. * @returns an array containing the root bones
  13411. */
  13412. getChildren(): Array<Bone>;
  13413. /**
  13414. * Sets the parent bone
  13415. * @param parent defines the parent (can be null if the bone is the root)
  13416. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13417. */
  13418. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13419. /**
  13420. * Gets the local matrix
  13421. * @returns a matrix
  13422. */
  13423. getLocalMatrix(): Matrix;
  13424. /**
  13425. * Gets the base matrix (initial matrix which remains unchanged)
  13426. * @returns a matrix
  13427. */
  13428. getBaseMatrix(): Matrix;
  13429. /**
  13430. * Gets the rest pose matrix
  13431. * @returns a matrix
  13432. */
  13433. getRestPose(): Matrix;
  13434. /**
  13435. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13436. */
  13437. getWorldMatrix(): Matrix;
  13438. /**
  13439. * Sets the local matrix to rest pose matrix
  13440. */
  13441. returnToRest(): void;
  13442. /**
  13443. * Gets the inverse of the absolute transform matrix.
  13444. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13445. * @returns a matrix
  13446. */
  13447. getInvertedAbsoluteTransform(): Matrix;
  13448. /**
  13449. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13450. * @returns a matrix
  13451. */
  13452. getAbsoluteTransform(): Matrix;
  13453. /**
  13454. * Links with the given transform node.
  13455. * The local matrix of this bone is copied from the transform node every frame.
  13456. * @param transformNode defines the transform node to link to
  13457. */
  13458. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13459. /**
  13460. * Gets the node used to drive the bone's transformation
  13461. * @returns a transform node or null
  13462. */
  13463. getTransformNode(): Nullable<TransformNode>;
  13464. /** Gets or sets current position (in local space) */
  13465. position: Vector3;
  13466. /** Gets or sets current rotation (in local space) */
  13467. rotation: Vector3;
  13468. /** Gets or sets current rotation quaternion (in local space) */
  13469. rotationQuaternion: Quaternion;
  13470. /** Gets or sets current scaling (in local space) */
  13471. scaling: Vector3;
  13472. /**
  13473. * Gets the animation properties override
  13474. */
  13475. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13476. private _decompose;
  13477. private _compose;
  13478. /**
  13479. * Update the base and local matrices
  13480. * @param matrix defines the new base or local matrix
  13481. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13482. * @param updateLocalMatrix defines if the local matrix should be updated
  13483. */
  13484. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13485. /** @hidden */
  13486. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13487. /**
  13488. * Flag the bone as dirty (Forcing it to update everything)
  13489. */
  13490. markAsDirty(): void;
  13491. /** @hidden */
  13492. _markAsDirtyAndCompose(): void;
  13493. private _markAsDirtyAndDecompose;
  13494. /**
  13495. * Translate the bone in local or world space
  13496. * @param vec The amount to translate the bone
  13497. * @param space The space that the translation is in
  13498. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13499. */
  13500. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13501. /**
  13502. * Set the postion of the bone in local or world space
  13503. * @param position The position to set the bone
  13504. * @param space The space that the position is in
  13505. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13506. */
  13507. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13508. /**
  13509. * Set the absolute position of the bone (world space)
  13510. * @param position The position to set the bone
  13511. * @param mesh The mesh that this bone is attached to
  13512. */
  13513. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13514. /**
  13515. * Scale the bone on the x, y and z axes (in local space)
  13516. * @param x The amount to scale the bone on the x axis
  13517. * @param y The amount to scale the bone on the y axis
  13518. * @param z The amount to scale the bone on the z axis
  13519. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13520. */
  13521. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13522. /**
  13523. * Set the bone scaling in local space
  13524. * @param scale defines the scaling vector
  13525. */
  13526. setScale(scale: Vector3): void;
  13527. /**
  13528. * Gets the current scaling in local space
  13529. * @returns the current scaling vector
  13530. */
  13531. getScale(): Vector3;
  13532. /**
  13533. * Gets the current scaling in local space and stores it in a target vector
  13534. * @param result defines the target vector
  13535. */
  13536. getScaleToRef(result: Vector3): void;
  13537. /**
  13538. * Set the yaw, pitch, and roll of the bone in local or world space
  13539. * @param yaw The rotation of the bone on the y axis
  13540. * @param pitch The rotation of the bone on the x axis
  13541. * @param roll The rotation of the bone on the z axis
  13542. * @param space The space that the axes of rotation are in
  13543. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13544. */
  13545. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13546. /**
  13547. * Add a rotation to the bone on an axis in local or world space
  13548. * @param axis The axis to rotate the bone on
  13549. * @param amount The amount to rotate the bone
  13550. * @param space The space that the axis is in
  13551. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13552. */
  13553. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13554. /**
  13555. * Set the rotation of the bone to a particular axis angle in local or world space
  13556. * @param axis The axis to rotate the bone on
  13557. * @param angle The angle that the bone should be rotated to
  13558. * @param space The space that the axis is in
  13559. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13560. */
  13561. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13562. /**
  13563. * Set the euler rotation of the bone in local of world space
  13564. * @param rotation The euler rotation that the bone should be set to
  13565. * @param space The space that the rotation is in
  13566. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13567. */
  13568. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13569. /**
  13570. * Set the quaternion rotation of the bone in local of world space
  13571. * @param quat The quaternion rotation that the bone should be set to
  13572. * @param space The space that the rotation is in
  13573. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13574. */
  13575. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13576. /**
  13577. * Set the rotation matrix of the bone in local of world space
  13578. * @param rotMat The rotation matrix that the bone should be set to
  13579. * @param space The space that the rotation is in
  13580. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13581. */
  13582. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13583. private _rotateWithMatrix;
  13584. private _getNegativeRotationToRef;
  13585. /**
  13586. * Get the position of the bone in local or world space
  13587. * @param space The space that the returned position is in
  13588. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13589. * @returns The position of the bone
  13590. */
  13591. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13592. /**
  13593. * Copy the position of the bone to a vector3 in local or world space
  13594. * @param space The space that the returned position is in
  13595. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13596. * @param result The vector3 to copy the position to
  13597. */
  13598. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13599. /**
  13600. * Get the absolute position of the bone (world space)
  13601. * @param mesh The mesh that this bone is attached to
  13602. * @returns The absolute position of the bone
  13603. */
  13604. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13605. /**
  13606. * Copy the absolute position of the bone (world space) to the result param
  13607. * @param mesh The mesh that this bone is attached to
  13608. * @param result The vector3 to copy the absolute position to
  13609. */
  13610. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13611. /**
  13612. * Compute the absolute transforms of this bone and its children
  13613. */
  13614. computeAbsoluteTransforms(): void;
  13615. /**
  13616. * Get the world direction from an axis that is in the local space of the bone
  13617. * @param localAxis The local direction that is used to compute the world direction
  13618. * @param mesh The mesh that this bone is attached to
  13619. * @returns The world direction
  13620. */
  13621. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13622. /**
  13623. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13624. * @param localAxis The local direction that is used to compute the world direction
  13625. * @param mesh The mesh that this bone is attached to
  13626. * @param result The vector3 that the world direction will be copied to
  13627. */
  13628. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13629. /**
  13630. * Get the euler rotation of the bone in local or world space
  13631. * @param space The space that the rotation should be in
  13632. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13633. * @returns The euler rotation
  13634. */
  13635. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13636. /**
  13637. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13638. * @param space The space that the rotation should be in
  13639. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13640. * @param result The vector3 that the rotation should be copied to
  13641. */
  13642. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13643. /**
  13644. * Get the quaternion rotation of the bone in either local or world space
  13645. * @param space The space that the rotation should be in
  13646. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13647. * @returns The quaternion rotation
  13648. */
  13649. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13650. /**
  13651. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13652. * @param space The space that the rotation should be in
  13653. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13654. * @param result The quaternion that the rotation should be copied to
  13655. */
  13656. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13657. /**
  13658. * Get the rotation matrix of the bone in local or world space
  13659. * @param space The space that the rotation should be in
  13660. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13661. * @returns The rotation matrix
  13662. */
  13663. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13664. /**
  13665. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13666. * @param space The space that the rotation should be in
  13667. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13668. * @param result The quaternion that the rotation should be copied to
  13669. */
  13670. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13671. /**
  13672. * Get the world position of a point that is in the local space of the bone
  13673. * @param position The local position
  13674. * @param mesh The mesh that this bone is attached to
  13675. * @returns The world position
  13676. */
  13677. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13678. /**
  13679. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13680. * @param position The local position
  13681. * @param mesh The mesh that this bone is attached to
  13682. * @param result The vector3 that the world position should be copied to
  13683. */
  13684. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13685. /**
  13686. * Get the local position of a point that is in world space
  13687. * @param position The world position
  13688. * @param mesh The mesh that this bone is attached to
  13689. * @returns The local position
  13690. */
  13691. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13692. /**
  13693. * Get the local position of a point that is in world space and copy it to the result param
  13694. * @param position The world position
  13695. * @param mesh The mesh that this bone is attached to
  13696. * @param result The vector3 that the local position should be copied to
  13697. */
  13698. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13699. }
  13700. }
  13701. declare module BABYLON {
  13702. /**
  13703. * 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.
  13704. * @see https://doc.babylonjs.com/how_to/transformnode
  13705. */
  13706. export class TransformNode extends Node {
  13707. /**
  13708. * Object will not rotate to face the camera
  13709. */
  13710. static BILLBOARDMODE_NONE: number;
  13711. /**
  13712. * Object will rotate to face the camera but only on the x axis
  13713. */
  13714. static BILLBOARDMODE_X: number;
  13715. /**
  13716. * Object will rotate to face the camera but only on the y axis
  13717. */
  13718. static BILLBOARDMODE_Y: number;
  13719. /**
  13720. * Object will rotate to face the camera but only on the z axis
  13721. */
  13722. static BILLBOARDMODE_Z: number;
  13723. /**
  13724. * Object will rotate to face the camera
  13725. */
  13726. static BILLBOARDMODE_ALL: number;
  13727. /**
  13728. * Object will rotate to face the camera's position instead of orientation
  13729. */
  13730. static BILLBOARDMODE_USE_POSITION: number;
  13731. private _forward;
  13732. private _forwardInverted;
  13733. private _up;
  13734. private _right;
  13735. private _rightInverted;
  13736. private _position;
  13737. private _rotation;
  13738. private _rotationQuaternion;
  13739. protected _scaling: Vector3;
  13740. protected _isDirty: boolean;
  13741. private _transformToBoneReferal;
  13742. private _isAbsoluteSynced;
  13743. private _billboardMode;
  13744. /**
  13745. * Gets or sets the billboard mode. Default is 0.
  13746. *
  13747. * | Value | Type | Description |
  13748. * | --- | --- | --- |
  13749. * | 0 | BILLBOARDMODE_NONE | |
  13750. * | 1 | BILLBOARDMODE_X | |
  13751. * | 2 | BILLBOARDMODE_Y | |
  13752. * | 4 | BILLBOARDMODE_Z | |
  13753. * | 7 | BILLBOARDMODE_ALL | |
  13754. *
  13755. */
  13756. billboardMode: number;
  13757. private _preserveParentRotationForBillboard;
  13758. /**
  13759. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13760. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13761. */
  13762. preserveParentRotationForBillboard: boolean;
  13763. /**
  13764. * 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
  13765. */
  13766. scalingDeterminant: number;
  13767. private _infiniteDistance;
  13768. /**
  13769. * Gets or sets the distance of the object to max, often used by skybox
  13770. */
  13771. infiniteDistance: boolean;
  13772. /**
  13773. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13774. * By default the system will update normals to compensate
  13775. */
  13776. ignoreNonUniformScaling: boolean;
  13777. /**
  13778. * 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
  13779. */
  13780. reIntegrateRotationIntoRotationQuaternion: boolean;
  13781. /** @hidden */
  13782. _poseMatrix: Nullable<Matrix>;
  13783. /** @hidden */
  13784. _localMatrix: Matrix;
  13785. private _usePivotMatrix;
  13786. private _absolutePosition;
  13787. private _absoluteScaling;
  13788. private _absoluteRotationQuaternion;
  13789. private _pivotMatrix;
  13790. private _pivotMatrixInverse;
  13791. protected _postMultiplyPivotMatrix: boolean;
  13792. protected _isWorldMatrixFrozen: boolean;
  13793. /** @hidden */
  13794. _indexInSceneTransformNodesArray: number;
  13795. /**
  13796. * An event triggered after the world matrix is updated
  13797. */
  13798. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13799. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13800. /**
  13801. * Gets a string identifying the name of the class
  13802. * @returns "TransformNode" string
  13803. */
  13804. getClassName(): string;
  13805. /**
  13806. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13807. */
  13808. position: Vector3;
  13809. /**
  13810. * 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)).
  13811. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13812. */
  13813. rotation: Vector3;
  13814. /**
  13815. * 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)).
  13816. */
  13817. scaling: Vector3;
  13818. /**
  13819. * 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).
  13820. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13821. */
  13822. rotationQuaternion: Nullable<Quaternion>;
  13823. /**
  13824. * The forward direction of that transform in world space.
  13825. */
  13826. readonly forward: Vector3;
  13827. /**
  13828. * The up direction of that transform in world space.
  13829. */
  13830. readonly up: Vector3;
  13831. /**
  13832. * The right direction of that transform in world space.
  13833. */
  13834. readonly right: Vector3;
  13835. /**
  13836. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13837. * @param matrix the matrix to copy the pose from
  13838. * @returns this TransformNode.
  13839. */
  13840. updatePoseMatrix(matrix: Matrix): TransformNode;
  13841. /**
  13842. * Returns the mesh Pose matrix.
  13843. * @returns the pose matrix
  13844. */
  13845. getPoseMatrix(): Matrix;
  13846. /** @hidden */
  13847. _isSynchronized(): boolean;
  13848. /** @hidden */
  13849. _initCache(): void;
  13850. /**
  13851. * Flag the transform node as dirty (Forcing it to update everything)
  13852. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13853. * @returns this transform node
  13854. */
  13855. markAsDirty(property: string): TransformNode;
  13856. /**
  13857. * Returns the current mesh absolute position.
  13858. * Returns a Vector3.
  13859. */
  13860. readonly absolutePosition: Vector3;
  13861. /**
  13862. * Returns the current mesh absolute scaling.
  13863. * Returns a Vector3.
  13864. */
  13865. readonly absoluteScaling: Vector3;
  13866. /**
  13867. * Returns the current mesh absolute rotation.
  13868. * Returns a Quaternion.
  13869. */
  13870. readonly absoluteRotationQuaternion: Quaternion;
  13871. /**
  13872. * Sets a new matrix to apply before all other transformation
  13873. * @param matrix defines the transform matrix
  13874. * @returns the current TransformNode
  13875. */
  13876. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13877. /**
  13878. * Sets a new pivot matrix to the current node
  13879. * @param matrix defines the new pivot matrix to use
  13880. * @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
  13881. * @returns the current TransformNode
  13882. */
  13883. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13884. /**
  13885. * Returns the mesh pivot matrix.
  13886. * Default : Identity.
  13887. * @returns the matrix
  13888. */
  13889. getPivotMatrix(): Matrix;
  13890. /**
  13891. * Instantiate (when possible) or clone that node with its hierarchy
  13892. * @param newParent defines the new parent to use for the instance (or clone)
  13893. * @returns an instance (or a clone) of the current node with its hiearchy
  13894. */
  13895. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13896. /**
  13897. * Prevents the World matrix to be computed any longer
  13898. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13899. * @returns the TransformNode.
  13900. */
  13901. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13902. /**
  13903. * Allows back the World matrix computation.
  13904. * @returns the TransformNode.
  13905. */
  13906. unfreezeWorldMatrix(): this;
  13907. /**
  13908. * True if the World matrix has been frozen.
  13909. */
  13910. readonly isWorldMatrixFrozen: boolean;
  13911. /**
  13912. * Retuns the mesh absolute position in the World.
  13913. * @returns a Vector3.
  13914. */
  13915. getAbsolutePosition(): Vector3;
  13916. /**
  13917. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13918. * @param absolutePosition the absolute position to set
  13919. * @returns the TransformNode.
  13920. */
  13921. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13922. /**
  13923. * Sets the mesh position in its local space.
  13924. * @param vector3 the position to set in localspace
  13925. * @returns the TransformNode.
  13926. */
  13927. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13928. /**
  13929. * Returns the mesh position in the local space from the current World matrix values.
  13930. * @returns a new Vector3.
  13931. */
  13932. getPositionExpressedInLocalSpace(): Vector3;
  13933. /**
  13934. * Translates the mesh along the passed Vector3 in its local space.
  13935. * @param vector3 the distance to translate in localspace
  13936. * @returns the TransformNode.
  13937. */
  13938. locallyTranslate(vector3: Vector3): TransformNode;
  13939. private static _lookAtVectorCache;
  13940. /**
  13941. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13942. * @param targetPoint the position (must be in same space as current mesh) to look at
  13943. * @param yawCor optional yaw (y-axis) correction in radians
  13944. * @param pitchCor optional pitch (x-axis) correction in radians
  13945. * @param rollCor optional roll (z-axis) correction in radians
  13946. * @param space the choosen space of the target
  13947. * @returns the TransformNode.
  13948. */
  13949. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13950. /**
  13951. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13952. * This Vector3 is expressed in the World space.
  13953. * @param localAxis axis to rotate
  13954. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13955. */
  13956. getDirection(localAxis: Vector3): Vector3;
  13957. /**
  13958. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13959. * localAxis is expressed in the mesh local space.
  13960. * result is computed in the Wordl space from the mesh World matrix.
  13961. * @param localAxis axis to rotate
  13962. * @param result the resulting transformnode
  13963. * @returns this TransformNode.
  13964. */
  13965. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13966. /**
  13967. * Sets this transform node rotation to the given local axis.
  13968. * @param localAxis the axis in local space
  13969. * @param yawCor optional yaw (y-axis) correction in radians
  13970. * @param pitchCor optional pitch (x-axis) correction in radians
  13971. * @param rollCor optional roll (z-axis) correction in radians
  13972. * @returns this TransformNode
  13973. */
  13974. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13975. /**
  13976. * Sets a new pivot point to the current node
  13977. * @param point defines the new pivot point to use
  13978. * @param space defines if the point is in world or local space (local by default)
  13979. * @returns the current TransformNode
  13980. */
  13981. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13982. /**
  13983. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13984. * @returns the pivot point
  13985. */
  13986. getPivotPoint(): Vector3;
  13987. /**
  13988. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13989. * @param result the vector3 to store the result
  13990. * @returns this TransformNode.
  13991. */
  13992. getPivotPointToRef(result: Vector3): TransformNode;
  13993. /**
  13994. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13995. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13996. */
  13997. getAbsolutePivotPoint(): Vector3;
  13998. /**
  13999. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14000. * @param result vector3 to store the result
  14001. * @returns this TransformNode.
  14002. */
  14003. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14004. /**
  14005. * Defines the passed node as the parent of the current node.
  14006. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14007. * @see https://doc.babylonjs.com/how_to/parenting
  14008. * @param node the node ot set as the parent
  14009. * @returns this TransformNode.
  14010. */
  14011. setParent(node: Nullable<Node>): TransformNode;
  14012. private _nonUniformScaling;
  14013. /**
  14014. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14015. */
  14016. readonly nonUniformScaling: boolean;
  14017. /** @hidden */
  14018. _updateNonUniformScalingState(value: boolean): boolean;
  14019. /**
  14020. * Attach the current TransformNode to another TransformNode associated with a bone
  14021. * @param bone Bone affecting the TransformNode
  14022. * @param affectedTransformNode TransformNode associated with the bone
  14023. * @returns this object
  14024. */
  14025. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14026. /**
  14027. * Detach the transform node if its associated with a bone
  14028. * @returns this object
  14029. */
  14030. detachFromBone(): TransformNode;
  14031. private static _rotationAxisCache;
  14032. /**
  14033. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14034. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14035. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14036. * The passed axis is also normalized.
  14037. * @param axis the axis to rotate around
  14038. * @param amount the amount to rotate in radians
  14039. * @param space Space to rotate in (Default: local)
  14040. * @returns the TransformNode.
  14041. */
  14042. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14043. /**
  14044. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14045. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14046. * The passed axis is also normalized. .
  14047. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14048. * @param point the point to rotate around
  14049. * @param axis the axis to rotate around
  14050. * @param amount the amount to rotate in radians
  14051. * @returns the TransformNode
  14052. */
  14053. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14054. /**
  14055. * Translates the mesh along the axis vector for the passed distance in the given space.
  14056. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14057. * @param axis the axis to translate in
  14058. * @param distance the distance to translate
  14059. * @param space Space to rotate in (Default: local)
  14060. * @returns the TransformNode.
  14061. */
  14062. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14063. /**
  14064. * Adds a rotation step to the mesh current rotation.
  14065. * x, y, z are Euler angles expressed in radians.
  14066. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14067. * This means this rotation is made in the mesh local space only.
  14068. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14069. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14070. * ```javascript
  14071. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14072. * ```
  14073. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14074. * 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.
  14075. * @param x Rotation to add
  14076. * @param y Rotation to add
  14077. * @param z Rotation to add
  14078. * @returns the TransformNode.
  14079. */
  14080. addRotation(x: number, y: number, z: number): TransformNode;
  14081. /**
  14082. * @hidden
  14083. */
  14084. protected _getEffectiveParent(): Nullable<Node>;
  14085. /**
  14086. * Computes the world matrix of the node
  14087. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14088. * @returns the world matrix
  14089. */
  14090. computeWorldMatrix(force?: boolean): Matrix;
  14091. protected _afterComputeWorldMatrix(): void;
  14092. /**
  14093. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14094. * @param func callback function to add
  14095. *
  14096. * @returns the TransformNode.
  14097. */
  14098. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14099. /**
  14100. * Removes a registered callback function.
  14101. * @param func callback function to remove
  14102. * @returns the TransformNode.
  14103. */
  14104. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14105. /**
  14106. * Gets the position of the current mesh in camera space
  14107. * @param camera defines the camera to use
  14108. * @returns a position
  14109. */
  14110. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14111. /**
  14112. * Returns the distance from the mesh to the active camera
  14113. * @param camera defines the camera to use
  14114. * @returns the distance
  14115. */
  14116. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14117. /**
  14118. * Clone the current transform node
  14119. * @param name Name of the new clone
  14120. * @param newParent New parent for the clone
  14121. * @param doNotCloneChildren Do not clone children hierarchy
  14122. * @returns the new transform node
  14123. */
  14124. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14125. /**
  14126. * Serializes the objects information.
  14127. * @param currentSerializationObject defines the object to serialize in
  14128. * @returns the serialized object
  14129. */
  14130. serialize(currentSerializationObject?: any): any;
  14131. /**
  14132. * Returns a new TransformNode object parsed from the source provided.
  14133. * @param parsedTransformNode is the source.
  14134. * @param scene the scne the object belongs to
  14135. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14136. * @returns a new TransformNode object parsed from the source provided.
  14137. */
  14138. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14139. /**
  14140. * Get all child-transformNodes of this node
  14141. * @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
  14142. * @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
  14143. * @returns an array of TransformNode
  14144. */
  14145. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14146. /**
  14147. * Releases resources associated with this transform node.
  14148. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14149. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14150. */
  14151. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14152. /**
  14153. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14154. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14155. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14156. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14157. * @returns the current mesh
  14158. */
  14159. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14160. private _syncAbsoluteScalingAndRotation;
  14161. }
  14162. }
  14163. declare module BABYLON {
  14164. /**
  14165. * Defines the types of pose enabled controllers that are supported
  14166. */
  14167. export enum PoseEnabledControllerType {
  14168. /**
  14169. * HTC Vive
  14170. */
  14171. VIVE = 0,
  14172. /**
  14173. * Oculus Rift
  14174. */
  14175. OCULUS = 1,
  14176. /**
  14177. * Windows mixed reality
  14178. */
  14179. WINDOWS = 2,
  14180. /**
  14181. * Samsung gear VR
  14182. */
  14183. GEAR_VR = 3,
  14184. /**
  14185. * Google Daydream
  14186. */
  14187. DAYDREAM = 4,
  14188. /**
  14189. * Generic
  14190. */
  14191. GENERIC = 5
  14192. }
  14193. /**
  14194. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14195. */
  14196. export interface MutableGamepadButton {
  14197. /**
  14198. * Value of the button/trigger
  14199. */
  14200. value: number;
  14201. /**
  14202. * If the button/trigger is currently touched
  14203. */
  14204. touched: boolean;
  14205. /**
  14206. * If the button/trigger is currently pressed
  14207. */
  14208. pressed: boolean;
  14209. }
  14210. /**
  14211. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14212. * @hidden
  14213. */
  14214. export interface ExtendedGamepadButton extends GamepadButton {
  14215. /**
  14216. * If the button/trigger is currently pressed
  14217. */
  14218. readonly pressed: boolean;
  14219. /**
  14220. * If the button/trigger is currently touched
  14221. */
  14222. readonly touched: boolean;
  14223. /**
  14224. * Value of the button/trigger
  14225. */
  14226. readonly value: number;
  14227. }
  14228. /** @hidden */
  14229. export interface _GamePadFactory {
  14230. /**
  14231. * Returns wether or not the current gamepad can be created for this type of controller.
  14232. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14233. * @returns true if it can be created, otherwise false
  14234. */
  14235. canCreate(gamepadInfo: any): boolean;
  14236. /**
  14237. * Creates a new instance of the Gamepad.
  14238. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14239. * @returns the new gamepad instance
  14240. */
  14241. create(gamepadInfo: any): Gamepad;
  14242. }
  14243. /**
  14244. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14245. */
  14246. export class PoseEnabledControllerHelper {
  14247. /** @hidden */
  14248. static _ControllerFactories: _GamePadFactory[];
  14249. /** @hidden */
  14250. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14251. /**
  14252. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14253. * @param vrGamepad the gamepad to initialized
  14254. * @returns a vr controller of the type the gamepad identified as
  14255. */
  14256. static InitiateController(vrGamepad: any): Gamepad;
  14257. }
  14258. /**
  14259. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14260. */
  14261. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14262. /**
  14263. * If the controller is used in a webXR session
  14264. */
  14265. isXR: boolean;
  14266. private _deviceRoomPosition;
  14267. private _deviceRoomRotationQuaternion;
  14268. /**
  14269. * The device position in babylon space
  14270. */
  14271. devicePosition: Vector3;
  14272. /**
  14273. * The device rotation in babylon space
  14274. */
  14275. deviceRotationQuaternion: Quaternion;
  14276. /**
  14277. * The scale factor of the device in babylon space
  14278. */
  14279. deviceScaleFactor: number;
  14280. /**
  14281. * (Likely devicePosition should be used instead) The device position in its room space
  14282. */
  14283. position: Vector3;
  14284. /**
  14285. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14286. */
  14287. rotationQuaternion: Quaternion;
  14288. /**
  14289. * The type of controller (Eg. Windows mixed reality)
  14290. */
  14291. controllerType: PoseEnabledControllerType;
  14292. protected _calculatedPosition: Vector3;
  14293. private _calculatedRotation;
  14294. /**
  14295. * The raw pose from the device
  14296. */
  14297. rawPose: DevicePose;
  14298. private _trackPosition;
  14299. private _maxRotationDistFromHeadset;
  14300. private _draggedRoomRotation;
  14301. /**
  14302. * @hidden
  14303. */
  14304. _disableTrackPosition(fixedPosition: Vector3): void;
  14305. /**
  14306. * Internal, the mesh attached to the controller
  14307. * @hidden
  14308. */
  14309. _mesh: Nullable<AbstractMesh>;
  14310. private _poseControlledCamera;
  14311. private _leftHandSystemQuaternion;
  14312. /**
  14313. * Internal, matrix used to convert room space to babylon space
  14314. * @hidden
  14315. */
  14316. _deviceToWorld: Matrix;
  14317. /**
  14318. * Node to be used when casting a ray from the controller
  14319. * @hidden
  14320. */
  14321. _pointingPoseNode: Nullable<TransformNode>;
  14322. /**
  14323. * Name of the child mesh that can be used to cast a ray from the controller
  14324. */
  14325. static readonly POINTING_POSE: string;
  14326. /**
  14327. * Creates a new PoseEnabledController from a gamepad
  14328. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14329. */
  14330. constructor(browserGamepad: any);
  14331. private _workingMatrix;
  14332. /**
  14333. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14334. */
  14335. update(): void;
  14336. /**
  14337. * Updates only the pose device and mesh without doing any button event checking
  14338. */
  14339. protected _updatePoseAndMesh(): void;
  14340. /**
  14341. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14342. * @param poseData raw pose fromthe device
  14343. */
  14344. updateFromDevice(poseData: DevicePose): void;
  14345. /**
  14346. * @hidden
  14347. */
  14348. _meshAttachedObservable: Observable<AbstractMesh>;
  14349. /**
  14350. * Attaches a mesh to the controller
  14351. * @param mesh the mesh to be attached
  14352. */
  14353. attachToMesh(mesh: AbstractMesh): void;
  14354. /**
  14355. * Attaches the controllers mesh to a camera
  14356. * @param camera the camera the mesh should be attached to
  14357. */
  14358. attachToPoseControlledCamera(camera: TargetCamera): void;
  14359. /**
  14360. * Disposes of the controller
  14361. */
  14362. dispose(): void;
  14363. /**
  14364. * The mesh that is attached to the controller
  14365. */
  14366. readonly mesh: Nullable<AbstractMesh>;
  14367. /**
  14368. * Gets the ray of the controller in the direction the controller is pointing
  14369. * @param length the length the resulting ray should be
  14370. * @returns a ray in the direction the controller is pointing
  14371. */
  14372. getForwardRay(length?: number): Ray;
  14373. }
  14374. }
  14375. declare module BABYLON {
  14376. /**
  14377. * Defines the WebVRController object that represents controllers tracked in 3D space
  14378. */
  14379. export abstract class WebVRController extends PoseEnabledController {
  14380. /**
  14381. * Internal, the default controller model for the controller
  14382. */
  14383. protected _defaultModel: AbstractMesh;
  14384. /**
  14385. * Fired when the trigger state has changed
  14386. */
  14387. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14388. /**
  14389. * Fired when the main button state has changed
  14390. */
  14391. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14392. /**
  14393. * Fired when the secondary button state has changed
  14394. */
  14395. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14396. /**
  14397. * Fired when the pad state has changed
  14398. */
  14399. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14400. /**
  14401. * Fired when controllers stick values have changed
  14402. */
  14403. onPadValuesChangedObservable: Observable<StickValues>;
  14404. /**
  14405. * Array of button availible on the controller
  14406. */
  14407. protected _buttons: Array<MutableGamepadButton>;
  14408. private _onButtonStateChange;
  14409. /**
  14410. * Fired when a controller button's state has changed
  14411. * @param callback the callback containing the button that was modified
  14412. */
  14413. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14414. /**
  14415. * X and Y axis corresponding to the controllers joystick
  14416. */
  14417. pad: StickValues;
  14418. /**
  14419. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14420. */
  14421. hand: string;
  14422. /**
  14423. * The default controller model for the controller
  14424. */
  14425. readonly defaultModel: AbstractMesh;
  14426. /**
  14427. * Creates a new WebVRController from a gamepad
  14428. * @param vrGamepad the gamepad that the WebVRController should be created from
  14429. */
  14430. constructor(vrGamepad: any);
  14431. /**
  14432. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14433. */
  14434. update(): void;
  14435. /**
  14436. * Function to be called when a button is modified
  14437. */
  14438. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14439. /**
  14440. * Loads a mesh and attaches it to the controller
  14441. * @param scene the scene the mesh should be added to
  14442. * @param meshLoaded callback for when the mesh has been loaded
  14443. */
  14444. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14445. private _setButtonValue;
  14446. private _changes;
  14447. private _checkChanges;
  14448. /**
  14449. * Disposes of th webVRCOntroller
  14450. */
  14451. dispose(): void;
  14452. }
  14453. }
  14454. declare module BABYLON {
  14455. /**
  14456. * The HemisphericLight simulates the ambient environment light,
  14457. * so the passed direction is the light reflection direction, not the incoming direction.
  14458. */
  14459. export class HemisphericLight extends Light {
  14460. /**
  14461. * The groundColor is the light in the opposite direction to the one specified during creation.
  14462. * 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.
  14463. */
  14464. groundColor: Color3;
  14465. /**
  14466. * The light reflection direction, not the incoming direction.
  14467. */
  14468. direction: Vector3;
  14469. /**
  14470. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14471. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14472. * The HemisphericLight can't cast shadows.
  14473. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14474. * @param name The friendly name of the light
  14475. * @param direction The direction of the light reflection
  14476. * @param scene The scene the light belongs to
  14477. */
  14478. constructor(name: string, direction: Vector3, scene: Scene);
  14479. protected _buildUniformLayout(): void;
  14480. /**
  14481. * Returns the string "HemisphericLight".
  14482. * @return The class name
  14483. */
  14484. getClassName(): string;
  14485. /**
  14486. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14487. * Returns the updated direction.
  14488. * @param target The target the direction should point to
  14489. * @return The computed direction
  14490. */
  14491. setDirectionToTarget(target: Vector3): Vector3;
  14492. /**
  14493. * Returns the shadow generator associated to the light.
  14494. * @returns Always null for hemispheric lights because it does not support shadows.
  14495. */
  14496. getShadowGenerator(): Nullable<IShadowGenerator>;
  14497. /**
  14498. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14499. * @param effect The effect to update
  14500. * @param lightIndex The index of the light in the effect to update
  14501. * @returns The hemispheric light
  14502. */
  14503. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14504. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14505. /**
  14506. * Computes the world matrix of the node
  14507. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14508. * @param useWasUpdatedFlag defines a reserved property
  14509. * @returns the world matrix
  14510. */
  14511. computeWorldMatrix(): Matrix;
  14512. /**
  14513. * Returns the integer 3.
  14514. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14515. */
  14516. getTypeID(): number;
  14517. /**
  14518. * Prepares the list of defines specific to the light type.
  14519. * @param defines the list of defines
  14520. * @param lightIndex defines the index of the light for the effect
  14521. */
  14522. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14523. }
  14524. }
  14525. declare module BABYLON {
  14526. /** @hidden */
  14527. export var vrMultiviewToSingleviewPixelShader: {
  14528. name: string;
  14529. shader: string;
  14530. };
  14531. }
  14532. declare module BABYLON {
  14533. /**
  14534. * Renders to multiple views with a single draw call
  14535. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14536. */
  14537. export class MultiviewRenderTarget extends RenderTargetTexture {
  14538. /**
  14539. * Creates a multiview render target
  14540. * @param scene scene used with the render target
  14541. * @param size the size of the render target (used for each view)
  14542. */
  14543. constructor(scene: Scene, size?: number | {
  14544. width: number;
  14545. height: number;
  14546. } | {
  14547. ratio: number;
  14548. });
  14549. /**
  14550. * @hidden
  14551. * @param faceIndex the face index, if its a cube texture
  14552. */
  14553. _bindFrameBuffer(faceIndex?: number): void;
  14554. /**
  14555. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14556. * @returns the view count
  14557. */
  14558. getViewCount(): number;
  14559. }
  14560. }
  14561. declare module BABYLON {
  14562. /**
  14563. * Represents a camera frustum
  14564. */
  14565. export class Frustum {
  14566. /**
  14567. * Gets the planes representing the frustum
  14568. * @param transform matrix to be applied to the returned planes
  14569. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14570. */
  14571. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14572. /**
  14573. * Gets the near frustum plane transformed by the transform matrix
  14574. * @param transform transformation matrix to be applied to the resulting frustum plane
  14575. * @param frustumPlane the resuling frustum plane
  14576. */
  14577. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14578. /**
  14579. * Gets the far frustum plane transformed by the transform matrix
  14580. * @param transform transformation matrix to be applied to the resulting frustum plane
  14581. * @param frustumPlane the resuling frustum plane
  14582. */
  14583. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14584. /**
  14585. * Gets the left frustum plane transformed by the transform matrix
  14586. * @param transform transformation matrix to be applied to the resulting frustum plane
  14587. * @param frustumPlane the resuling frustum plane
  14588. */
  14589. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14590. /**
  14591. * Gets the right frustum plane transformed by the transform matrix
  14592. * @param transform transformation matrix to be applied to the resulting frustum plane
  14593. * @param frustumPlane the resuling frustum plane
  14594. */
  14595. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14596. /**
  14597. * Gets the top frustum plane transformed by the transform matrix
  14598. * @param transform transformation matrix to be applied to the resulting frustum plane
  14599. * @param frustumPlane the resuling frustum plane
  14600. */
  14601. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14602. /**
  14603. * Gets the bottom frustum plane transformed by the transform matrix
  14604. * @param transform transformation matrix to be applied to the resulting frustum plane
  14605. * @param frustumPlane the resuling frustum plane
  14606. */
  14607. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14608. /**
  14609. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14610. * @param transform transformation matrix to be applied to the resulting frustum planes
  14611. * @param frustumPlanes the resuling frustum planes
  14612. */
  14613. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14614. }
  14615. }
  14616. declare module BABYLON {
  14617. interface Engine {
  14618. /**
  14619. * Creates a new multiview render target
  14620. * @param width defines the width of the texture
  14621. * @param height defines the height of the texture
  14622. * @returns the created multiview texture
  14623. */
  14624. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14625. /**
  14626. * Binds a multiview framebuffer to be drawn to
  14627. * @param multiviewTexture texture to bind
  14628. */
  14629. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14630. }
  14631. interface Camera {
  14632. /**
  14633. * @hidden
  14634. * 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)
  14635. */
  14636. _useMultiviewToSingleView: boolean;
  14637. /**
  14638. * @hidden
  14639. * 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)
  14640. */
  14641. _multiviewTexture: Nullable<RenderTargetTexture>;
  14642. /**
  14643. * @hidden
  14644. * ensures the multiview texture of the camera exists and has the specified width/height
  14645. * @param width height to set on the multiview texture
  14646. * @param height width to set on the multiview texture
  14647. */
  14648. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14649. }
  14650. interface Scene {
  14651. /** @hidden */
  14652. _transformMatrixR: Matrix;
  14653. /** @hidden */
  14654. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14655. /** @hidden */
  14656. _createMultiviewUbo(): void;
  14657. /** @hidden */
  14658. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14659. /** @hidden */
  14660. _renderMultiviewToSingleView(camera: Camera): void;
  14661. }
  14662. }
  14663. declare module BABYLON {
  14664. /**
  14665. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14666. * This will not be used for webXR as it supports displaying texture arrays directly
  14667. */
  14668. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14669. /**
  14670. * Initializes a VRMultiviewToSingleview
  14671. * @param name name of the post process
  14672. * @param camera camera to be applied to
  14673. * @param scaleFactor scaling factor to the size of the output texture
  14674. */
  14675. constructor(name: string, camera: Camera, scaleFactor: number);
  14676. }
  14677. }
  14678. declare module BABYLON {
  14679. interface Engine {
  14680. /** @hidden */
  14681. _vrDisplay: any;
  14682. /** @hidden */
  14683. _vrSupported: boolean;
  14684. /** @hidden */
  14685. _oldSize: Size;
  14686. /** @hidden */
  14687. _oldHardwareScaleFactor: number;
  14688. /** @hidden */
  14689. _vrExclusivePointerMode: boolean;
  14690. /** @hidden */
  14691. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14692. /** @hidden */
  14693. _onVRDisplayPointerRestricted: () => void;
  14694. /** @hidden */
  14695. _onVRDisplayPointerUnrestricted: () => void;
  14696. /** @hidden */
  14697. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14698. /** @hidden */
  14699. _onVrDisplayDisconnect: Nullable<() => void>;
  14700. /** @hidden */
  14701. _onVrDisplayPresentChange: Nullable<() => void>;
  14702. /**
  14703. * Observable signaled when VR display mode changes
  14704. */
  14705. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14706. /**
  14707. * Observable signaled when VR request present is complete
  14708. */
  14709. onVRRequestPresentComplete: Observable<boolean>;
  14710. /**
  14711. * Observable signaled when VR request present starts
  14712. */
  14713. onVRRequestPresentStart: Observable<Engine>;
  14714. /**
  14715. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14716. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14717. */
  14718. isInVRExclusivePointerMode: boolean;
  14719. /**
  14720. * Gets a boolean indicating if a webVR device was detected
  14721. * @returns true if a webVR device was detected
  14722. */
  14723. isVRDevicePresent(): boolean;
  14724. /**
  14725. * Gets the current webVR device
  14726. * @returns the current webVR device (or null)
  14727. */
  14728. getVRDevice(): any;
  14729. /**
  14730. * Initializes a webVR display and starts listening to display change events
  14731. * The onVRDisplayChangedObservable will be notified upon these changes
  14732. * @returns A promise containing a VRDisplay and if vr is supported
  14733. */
  14734. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14735. /** @hidden */
  14736. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14737. /**
  14738. * Call this function to switch to webVR mode
  14739. * Will do nothing if webVR is not supported or if there is no webVR device
  14740. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14741. */
  14742. enableVR(): void;
  14743. /** @hidden */
  14744. _onVRFullScreenTriggered(): void;
  14745. }
  14746. }
  14747. declare module BABYLON {
  14748. /**
  14749. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14750. * IMPORTANT!! The data is right-hand data.
  14751. * @export
  14752. * @interface DevicePose
  14753. */
  14754. export interface DevicePose {
  14755. /**
  14756. * The position of the device, values in array are [x,y,z].
  14757. */
  14758. readonly position: Nullable<Float32Array>;
  14759. /**
  14760. * The linearVelocity of the device, values in array are [x,y,z].
  14761. */
  14762. readonly linearVelocity: Nullable<Float32Array>;
  14763. /**
  14764. * The linearAcceleration of the device, values in array are [x,y,z].
  14765. */
  14766. readonly linearAcceleration: Nullable<Float32Array>;
  14767. /**
  14768. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14769. */
  14770. readonly orientation: Nullable<Float32Array>;
  14771. /**
  14772. * The angularVelocity of the device, values in array are [x,y,z].
  14773. */
  14774. readonly angularVelocity: Nullable<Float32Array>;
  14775. /**
  14776. * The angularAcceleration of the device, values in array are [x,y,z].
  14777. */
  14778. readonly angularAcceleration: Nullable<Float32Array>;
  14779. }
  14780. /**
  14781. * Interface representing a pose controlled object in Babylon.
  14782. * A pose controlled object has both regular pose values as well as pose values
  14783. * from an external device such as a VR head mounted display
  14784. */
  14785. export interface PoseControlled {
  14786. /**
  14787. * The position of the object in babylon space.
  14788. */
  14789. position: Vector3;
  14790. /**
  14791. * The rotation quaternion of the object in babylon space.
  14792. */
  14793. rotationQuaternion: Quaternion;
  14794. /**
  14795. * The position of the device in babylon space.
  14796. */
  14797. devicePosition?: Vector3;
  14798. /**
  14799. * The rotation quaternion of the device in babylon space.
  14800. */
  14801. deviceRotationQuaternion: Quaternion;
  14802. /**
  14803. * The raw pose coming from the device.
  14804. */
  14805. rawPose: Nullable<DevicePose>;
  14806. /**
  14807. * The scale of the device to be used when translating from device space to babylon space.
  14808. */
  14809. deviceScaleFactor: number;
  14810. /**
  14811. * Updates the poseControlled values based on the input device pose.
  14812. * @param poseData the pose data to update the object with
  14813. */
  14814. updateFromDevice(poseData: DevicePose): void;
  14815. }
  14816. /**
  14817. * Set of options to customize the webVRCamera
  14818. */
  14819. export interface WebVROptions {
  14820. /**
  14821. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14822. */
  14823. trackPosition?: boolean;
  14824. /**
  14825. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14826. */
  14827. positionScale?: number;
  14828. /**
  14829. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14830. */
  14831. displayName?: string;
  14832. /**
  14833. * Should the native controller meshes be initialized. (default: true)
  14834. */
  14835. controllerMeshes?: boolean;
  14836. /**
  14837. * Creating a default HemiLight only on controllers. (default: true)
  14838. */
  14839. defaultLightingOnControllers?: boolean;
  14840. /**
  14841. * If you don't want to use the default VR button of the helper. (default: false)
  14842. */
  14843. useCustomVRButton?: boolean;
  14844. /**
  14845. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14846. */
  14847. customVRButton?: HTMLButtonElement;
  14848. /**
  14849. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14850. */
  14851. rayLength?: number;
  14852. /**
  14853. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14854. */
  14855. defaultHeight?: number;
  14856. /**
  14857. * If multiview should be used if availible (default: false)
  14858. */
  14859. useMultiview?: boolean;
  14860. }
  14861. /**
  14862. * This represents a WebVR camera.
  14863. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14864. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14865. */
  14866. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14867. private webVROptions;
  14868. /**
  14869. * @hidden
  14870. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14871. */
  14872. _vrDevice: any;
  14873. /**
  14874. * The rawPose of the vrDevice.
  14875. */
  14876. rawPose: Nullable<DevicePose>;
  14877. private _onVREnabled;
  14878. private _specsVersion;
  14879. private _attached;
  14880. private _frameData;
  14881. protected _descendants: Array<Node>;
  14882. private _deviceRoomPosition;
  14883. /** @hidden */
  14884. _deviceRoomRotationQuaternion: Quaternion;
  14885. private _standingMatrix;
  14886. /**
  14887. * Represents device position in babylon space.
  14888. */
  14889. devicePosition: Vector3;
  14890. /**
  14891. * Represents device rotation in babylon space.
  14892. */
  14893. deviceRotationQuaternion: Quaternion;
  14894. /**
  14895. * The scale of the device to be used when translating from device space to babylon space.
  14896. */
  14897. deviceScaleFactor: number;
  14898. private _deviceToWorld;
  14899. private _worldToDevice;
  14900. /**
  14901. * References to the webVR controllers for the vrDevice.
  14902. */
  14903. controllers: Array<WebVRController>;
  14904. /**
  14905. * Emits an event when a controller is attached.
  14906. */
  14907. onControllersAttachedObservable: Observable<WebVRController[]>;
  14908. /**
  14909. * Emits an event when a controller's mesh has been loaded;
  14910. */
  14911. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14912. /**
  14913. * Emits an event when the HMD's pose has been updated.
  14914. */
  14915. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14916. private _poseSet;
  14917. /**
  14918. * If the rig cameras be used as parent instead of this camera.
  14919. */
  14920. rigParenting: boolean;
  14921. private _lightOnControllers;
  14922. private _defaultHeight?;
  14923. /**
  14924. * Instantiates a WebVRFreeCamera.
  14925. * @param name The name of the WebVRFreeCamera
  14926. * @param position The starting anchor position for the camera
  14927. * @param scene The scene the camera belongs to
  14928. * @param webVROptions a set of customizable options for the webVRCamera
  14929. */
  14930. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14931. /**
  14932. * Gets the device distance from the ground in meters.
  14933. * @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.
  14934. */
  14935. deviceDistanceToRoomGround(): number;
  14936. /**
  14937. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14938. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14939. */
  14940. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14941. /**
  14942. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14943. * @returns A promise with a boolean set to if the standing matrix is supported.
  14944. */
  14945. useStandingMatrixAsync(): Promise<boolean>;
  14946. /**
  14947. * Disposes the camera
  14948. */
  14949. dispose(): void;
  14950. /**
  14951. * Gets a vrController by name.
  14952. * @param name The name of the controller to retreive
  14953. * @returns the controller matching the name specified or null if not found
  14954. */
  14955. getControllerByName(name: string): Nullable<WebVRController>;
  14956. private _leftController;
  14957. /**
  14958. * The controller corresponding to the users left hand.
  14959. */
  14960. readonly leftController: Nullable<WebVRController>;
  14961. private _rightController;
  14962. /**
  14963. * The controller corresponding to the users right hand.
  14964. */
  14965. readonly rightController: Nullable<WebVRController>;
  14966. /**
  14967. * Casts a ray forward from the vrCamera's gaze.
  14968. * @param length Length of the ray (default: 100)
  14969. * @returns the ray corresponding to the gaze
  14970. */
  14971. getForwardRay(length?: number): Ray;
  14972. /**
  14973. * @hidden
  14974. * Updates the camera based on device's frame data
  14975. */
  14976. _checkInputs(): void;
  14977. /**
  14978. * Updates the poseControlled values based on the input device pose.
  14979. * @param poseData Pose coming from the device
  14980. */
  14981. updateFromDevice(poseData: DevicePose): void;
  14982. private _htmlElementAttached;
  14983. private _detachIfAttached;
  14984. /**
  14985. * WebVR's attach control will start broadcasting frames to the device.
  14986. * Note that in certain browsers (chrome for example) this function must be called
  14987. * within a user-interaction callback. Example:
  14988. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14989. *
  14990. * @param element html element to attach the vrDevice to
  14991. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14992. */
  14993. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14994. /**
  14995. * Detaches the camera from the html element and disables VR
  14996. *
  14997. * @param element html element to detach from
  14998. */
  14999. detachControl(element: HTMLElement): void;
  15000. /**
  15001. * @returns the name of this class
  15002. */
  15003. getClassName(): string;
  15004. /**
  15005. * Calls resetPose on the vrDisplay
  15006. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15007. */
  15008. resetToCurrentRotation(): void;
  15009. /**
  15010. * @hidden
  15011. * Updates the rig cameras (left and right eye)
  15012. */
  15013. _updateRigCameras(): void;
  15014. private _workingVector;
  15015. private _oneVector;
  15016. private _workingMatrix;
  15017. private updateCacheCalled;
  15018. private _correctPositionIfNotTrackPosition;
  15019. /**
  15020. * @hidden
  15021. * Updates the cached values of the camera
  15022. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15023. */
  15024. _updateCache(ignoreParentClass?: boolean): void;
  15025. /**
  15026. * @hidden
  15027. * Get current device position in babylon world
  15028. */
  15029. _computeDevicePosition(): void;
  15030. /**
  15031. * Updates the current device position and rotation in the babylon world
  15032. */
  15033. update(): void;
  15034. /**
  15035. * @hidden
  15036. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15037. * @returns an identity matrix
  15038. */
  15039. _getViewMatrix(): Matrix;
  15040. private _tmpMatrix;
  15041. /**
  15042. * This function is called by the two RIG cameras.
  15043. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15044. * @hidden
  15045. */
  15046. _getWebVRViewMatrix(): Matrix;
  15047. /** @hidden */
  15048. _getWebVRProjectionMatrix(): Matrix;
  15049. private _onGamepadConnectedObserver;
  15050. private _onGamepadDisconnectedObserver;
  15051. private _updateCacheWhenTrackingDisabledObserver;
  15052. /**
  15053. * Initializes the controllers and their meshes
  15054. */
  15055. initControllers(): void;
  15056. }
  15057. }
  15058. declare module BABYLON {
  15059. /**
  15060. * Size options for a post process
  15061. */
  15062. export type PostProcessOptions = {
  15063. width: number;
  15064. height: number;
  15065. };
  15066. /**
  15067. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15068. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15069. */
  15070. export class PostProcess {
  15071. /** Name of the PostProcess. */
  15072. name: string;
  15073. /**
  15074. * Gets or sets the unique id of the post process
  15075. */
  15076. uniqueId: number;
  15077. /**
  15078. * Width of the texture to apply the post process on
  15079. */
  15080. width: number;
  15081. /**
  15082. * Height of the texture to apply the post process on
  15083. */
  15084. height: number;
  15085. /**
  15086. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15087. * @hidden
  15088. */
  15089. _outputTexture: Nullable<InternalTexture>;
  15090. /**
  15091. * Sampling mode used by the shader
  15092. * See https://doc.babylonjs.com/classes/3.1/texture
  15093. */
  15094. renderTargetSamplingMode: number;
  15095. /**
  15096. * Clear color to use when screen clearing
  15097. */
  15098. clearColor: Color4;
  15099. /**
  15100. * If the buffer needs to be cleared before applying the post process. (default: true)
  15101. * Should be set to false if shader will overwrite all previous pixels.
  15102. */
  15103. autoClear: boolean;
  15104. /**
  15105. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15106. */
  15107. alphaMode: number;
  15108. /**
  15109. * Sets the setAlphaBlendConstants of the babylon engine
  15110. */
  15111. alphaConstants: Color4;
  15112. /**
  15113. * Animations to be used for the post processing
  15114. */
  15115. animations: Animation[];
  15116. /**
  15117. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15118. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15119. */
  15120. enablePixelPerfectMode: boolean;
  15121. /**
  15122. * Force the postprocess to be applied without taking in account viewport
  15123. */
  15124. forceFullscreenViewport: boolean;
  15125. /**
  15126. * List of inspectable custom properties (used by the Inspector)
  15127. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15128. */
  15129. inspectableCustomProperties: IInspectable[];
  15130. /**
  15131. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15132. *
  15133. * | Value | Type | Description |
  15134. * | ----- | ----------------------------------- | ----------- |
  15135. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15136. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15137. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15138. *
  15139. */
  15140. scaleMode: number;
  15141. /**
  15142. * Force textures to be a power of two (default: false)
  15143. */
  15144. alwaysForcePOT: boolean;
  15145. private _samples;
  15146. /**
  15147. * Number of sample textures (default: 1)
  15148. */
  15149. samples: number;
  15150. /**
  15151. * Modify the scale of the post process to be the same as the viewport (default: false)
  15152. */
  15153. adaptScaleToCurrentViewport: boolean;
  15154. private _camera;
  15155. private _scene;
  15156. private _engine;
  15157. private _options;
  15158. private _reusable;
  15159. private _textureType;
  15160. /**
  15161. * Smart array of input and output textures for the post process.
  15162. * @hidden
  15163. */
  15164. _textures: SmartArray<InternalTexture>;
  15165. /**
  15166. * The index in _textures that corresponds to the output texture.
  15167. * @hidden
  15168. */
  15169. _currentRenderTextureInd: number;
  15170. private _effect;
  15171. private _samplers;
  15172. private _fragmentUrl;
  15173. private _vertexUrl;
  15174. private _parameters;
  15175. private _scaleRatio;
  15176. protected _indexParameters: any;
  15177. private _shareOutputWithPostProcess;
  15178. private _texelSize;
  15179. private _forcedOutputTexture;
  15180. /**
  15181. * Returns the fragment url or shader name used in the post process.
  15182. * @returns the fragment url or name in the shader store.
  15183. */
  15184. getEffectName(): string;
  15185. /**
  15186. * An event triggered when the postprocess is activated.
  15187. */
  15188. onActivateObservable: Observable<Camera>;
  15189. private _onActivateObserver;
  15190. /**
  15191. * A function that is added to the onActivateObservable
  15192. */
  15193. onActivate: Nullable<(camera: Camera) => void>;
  15194. /**
  15195. * An event triggered when the postprocess changes its size.
  15196. */
  15197. onSizeChangedObservable: Observable<PostProcess>;
  15198. private _onSizeChangedObserver;
  15199. /**
  15200. * A function that is added to the onSizeChangedObservable
  15201. */
  15202. onSizeChanged: (postProcess: PostProcess) => void;
  15203. /**
  15204. * An event triggered when the postprocess applies its effect.
  15205. */
  15206. onApplyObservable: Observable<Effect>;
  15207. private _onApplyObserver;
  15208. /**
  15209. * A function that is added to the onApplyObservable
  15210. */
  15211. onApply: (effect: Effect) => void;
  15212. /**
  15213. * An event triggered before rendering the postprocess
  15214. */
  15215. onBeforeRenderObservable: Observable<Effect>;
  15216. private _onBeforeRenderObserver;
  15217. /**
  15218. * A function that is added to the onBeforeRenderObservable
  15219. */
  15220. onBeforeRender: (effect: Effect) => void;
  15221. /**
  15222. * An event triggered after rendering the postprocess
  15223. */
  15224. onAfterRenderObservable: Observable<Effect>;
  15225. private _onAfterRenderObserver;
  15226. /**
  15227. * A function that is added to the onAfterRenderObservable
  15228. */
  15229. onAfterRender: (efect: Effect) => void;
  15230. /**
  15231. * 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
  15232. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15233. */
  15234. inputTexture: InternalTexture;
  15235. /**
  15236. * Gets the camera which post process is applied to.
  15237. * @returns The camera the post process is applied to.
  15238. */
  15239. getCamera(): Camera;
  15240. /**
  15241. * Gets the texel size of the postprocess.
  15242. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15243. */
  15244. readonly texelSize: Vector2;
  15245. /**
  15246. * Creates a new instance PostProcess
  15247. * @param name The name of the PostProcess.
  15248. * @param fragmentUrl The url of the fragment shader to be used.
  15249. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15250. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15251. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15252. * @param camera The camera to apply the render pass to.
  15253. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15254. * @param engine The engine which the post process will be applied. (default: current engine)
  15255. * @param reusable If the post process can be reused on the same frame. (default: false)
  15256. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15257. * @param textureType Type of textures used when performing the post process. (default: 0)
  15258. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15259. * @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
  15260. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15261. */
  15262. constructor(
  15263. /** Name of the PostProcess. */
  15264. 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);
  15265. /**
  15266. * Gets a string idenfifying the name of the class
  15267. * @returns "PostProcess" string
  15268. */
  15269. getClassName(): string;
  15270. /**
  15271. * Gets the engine which this post process belongs to.
  15272. * @returns The engine the post process was enabled with.
  15273. */
  15274. getEngine(): Engine;
  15275. /**
  15276. * The effect that is created when initializing the post process.
  15277. * @returns The created effect corresponding the the postprocess.
  15278. */
  15279. getEffect(): Effect;
  15280. /**
  15281. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15282. * @param postProcess The post process to share the output with.
  15283. * @returns This post process.
  15284. */
  15285. shareOutputWith(postProcess: PostProcess): PostProcess;
  15286. /**
  15287. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15288. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15289. */
  15290. useOwnOutput(): void;
  15291. /**
  15292. * Updates the effect with the current post process compile time values and recompiles the shader.
  15293. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15294. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15295. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15296. * @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
  15297. * @param onCompiled Called when the shader has been compiled.
  15298. * @param onError Called if there is an error when compiling a shader.
  15299. */
  15300. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15301. /**
  15302. * The post process is reusable if it can be used multiple times within one frame.
  15303. * @returns If the post process is reusable
  15304. */
  15305. isReusable(): boolean;
  15306. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15307. markTextureDirty(): void;
  15308. /**
  15309. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15310. * 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.
  15311. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15312. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15313. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15314. * @returns The target texture that was bound to be written to.
  15315. */
  15316. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15317. /**
  15318. * If the post process is supported.
  15319. */
  15320. readonly isSupported: boolean;
  15321. /**
  15322. * The aspect ratio of the output texture.
  15323. */
  15324. readonly aspectRatio: number;
  15325. /**
  15326. * Get a value indicating if the post-process is ready to be used
  15327. * @returns true if the post-process is ready (shader is compiled)
  15328. */
  15329. isReady(): boolean;
  15330. /**
  15331. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15332. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15333. */
  15334. apply(): Nullable<Effect>;
  15335. private _disposeTextures;
  15336. /**
  15337. * Disposes the post process.
  15338. * @param camera The camera to dispose the post process on.
  15339. */
  15340. dispose(camera?: Camera): void;
  15341. }
  15342. }
  15343. declare module BABYLON {
  15344. /** @hidden */
  15345. export var kernelBlurVaryingDeclaration: {
  15346. name: string;
  15347. shader: string;
  15348. };
  15349. }
  15350. declare module BABYLON {
  15351. /** @hidden */
  15352. export var kernelBlurFragment: {
  15353. name: string;
  15354. shader: string;
  15355. };
  15356. }
  15357. declare module BABYLON {
  15358. /** @hidden */
  15359. export var kernelBlurFragment2: {
  15360. name: string;
  15361. shader: string;
  15362. };
  15363. }
  15364. declare module BABYLON {
  15365. /** @hidden */
  15366. export var kernelBlurPixelShader: {
  15367. name: string;
  15368. shader: string;
  15369. };
  15370. }
  15371. declare module BABYLON {
  15372. /** @hidden */
  15373. export var kernelBlurVertex: {
  15374. name: string;
  15375. shader: string;
  15376. };
  15377. }
  15378. declare module BABYLON {
  15379. /** @hidden */
  15380. export var kernelBlurVertexShader: {
  15381. name: string;
  15382. shader: string;
  15383. };
  15384. }
  15385. declare module BABYLON {
  15386. /**
  15387. * The Blur Post Process which blurs an image based on a kernel and direction.
  15388. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15389. */
  15390. export class BlurPostProcess extends PostProcess {
  15391. /** The direction in which to blur the image. */
  15392. direction: Vector2;
  15393. private blockCompilation;
  15394. protected _kernel: number;
  15395. protected _idealKernel: number;
  15396. protected _packedFloat: boolean;
  15397. private _staticDefines;
  15398. /**
  15399. * Sets the length in pixels of the blur sample region
  15400. */
  15401. /**
  15402. * Gets the length in pixels of the blur sample region
  15403. */
  15404. kernel: number;
  15405. /**
  15406. * Sets wether or not the blur needs to unpack/repack floats
  15407. */
  15408. /**
  15409. * Gets wether or not the blur is unpacking/repacking floats
  15410. */
  15411. packedFloat: boolean;
  15412. /**
  15413. * Creates a new instance BlurPostProcess
  15414. * @param name The name of the effect.
  15415. * @param direction The direction in which to blur the image.
  15416. * @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.
  15417. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15418. * @param camera The camera to apply the render pass to.
  15419. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15420. * @param engine The engine which the post process will be applied. (default: current engine)
  15421. * @param reusable If the post process can be reused on the same frame. (default: false)
  15422. * @param textureType Type of textures used when performing the post process. (default: 0)
  15423. * @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)
  15424. */
  15425. constructor(name: string,
  15426. /** The direction in which to blur the image. */
  15427. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15428. /**
  15429. * Updates the effect with the current post process compile time values and recompiles the shader.
  15430. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15431. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15432. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15433. * @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
  15434. * @param onCompiled Called when the shader has been compiled.
  15435. * @param onError Called if there is an error when compiling a shader.
  15436. */
  15437. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15438. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15439. /**
  15440. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15441. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15442. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15443. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15444. * The gaps between physical kernels are compensated for in the weighting of the samples
  15445. * @param idealKernel Ideal blur kernel.
  15446. * @return Nearest best kernel.
  15447. */
  15448. protected _nearestBestKernel(idealKernel: number): number;
  15449. /**
  15450. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15451. * @param x The point on the Gaussian distribution to sample.
  15452. * @return the value of the Gaussian function at x.
  15453. */
  15454. protected _gaussianWeight(x: number): number;
  15455. /**
  15456. * Generates a string that can be used as a floating point number in GLSL.
  15457. * @param x Value to print.
  15458. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15459. * @return GLSL float string.
  15460. */
  15461. protected _glslFloat(x: number, decimalFigures?: number): string;
  15462. }
  15463. }
  15464. declare module BABYLON {
  15465. /**
  15466. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15467. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15468. * You can then easily use it as a reflectionTexture on a flat surface.
  15469. * In case the surface is not a plane, please consider relying on reflection probes.
  15470. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15471. */
  15472. export class MirrorTexture extends RenderTargetTexture {
  15473. private scene;
  15474. /**
  15475. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15476. * 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.
  15477. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15478. */
  15479. mirrorPlane: Plane;
  15480. /**
  15481. * Define the blur ratio used to blur the reflection if needed.
  15482. */
  15483. blurRatio: number;
  15484. /**
  15485. * Define the adaptive blur kernel used to blur the reflection if needed.
  15486. * This will autocompute the closest best match for the `blurKernel`
  15487. */
  15488. adaptiveBlurKernel: number;
  15489. /**
  15490. * Define the blur kernel used to blur the reflection if needed.
  15491. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15492. */
  15493. blurKernel: number;
  15494. /**
  15495. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15496. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15497. */
  15498. blurKernelX: number;
  15499. /**
  15500. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15501. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15502. */
  15503. blurKernelY: number;
  15504. private _autoComputeBlurKernel;
  15505. protected _onRatioRescale(): void;
  15506. private _updateGammaSpace;
  15507. private _imageProcessingConfigChangeObserver;
  15508. private _transformMatrix;
  15509. private _mirrorMatrix;
  15510. private _savedViewMatrix;
  15511. private _blurX;
  15512. private _blurY;
  15513. private _adaptiveBlurKernel;
  15514. private _blurKernelX;
  15515. private _blurKernelY;
  15516. private _blurRatio;
  15517. /**
  15518. * Instantiates a Mirror Texture.
  15519. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15520. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15521. * You can then easily use it as a reflectionTexture on a flat surface.
  15522. * In case the surface is not a plane, please consider relying on reflection probes.
  15523. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15524. * @param name
  15525. * @param size
  15526. * @param scene
  15527. * @param generateMipMaps
  15528. * @param type
  15529. * @param samplingMode
  15530. * @param generateDepthBuffer
  15531. */
  15532. constructor(name: string, size: number | {
  15533. width: number;
  15534. height: number;
  15535. } | {
  15536. ratio: number;
  15537. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15538. private _preparePostProcesses;
  15539. /**
  15540. * Clone the mirror texture.
  15541. * @returns the cloned texture
  15542. */
  15543. clone(): MirrorTexture;
  15544. /**
  15545. * Serialize the texture to a JSON representation you could use in Parse later on
  15546. * @returns the serialized JSON representation
  15547. */
  15548. serialize(): any;
  15549. /**
  15550. * Dispose the texture and release its associated resources.
  15551. */
  15552. dispose(): void;
  15553. }
  15554. }
  15555. declare module BABYLON {
  15556. /**
  15557. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15558. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15559. */
  15560. export class Texture extends BaseTexture {
  15561. /**
  15562. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15563. */
  15564. static SerializeBuffers: boolean;
  15565. /** @hidden */
  15566. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15567. /** @hidden */
  15568. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15569. /** @hidden */
  15570. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15571. /** nearest is mag = nearest and min = nearest and mip = linear */
  15572. static readonly NEAREST_SAMPLINGMODE: number;
  15573. /** nearest is mag = nearest and min = nearest and mip = linear */
  15574. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15575. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15576. static readonly BILINEAR_SAMPLINGMODE: number;
  15577. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15578. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15579. /** Trilinear is mag = linear and min = linear and mip = linear */
  15580. static readonly TRILINEAR_SAMPLINGMODE: number;
  15581. /** Trilinear is mag = linear and min = linear and mip = linear */
  15582. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15583. /** mag = nearest and min = nearest and mip = nearest */
  15584. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15585. /** mag = nearest and min = linear and mip = nearest */
  15586. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15587. /** mag = nearest and min = linear and mip = linear */
  15588. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15589. /** mag = nearest and min = linear and mip = none */
  15590. static readonly NEAREST_LINEAR: number;
  15591. /** mag = nearest and min = nearest and mip = none */
  15592. static readonly NEAREST_NEAREST: number;
  15593. /** mag = linear and min = nearest and mip = nearest */
  15594. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15595. /** mag = linear and min = nearest and mip = linear */
  15596. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15597. /** mag = linear and min = linear and mip = none */
  15598. static readonly LINEAR_LINEAR: number;
  15599. /** mag = linear and min = nearest and mip = none */
  15600. static readonly LINEAR_NEAREST: number;
  15601. /** Explicit coordinates mode */
  15602. static readonly EXPLICIT_MODE: number;
  15603. /** Spherical coordinates mode */
  15604. static readonly SPHERICAL_MODE: number;
  15605. /** Planar coordinates mode */
  15606. static readonly PLANAR_MODE: number;
  15607. /** Cubic coordinates mode */
  15608. static readonly CUBIC_MODE: number;
  15609. /** Projection coordinates mode */
  15610. static readonly PROJECTION_MODE: number;
  15611. /** Inverse Cubic coordinates mode */
  15612. static readonly SKYBOX_MODE: number;
  15613. /** Inverse Cubic coordinates mode */
  15614. static readonly INVCUBIC_MODE: number;
  15615. /** Equirectangular coordinates mode */
  15616. static readonly EQUIRECTANGULAR_MODE: number;
  15617. /** Equirectangular Fixed coordinates mode */
  15618. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15619. /** Equirectangular Fixed Mirrored coordinates mode */
  15620. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15621. /** Texture is not repeating outside of 0..1 UVs */
  15622. static readonly CLAMP_ADDRESSMODE: number;
  15623. /** Texture is repeating outside of 0..1 UVs */
  15624. static readonly WRAP_ADDRESSMODE: number;
  15625. /** Texture is repeating and mirrored */
  15626. static readonly MIRROR_ADDRESSMODE: number;
  15627. /**
  15628. * 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
  15629. */
  15630. static UseSerializedUrlIfAny: boolean;
  15631. /**
  15632. * Define the url of the texture.
  15633. */
  15634. url: Nullable<string>;
  15635. /**
  15636. * Define an offset on the texture to offset the u coordinates of the UVs
  15637. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15638. */
  15639. uOffset: number;
  15640. /**
  15641. * Define an offset on the texture to offset the v coordinates of the UVs
  15642. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15643. */
  15644. vOffset: number;
  15645. /**
  15646. * Define an offset on the texture to scale the u coordinates of the UVs
  15647. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15648. */
  15649. uScale: number;
  15650. /**
  15651. * Define an offset on the texture to scale the v coordinates of the UVs
  15652. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15653. */
  15654. vScale: number;
  15655. /**
  15656. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15657. * @see http://doc.babylonjs.com/how_to/more_materials
  15658. */
  15659. uAng: number;
  15660. /**
  15661. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15662. * @see http://doc.babylonjs.com/how_to/more_materials
  15663. */
  15664. vAng: number;
  15665. /**
  15666. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15667. * @see http://doc.babylonjs.com/how_to/more_materials
  15668. */
  15669. wAng: number;
  15670. /**
  15671. * Defines the center of rotation (U)
  15672. */
  15673. uRotationCenter: number;
  15674. /**
  15675. * Defines the center of rotation (V)
  15676. */
  15677. vRotationCenter: number;
  15678. /**
  15679. * Defines the center of rotation (W)
  15680. */
  15681. wRotationCenter: number;
  15682. /**
  15683. * Are mip maps generated for this texture or not.
  15684. */
  15685. readonly noMipmap: boolean;
  15686. /**
  15687. * List of inspectable custom properties (used by the Inspector)
  15688. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15689. */
  15690. inspectableCustomProperties: Nullable<IInspectable[]>;
  15691. private _noMipmap;
  15692. /** @hidden */
  15693. _invertY: boolean;
  15694. private _rowGenerationMatrix;
  15695. private _cachedTextureMatrix;
  15696. private _projectionModeMatrix;
  15697. private _t0;
  15698. private _t1;
  15699. private _t2;
  15700. private _cachedUOffset;
  15701. private _cachedVOffset;
  15702. private _cachedUScale;
  15703. private _cachedVScale;
  15704. private _cachedUAng;
  15705. private _cachedVAng;
  15706. private _cachedWAng;
  15707. private _cachedProjectionMatrixId;
  15708. private _cachedCoordinatesMode;
  15709. /** @hidden */
  15710. protected _initialSamplingMode: number;
  15711. /** @hidden */
  15712. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  15713. private _deleteBuffer;
  15714. protected _format: Nullable<number>;
  15715. private _delayedOnLoad;
  15716. private _delayedOnError;
  15717. /**
  15718. * Observable triggered once the texture has been loaded.
  15719. */
  15720. onLoadObservable: Observable<Texture>;
  15721. protected _isBlocking: boolean;
  15722. /**
  15723. * Is the texture preventing material to render while loading.
  15724. * If false, a default texture will be used instead of the loading one during the preparation step.
  15725. */
  15726. isBlocking: boolean;
  15727. /**
  15728. * Get the current sampling mode associated with the texture.
  15729. */
  15730. readonly samplingMode: number;
  15731. /**
  15732. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15733. */
  15734. readonly invertY: boolean;
  15735. /**
  15736. * Instantiates a new texture.
  15737. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15738. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15739. * @param url define the url of the picture to load as a texture
  15740. * @param scene define the scene or engine the texture will belong to
  15741. * @param noMipmap define if the texture will require mip maps or not
  15742. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15743. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15744. * @param onLoad define a callback triggered when the texture has been loaded
  15745. * @param onError define a callback triggered when an error occurred during the loading session
  15746. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15747. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15748. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15749. */
  15750. 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 | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15751. /**
  15752. * Update the url (and optional buffer) of this texture if url was null during construction.
  15753. * @param url the url of the texture
  15754. * @param buffer the buffer of the texture (defaults to null)
  15755. * @param onLoad callback called when the texture is loaded (defaults to null)
  15756. */
  15757. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15758. /**
  15759. * Finish the loading sequence of a texture flagged as delayed load.
  15760. * @hidden
  15761. */
  15762. delayLoad(): void;
  15763. private _prepareRowForTextureGeneration;
  15764. /**
  15765. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15766. * @returns the transform matrix of the texture.
  15767. */
  15768. getTextureMatrix(): Matrix;
  15769. /**
  15770. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15771. * @returns The reflection texture transform
  15772. */
  15773. getReflectionTextureMatrix(): Matrix;
  15774. /**
  15775. * Clones the texture.
  15776. * @returns the cloned texture
  15777. */
  15778. clone(): Texture;
  15779. /**
  15780. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15781. * @returns The JSON representation of the texture
  15782. */
  15783. serialize(): any;
  15784. /**
  15785. * Get the current class name of the texture useful for serialization or dynamic coding.
  15786. * @returns "Texture"
  15787. */
  15788. getClassName(): string;
  15789. /**
  15790. * Dispose the texture and release its associated resources.
  15791. */
  15792. dispose(): void;
  15793. /**
  15794. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15795. * @param parsedTexture Define the JSON representation of the texture
  15796. * @param scene Define the scene the parsed texture should be instantiated in
  15797. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15798. * @returns The parsed texture if successful
  15799. */
  15800. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15801. /**
  15802. * Creates a texture from its base 64 representation.
  15803. * @param data Define the base64 payload without the data: prefix
  15804. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15805. * @param scene Define the scene the texture should belong to
  15806. * @param noMipmap Forces the texture to not create mip map information if true
  15807. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15808. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15809. * @param onLoad define a callback triggered when the texture has been loaded
  15810. * @param onError define a callback triggered when an error occurred during the loading session
  15811. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15812. * @returns the created texture
  15813. */
  15814. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15815. /**
  15816. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15817. * @param data Define the base64 payload without the data: prefix
  15818. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15819. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15820. * @param scene Define the scene the texture should belong to
  15821. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15822. * @param noMipmap Forces the texture to not create mip map information if true
  15823. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15824. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15825. * @param onLoad define a callback triggered when the texture has been loaded
  15826. * @param onError define a callback triggered when an error occurred during the loading session
  15827. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15828. * @returns the created texture
  15829. */
  15830. 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;
  15831. }
  15832. }
  15833. declare module BABYLON {
  15834. /**
  15835. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15836. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15837. */
  15838. export class PostProcessManager {
  15839. private _scene;
  15840. private _indexBuffer;
  15841. private _vertexBuffers;
  15842. /**
  15843. * Creates a new instance PostProcess
  15844. * @param scene The scene that the post process is associated with.
  15845. */
  15846. constructor(scene: Scene);
  15847. private _prepareBuffers;
  15848. private _buildIndexBuffer;
  15849. /**
  15850. * Rebuilds the vertex buffers of the manager.
  15851. * @hidden
  15852. */
  15853. _rebuild(): void;
  15854. /**
  15855. * Prepares a frame to be run through a post process.
  15856. * @param sourceTexture The input texture to the post procesess. (default: null)
  15857. * @param postProcesses An array of post processes to be run. (default: null)
  15858. * @returns True if the post processes were able to be run.
  15859. * @hidden
  15860. */
  15861. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15862. /**
  15863. * Manually render a set of post processes to a texture.
  15864. * @param postProcesses An array of post processes to be run.
  15865. * @param targetTexture The target texture to render to.
  15866. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15867. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15868. * @param lodLevel defines which lod of the texture to render to
  15869. */
  15870. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15871. /**
  15872. * Finalize the result of the output of the postprocesses.
  15873. * @param doNotPresent If true the result will not be displayed to the screen.
  15874. * @param targetTexture The target texture to render to.
  15875. * @param faceIndex The index of the face to bind the target texture to.
  15876. * @param postProcesses The array of post processes to render.
  15877. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15878. * @hidden
  15879. */
  15880. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15881. /**
  15882. * Disposes of the post process manager.
  15883. */
  15884. dispose(): void;
  15885. }
  15886. }
  15887. declare module BABYLON {
  15888. /** Interface used by value gradients (color, factor, ...) */
  15889. export interface IValueGradient {
  15890. /**
  15891. * Gets or sets the gradient value (between 0 and 1)
  15892. */
  15893. gradient: number;
  15894. }
  15895. /** Class used to store color4 gradient */
  15896. export class ColorGradient implements IValueGradient {
  15897. /**
  15898. * Gets or sets the gradient value (between 0 and 1)
  15899. */
  15900. gradient: number;
  15901. /**
  15902. * Gets or sets first associated color
  15903. */
  15904. color1: Color4;
  15905. /**
  15906. * Gets or sets second associated color
  15907. */
  15908. color2?: Color4;
  15909. /**
  15910. * Will get a color picked randomly between color1 and color2.
  15911. * If color2 is undefined then color1 will be used
  15912. * @param result defines the target Color4 to store the result in
  15913. */
  15914. getColorToRef(result: Color4): void;
  15915. }
  15916. /** Class used to store color 3 gradient */
  15917. export class Color3Gradient implements IValueGradient {
  15918. /**
  15919. * Gets or sets the gradient value (between 0 and 1)
  15920. */
  15921. gradient: number;
  15922. /**
  15923. * Gets or sets the associated color
  15924. */
  15925. color: Color3;
  15926. }
  15927. /** Class used to store factor gradient */
  15928. export class FactorGradient implements IValueGradient {
  15929. /**
  15930. * Gets or sets the gradient value (between 0 and 1)
  15931. */
  15932. gradient: number;
  15933. /**
  15934. * Gets or sets first associated factor
  15935. */
  15936. factor1: number;
  15937. /**
  15938. * Gets or sets second associated factor
  15939. */
  15940. factor2?: number;
  15941. /**
  15942. * Will get a number picked randomly between factor1 and factor2.
  15943. * If factor2 is undefined then factor1 will be used
  15944. * @returns the picked number
  15945. */
  15946. getFactor(): number;
  15947. }
  15948. /**
  15949. * Helper used to simplify some generic gradient tasks
  15950. */
  15951. export class GradientHelper {
  15952. /**
  15953. * Gets the current gradient from an array of IValueGradient
  15954. * @param ratio defines the current ratio to get
  15955. * @param gradients defines the array of IValueGradient
  15956. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15957. */
  15958. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15959. }
  15960. }
  15961. declare module BABYLON {
  15962. /**
  15963. * A class extending Texture allowing drawing on a texture
  15964. * @see http://doc.babylonjs.com/how_to/dynamictexture
  15965. */
  15966. export class DynamicTexture extends Texture {
  15967. private _generateMipMaps;
  15968. private _canvas;
  15969. private _context;
  15970. private _engine;
  15971. /**
  15972. * Creates a DynamicTexture
  15973. * @param name defines the name of the texture
  15974. * @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
  15975. * @param scene defines the scene where you want the texture
  15976. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  15977. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  15978. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  15979. */
  15980. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  15981. /**
  15982. * Get the current class name of the texture useful for serialization or dynamic coding.
  15983. * @returns "DynamicTexture"
  15984. */
  15985. getClassName(): string;
  15986. /**
  15987. * Gets the current state of canRescale
  15988. */
  15989. readonly canRescale: boolean;
  15990. private _recreate;
  15991. /**
  15992. * Scales the texture
  15993. * @param ratio the scale factor to apply to both width and height
  15994. */
  15995. scale(ratio: number): void;
  15996. /**
  15997. * Resizes the texture
  15998. * @param width the new width
  15999. * @param height the new height
  16000. */
  16001. scaleTo(width: number, height: number): void;
  16002. /**
  16003. * Gets the context of the canvas used by the texture
  16004. * @returns the canvas context of the dynamic texture
  16005. */
  16006. getContext(): CanvasRenderingContext2D;
  16007. /**
  16008. * Clears the texture
  16009. */
  16010. clear(): void;
  16011. /**
  16012. * Updates the texture
  16013. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16014. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16015. */
  16016. update(invertY?: boolean, premulAlpha?: boolean): void;
  16017. /**
  16018. * Draws text onto the texture
  16019. * @param text defines the text to be drawn
  16020. * @param x defines the placement of the text from the left
  16021. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16022. * @param font defines the font to be used with font-style, font-size, font-name
  16023. * @param color defines the color used for the text
  16024. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16025. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16026. * @param update defines whether texture is immediately update (default is true)
  16027. */
  16028. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16029. /**
  16030. * Clones the texture
  16031. * @returns the clone of the texture.
  16032. */
  16033. clone(): DynamicTexture;
  16034. /**
  16035. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16036. * @returns a serialized dynamic texture object
  16037. */
  16038. serialize(): any;
  16039. /** @hidden */
  16040. _rebuild(): void;
  16041. }
  16042. }
  16043. declare module BABYLON {
  16044. interface AbstractScene {
  16045. /**
  16046. * The list of procedural textures added to the scene
  16047. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16048. */
  16049. proceduralTextures: Array<ProceduralTexture>;
  16050. }
  16051. /**
  16052. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16053. * in a given scene.
  16054. */
  16055. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16056. /**
  16057. * The component name helpfull to identify the component in the list of scene components.
  16058. */
  16059. readonly name: string;
  16060. /**
  16061. * The scene the component belongs to.
  16062. */
  16063. scene: Scene;
  16064. /**
  16065. * Creates a new instance of the component for the given scene
  16066. * @param scene Defines the scene to register the component in
  16067. */
  16068. constructor(scene: Scene);
  16069. /**
  16070. * Registers the component in a given scene
  16071. */
  16072. register(): void;
  16073. /**
  16074. * Rebuilds the elements related to this component in case of
  16075. * context lost for instance.
  16076. */
  16077. rebuild(): void;
  16078. /**
  16079. * Disposes the component and the associated ressources.
  16080. */
  16081. dispose(): void;
  16082. private _beforeClear;
  16083. }
  16084. }
  16085. declare module BABYLON {
  16086. interface Engine {
  16087. /**
  16088. * Creates a new render target cube texture
  16089. * @param size defines the size of the texture
  16090. * @param options defines the options used to create the texture
  16091. * @returns a new render target cube texture stored in an InternalTexture
  16092. */
  16093. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16094. }
  16095. }
  16096. declare module BABYLON {
  16097. /** @hidden */
  16098. export var proceduralVertexShader: {
  16099. name: string;
  16100. shader: string;
  16101. };
  16102. }
  16103. declare module BABYLON {
  16104. /**
  16105. * 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.
  16106. * This is the base class of any Procedural texture and contains most of the shareable code.
  16107. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16108. */
  16109. export class ProceduralTexture extends Texture {
  16110. isCube: boolean;
  16111. /**
  16112. * Define if the texture is enabled or not (disabled texture will not render)
  16113. */
  16114. isEnabled: boolean;
  16115. /**
  16116. * Define if the texture must be cleared before rendering (default is true)
  16117. */
  16118. autoClear: boolean;
  16119. /**
  16120. * Callback called when the texture is generated
  16121. */
  16122. onGenerated: () => void;
  16123. /**
  16124. * Event raised when the texture is generated
  16125. */
  16126. onGeneratedObservable: Observable<ProceduralTexture>;
  16127. /** @hidden */
  16128. _generateMipMaps: boolean;
  16129. /** @hidden **/
  16130. _effect: Effect;
  16131. /** @hidden */
  16132. _textures: {
  16133. [key: string]: Texture;
  16134. };
  16135. private _size;
  16136. private _currentRefreshId;
  16137. private _refreshRate;
  16138. private _vertexBuffers;
  16139. private _indexBuffer;
  16140. private _uniforms;
  16141. private _samplers;
  16142. private _fragment;
  16143. private _floats;
  16144. private _ints;
  16145. private _floatsArrays;
  16146. private _colors3;
  16147. private _colors4;
  16148. private _vectors2;
  16149. private _vectors3;
  16150. private _matrices;
  16151. private _fallbackTexture;
  16152. private _fallbackTextureUsed;
  16153. private _engine;
  16154. private _cachedDefines;
  16155. private _contentUpdateId;
  16156. private _contentData;
  16157. /**
  16158. * Instantiates a new procedural texture.
  16159. * 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.
  16160. * This is the base class of any Procedural texture and contains most of the shareable code.
  16161. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16162. * @param name Define the name of the texture
  16163. * @param size Define the size of the texture to create
  16164. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16165. * @param scene Define the scene the texture belongs to
  16166. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16167. * @param generateMipMaps Define if the texture should creates mip maps or not
  16168. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16169. */
  16170. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16171. /**
  16172. * The effect that is created when initializing the post process.
  16173. * @returns The created effect corresponding the the postprocess.
  16174. */
  16175. getEffect(): Effect;
  16176. /**
  16177. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16178. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16179. */
  16180. getContent(): Nullable<ArrayBufferView>;
  16181. private _createIndexBuffer;
  16182. /** @hidden */
  16183. _rebuild(): void;
  16184. /**
  16185. * Resets the texture in order to recreate its associated resources.
  16186. * This can be called in case of context loss
  16187. */
  16188. reset(): void;
  16189. protected _getDefines(): string;
  16190. /**
  16191. * Is the texture ready to be used ? (rendered at least once)
  16192. * @returns true if ready, otherwise, false.
  16193. */
  16194. isReady(): boolean;
  16195. /**
  16196. * Resets the refresh counter of the texture and start bak from scratch.
  16197. * Could be useful to regenerate the texture if it is setup to render only once.
  16198. */
  16199. resetRefreshCounter(): void;
  16200. /**
  16201. * Set the fragment shader to use in order to render the texture.
  16202. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16203. */
  16204. setFragment(fragment: any): void;
  16205. /**
  16206. * Define the refresh rate of the texture or the rendering frequency.
  16207. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16208. */
  16209. refreshRate: number;
  16210. /** @hidden */
  16211. _shouldRender(): boolean;
  16212. /**
  16213. * Get the size the texture is rendering at.
  16214. * @returns the size (texture is always squared)
  16215. */
  16216. getRenderSize(): number;
  16217. /**
  16218. * Resize the texture to new value.
  16219. * @param size Define the new size the texture should have
  16220. * @param generateMipMaps Define whether the new texture should create mip maps
  16221. */
  16222. resize(size: number, generateMipMaps: boolean): void;
  16223. private _checkUniform;
  16224. /**
  16225. * Set a texture in the shader program used to render.
  16226. * @param name Define the name of the uniform samplers as defined in the shader
  16227. * @param texture Define the texture to bind to this sampler
  16228. * @return the texture itself allowing "fluent" like uniform updates
  16229. */
  16230. setTexture(name: string, texture: Texture): ProceduralTexture;
  16231. /**
  16232. * Set a float in the shader.
  16233. * @param name Define the name of the uniform as defined in the shader
  16234. * @param value Define the value to give to the uniform
  16235. * @return the texture itself allowing "fluent" like uniform updates
  16236. */
  16237. setFloat(name: string, value: number): ProceduralTexture;
  16238. /**
  16239. * Set a int in the shader.
  16240. * @param name Define the name of the uniform as defined in the shader
  16241. * @param value Define the value to give to the uniform
  16242. * @return the texture itself allowing "fluent" like uniform updates
  16243. */
  16244. setInt(name: string, value: number): ProceduralTexture;
  16245. /**
  16246. * Set an array of floats in the shader.
  16247. * @param name Define the name of the uniform as defined in the shader
  16248. * @param value Define the value to give to the uniform
  16249. * @return the texture itself allowing "fluent" like uniform updates
  16250. */
  16251. setFloats(name: string, value: number[]): ProceduralTexture;
  16252. /**
  16253. * Set a vec3 in the shader from a Color3.
  16254. * @param name Define the name of the uniform as defined in the shader
  16255. * @param value Define the value to give to the uniform
  16256. * @return the texture itself allowing "fluent" like uniform updates
  16257. */
  16258. setColor3(name: string, value: Color3): ProceduralTexture;
  16259. /**
  16260. * Set a vec4 in the shader from a Color4.
  16261. * @param name Define the name of the uniform as defined in the shader
  16262. * @param value Define the value to give to the uniform
  16263. * @return the texture itself allowing "fluent" like uniform updates
  16264. */
  16265. setColor4(name: string, value: Color4): ProceduralTexture;
  16266. /**
  16267. * Set a vec2 in the shader from a Vector2.
  16268. * @param name Define the name of the uniform as defined in the shader
  16269. * @param value Define the value to give to the uniform
  16270. * @return the texture itself allowing "fluent" like uniform updates
  16271. */
  16272. setVector2(name: string, value: Vector2): ProceduralTexture;
  16273. /**
  16274. * Set a vec3 in the shader from a Vector3.
  16275. * @param name Define the name of the uniform as defined in the shader
  16276. * @param value Define the value to give to the uniform
  16277. * @return the texture itself allowing "fluent" like uniform updates
  16278. */
  16279. setVector3(name: string, value: Vector3): ProceduralTexture;
  16280. /**
  16281. * Set a mat4 in the shader from a MAtrix.
  16282. * @param name Define the name of the uniform as defined in the shader
  16283. * @param value Define the value to give to the uniform
  16284. * @return the texture itself allowing "fluent" like uniform updates
  16285. */
  16286. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16287. /**
  16288. * Render the texture to its associated render target.
  16289. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16290. */
  16291. render(useCameraPostProcess?: boolean): void;
  16292. /**
  16293. * Clone the texture.
  16294. * @returns the cloned texture
  16295. */
  16296. clone(): ProceduralTexture;
  16297. /**
  16298. * Dispose the texture and release its asoociated resources.
  16299. */
  16300. dispose(): void;
  16301. }
  16302. }
  16303. declare module BABYLON {
  16304. /**
  16305. * This represents the base class for particle system in Babylon.
  16306. * 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.
  16307. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16308. * @example https://doc.babylonjs.com/babylon101/particles
  16309. */
  16310. export class BaseParticleSystem {
  16311. /**
  16312. * Source color is added to the destination color without alpha affecting the result
  16313. */
  16314. static BLENDMODE_ONEONE: number;
  16315. /**
  16316. * Blend current color and particle color using particle’s alpha
  16317. */
  16318. static BLENDMODE_STANDARD: number;
  16319. /**
  16320. * Add current color and particle color multiplied by particle’s alpha
  16321. */
  16322. static BLENDMODE_ADD: number;
  16323. /**
  16324. * Multiply current color with particle color
  16325. */
  16326. static BLENDMODE_MULTIPLY: number;
  16327. /**
  16328. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16329. */
  16330. static BLENDMODE_MULTIPLYADD: number;
  16331. /**
  16332. * List of animations used by the particle system.
  16333. */
  16334. animations: Animation[];
  16335. /**
  16336. * The id of the Particle system.
  16337. */
  16338. id: string;
  16339. /**
  16340. * The friendly name of the Particle system.
  16341. */
  16342. name: string;
  16343. /**
  16344. * The rendering group used by the Particle system to chose when to render.
  16345. */
  16346. renderingGroupId: number;
  16347. /**
  16348. * The emitter represents the Mesh or position we are attaching the particle system to.
  16349. */
  16350. emitter: Nullable<AbstractMesh | Vector3>;
  16351. /**
  16352. * The maximum number of particles to emit per frame
  16353. */
  16354. emitRate: number;
  16355. /**
  16356. * If you want to launch only a few particles at once, that can be done, as well.
  16357. */
  16358. manualEmitCount: number;
  16359. /**
  16360. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16361. */
  16362. updateSpeed: number;
  16363. /**
  16364. * The amount of time the particle system is running (depends of the overall update speed).
  16365. */
  16366. targetStopDuration: number;
  16367. /**
  16368. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16369. */
  16370. disposeOnStop: boolean;
  16371. /**
  16372. * Minimum power of emitting particles.
  16373. */
  16374. minEmitPower: number;
  16375. /**
  16376. * Maximum power of emitting particles.
  16377. */
  16378. maxEmitPower: number;
  16379. /**
  16380. * Minimum life time of emitting particles.
  16381. */
  16382. minLifeTime: number;
  16383. /**
  16384. * Maximum life time of emitting particles.
  16385. */
  16386. maxLifeTime: number;
  16387. /**
  16388. * Minimum Size of emitting particles.
  16389. */
  16390. minSize: number;
  16391. /**
  16392. * Maximum Size of emitting particles.
  16393. */
  16394. maxSize: number;
  16395. /**
  16396. * Minimum scale of emitting particles on X axis.
  16397. */
  16398. minScaleX: number;
  16399. /**
  16400. * Maximum scale of emitting particles on X axis.
  16401. */
  16402. maxScaleX: number;
  16403. /**
  16404. * Minimum scale of emitting particles on Y axis.
  16405. */
  16406. minScaleY: number;
  16407. /**
  16408. * Maximum scale of emitting particles on Y axis.
  16409. */
  16410. maxScaleY: number;
  16411. /**
  16412. * Gets or sets the minimal initial rotation in radians.
  16413. */
  16414. minInitialRotation: number;
  16415. /**
  16416. * Gets or sets the maximal initial rotation in radians.
  16417. */
  16418. maxInitialRotation: number;
  16419. /**
  16420. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16421. */
  16422. minAngularSpeed: number;
  16423. /**
  16424. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16425. */
  16426. maxAngularSpeed: number;
  16427. /**
  16428. * The texture used to render each particle. (this can be a spritesheet)
  16429. */
  16430. particleTexture: Nullable<Texture>;
  16431. /**
  16432. * The layer mask we are rendering the particles through.
  16433. */
  16434. layerMask: number;
  16435. /**
  16436. * This can help using your own shader to render the particle system.
  16437. * The according effect will be created
  16438. */
  16439. customShader: any;
  16440. /**
  16441. * By default particle system starts as soon as they are created. This prevents the
  16442. * automatic start to happen and let you decide when to start emitting particles.
  16443. */
  16444. preventAutoStart: boolean;
  16445. private _noiseTexture;
  16446. /**
  16447. * Gets or sets a texture used to add random noise to particle positions
  16448. */
  16449. noiseTexture: Nullable<ProceduralTexture>;
  16450. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16451. noiseStrength: Vector3;
  16452. /**
  16453. * Callback triggered when the particle animation is ending.
  16454. */
  16455. onAnimationEnd: Nullable<() => void>;
  16456. /**
  16457. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16458. */
  16459. blendMode: number;
  16460. /**
  16461. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16462. * to override the particles.
  16463. */
  16464. forceDepthWrite: boolean;
  16465. /** 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 */
  16466. preWarmCycles: number;
  16467. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16468. preWarmStepOffset: number;
  16469. /**
  16470. * 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)
  16471. */
  16472. spriteCellChangeSpeed: number;
  16473. /**
  16474. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16475. */
  16476. startSpriteCellID: number;
  16477. /**
  16478. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16479. */
  16480. endSpriteCellID: number;
  16481. /**
  16482. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16483. */
  16484. spriteCellWidth: number;
  16485. /**
  16486. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16487. */
  16488. spriteCellHeight: number;
  16489. /**
  16490. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16491. */
  16492. spriteRandomStartCell: boolean;
  16493. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16494. translationPivot: Vector2;
  16495. /** @hidden */
  16496. protected _isAnimationSheetEnabled: boolean;
  16497. /**
  16498. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16499. */
  16500. beginAnimationOnStart: boolean;
  16501. /**
  16502. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16503. */
  16504. beginAnimationFrom: number;
  16505. /**
  16506. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16507. */
  16508. beginAnimationTo: number;
  16509. /**
  16510. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16511. */
  16512. beginAnimationLoop: boolean;
  16513. /**
  16514. * Gets or sets a world offset applied to all particles
  16515. */
  16516. worldOffset: Vector3;
  16517. /**
  16518. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16519. */
  16520. isAnimationSheetEnabled: boolean;
  16521. /**
  16522. * Get hosting scene
  16523. * @returns the scene
  16524. */
  16525. getScene(): Scene;
  16526. /**
  16527. * You can use gravity if you want to give an orientation to your particles.
  16528. */
  16529. gravity: Vector3;
  16530. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16531. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16532. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16533. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16534. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16535. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16536. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16537. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16538. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16539. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16540. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16541. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16542. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16543. /**
  16544. * Defines the delay in milliseconds before starting the system (0 by default)
  16545. */
  16546. startDelay: number;
  16547. /**
  16548. * Gets the current list of drag gradients.
  16549. * You must use addDragGradient and removeDragGradient to udpate this list
  16550. * @returns the list of drag gradients
  16551. */
  16552. getDragGradients(): Nullable<Array<FactorGradient>>;
  16553. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16554. limitVelocityDamping: number;
  16555. /**
  16556. * Gets the current list of limit velocity gradients.
  16557. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16558. * @returns the list of limit velocity gradients
  16559. */
  16560. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16561. /**
  16562. * Gets the current list of color gradients.
  16563. * You must use addColorGradient and removeColorGradient to udpate this list
  16564. * @returns the list of color gradients
  16565. */
  16566. getColorGradients(): Nullable<Array<ColorGradient>>;
  16567. /**
  16568. * Gets the current list of size gradients.
  16569. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16570. * @returns the list of size gradients
  16571. */
  16572. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16573. /**
  16574. * Gets the current list of color remap gradients.
  16575. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16576. * @returns the list of color remap gradients
  16577. */
  16578. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16579. /**
  16580. * Gets the current list of alpha remap gradients.
  16581. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16582. * @returns the list of alpha remap gradients
  16583. */
  16584. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16585. /**
  16586. * Gets the current list of life time gradients.
  16587. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16588. * @returns the list of life time gradients
  16589. */
  16590. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16591. /**
  16592. * Gets the current list of angular speed gradients.
  16593. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16594. * @returns the list of angular speed gradients
  16595. */
  16596. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16597. /**
  16598. * Gets the current list of velocity gradients.
  16599. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16600. * @returns the list of velocity gradients
  16601. */
  16602. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16603. /**
  16604. * Gets the current list of start size gradients.
  16605. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16606. * @returns the list of start size gradients
  16607. */
  16608. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16609. /**
  16610. * Gets the current list of emit rate gradients.
  16611. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16612. * @returns the list of emit rate gradients
  16613. */
  16614. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16615. /**
  16616. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16617. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16618. */
  16619. direction1: Vector3;
  16620. /**
  16621. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16622. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16623. */
  16624. direction2: Vector3;
  16625. /**
  16626. * 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.
  16627. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16628. */
  16629. minEmitBox: Vector3;
  16630. /**
  16631. * 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.
  16632. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16633. */
  16634. maxEmitBox: Vector3;
  16635. /**
  16636. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16637. */
  16638. color1: Color4;
  16639. /**
  16640. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16641. */
  16642. color2: Color4;
  16643. /**
  16644. * Color the particle will have at the end of its lifetime
  16645. */
  16646. colorDead: Color4;
  16647. /**
  16648. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16649. */
  16650. textureMask: Color4;
  16651. /**
  16652. * The particle emitter type defines the emitter used by the particle system.
  16653. * It can be for example box, sphere, or cone...
  16654. */
  16655. particleEmitterType: IParticleEmitterType;
  16656. /** @hidden */
  16657. _isSubEmitter: boolean;
  16658. /**
  16659. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16660. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16661. */
  16662. billboardMode: number;
  16663. protected _isBillboardBased: boolean;
  16664. /**
  16665. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16666. */
  16667. isBillboardBased: boolean;
  16668. /**
  16669. * The scene the particle system belongs to.
  16670. */
  16671. protected _scene: Scene;
  16672. /**
  16673. * Local cache of defines for image processing.
  16674. */
  16675. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16676. /**
  16677. * Default configuration related to image processing available in the standard Material.
  16678. */
  16679. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16680. /**
  16681. * Gets the image processing configuration used either in this material.
  16682. */
  16683. /**
  16684. * Sets the Default image processing configuration used either in the this material.
  16685. *
  16686. * If sets to null, the scene one is in use.
  16687. */
  16688. imageProcessingConfiguration: ImageProcessingConfiguration;
  16689. /**
  16690. * Attaches a new image processing configuration to the Standard Material.
  16691. * @param configuration
  16692. */
  16693. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16694. /** @hidden */
  16695. protected _reset(): void;
  16696. /** @hidden */
  16697. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16698. /**
  16699. * Instantiates a particle system.
  16700. * 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.
  16701. * @param name The name of the particle system
  16702. */
  16703. constructor(name: string);
  16704. /**
  16705. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16706. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16707. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16708. * @returns the emitter
  16709. */
  16710. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16711. /**
  16712. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16713. * @param radius The radius of the hemisphere to emit from
  16714. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16715. * @returns the emitter
  16716. */
  16717. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16718. /**
  16719. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16720. * @param radius The radius of the sphere to emit from
  16721. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16722. * @returns the emitter
  16723. */
  16724. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16725. /**
  16726. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16727. * @param radius The radius of the sphere to emit from
  16728. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16729. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16730. * @returns the emitter
  16731. */
  16732. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16733. /**
  16734. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16735. * @param radius The radius of the emission cylinder
  16736. * @param height The height of the emission cylinder
  16737. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16738. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16739. * @returns the emitter
  16740. */
  16741. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16742. /**
  16743. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16744. * @param radius The radius of the cylinder to emit from
  16745. * @param height The height of the emission cylinder
  16746. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16747. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16748. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16749. * @returns the emitter
  16750. */
  16751. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16752. /**
  16753. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16754. * @param radius The radius of the cone to emit from
  16755. * @param angle The base angle of the cone
  16756. * @returns the emitter
  16757. */
  16758. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16759. /**
  16760. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16761. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16762. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16763. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16764. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16765. * @returns the emitter
  16766. */
  16767. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16768. }
  16769. }
  16770. declare module BABYLON {
  16771. /**
  16772. * Type of sub emitter
  16773. */
  16774. export enum SubEmitterType {
  16775. /**
  16776. * Attached to the particle over it's lifetime
  16777. */
  16778. ATTACHED = 0,
  16779. /**
  16780. * Created when the particle dies
  16781. */
  16782. END = 1
  16783. }
  16784. /**
  16785. * Sub emitter class used to emit particles from an existing particle
  16786. */
  16787. export class SubEmitter {
  16788. /**
  16789. * the particle system to be used by the sub emitter
  16790. */
  16791. particleSystem: ParticleSystem;
  16792. /**
  16793. * Type of the submitter (Default: END)
  16794. */
  16795. type: SubEmitterType;
  16796. /**
  16797. * 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)
  16798. * Note: This only is supported when using an emitter of type Mesh
  16799. */
  16800. inheritDirection: boolean;
  16801. /**
  16802. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16803. */
  16804. inheritedVelocityAmount: number;
  16805. /**
  16806. * Creates a sub emitter
  16807. * @param particleSystem the particle system to be used by the sub emitter
  16808. */
  16809. constructor(
  16810. /**
  16811. * the particle system to be used by the sub emitter
  16812. */
  16813. particleSystem: ParticleSystem);
  16814. /**
  16815. * Clones the sub emitter
  16816. * @returns the cloned sub emitter
  16817. */
  16818. clone(): SubEmitter;
  16819. /**
  16820. * Serialize current object to a JSON object
  16821. * @returns the serialized object
  16822. */
  16823. serialize(): any;
  16824. /** @hidden */
  16825. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16826. /**
  16827. * Creates a new SubEmitter from a serialized JSON version
  16828. * @param serializationObject defines the JSON object to read from
  16829. * @param scene defines the hosting scene
  16830. * @param rootUrl defines the rootUrl for data loading
  16831. * @returns a new SubEmitter
  16832. */
  16833. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16834. /** Release associated resources */
  16835. dispose(): void;
  16836. }
  16837. }
  16838. declare module BABYLON {
  16839. /** @hidden */
  16840. export var clipPlaneFragmentDeclaration: {
  16841. name: string;
  16842. shader: string;
  16843. };
  16844. }
  16845. declare module BABYLON {
  16846. /** @hidden */
  16847. export var imageProcessingDeclaration: {
  16848. name: string;
  16849. shader: string;
  16850. };
  16851. }
  16852. declare module BABYLON {
  16853. /** @hidden */
  16854. export var imageProcessingFunctions: {
  16855. name: string;
  16856. shader: string;
  16857. };
  16858. }
  16859. declare module BABYLON {
  16860. /** @hidden */
  16861. export var clipPlaneFragment: {
  16862. name: string;
  16863. shader: string;
  16864. };
  16865. }
  16866. declare module BABYLON {
  16867. /** @hidden */
  16868. export var particlesPixelShader: {
  16869. name: string;
  16870. shader: string;
  16871. };
  16872. }
  16873. declare module BABYLON {
  16874. /** @hidden */
  16875. export var clipPlaneVertexDeclaration: {
  16876. name: string;
  16877. shader: string;
  16878. };
  16879. }
  16880. declare module BABYLON {
  16881. /** @hidden */
  16882. export var clipPlaneVertex: {
  16883. name: string;
  16884. shader: string;
  16885. };
  16886. }
  16887. declare module BABYLON {
  16888. /** @hidden */
  16889. export var particlesVertexShader: {
  16890. name: string;
  16891. shader: string;
  16892. };
  16893. }
  16894. declare module BABYLON {
  16895. /**
  16896. * This represents a particle system in Babylon.
  16897. * 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.
  16898. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16899. * @example https://doc.babylonjs.com/babylon101/particles
  16900. */
  16901. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16902. /**
  16903. * Billboard mode will only apply to Y axis
  16904. */
  16905. static readonly BILLBOARDMODE_Y: number;
  16906. /**
  16907. * Billboard mode will apply to all axes
  16908. */
  16909. static readonly BILLBOARDMODE_ALL: number;
  16910. /**
  16911. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16912. */
  16913. static readonly BILLBOARDMODE_STRETCHED: number;
  16914. /**
  16915. * This function can be defined to provide custom update for active particles.
  16916. * This function will be called instead of regular update (age, position, color, etc.).
  16917. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16918. */
  16919. updateFunction: (particles: Particle[]) => void;
  16920. private _emitterWorldMatrix;
  16921. /**
  16922. * This function can be defined to specify initial direction for every new particle.
  16923. * It by default use the emitterType defined function
  16924. */
  16925. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16926. /**
  16927. * This function can be defined to specify initial position for every new particle.
  16928. * It by default use the emitterType defined function
  16929. */
  16930. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16931. /**
  16932. * @hidden
  16933. */
  16934. _inheritedVelocityOffset: Vector3;
  16935. /**
  16936. * An event triggered when the system is disposed
  16937. */
  16938. onDisposeObservable: Observable<ParticleSystem>;
  16939. private _onDisposeObserver;
  16940. /**
  16941. * Sets a callback that will be triggered when the system is disposed
  16942. */
  16943. onDispose: () => void;
  16944. private _particles;
  16945. private _epsilon;
  16946. private _capacity;
  16947. private _stockParticles;
  16948. private _newPartsExcess;
  16949. private _vertexData;
  16950. private _vertexBuffer;
  16951. private _vertexBuffers;
  16952. private _spriteBuffer;
  16953. private _indexBuffer;
  16954. private _effect;
  16955. private _customEffect;
  16956. private _cachedDefines;
  16957. private _scaledColorStep;
  16958. private _colorDiff;
  16959. private _scaledDirection;
  16960. private _scaledGravity;
  16961. private _currentRenderId;
  16962. private _alive;
  16963. private _useInstancing;
  16964. private _started;
  16965. private _stopped;
  16966. private _actualFrame;
  16967. private _scaledUpdateSpeed;
  16968. private _vertexBufferSize;
  16969. /** @hidden */
  16970. _currentEmitRateGradient: Nullable<FactorGradient>;
  16971. /** @hidden */
  16972. _currentEmitRate1: number;
  16973. /** @hidden */
  16974. _currentEmitRate2: number;
  16975. /** @hidden */
  16976. _currentStartSizeGradient: Nullable<FactorGradient>;
  16977. /** @hidden */
  16978. _currentStartSize1: number;
  16979. /** @hidden */
  16980. _currentStartSize2: number;
  16981. private readonly _rawTextureWidth;
  16982. private _rampGradientsTexture;
  16983. private _useRampGradients;
  16984. /** Gets or sets a boolean indicating that ramp gradients must be used
  16985. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16986. */
  16987. useRampGradients: boolean;
  16988. /**
  16989. * 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.
  16990. * 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: [])
  16991. */
  16992. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16993. private _subEmitters;
  16994. /**
  16995. * @hidden
  16996. * If the particle systems emitter should be disposed when the particle system is disposed
  16997. */
  16998. _disposeEmitterOnDispose: boolean;
  16999. /**
  17000. * The current active Sub-systems, this property is used by the root particle system only.
  17001. */
  17002. activeSubSystems: Array<ParticleSystem>;
  17003. private _rootParticleSystem;
  17004. /**
  17005. * Gets the current list of active particles
  17006. */
  17007. readonly particles: Particle[];
  17008. /**
  17009. * Returns the string "ParticleSystem"
  17010. * @returns a string containing the class name
  17011. */
  17012. getClassName(): string;
  17013. /**
  17014. * Instantiates a particle system.
  17015. * 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.
  17016. * @param name The name of the particle system
  17017. * @param capacity The max number of particles alive at the same time
  17018. * @param scene The scene the particle system belongs to
  17019. * @param customEffect a custom effect used to change the way particles are rendered by default
  17020. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17021. * @param epsilon Offset used to render the particles
  17022. */
  17023. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17024. private _addFactorGradient;
  17025. private _removeFactorGradient;
  17026. /**
  17027. * Adds a new life time gradient
  17028. * @param gradient defines the gradient to use (between 0 and 1)
  17029. * @param factor defines the life time factor to affect to the specified gradient
  17030. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17031. * @returns the current particle system
  17032. */
  17033. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17034. /**
  17035. * Remove a specific life time gradient
  17036. * @param gradient defines the gradient to remove
  17037. * @returns the current particle system
  17038. */
  17039. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17040. /**
  17041. * Adds a new size gradient
  17042. * @param gradient defines the gradient to use (between 0 and 1)
  17043. * @param factor defines the size factor to affect to the specified gradient
  17044. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17045. * @returns the current particle system
  17046. */
  17047. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17048. /**
  17049. * Remove a specific size gradient
  17050. * @param gradient defines the gradient to remove
  17051. * @returns the current particle system
  17052. */
  17053. removeSizeGradient(gradient: number): IParticleSystem;
  17054. /**
  17055. * Adds a new color remap gradient
  17056. * @param gradient defines the gradient to use (between 0 and 1)
  17057. * @param min defines the color remap minimal range
  17058. * @param max defines the color remap maximal range
  17059. * @returns the current particle system
  17060. */
  17061. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17062. /**
  17063. * Remove a specific color remap gradient
  17064. * @param gradient defines the gradient to remove
  17065. * @returns the current particle system
  17066. */
  17067. removeColorRemapGradient(gradient: number): IParticleSystem;
  17068. /**
  17069. * Adds a new alpha remap gradient
  17070. * @param gradient defines the gradient to use (between 0 and 1)
  17071. * @param min defines the alpha remap minimal range
  17072. * @param max defines the alpha remap maximal range
  17073. * @returns the current particle system
  17074. */
  17075. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17076. /**
  17077. * Remove a specific alpha remap gradient
  17078. * @param gradient defines the gradient to remove
  17079. * @returns the current particle system
  17080. */
  17081. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17082. /**
  17083. * Adds a new angular speed gradient
  17084. * @param gradient defines the gradient to use (between 0 and 1)
  17085. * @param factor defines the angular speed to affect to the specified gradient
  17086. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17087. * @returns the current particle system
  17088. */
  17089. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17090. /**
  17091. * Remove a specific angular speed gradient
  17092. * @param gradient defines the gradient to remove
  17093. * @returns the current particle system
  17094. */
  17095. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17096. /**
  17097. * Adds a new velocity gradient
  17098. * @param gradient defines the gradient to use (between 0 and 1)
  17099. * @param factor defines the velocity to affect to the specified gradient
  17100. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17101. * @returns the current particle system
  17102. */
  17103. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17104. /**
  17105. * Remove a specific velocity gradient
  17106. * @param gradient defines the gradient to remove
  17107. * @returns the current particle system
  17108. */
  17109. removeVelocityGradient(gradient: number): IParticleSystem;
  17110. /**
  17111. * Adds a new limit velocity gradient
  17112. * @param gradient defines the gradient to use (between 0 and 1)
  17113. * @param factor defines the limit velocity value to affect to the specified gradient
  17114. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17115. * @returns the current particle system
  17116. */
  17117. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17118. /**
  17119. * Remove a specific limit velocity gradient
  17120. * @param gradient defines the gradient to remove
  17121. * @returns the current particle system
  17122. */
  17123. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17124. /**
  17125. * Adds a new drag gradient
  17126. * @param gradient defines the gradient to use (between 0 and 1)
  17127. * @param factor defines the drag value to affect to the specified gradient
  17128. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17129. * @returns the current particle system
  17130. */
  17131. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17132. /**
  17133. * Remove a specific drag gradient
  17134. * @param gradient defines the gradient to remove
  17135. * @returns the current particle system
  17136. */
  17137. removeDragGradient(gradient: number): IParticleSystem;
  17138. /**
  17139. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17140. * @param gradient defines the gradient to use (between 0 and 1)
  17141. * @param factor defines the emit rate value to affect to the specified gradient
  17142. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17143. * @returns the current particle system
  17144. */
  17145. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17146. /**
  17147. * Remove a specific emit rate gradient
  17148. * @param gradient defines the gradient to remove
  17149. * @returns the current particle system
  17150. */
  17151. removeEmitRateGradient(gradient: number): IParticleSystem;
  17152. /**
  17153. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17154. * @param gradient defines the gradient to use (between 0 and 1)
  17155. * @param factor defines the start size value to affect to the specified gradient
  17156. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17157. * @returns the current particle system
  17158. */
  17159. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17160. /**
  17161. * Remove a specific start size gradient
  17162. * @param gradient defines the gradient to remove
  17163. * @returns the current particle system
  17164. */
  17165. removeStartSizeGradient(gradient: number): IParticleSystem;
  17166. private _createRampGradientTexture;
  17167. /**
  17168. * Gets the current list of ramp gradients.
  17169. * You must use addRampGradient and removeRampGradient to udpate this list
  17170. * @returns the list of ramp gradients
  17171. */
  17172. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17173. /**
  17174. * Adds a new ramp gradient used to remap particle colors
  17175. * @param gradient defines the gradient to use (between 0 and 1)
  17176. * @param color defines the color to affect to the specified gradient
  17177. * @returns the current particle system
  17178. */
  17179. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17180. /**
  17181. * Remove a specific ramp gradient
  17182. * @param gradient defines the gradient to remove
  17183. * @returns the current particle system
  17184. */
  17185. removeRampGradient(gradient: number): ParticleSystem;
  17186. /**
  17187. * Adds a new color gradient
  17188. * @param gradient defines the gradient to use (between 0 and 1)
  17189. * @param color1 defines the color to affect to the specified gradient
  17190. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17191. * @returns this particle system
  17192. */
  17193. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17194. /**
  17195. * Remove a specific color gradient
  17196. * @param gradient defines the gradient to remove
  17197. * @returns this particle system
  17198. */
  17199. removeColorGradient(gradient: number): IParticleSystem;
  17200. private _fetchR;
  17201. protected _reset(): void;
  17202. private _resetEffect;
  17203. private _createVertexBuffers;
  17204. private _createIndexBuffer;
  17205. /**
  17206. * Gets the maximum number of particles active at the same time.
  17207. * @returns The max number of active particles.
  17208. */
  17209. getCapacity(): number;
  17210. /**
  17211. * Gets whether there are still active particles in the system.
  17212. * @returns True if it is alive, otherwise false.
  17213. */
  17214. isAlive(): boolean;
  17215. /**
  17216. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17217. * @returns True if it has been started, otherwise false.
  17218. */
  17219. isStarted(): boolean;
  17220. private _prepareSubEmitterInternalArray;
  17221. /**
  17222. * Starts the particle system and begins to emit
  17223. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17224. */
  17225. start(delay?: number): void;
  17226. /**
  17227. * Stops the particle system.
  17228. * @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.
  17229. */
  17230. stop(stopSubEmitters?: boolean): void;
  17231. /**
  17232. * Remove all active particles
  17233. */
  17234. reset(): void;
  17235. /**
  17236. * @hidden (for internal use only)
  17237. */
  17238. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17239. /**
  17240. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17241. * Its lifetime will start back at 0.
  17242. */
  17243. recycleParticle: (particle: Particle) => void;
  17244. private _stopSubEmitters;
  17245. private _createParticle;
  17246. private _removeFromRoot;
  17247. private _emitFromParticle;
  17248. private _update;
  17249. /** @hidden */
  17250. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17251. /** @hidden */
  17252. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17253. /** @hidden */
  17254. private _getEffect;
  17255. /**
  17256. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17257. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17258. */
  17259. animate(preWarmOnly?: boolean): void;
  17260. private _appendParticleVertices;
  17261. /**
  17262. * Rebuilds the particle system.
  17263. */
  17264. rebuild(): void;
  17265. /**
  17266. * Is this system ready to be used/rendered
  17267. * @return true if the system is ready
  17268. */
  17269. isReady(): boolean;
  17270. private _render;
  17271. /**
  17272. * Renders the particle system in its current state.
  17273. * @returns the current number of particles
  17274. */
  17275. render(): number;
  17276. /**
  17277. * Disposes the particle system and free the associated resources
  17278. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17279. */
  17280. dispose(disposeTexture?: boolean): void;
  17281. /**
  17282. * Clones the particle system.
  17283. * @param name The name of the cloned object
  17284. * @param newEmitter The new emitter to use
  17285. * @returns the cloned particle system
  17286. */
  17287. clone(name: string, newEmitter: any): ParticleSystem;
  17288. /**
  17289. * Serializes the particle system to a JSON object.
  17290. * @returns the JSON object
  17291. */
  17292. serialize(): any;
  17293. /** @hidden */
  17294. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17295. /** @hidden */
  17296. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17297. /**
  17298. * Parses a JSON object to create a particle system.
  17299. * @param parsedParticleSystem The JSON object to parse
  17300. * @param scene The scene to create the particle system in
  17301. * @param rootUrl The root url to use to load external dependencies like texture
  17302. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17303. * @returns the Parsed particle system
  17304. */
  17305. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17306. }
  17307. }
  17308. declare module BABYLON {
  17309. /**
  17310. * A particle represents one of the element emitted by a particle system.
  17311. * This is mainly define by its coordinates, direction, velocity and age.
  17312. */
  17313. export class Particle {
  17314. /**
  17315. * The particle system the particle belongs to.
  17316. */
  17317. particleSystem: ParticleSystem;
  17318. private static _Count;
  17319. /**
  17320. * Unique ID of the particle
  17321. */
  17322. id: number;
  17323. /**
  17324. * The world position of the particle in the scene.
  17325. */
  17326. position: Vector3;
  17327. /**
  17328. * The world direction of the particle in the scene.
  17329. */
  17330. direction: Vector3;
  17331. /**
  17332. * The color of the particle.
  17333. */
  17334. color: Color4;
  17335. /**
  17336. * The color change of the particle per step.
  17337. */
  17338. colorStep: Color4;
  17339. /**
  17340. * Defines how long will the life of the particle be.
  17341. */
  17342. lifeTime: number;
  17343. /**
  17344. * The current age of the particle.
  17345. */
  17346. age: number;
  17347. /**
  17348. * The current size of the particle.
  17349. */
  17350. size: number;
  17351. /**
  17352. * The current scale of the particle.
  17353. */
  17354. scale: Vector2;
  17355. /**
  17356. * The current angle of the particle.
  17357. */
  17358. angle: number;
  17359. /**
  17360. * Defines how fast is the angle changing.
  17361. */
  17362. angularSpeed: number;
  17363. /**
  17364. * Defines the cell index used by the particle to be rendered from a sprite.
  17365. */
  17366. cellIndex: number;
  17367. /**
  17368. * The information required to support color remapping
  17369. */
  17370. remapData: Vector4;
  17371. /** @hidden */
  17372. _randomCellOffset?: number;
  17373. /** @hidden */
  17374. _initialDirection: Nullable<Vector3>;
  17375. /** @hidden */
  17376. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17377. /** @hidden */
  17378. _initialStartSpriteCellID: number;
  17379. /** @hidden */
  17380. _initialEndSpriteCellID: number;
  17381. /** @hidden */
  17382. _currentColorGradient: Nullable<ColorGradient>;
  17383. /** @hidden */
  17384. _currentColor1: Color4;
  17385. /** @hidden */
  17386. _currentColor2: Color4;
  17387. /** @hidden */
  17388. _currentSizeGradient: Nullable<FactorGradient>;
  17389. /** @hidden */
  17390. _currentSize1: number;
  17391. /** @hidden */
  17392. _currentSize2: number;
  17393. /** @hidden */
  17394. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17395. /** @hidden */
  17396. _currentAngularSpeed1: number;
  17397. /** @hidden */
  17398. _currentAngularSpeed2: number;
  17399. /** @hidden */
  17400. _currentVelocityGradient: Nullable<FactorGradient>;
  17401. /** @hidden */
  17402. _currentVelocity1: number;
  17403. /** @hidden */
  17404. _currentVelocity2: number;
  17405. /** @hidden */
  17406. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17407. /** @hidden */
  17408. _currentLimitVelocity1: number;
  17409. /** @hidden */
  17410. _currentLimitVelocity2: number;
  17411. /** @hidden */
  17412. _currentDragGradient: Nullable<FactorGradient>;
  17413. /** @hidden */
  17414. _currentDrag1: number;
  17415. /** @hidden */
  17416. _currentDrag2: number;
  17417. /** @hidden */
  17418. _randomNoiseCoordinates1: Vector3;
  17419. /** @hidden */
  17420. _randomNoiseCoordinates2: Vector3;
  17421. /**
  17422. * Creates a new instance Particle
  17423. * @param particleSystem the particle system the particle belongs to
  17424. */
  17425. constructor(
  17426. /**
  17427. * The particle system the particle belongs to.
  17428. */
  17429. particleSystem: ParticleSystem);
  17430. private updateCellInfoFromSystem;
  17431. /**
  17432. * Defines how the sprite cell index is updated for the particle
  17433. */
  17434. updateCellIndex(): void;
  17435. /** @hidden */
  17436. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17437. /** @hidden */
  17438. _inheritParticleInfoToSubEmitters(): void;
  17439. /** @hidden */
  17440. _reset(): void;
  17441. /**
  17442. * Copy the properties of particle to another one.
  17443. * @param other the particle to copy the information to.
  17444. */
  17445. copyTo(other: Particle): void;
  17446. }
  17447. }
  17448. declare module BABYLON {
  17449. /**
  17450. * Particle emitter represents a volume emitting particles.
  17451. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17452. */
  17453. export interface IParticleEmitterType {
  17454. /**
  17455. * Called by the particle System when the direction is computed for the created particle.
  17456. * @param worldMatrix is the world matrix of the particle system
  17457. * @param directionToUpdate is the direction vector to update with the result
  17458. * @param particle is the particle we are computed the direction for
  17459. */
  17460. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17461. /**
  17462. * Called by the particle System when the position is computed for the created particle.
  17463. * @param worldMatrix is the world matrix of the particle system
  17464. * @param positionToUpdate is the position vector to update with the result
  17465. * @param particle is the particle we are computed the position for
  17466. */
  17467. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17468. /**
  17469. * Clones the current emitter and returns a copy of it
  17470. * @returns the new emitter
  17471. */
  17472. clone(): IParticleEmitterType;
  17473. /**
  17474. * Called by the GPUParticleSystem to setup the update shader
  17475. * @param effect defines the update shader
  17476. */
  17477. applyToShader(effect: Effect): void;
  17478. /**
  17479. * Returns a string to use to update the GPU particles update shader
  17480. * @returns the effect defines string
  17481. */
  17482. getEffectDefines(): string;
  17483. /**
  17484. * Returns a string representing the class name
  17485. * @returns a string containing the class name
  17486. */
  17487. getClassName(): string;
  17488. /**
  17489. * Serializes the particle system to a JSON object.
  17490. * @returns the JSON object
  17491. */
  17492. serialize(): any;
  17493. /**
  17494. * Parse properties from a JSON object
  17495. * @param serializationObject defines the JSON object
  17496. */
  17497. parse(serializationObject: any): void;
  17498. }
  17499. }
  17500. declare module BABYLON {
  17501. /**
  17502. * Particle emitter emitting particles from the inside of a box.
  17503. * It emits the particles randomly between 2 given directions.
  17504. */
  17505. export class BoxParticleEmitter implements IParticleEmitterType {
  17506. /**
  17507. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17508. */
  17509. direction1: Vector3;
  17510. /**
  17511. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17512. */
  17513. direction2: Vector3;
  17514. /**
  17515. * 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.
  17516. */
  17517. minEmitBox: Vector3;
  17518. /**
  17519. * 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.
  17520. */
  17521. maxEmitBox: Vector3;
  17522. /**
  17523. * Creates a new instance BoxParticleEmitter
  17524. */
  17525. constructor();
  17526. /**
  17527. * Called by the particle System when the direction is computed for the created particle.
  17528. * @param worldMatrix is the world matrix of the particle system
  17529. * @param directionToUpdate is the direction vector to update with the result
  17530. * @param particle is the particle we are computed the direction for
  17531. */
  17532. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17533. /**
  17534. * Called by the particle System when the position is computed for the created particle.
  17535. * @param worldMatrix is the world matrix of the particle system
  17536. * @param positionToUpdate is the position vector to update with the result
  17537. * @param particle is the particle we are computed the position for
  17538. */
  17539. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17540. /**
  17541. * Clones the current emitter and returns a copy of it
  17542. * @returns the new emitter
  17543. */
  17544. clone(): BoxParticleEmitter;
  17545. /**
  17546. * Called by the GPUParticleSystem to setup the update shader
  17547. * @param effect defines the update shader
  17548. */
  17549. applyToShader(effect: Effect): void;
  17550. /**
  17551. * Returns a string to use to update the GPU particles update shader
  17552. * @returns a string containng the defines string
  17553. */
  17554. getEffectDefines(): string;
  17555. /**
  17556. * Returns the string "BoxParticleEmitter"
  17557. * @returns a string containing the class name
  17558. */
  17559. getClassName(): string;
  17560. /**
  17561. * Serializes the particle system to a JSON object.
  17562. * @returns the JSON object
  17563. */
  17564. serialize(): any;
  17565. /**
  17566. * Parse properties from a JSON object
  17567. * @param serializationObject defines the JSON object
  17568. */
  17569. parse(serializationObject: any): void;
  17570. }
  17571. }
  17572. declare module BABYLON {
  17573. /**
  17574. * Particle emitter emitting particles from the inside of a cone.
  17575. * It emits the particles alongside the cone volume from the base to the particle.
  17576. * The emission direction might be randomized.
  17577. */
  17578. export class ConeParticleEmitter implements IParticleEmitterType {
  17579. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17580. directionRandomizer: number;
  17581. private _radius;
  17582. private _angle;
  17583. private _height;
  17584. /**
  17585. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17586. */
  17587. radiusRange: number;
  17588. /**
  17589. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17590. */
  17591. heightRange: number;
  17592. /**
  17593. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17594. */
  17595. emitFromSpawnPointOnly: boolean;
  17596. /**
  17597. * Gets or sets the radius of the emission cone
  17598. */
  17599. radius: number;
  17600. /**
  17601. * Gets or sets the angle of the emission cone
  17602. */
  17603. angle: number;
  17604. private _buildHeight;
  17605. /**
  17606. * Creates a new instance ConeParticleEmitter
  17607. * @param radius the radius of the emission cone (1 by default)
  17608. * @param angle the cone base angle (PI by default)
  17609. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17610. */
  17611. constructor(radius?: number, angle?: number,
  17612. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17613. directionRandomizer?: number);
  17614. /**
  17615. * Called by the particle System when the direction is computed for the created particle.
  17616. * @param worldMatrix is the world matrix of the particle system
  17617. * @param directionToUpdate is the direction vector to update with the result
  17618. * @param particle is the particle we are computed the direction for
  17619. */
  17620. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17621. /**
  17622. * Called by the particle System when the position is computed for the created particle.
  17623. * @param worldMatrix is the world matrix of the particle system
  17624. * @param positionToUpdate is the position vector to update with the result
  17625. * @param particle is the particle we are computed the position for
  17626. */
  17627. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17628. /**
  17629. * Clones the current emitter and returns a copy of it
  17630. * @returns the new emitter
  17631. */
  17632. clone(): ConeParticleEmitter;
  17633. /**
  17634. * Called by the GPUParticleSystem to setup the update shader
  17635. * @param effect defines the update shader
  17636. */
  17637. applyToShader(effect: Effect): void;
  17638. /**
  17639. * Returns a string to use to update the GPU particles update shader
  17640. * @returns a string containng the defines string
  17641. */
  17642. getEffectDefines(): string;
  17643. /**
  17644. * Returns the string "ConeParticleEmitter"
  17645. * @returns a string containing the class name
  17646. */
  17647. getClassName(): string;
  17648. /**
  17649. * Serializes the particle system to a JSON object.
  17650. * @returns the JSON object
  17651. */
  17652. serialize(): any;
  17653. /**
  17654. * Parse properties from a JSON object
  17655. * @param serializationObject defines the JSON object
  17656. */
  17657. parse(serializationObject: any): void;
  17658. }
  17659. }
  17660. declare module BABYLON {
  17661. /**
  17662. * Particle emitter emitting particles from the inside of a cylinder.
  17663. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17664. */
  17665. export class CylinderParticleEmitter implements IParticleEmitterType {
  17666. /**
  17667. * The radius of the emission cylinder.
  17668. */
  17669. radius: number;
  17670. /**
  17671. * The height of the emission cylinder.
  17672. */
  17673. height: number;
  17674. /**
  17675. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17676. */
  17677. radiusRange: number;
  17678. /**
  17679. * How much to randomize the particle direction [0-1].
  17680. */
  17681. directionRandomizer: number;
  17682. /**
  17683. * Creates a new instance CylinderParticleEmitter
  17684. * @param radius the radius of the emission cylinder (1 by default)
  17685. * @param height the height of the emission cylinder (1 by default)
  17686. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17687. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17688. */
  17689. constructor(
  17690. /**
  17691. * The radius of the emission cylinder.
  17692. */
  17693. radius?: number,
  17694. /**
  17695. * The height of the emission cylinder.
  17696. */
  17697. height?: number,
  17698. /**
  17699. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17700. */
  17701. radiusRange?: number,
  17702. /**
  17703. * How much to randomize the particle direction [0-1].
  17704. */
  17705. directionRandomizer?: number);
  17706. /**
  17707. * Called by the particle System when the direction is computed for the created particle.
  17708. * @param worldMatrix is the world matrix of the particle system
  17709. * @param directionToUpdate is the direction vector to update with the result
  17710. * @param particle is the particle we are computed the direction for
  17711. */
  17712. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17713. /**
  17714. * Called by the particle System when the position is computed for the created particle.
  17715. * @param worldMatrix is the world matrix of the particle system
  17716. * @param positionToUpdate is the position vector to update with the result
  17717. * @param particle is the particle we are computed the position for
  17718. */
  17719. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17720. /**
  17721. * Clones the current emitter and returns a copy of it
  17722. * @returns the new emitter
  17723. */
  17724. clone(): CylinderParticleEmitter;
  17725. /**
  17726. * Called by the GPUParticleSystem to setup the update shader
  17727. * @param effect defines the update shader
  17728. */
  17729. applyToShader(effect: Effect): void;
  17730. /**
  17731. * Returns a string to use to update the GPU particles update shader
  17732. * @returns a string containng the defines string
  17733. */
  17734. getEffectDefines(): string;
  17735. /**
  17736. * Returns the string "CylinderParticleEmitter"
  17737. * @returns a string containing the class name
  17738. */
  17739. getClassName(): string;
  17740. /**
  17741. * Serializes the particle system to a JSON object.
  17742. * @returns the JSON object
  17743. */
  17744. serialize(): any;
  17745. /**
  17746. * Parse properties from a JSON object
  17747. * @param serializationObject defines the JSON object
  17748. */
  17749. parse(serializationObject: any): void;
  17750. }
  17751. /**
  17752. * Particle emitter emitting particles from the inside of a cylinder.
  17753. * It emits the particles randomly between two vectors.
  17754. */
  17755. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17756. /**
  17757. * The min limit of the emission direction.
  17758. */
  17759. direction1: Vector3;
  17760. /**
  17761. * The max limit of the emission direction.
  17762. */
  17763. direction2: Vector3;
  17764. /**
  17765. * Creates a new instance CylinderDirectedParticleEmitter
  17766. * @param radius the radius of the emission cylinder (1 by default)
  17767. * @param height the height of the emission cylinder (1 by default)
  17768. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17769. * @param direction1 the min limit of the emission direction (up vector by default)
  17770. * @param direction2 the max limit of the emission direction (up vector by default)
  17771. */
  17772. constructor(radius?: number, height?: number, radiusRange?: number,
  17773. /**
  17774. * The min limit of the emission direction.
  17775. */
  17776. direction1?: Vector3,
  17777. /**
  17778. * The max limit of the emission direction.
  17779. */
  17780. direction2?: Vector3);
  17781. /**
  17782. * Called by the particle System when the direction is computed for the created particle.
  17783. * @param worldMatrix is the world matrix of the particle system
  17784. * @param directionToUpdate is the direction vector to update with the result
  17785. * @param particle is the particle we are computed the direction for
  17786. */
  17787. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17788. /**
  17789. * Clones the current emitter and returns a copy of it
  17790. * @returns the new emitter
  17791. */
  17792. clone(): CylinderDirectedParticleEmitter;
  17793. /**
  17794. * Called by the GPUParticleSystem to setup the update shader
  17795. * @param effect defines the update shader
  17796. */
  17797. applyToShader(effect: Effect): void;
  17798. /**
  17799. * Returns a string to use to update the GPU particles update shader
  17800. * @returns a string containng the defines string
  17801. */
  17802. getEffectDefines(): string;
  17803. /**
  17804. * Returns the string "CylinderDirectedParticleEmitter"
  17805. * @returns a string containing the class name
  17806. */
  17807. getClassName(): string;
  17808. /**
  17809. * Serializes the particle system to a JSON object.
  17810. * @returns the JSON object
  17811. */
  17812. serialize(): any;
  17813. /**
  17814. * Parse properties from a JSON object
  17815. * @param serializationObject defines the JSON object
  17816. */
  17817. parse(serializationObject: any): void;
  17818. }
  17819. }
  17820. declare module BABYLON {
  17821. /**
  17822. * Particle emitter emitting particles from the inside of a hemisphere.
  17823. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17824. */
  17825. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17826. /**
  17827. * The radius of the emission hemisphere.
  17828. */
  17829. radius: number;
  17830. /**
  17831. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17832. */
  17833. radiusRange: number;
  17834. /**
  17835. * How much to randomize the particle direction [0-1].
  17836. */
  17837. directionRandomizer: number;
  17838. /**
  17839. * Creates a new instance HemisphericParticleEmitter
  17840. * @param radius the radius of the emission hemisphere (1 by default)
  17841. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17842. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17843. */
  17844. constructor(
  17845. /**
  17846. * The radius of the emission hemisphere.
  17847. */
  17848. radius?: number,
  17849. /**
  17850. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17851. */
  17852. radiusRange?: number,
  17853. /**
  17854. * How much to randomize the particle direction [0-1].
  17855. */
  17856. directionRandomizer?: number);
  17857. /**
  17858. * Called by the particle System when the direction is computed for the created particle.
  17859. * @param worldMatrix is the world matrix of the particle system
  17860. * @param directionToUpdate is the direction vector to update with the result
  17861. * @param particle is the particle we are computed the direction for
  17862. */
  17863. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17864. /**
  17865. * Called by the particle System when the position is computed for the created particle.
  17866. * @param worldMatrix is the world matrix of the particle system
  17867. * @param positionToUpdate is the position vector to update with the result
  17868. * @param particle is the particle we are computed the position for
  17869. */
  17870. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17871. /**
  17872. * Clones the current emitter and returns a copy of it
  17873. * @returns the new emitter
  17874. */
  17875. clone(): HemisphericParticleEmitter;
  17876. /**
  17877. * Called by the GPUParticleSystem to setup the update shader
  17878. * @param effect defines the update shader
  17879. */
  17880. applyToShader(effect: Effect): void;
  17881. /**
  17882. * Returns a string to use to update the GPU particles update shader
  17883. * @returns a string containng the defines string
  17884. */
  17885. getEffectDefines(): string;
  17886. /**
  17887. * Returns the string "HemisphericParticleEmitter"
  17888. * @returns a string containing the class name
  17889. */
  17890. getClassName(): string;
  17891. /**
  17892. * Serializes the particle system to a JSON object.
  17893. * @returns the JSON object
  17894. */
  17895. serialize(): any;
  17896. /**
  17897. * Parse properties from a JSON object
  17898. * @param serializationObject defines the JSON object
  17899. */
  17900. parse(serializationObject: any): void;
  17901. }
  17902. }
  17903. declare module BABYLON {
  17904. /**
  17905. * Particle emitter emitting particles from a point.
  17906. * It emits the particles randomly between 2 given directions.
  17907. */
  17908. export class PointParticleEmitter implements IParticleEmitterType {
  17909. /**
  17910. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17911. */
  17912. direction1: Vector3;
  17913. /**
  17914. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17915. */
  17916. direction2: Vector3;
  17917. /**
  17918. * Creates a new instance PointParticleEmitter
  17919. */
  17920. constructor();
  17921. /**
  17922. * Called by the particle System when the direction is computed for the created particle.
  17923. * @param worldMatrix is the world matrix of the particle system
  17924. * @param directionToUpdate is the direction vector to update with the result
  17925. * @param particle is the particle we are computed the direction for
  17926. */
  17927. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17928. /**
  17929. * Called by the particle System when the position is computed for the created particle.
  17930. * @param worldMatrix is the world matrix of the particle system
  17931. * @param positionToUpdate is the position vector to update with the result
  17932. * @param particle is the particle we are computed the position for
  17933. */
  17934. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17935. /**
  17936. * Clones the current emitter and returns a copy of it
  17937. * @returns the new emitter
  17938. */
  17939. clone(): PointParticleEmitter;
  17940. /**
  17941. * Called by the GPUParticleSystem to setup the update shader
  17942. * @param effect defines the update shader
  17943. */
  17944. applyToShader(effect: Effect): void;
  17945. /**
  17946. * Returns a string to use to update the GPU particles update shader
  17947. * @returns a string containng the defines string
  17948. */
  17949. getEffectDefines(): string;
  17950. /**
  17951. * Returns the string "PointParticleEmitter"
  17952. * @returns a string containing the class name
  17953. */
  17954. getClassName(): string;
  17955. /**
  17956. * Serializes the particle system to a JSON object.
  17957. * @returns the JSON object
  17958. */
  17959. serialize(): any;
  17960. /**
  17961. * Parse properties from a JSON object
  17962. * @param serializationObject defines the JSON object
  17963. */
  17964. parse(serializationObject: any): void;
  17965. }
  17966. }
  17967. declare module BABYLON {
  17968. /**
  17969. * Particle emitter emitting particles from the inside of a sphere.
  17970. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17971. */
  17972. export class SphereParticleEmitter implements IParticleEmitterType {
  17973. /**
  17974. * The radius of the emission sphere.
  17975. */
  17976. radius: number;
  17977. /**
  17978. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17979. */
  17980. radiusRange: number;
  17981. /**
  17982. * How much to randomize the particle direction [0-1].
  17983. */
  17984. directionRandomizer: number;
  17985. /**
  17986. * Creates a new instance SphereParticleEmitter
  17987. * @param radius the radius of the emission sphere (1 by default)
  17988. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17989. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17990. */
  17991. constructor(
  17992. /**
  17993. * The radius of the emission sphere.
  17994. */
  17995. radius?: number,
  17996. /**
  17997. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17998. */
  17999. radiusRange?: number,
  18000. /**
  18001. * How much to randomize the particle direction [0-1].
  18002. */
  18003. directionRandomizer?: number);
  18004. /**
  18005. * Called by the particle System when the direction is computed for the created particle.
  18006. * @param worldMatrix is the world matrix of the particle system
  18007. * @param directionToUpdate is the direction vector to update with the result
  18008. * @param particle is the particle we are computed the direction for
  18009. */
  18010. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18011. /**
  18012. * Called by the particle System when the position is computed for the created particle.
  18013. * @param worldMatrix is the world matrix of the particle system
  18014. * @param positionToUpdate is the position vector to update with the result
  18015. * @param particle is the particle we are computed the position for
  18016. */
  18017. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18018. /**
  18019. * Clones the current emitter and returns a copy of it
  18020. * @returns the new emitter
  18021. */
  18022. clone(): SphereParticleEmitter;
  18023. /**
  18024. * Called by the GPUParticleSystem to setup the update shader
  18025. * @param effect defines the update shader
  18026. */
  18027. applyToShader(effect: Effect): void;
  18028. /**
  18029. * Returns a string to use to update the GPU particles update shader
  18030. * @returns a string containng the defines string
  18031. */
  18032. getEffectDefines(): string;
  18033. /**
  18034. * Returns the string "SphereParticleEmitter"
  18035. * @returns a string containing the class name
  18036. */
  18037. getClassName(): string;
  18038. /**
  18039. * Serializes the particle system to a JSON object.
  18040. * @returns the JSON object
  18041. */
  18042. serialize(): any;
  18043. /**
  18044. * Parse properties from a JSON object
  18045. * @param serializationObject defines the JSON object
  18046. */
  18047. parse(serializationObject: any): void;
  18048. }
  18049. /**
  18050. * Particle emitter emitting particles from the inside of a sphere.
  18051. * It emits the particles randomly between two vectors.
  18052. */
  18053. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18054. /**
  18055. * The min limit of the emission direction.
  18056. */
  18057. direction1: Vector3;
  18058. /**
  18059. * The max limit of the emission direction.
  18060. */
  18061. direction2: Vector3;
  18062. /**
  18063. * Creates a new instance SphereDirectedParticleEmitter
  18064. * @param radius the radius of the emission sphere (1 by default)
  18065. * @param direction1 the min limit of the emission direction (up vector by default)
  18066. * @param direction2 the max limit of the emission direction (up vector by default)
  18067. */
  18068. constructor(radius?: number,
  18069. /**
  18070. * The min limit of the emission direction.
  18071. */
  18072. direction1?: Vector3,
  18073. /**
  18074. * The max limit of the emission direction.
  18075. */
  18076. direction2?: Vector3);
  18077. /**
  18078. * Called by the particle System when the direction is computed for the created particle.
  18079. * @param worldMatrix is the world matrix of the particle system
  18080. * @param directionToUpdate is the direction vector to update with the result
  18081. * @param particle is the particle we are computed the direction for
  18082. */
  18083. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18084. /**
  18085. * Clones the current emitter and returns a copy of it
  18086. * @returns the new emitter
  18087. */
  18088. clone(): SphereDirectedParticleEmitter;
  18089. /**
  18090. * Called by the GPUParticleSystem to setup the update shader
  18091. * @param effect defines the update shader
  18092. */
  18093. applyToShader(effect: Effect): void;
  18094. /**
  18095. * Returns a string to use to update the GPU particles update shader
  18096. * @returns a string containng the defines string
  18097. */
  18098. getEffectDefines(): string;
  18099. /**
  18100. * Returns the string "SphereDirectedParticleEmitter"
  18101. * @returns a string containing the class name
  18102. */
  18103. getClassName(): string;
  18104. /**
  18105. * Serializes the particle system to a JSON object.
  18106. * @returns the JSON object
  18107. */
  18108. serialize(): any;
  18109. /**
  18110. * Parse properties from a JSON object
  18111. * @param serializationObject defines the JSON object
  18112. */
  18113. parse(serializationObject: any): void;
  18114. }
  18115. }
  18116. declare module BABYLON {
  18117. /**
  18118. * Interface representing a particle system in Babylon.js.
  18119. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18120. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18121. */
  18122. export interface IParticleSystem {
  18123. /**
  18124. * List of animations used by the particle system.
  18125. */
  18126. animations: Animation[];
  18127. /**
  18128. * The id of the Particle system.
  18129. */
  18130. id: string;
  18131. /**
  18132. * The name of the Particle system.
  18133. */
  18134. name: string;
  18135. /**
  18136. * The emitter represents the Mesh or position we are attaching the particle system to.
  18137. */
  18138. emitter: Nullable<AbstractMesh | Vector3>;
  18139. /**
  18140. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18141. */
  18142. isBillboardBased: boolean;
  18143. /**
  18144. * The rendering group used by the Particle system to chose when to render.
  18145. */
  18146. renderingGroupId: number;
  18147. /**
  18148. * The layer mask we are rendering the particles through.
  18149. */
  18150. layerMask: number;
  18151. /**
  18152. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18153. */
  18154. updateSpeed: number;
  18155. /**
  18156. * The amount of time the particle system is running (depends of the overall update speed).
  18157. */
  18158. targetStopDuration: number;
  18159. /**
  18160. * The texture used to render each particle. (this can be a spritesheet)
  18161. */
  18162. particleTexture: Nullable<Texture>;
  18163. /**
  18164. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18165. */
  18166. blendMode: number;
  18167. /**
  18168. * Minimum life time of emitting particles.
  18169. */
  18170. minLifeTime: number;
  18171. /**
  18172. * Maximum life time of emitting particles.
  18173. */
  18174. maxLifeTime: number;
  18175. /**
  18176. * Minimum Size of emitting particles.
  18177. */
  18178. minSize: number;
  18179. /**
  18180. * Maximum Size of emitting particles.
  18181. */
  18182. maxSize: number;
  18183. /**
  18184. * Minimum scale of emitting particles on X axis.
  18185. */
  18186. minScaleX: number;
  18187. /**
  18188. * Maximum scale of emitting particles on X axis.
  18189. */
  18190. maxScaleX: number;
  18191. /**
  18192. * Minimum scale of emitting particles on Y axis.
  18193. */
  18194. minScaleY: number;
  18195. /**
  18196. * Maximum scale of emitting particles on Y axis.
  18197. */
  18198. maxScaleY: number;
  18199. /**
  18200. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18201. */
  18202. color1: Color4;
  18203. /**
  18204. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18205. */
  18206. color2: Color4;
  18207. /**
  18208. * Color the particle will have at the end of its lifetime.
  18209. */
  18210. colorDead: Color4;
  18211. /**
  18212. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18213. */
  18214. emitRate: number;
  18215. /**
  18216. * You can use gravity if you want to give an orientation to your particles.
  18217. */
  18218. gravity: Vector3;
  18219. /**
  18220. * Minimum power of emitting particles.
  18221. */
  18222. minEmitPower: number;
  18223. /**
  18224. * Maximum power of emitting particles.
  18225. */
  18226. maxEmitPower: number;
  18227. /**
  18228. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18229. */
  18230. minAngularSpeed: number;
  18231. /**
  18232. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18233. */
  18234. maxAngularSpeed: number;
  18235. /**
  18236. * Gets or sets the minimal initial rotation in radians.
  18237. */
  18238. minInitialRotation: number;
  18239. /**
  18240. * Gets or sets the maximal initial rotation in radians.
  18241. */
  18242. maxInitialRotation: number;
  18243. /**
  18244. * The particle emitter type defines the emitter used by the particle system.
  18245. * It can be for example box, sphere, or cone...
  18246. */
  18247. particleEmitterType: Nullable<IParticleEmitterType>;
  18248. /**
  18249. * Defines the delay in milliseconds before starting the system (0 by default)
  18250. */
  18251. startDelay: number;
  18252. /**
  18253. * 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
  18254. */
  18255. preWarmCycles: number;
  18256. /**
  18257. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18258. */
  18259. preWarmStepOffset: number;
  18260. /**
  18261. * 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)
  18262. */
  18263. spriteCellChangeSpeed: number;
  18264. /**
  18265. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18266. */
  18267. startSpriteCellID: number;
  18268. /**
  18269. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18270. */
  18271. endSpriteCellID: number;
  18272. /**
  18273. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18274. */
  18275. spriteCellWidth: number;
  18276. /**
  18277. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18278. */
  18279. spriteCellHeight: number;
  18280. /**
  18281. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18282. */
  18283. spriteRandomStartCell: boolean;
  18284. /**
  18285. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18286. */
  18287. isAnimationSheetEnabled: boolean;
  18288. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18289. translationPivot: Vector2;
  18290. /**
  18291. * Gets or sets a texture used to add random noise to particle positions
  18292. */
  18293. noiseTexture: Nullable<BaseTexture>;
  18294. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18295. noiseStrength: Vector3;
  18296. /**
  18297. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18298. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18299. */
  18300. billboardMode: number;
  18301. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18302. limitVelocityDamping: number;
  18303. /**
  18304. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18305. */
  18306. beginAnimationOnStart: boolean;
  18307. /**
  18308. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18309. */
  18310. beginAnimationFrom: number;
  18311. /**
  18312. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18313. */
  18314. beginAnimationTo: number;
  18315. /**
  18316. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18317. */
  18318. beginAnimationLoop: boolean;
  18319. /**
  18320. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18321. */
  18322. disposeOnStop: boolean;
  18323. /**
  18324. * Gets the maximum number of particles active at the same time.
  18325. * @returns The max number of active particles.
  18326. */
  18327. getCapacity(): number;
  18328. /**
  18329. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18330. * @returns True if it has been started, otherwise false.
  18331. */
  18332. isStarted(): boolean;
  18333. /**
  18334. * Animates the particle system for this frame.
  18335. */
  18336. animate(): void;
  18337. /**
  18338. * Renders the particle system in its current state.
  18339. * @returns the current number of particles
  18340. */
  18341. render(): number;
  18342. /**
  18343. * Dispose the particle system and frees its associated resources.
  18344. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18345. */
  18346. dispose(disposeTexture?: boolean): void;
  18347. /**
  18348. * Clones the particle system.
  18349. * @param name The name of the cloned object
  18350. * @param newEmitter The new emitter to use
  18351. * @returns the cloned particle system
  18352. */
  18353. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18354. /**
  18355. * Serializes the particle system to a JSON object.
  18356. * @returns the JSON object
  18357. */
  18358. serialize(): any;
  18359. /**
  18360. * Rebuild the particle system
  18361. */
  18362. rebuild(): void;
  18363. /**
  18364. * Starts the particle system and begins to emit
  18365. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18366. */
  18367. start(delay?: number): void;
  18368. /**
  18369. * Stops the particle system.
  18370. */
  18371. stop(): void;
  18372. /**
  18373. * Remove all active particles
  18374. */
  18375. reset(): void;
  18376. /**
  18377. * Is this system ready to be used/rendered
  18378. * @return true if the system is ready
  18379. */
  18380. isReady(): boolean;
  18381. /**
  18382. * Adds a new color gradient
  18383. * @param gradient defines the gradient to use (between 0 and 1)
  18384. * @param color1 defines the color to affect to the specified gradient
  18385. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18386. * @returns the current particle system
  18387. */
  18388. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18389. /**
  18390. * Remove a specific color gradient
  18391. * @param gradient defines the gradient to remove
  18392. * @returns the current particle system
  18393. */
  18394. removeColorGradient(gradient: number): IParticleSystem;
  18395. /**
  18396. * Adds a new size gradient
  18397. * @param gradient defines the gradient to use (between 0 and 1)
  18398. * @param factor defines the size factor to affect to the specified gradient
  18399. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18400. * @returns the current particle system
  18401. */
  18402. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18403. /**
  18404. * Remove a specific size gradient
  18405. * @param gradient defines the gradient to remove
  18406. * @returns the current particle system
  18407. */
  18408. removeSizeGradient(gradient: number): IParticleSystem;
  18409. /**
  18410. * Gets the current list of color gradients.
  18411. * You must use addColorGradient and removeColorGradient to udpate this list
  18412. * @returns the list of color gradients
  18413. */
  18414. getColorGradients(): Nullable<Array<ColorGradient>>;
  18415. /**
  18416. * Gets the current list of size gradients.
  18417. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18418. * @returns the list of size gradients
  18419. */
  18420. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18421. /**
  18422. * Gets the current list of angular speed gradients.
  18423. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18424. * @returns the list of angular speed gradients
  18425. */
  18426. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18427. /**
  18428. * Adds a new angular speed gradient
  18429. * @param gradient defines the gradient to use (between 0 and 1)
  18430. * @param factor defines the angular speed to affect to the specified gradient
  18431. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18432. * @returns the current particle system
  18433. */
  18434. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18435. /**
  18436. * Remove a specific angular speed gradient
  18437. * @param gradient defines the gradient to remove
  18438. * @returns the current particle system
  18439. */
  18440. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18441. /**
  18442. * Gets the current list of velocity gradients.
  18443. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18444. * @returns the list of velocity gradients
  18445. */
  18446. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18447. /**
  18448. * Adds a new velocity gradient
  18449. * @param gradient defines the gradient to use (between 0 and 1)
  18450. * @param factor defines the velocity to affect to the specified gradient
  18451. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18452. * @returns the current particle system
  18453. */
  18454. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18455. /**
  18456. * Remove a specific velocity gradient
  18457. * @param gradient defines the gradient to remove
  18458. * @returns the current particle system
  18459. */
  18460. removeVelocityGradient(gradient: number): IParticleSystem;
  18461. /**
  18462. * Gets the current list of limit velocity gradients.
  18463. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18464. * @returns the list of limit velocity gradients
  18465. */
  18466. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18467. /**
  18468. * Adds a new limit velocity gradient
  18469. * @param gradient defines the gradient to use (between 0 and 1)
  18470. * @param factor defines the limit velocity to affect to the specified gradient
  18471. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18472. * @returns the current particle system
  18473. */
  18474. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18475. /**
  18476. * Remove a specific limit velocity gradient
  18477. * @param gradient defines the gradient to remove
  18478. * @returns the current particle system
  18479. */
  18480. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18481. /**
  18482. * Adds a new drag gradient
  18483. * @param gradient defines the gradient to use (between 0 and 1)
  18484. * @param factor defines the drag to affect to the specified gradient
  18485. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18486. * @returns the current particle system
  18487. */
  18488. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18489. /**
  18490. * Remove a specific drag gradient
  18491. * @param gradient defines the gradient to remove
  18492. * @returns the current particle system
  18493. */
  18494. removeDragGradient(gradient: number): IParticleSystem;
  18495. /**
  18496. * Gets the current list of drag gradients.
  18497. * You must use addDragGradient and removeDragGradient to udpate this list
  18498. * @returns the list of drag gradients
  18499. */
  18500. getDragGradients(): Nullable<Array<FactorGradient>>;
  18501. /**
  18502. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18503. * @param gradient defines the gradient to use (between 0 and 1)
  18504. * @param factor defines the emit rate to affect to the specified gradient
  18505. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18506. * @returns the current particle system
  18507. */
  18508. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18509. /**
  18510. * Remove a specific emit rate gradient
  18511. * @param gradient defines the gradient to remove
  18512. * @returns the current particle system
  18513. */
  18514. removeEmitRateGradient(gradient: number): IParticleSystem;
  18515. /**
  18516. * Gets the current list of emit rate gradients.
  18517. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18518. * @returns the list of emit rate gradients
  18519. */
  18520. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18521. /**
  18522. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18523. * @param gradient defines the gradient to use (between 0 and 1)
  18524. * @param factor defines the start size to affect to the specified gradient
  18525. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18526. * @returns the current particle system
  18527. */
  18528. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18529. /**
  18530. * Remove a specific start size gradient
  18531. * @param gradient defines the gradient to remove
  18532. * @returns the current particle system
  18533. */
  18534. removeStartSizeGradient(gradient: number): IParticleSystem;
  18535. /**
  18536. * Gets the current list of start size gradients.
  18537. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18538. * @returns the list of start size gradients
  18539. */
  18540. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18541. /**
  18542. * Adds a new life time gradient
  18543. * @param gradient defines the gradient to use (between 0 and 1)
  18544. * @param factor defines the life time factor to affect to the specified gradient
  18545. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18546. * @returns the current particle system
  18547. */
  18548. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18549. /**
  18550. * Remove a specific life time gradient
  18551. * @param gradient defines the gradient to remove
  18552. * @returns the current particle system
  18553. */
  18554. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18555. /**
  18556. * Gets the current list of life time gradients.
  18557. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18558. * @returns the list of life time gradients
  18559. */
  18560. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18561. /**
  18562. * Gets the current list of color gradients.
  18563. * You must use addColorGradient and removeColorGradient to udpate this list
  18564. * @returns the list of color gradients
  18565. */
  18566. getColorGradients(): Nullable<Array<ColorGradient>>;
  18567. /**
  18568. * Adds a new ramp gradient used to remap particle colors
  18569. * @param gradient defines the gradient to use (between 0 and 1)
  18570. * @param color defines the color to affect to the specified gradient
  18571. * @returns the current particle system
  18572. */
  18573. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18574. /**
  18575. * Gets the current list of ramp gradients.
  18576. * You must use addRampGradient and removeRampGradient to udpate this list
  18577. * @returns the list of ramp gradients
  18578. */
  18579. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18580. /** Gets or sets a boolean indicating that ramp gradients must be used
  18581. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18582. */
  18583. useRampGradients: boolean;
  18584. /**
  18585. * Adds a new color remap gradient
  18586. * @param gradient defines the gradient to use (between 0 and 1)
  18587. * @param min defines the color remap minimal range
  18588. * @param max defines the color remap maximal range
  18589. * @returns the current particle system
  18590. */
  18591. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18592. /**
  18593. * Gets the current list of color remap gradients.
  18594. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18595. * @returns the list of color remap gradients
  18596. */
  18597. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18598. /**
  18599. * Adds a new alpha remap gradient
  18600. * @param gradient defines the gradient to use (between 0 and 1)
  18601. * @param min defines the alpha remap minimal range
  18602. * @param max defines the alpha remap maximal range
  18603. * @returns the current particle system
  18604. */
  18605. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18606. /**
  18607. * Gets the current list of alpha remap gradients.
  18608. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18609. * @returns the list of alpha remap gradients
  18610. */
  18611. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18612. /**
  18613. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18614. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18615. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18616. * @returns the emitter
  18617. */
  18618. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18619. /**
  18620. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18621. * @param radius The radius of the hemisphere to emit from
  18622. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18623. * @returns the emitter
  18624. */
  18625. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18626. /**
  18627. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18628. * @param radius The radius of the sphere to emit from
  18629. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18630. * @returns the emitter
  18631. */
  18632. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18633. /**
  18634. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18635. * @param radius The radius of the sphere to emit from
  18636. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18637. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18638. * @returns the emitter
  18639. */
  18640. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18641. /**
  18642. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18643. * @param radius The radius of the emission cylinder
  18644. * @param height The height of the emission cylinder
  18645. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18646. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18647. * @returns the emitter
  18648. */
  18649. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18650. /**
  18651. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18652. * @param radius The radius of the cylinder to emit from
  18653. * @param height The height of the emission cylinder
  18654. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18655. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18656. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18657. * @returns the emitter
  18658. */
  18659. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18660. /**
  18661. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18662. * @param radius The radius of the cone to emit from
  18663. * @param angle The base angle of the cone
  18664. * @returns the emitter
  18665. */
  18666. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18667. /**
  18668. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18669. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18670. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18671. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18672. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18673. * @returns the emitter
  18674. */
  18675. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18676. /**
  18677. * Get hosting scene
  18678. * @returns the scene
  18679. */
  18680. getScene(): Scene;
  18681. }
  18682. }
  18683. declare module BABYLON {
  18684. /**
  18685. * Creates an instance based on a source mesh.
  18686. */
  18687. export class InstancedMesh extends AbstractMesh {
  18688. private _sourceMesh;
  18689. private _currentLOD;
  18690. /** @hidden */
  18691. _indexInSourceMeshInstanceArray: number;
  18692. constructor(name: string, source: Mesh);
  18693. /**
  18694. * Returns the string "InstancedMesh".
  18695. */
  18696. getClassName(): string;
  18697. /** Gets the list of lights affecting that mesh */
  18698. readonly lightSources: Light[];
  18699. _resyncLightSources(): void;
  18700. _resyncLighSource(light: Light): void;
  18701. _removeLightSource(light: Light, dispose: boolean): void;
  18702. /**
  18703. * If the source mesh receives shadows
  18704. */
  18705. readonly receiveShadows: boolean;
  18706. /**
  18707. * The material of the source mesh
  18708. */
  18709. readonly material: Nullable<Material>;
  18710. /**
  18711. * Visibility of the source mesh
  18712. */
  18713. readonly visibility: number;
  18714. /**
  18715. * Skeleton of the source mesh
  18716. */
  18717. readonly skeleton: Nullable<Skeleton>;
  18718. /**
  18719. * Rendering ground id of the source mesh
  18720. */
  18721. renderingGroupId: number;
  18722. /**
  18723. * Returns the total number of vertices (integer).
  18724. */
  18725. getTotalVertices(): number;
  18726. /**
  18727. * Returns a positive integer : the total number of indices in this mesh geometry.
  18728. * @returns the numner of indices or zero if the mesh has no geometry.
  18729. */
  18730. getTotalIndices(): number;
  18731. /**
  18732. * The source mesh of the instance
  18733. */
  18734. readonly sourceMesh: Mesh;
  18735. /**
  18736. * Is this node ready to be used/rendered
  18737. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18738. * @return {boolean} is it ready
  18739. */
  18740. isReady(completeCheck?: boolean): boolean;
  18741. /**
  18742. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18743. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18744. * @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.
  18745. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18746. */
  18747. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18748. /**
  18749. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18750. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18751. * The `data` are either a numeric array either a Float32Array.
  18752. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18753. * 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).
  18754. * Note that a new underlying VertexBuffer object is created each call.
  18755. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18756. *
  18757. * Possible `kind` values :
  18758. * - VertexBuffer.PositionKind
  18759. * - VertexBuffer.UVKind
  18760. * - VertexBuffer.UV2Kind
  18761. * - VertexBuffer.UV3Kind
  18762. * - VertexBuffer.UV4Kind
  18763. * - VertexBuffer.UV5Kind
  18764. * - VertexBuffer.UV6Kind
  18765. * - VertexBuffer.ColorKind
  18766. * - VertexBuffer.MatricesIndicesKind
  18767. * - VertexBuffer.MatricesIndicesExtraKind
  18768. * - VertexBuffer.MatricesWeightsKind
  18769. * - VertexBuffer.MatricesWeightsExtraKind
  18770. *
  18771. * Returns the Mesh.
  18772. */
  18773. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18774. /**
  18775. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18776. * If the mesh has no geometry, it is simply returned as it is.
  18777. * The `data` are either a numeric array either a Float32Array.
  18778. * No new underlying VertexBuffer object is created.
  18779. * 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.
  18780. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18781. *
  18782. * Possible `kind` values :
  18783. * - VertexBuffer.PositionKind
  18784. * - VertexBuffer.UVKind
  18785. * - VertexBuffer.UV2Kind
  18786. * - VertexBuffer.UV3Kind
  18787. * - VertexBuffer.UV4Kind
  18788. * - VertexBuffer.UV5Kind
  18789. * - VertexBuffer.UV6Kind
  18790. * - VertexBuffer.ColorKind
  18791. * - VertexBuffer.MatricesIndicesKind
  18792. * - VertexBuffer.MatricesIndicesExtraKind
  18793. * - VertexBuffer.MatricesWeightsKind
  18794. * - VertexBuffer.MatricesWeightsExtraKind
  18795. *
  18796. * Returns the Mesh.
  18797. */
  18798. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18799. /**
  18800. * Sets the mesh indices.
  18801. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18802. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18803. * This method creates a new index buffer each call.
  18804. * Returns the Mesh.
  18805. */
  18806. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18807. /**
  18808. * Boolean : True if the mesh owns the requested kind of data.
  18809. */
  18810. isVerticesDataPresent(kind: string): boolean;
  18811. /**
  18812. * Returns an array of indices (IndicesArray).
  18813. */
  18814. getIndices(): Nullable<IndicesArray>;
  18815. readonly _positions: Nullable<Vector3[]>;
  18816. /**
  18817. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18818. * This means the mesh underlying bounding box and sphere are recomputed.
  18819. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18820. * @returns the current mesh
  18821. */
  18822. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18823. /** @hidden */
  18824. _preActivate(): InstancedMesh;
  18825. /** @hidden */
  18826. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18827. /** @hidden */
  18828. _postActivate(): void;
  18829. getWorldMatrix(): Matrix;
  18830. readonly isAnInstance: boolean;
  18831. /**
  18832. * Returns the current associated LOD AbstractMesh.
  18833. */
  18834. getLOD(camera: Camera): AbstractMesh;
  18835. /** @hidden */
  18836. _syncSubMeshes(): InstancedMesh;
  18837. /** @hidden */
  18838. _generatePointsArray(): boolean;
  18839. /**
  18840. * Creates a new InstancedMesh from the current mesh.
  18841. * - name (string) : the cloned mesh name
  18842. * - newParent (optional Node) : the optional Node to parent the clone to.
  18843. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18844. *
  18845. * Returns the clone.
  18846. */
  18847. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18848. /**
  18849. * Disposes the InstancedMesh.
  18850. * Returns nothing.
  18851. */
  18852. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18853. }
  18854. }
  18855. declare module BABYLON {
  18856. /**
  18857. * Defines the options associated with the creation of a shader material.
  18858. */
  18859. export interface IShaderMaterialOptions {
  18860. /**
  18861. * Does the material work in alpha blend mode
  18862. */
  18863. needAlphaBlending: boolean;
  18864. /**
  18865. * Does the material work in alpha test mode
  18866. */
  18867. needAlphaTesting: boolean;
  18868. /**
  18869. * The list of attribute names used in the shader
  18870. */
  18871. attributes: string[];
  18872. /**
  18873. * The list of unifrom names used in the shader
  18874. */
  18875. uniforms: string[];
  18876. /**
  18877. * The list of UBO names used in the shader
  18878. */
  18879. uniformBuffers: string[];
  18880. /**
  18881. * The list of sampler names used in the shader
  18882. */
  18883. samplers: string[];
  18884. /**
  18885. * The list of defines used in the shader
  18886. */
  18887. defines: string[];
  18888. }
  18889. /**
  18890. * 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.
  18891. *
  18892. * This returned material effects how the mesh will look based on the code in the shaders.
  18893. *
  18894. * @see http://doc.babylonjs.com/how_to/shader_material
  18895. */
  18896. export class ShaderMaterial extends Material {
  18897. private _shaderPath;
  18898. private _options;
  18899. private _textures;
  18900. private _textureArrays;
  18901. private _floats;
  18902. private _ints;
  18903. private _floatsArrays;
  18904. private _colors3;
  18905. private _colors3Arrays;
  18906. private _colors4;
  18907. private _colors4Arrays;
  18908. private _vectors2;
  18909. private _vectors3;
  18910. private _vectors4;
  18911. private _matrices;
  18912. private _matrices3x3;
  18913. private _matrices2x2;
  18914. private _vectors2Arrays;
  18915. private _vectors3Arrays;
  18916. private _vectors4Arrays;
  18917. private _cachedWorldViewMatrix;
  18918. private _cachedWorldViewProjectionMatrix;
  18919. private _renderId;
  18920. /**
  18921. * Instantiate a new shader material.
  18922. * 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.
  18923. * This returned material effects how the mesh will look based on the code in the shaders.
  18924. * @see http://doc.babylonjs.com/how_to/shader_material
  18925. * @param name Define the name of the material in the scene
  18926. * @param scene Define the scene the material belongs to
  18927. * @param shaderPath Defines the route to the shader code in one of three ways:
  18928. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18929. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  18930. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  18931. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18932. * @param options Define the options used to create the shader
  18933. */
  18934. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18935. /**
  18936. * Gets the options used to compile the shader.
  18937. * They can be modified to trigger a new compilation
  18938. */
  18939. readonly options: IShaderMaterialOptions;
  18940. /**
  18941. * Gets the current class name of the material e.g. "ShaderMaterial"
  18942. * Mainly use in serialization.
  18943. * @returns the class name
  18944. */
  18945. getClassName(): string;
  18946. /**
  18947. * Specifies if the material will require alpha blending
  18948. * @returns a boolean specifying if alpha blending is needed
  18949. */
  18950. needAlphaBlending(): boolean;
  18951. /**
  18952. * Specifies if this material should be rendered in alpha test mode
  18953. * @returns a boolean specifying if an alpha test is needed.
  18954. */
  18955. needAlphaTesting(): boolean;
  18956. private _checkUniform;
  18957. /**
  18958. * Set a texture in the shader.
  18959. * @param name Define the name of the uniform samplers as defined in the shader
  18960. * @param texture Define the texture to bind to this sampler
  18961. * @return the material itself allowing "fluent" like uniform updates
  18962. */
  18963. setTexture(name: string, texture: Texture): ShaderMaterial;
  18964. /**
  18965. * Set a texture array in the shader.
  18966. * @param name Define the name of the uniform sampler array as defined in the shader
  18967. * @param textures Define the list of textures to bind to this sampler
  18968. * @return the material itself allowing "fluent" like uniform updates
  18969. */
  18970. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18971. /**
  18972. * Set a float in the shader.
  18973. * @param name Define the name of the uniform as defined in the shader
  18974. * @param value Define the value to give to the uniform
  18975. * @return the material itself allowing "fluent" like uniform updates
  18976. */
  18977. setFloat(name: string, value: number): ShaderMaterial;
  18978. /**
  18979. * Set a int in the shader.
  18980. * @param name Define the name of the uniform as defined in the shader
  18981. * @param value Define the value to give to the uniform
  18982. * @return the material itself allowing "fluent" like uniform updates
  18983. */
  18984. setInt(name: string, value: number): ShaderMaterial;
  18985. /**
  18986. * Set an array of floats in the shader.
  18987. * @param name Define the name of the uniform as defined in the shader
  18988. * @param value Define the value to give to the uniform
  18989. * @return the material itself allowing "fluent" like uniform updates
  18990. */
  18991. setFloats(name: string, value: number[]): ShaderMaterial;
  18992. /**
  18993. * Set a vec3 in the shader from a Color3.
  18994. * @param name Define the name of the uniform as defined in the shader
  18995. * @param value Define the value to give to the uniform
  18996. * @return the material itself allowing "fluent" like uniform updates
  18997. */
  18998. setColor3(name: string, value: Color3): ShaderMaterial;
  18999. /**
  19000. * Set a vec3 array in the shader from a Color3 array.
  19001. * @param name Define the name of the uniform as defined in the shader
  19002. * @param value Define the value to give to the uniform
  19003. * @return the material itself allowing "fluent" like uniform updates
  19004. */
  19005. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19006. /**
  19007. * Set a vec4 in the shader from a Color4.
  19008. * @param name Define the name of the uniform as defined in the shader
  19009. * @param value Define the value to give to the uniform
  19010. * @return the material itself allowing "fluent" like uniform updates
  19011. */
  19012. setColor4(name: string, value: Color4): ShaderMaterial;
  19013. /**
  19014. * Set a vec4 array in the shader from a Color4 array.
  19015. * @param name Define the name of the uniform as defined in the shader
  19016. * @param value Define the value to give to the uniform
  19017. * @return the material itself allowing "fluent" like uniform updates
  19018. */
  19019. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19020. /**
  19021. * Set a vec2 in the shader from a Vector2.
  19022. * @param name Define the name of the uniform as defined in the shader
  19023. * @param value Define the value to give to the uniform
  19024. * @return the material itself allowing "fluent" like uniform updates
  19025. */
  19026. setVector2(name: string, value: Vector2): ShaderMaterial;
  19027. /**
  19028. * Set a vec3 in the shader from a Vector3.
  19029. * @param name Define the name of the uniform as defined in the shader
  19030. * @param value Define the value to give to the uniform
  19031. * @return the material itself allowing "fluent" like uniform updates
  19032. */
  19033. setVector3(name: string, value: Vector3): ShaderMaterial;
  19034. /**
  19035. * Set a vec4 in the shader from a Vector4.
  19036. * @param name Define the name of the uniform as defined in the shader
  19037. * @param value Define the value to give to the uniform
  19038. * @return the material itself allowing "fluent" like uniform updates
  19039. */
  19040. setVector4(name: string, value: Vector4): ShaderMaterial;
  19041. /**
  19042. * Set a mat4 in the shader from a Matrix.
  19043. * @param name Define the name of the uniform as defined in the shader
  19044. * @param value Define the value to give to the uniform
  19045. * @return the material itself allowing "fluent" like uniform updates
  19046. */
  19047. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19048. /**
  19049. * Set a mat3 in the shader from a Float32Array.
  19050. * @param name Define the name of the uniform as defined in the shader
  19051. * @param value Define the value to give to the uniform
  19052. * @return the material itself allowing "fluent" like uniform updates
  19053. */
  19054. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19055. /**
  19056. * Set a mat2 in the shader from a Float32Array.
  19057. * @param name Define the name of the uniform as defined in the shader
  19058. * @param value Define the value to give to the uniform
  19059. * @return the material itself allowing "fluent" like uniform updates
  19060. */
  19061. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19062. /**
  19063. * Set a vec2 array in the shader from a number array.
  19064. * @param name Define the name of the uniform as defined in the shader
  19065. * @param value Define the value to give to the uniform
  19066. * @return the material itself allowing "fluent" like uniform updates
  19067. */
  19068. setArray2(name: string, value: number[]): ShaderMaterial;
  19069. /**
  19070. * Set a vec3 array in the shader from a number array.
  19071. * @param name Define the name of the uniform as defined in the shader
  19072. * @param value Define the value to give to the uniform
  19073. * @return the material itself allowing "fluent" like uniform updates
  19074. */
  19075. setArray3(name: string, value: number[]): ShaderMaterial;
  19076. /**
  19077. * Set a vec4 array in the shader from a number array.
  19078. * @param name Define the name of the uniform as defined in the shader
  19079. * @param value Define the value to give to the uniform
  19080. * @return the material itself allowing "fluent" like uniform updates
  19081. */
  19082. setArray4(name: string, value: number[]): ShaderMaterial;
  19083. private _checkCache;
  19084. /**
  19085. * Specifies that the submesh is ready to be used
  19086. * @param mesh defines the mesh to check
  19087. * @param subMesh defines which submesh to check
  19088. * @param useInstances specifies that instances should be used
  19089. * @returns a boolean indicating that the submesh is ready or not
  19090. */
  19091. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19092. /**
  19093. * Checks if the material is ready to render the requested mesh
  19094. * @param mesh Define the mesh to render
  19095. * @param useInstances Define whether or not the material is used with instances
  19096. * @returns true if ready, otherwise false
  19097. */
  19098. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19099. /**
  19100. * Binds the world matrix to the material
  19101. * @param world defines the world transformation matrix
  19102. */
  19103. bindOnlyWorldMatrix(world: Matrix): void;
  19104. /**
  19105. * Binds the material to the mesh
  19106. * @param world defines the world transformation matrix
  19107. * @param mesh defines the mesh to bind the material to
  19108. */
  19109. bind(world: Matrix, mesh?: Mesh): void;
  19110. /**
  19111. * Gets the active textures from the material
  19112. * @returns an array of textures
  19113. */
  19114. getActiveTextures(): BaseTexture[];
  19115. /**
  19116. * Specifies if the material uses a texture
  19117. * @param texture defines the texture to check against the material
  19118. * @returns a boolean specifying if the material uses the texture
  19119. */
  19120. hasTexture(texture: BaseTexture): boolean;
  19121. /**
  19122. * Makes a duplicate of the material, and gives it a new name
  19123. * @param name defines the new name for the duplicated material
  19124. * @returns the cloned material
  19125. */
  19126. clone(name: string): ShaderMaterial;
  19127. /**
  19128. * Disposes the material
  19129. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19130. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19131. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19132. */
  19133. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19134. /**
  19135. * Serializes this material in a JSON representation
  19136. * @returns the serialized material object
  19137. */
  19138. serialize(): any;
  19139. /**
  19140. * Creates a shader material from parsed shader material data
  19141. * @param source defines the JSON represnetation of the material
  19142. * @param scene defines the hosting scene
  19143. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19144. * @returns a new material
  19145. */
  19146. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19147. }
  19148. }
  19149. declare module BABYLON {
  19150. /** @hidden */
  19151. export var colorPixelShader: {
  19152. name: string;
  19153. shader: string;
  19154. };
  19155. }
  19156. declare module BABYLON {
  19157. /** @hidden */
  19158. export var colorVertexShader: {
  19159. name: string;
  19160. shader: string;
  19161. };
  19162. }
  19163. declare module BABYLON {
  19164. /**
  19165. * Line mesh
  19166. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19167. */
  19168. export class LinesMesh extends Mesh {
  19169. /**
  19170. * If vertex color should be applied to the mesh
  19171. */
  19172. readonly useVertexColor?: boolean | undefined;
  19173. /**
  19174. * If vertex alpha should be applied to the mesh
  19175. */
  19176. readonly useVertexAlpha?: boolean | undefined;
  19177. /**
  19178. * Color of the line (Default: White)
  19179. */
  19180. color: Color3;
  19181. /**
  19182. * Alpha of the line (Default: 1)
  19183. */
  19184. alpha: number;
  19185. /**
  19186. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19187. * This margin is expressed in world space coordinates, so its value may vary.
  19188. * Default value is 0.1
  19189. */
  19190. intersectionThreshold: number;
  19191. private _colorShader;
  19192. private color4;
  19193. /**
  19194. * Creates a new LinesMesh
  19195. * @param name defines the name
  19196. * @param scene defines the hosting scene
  19197. * @param parent defines the parent mesh if any
  19198. * @param source defines the optional source LinesMesh used to clone data from
  19199. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19200. * When false, achieved by calling a clone(), also passing False.
  19201. * This will make creation of children, recursive.
  19202. * @param useVertexColor defines if this LinesMesh supports vertex color
  19203. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19204. */
  19205. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19206. /**
  19207. * If vertex color should be applied to the mesh
  19208. */
  19209. useVertexColor?: boolean | undefined,
  19210. /**
  19211. * If vertex alpha should be applied to the mesh
  19212. */
  19213. useVertexAlpha?: boolean | undefined);
  19214. private _addClipPlaneDefine;
  19215. private _removeClipPlaneDefine;
  19216. isReady(): boolean;
  19217. /**
  19218. * Returns the string "LineMesh"
  19219. */
  19220. getClassName(): string;
  19221. /**
  19222. * @hidden
  19223. */
  19224. /**
  19225. * @hidden
  19226. */
  19227. material: Material;
  19228. /**
  19229. * @hidden
  19230. */
  19231. readonly checkCollisions: boolean;
  19232. /** @hidden */
  19233. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19234. /** @hidden */
  19235. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19236. /**
  19237. * Disposes of the line mesh
  19238. * @param doNotRecurse If children should be disposed
  19239. */
  19240. dispose(doNotRecurse?: boolean): void;
  19241. /**
  19242. * Returns a new LineMesh object cloned from the current one.
  19243. */
  19244. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19245. /**
  19246. * Creates a new InstancedLinesMesh object from the mesh model.
  19247. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19248. * @param name defines the name of the new instance
  19249. * @returns a new InstancedLinesMesh
  19250. */
  19251. createInstance(name: string): InstancedLinesMesh;
  19252. }
  19253. /**
  19254. * Creates an instance based on a source LinesMesh
  19255. */
  19256. export class InstancedLinesMesh extends InstancedMesh {
  19257. /**
  19258. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19259. * This margin is expressed in world space coordinates, so its value may vary.
  19260. * Initilized with the intersectionThreshold value of the source LinesMesh
  19261. */
  19262. intersectionThreshold: number;
  19263. constructor(name: string, source: LinesMesh);
  19264. /**
  19265. * Returns the string "InstancedLinesMesh".
  19266. */
  19267. getClassName(): string;
  19268. }
  19269. }
  19270. declare module BABYLON {
  19271. /** @hidden */
  19272. export var linePixelShader: {
  19273. name: string;
  19274. shader: string;
  19275. };
  19276. }
  19277. declare module BABYLON {
  19278. /** @hidden */
  19279. export var lineVertexShader: {
  19280. name: string;
  19281. shader: string;
  19282. };
  19283. }
  19284. declare module BABYLON {
  19285. interface AbstractMesh {
  19286. /**
  19287. * Gets the edgesRenderer associated with the mesh
  19288. */
  19289. edgesRenderer: Nullable<EdgesRenderer>;
  19290. }
  19291. interface LinesMesh {
  19292. /**
  19293. * Enables the edge rendering mode on the mesh.
  19294. * This mode makes the mesh edges visible
  19295. * @param epsilon defines the maximal distance between two angles to detect a face
  19296. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19297. * @returns the currentAbstractMesh
  19298. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19299. */
  19300. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19301. }
  19302. interface InstancedLinesMesh {
  19303. /**
  19304. * Enables the edge rendering mode on the mesh.
  19305. * This mode makes the mesh edges visible
  19306. * @param epsilon defines the maximal distance between two angles to detect a face
  19307. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19308. * @returns the current InstancedLinesMesh
  19309. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19310. */
  19311. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19312. }
  19313. /**
  19314. * Defines the minimum contract an Edges renderer should follow.
  19315. */
  19316. export interface IEdgesRenderer extends IDisposable {
  19317. /**
  19318. * Gets or sets a boolean indicating if the edgesRenderer is active
  19319. */
  19320. isEnabled: boolean;
  19321. /**
  19322. * Renders the edges of the attached mesh,
  19323. */
  19324. render(): void;
  19325. /**
  19326. * Checks wether or not the edges renderer is ready to render.
  19327. * @return true if ready, otherwise false.
  19328. */
  19329. isReady(): boolean;
  19330. }
  19331. /**
  19332. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19333. */
  19334. export class EdgesRenderer implements IEdgesRenderer {
  19335. /**
  19336. * Define the size of the edges with an orthographic camera
  19337. */
  19338. edgesWidthScalerForOrthographic: number;
  19339. /**
  19340. * Define the size of the edges with a perspective camera
  19341. */
  19342. edgesWidthScalerForPerspective: number;
  19343. protected _source: AbstractMesh;
  19344. protected _linesPositions: number[];
  19345. protected _linesNormals: number[];
  19346. protected _linesIndices: number[];
  19347. protected _epsilon: number;
  19348. protected _indicesCount: number;
  19349. protected _lineShader: ShaderMaterial;
  19350. protected _ib: DataBuffer;
  19351. protected _buffers: {
  19352. [key: string]: Nullable<VertexBuffer>;
  19353. };
  19354. protected _checkVerticesInsteadOfIndices: boolean;
  19355. private _meshRebuildObserver;
  19356. private _meshDisposeObserver;
  19357. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19358. isEnabled: boolean;
  19359. /**
  19360. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19361. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19362. * @param source Mesh used to create edges
  19363. * @param epsilon sum of angles in adjacency to check for edge
  19364. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19365. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19366. */
  19367. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19368. protected _prepareRessources(): void;
  19369. /** @hidden */
  19370. _rebuild(): void;
  19371. /**
  19372. * Releases the required resources for the edges renderer
  19373. */
  19374. dispose(): void;
  19375. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19376. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19377. /**
  19378. * Checks if the pair of p0 and p1 is en edge
  19379. * @param faceIndex
  19380. * @param edge
  19381. * @param faceNormals
  19382. * @param p0
  19383. * @param p1
  19384. * @private
  19385. */
  19386. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19387. /**
  19388. * push line into the position, normal and index buffer
  19389. * @protected
  19390. */
  19391. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19392. /**
  19393. * Generates lines edges from adjacencjes
  19394. * @private
  19395. */
  19396. _generateEdgesLines(): void;
  19397. /**
  19398. * Checks wether or not the edges renderer is ready to render.
  19399. * @return true if ready, otherwise false.
  19400. */
  19401. isReady(): boolean;
  19402. /**
  19403. * Renders the edges of the attached mesh,
  19404. */
  19405. render(): void;
  19406. }
  19407. /**
  19408. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19409. */
  19410. export class LineEdgesRenderer extends EdgesRenderer {
  19411. /**
  19412. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19413. * @param source LineMesh used to generate edges
  19414. * @param epsilon not important (specified angle for edge detection)
  19415. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19416. */
  19417. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19418. /**
  19419. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19420. */
  19421. _generateEdgesLines(): void;
  19422. }
  19423. }
  19424. declare module BABYLON {
  19425. /**
  19426. * This represents the object necessary to create a rendering group.
  19427. * This is exclusively used and created by the rendering manager.
  19428. * To modify the behavior, you use the available helpers in your scene or meshes.
  19429. * @hidden
  19430. */
  19431. export class RenderingGroup {
  19432. index: number;
  19433. private static _zeroVector;
  19434. private _scene;
  19435. private _opaqueSubMeshes;
  19436. private _transparentSubMeshes;
  19437. private _alphaTestSubMeshes;
  19438. private _depthOnlySubMeshes;
  19439. private _particleSystems;
  19440. private _spriteManagers;
  19441. private _opaqueSortCompareFn;
  19442. private _alphaTestSortCompareFn;
  19443. private _transparentSortCompareFn;
  19444. private _renderOpaque;
  19445. private _renderAlphaTest;
  19446. private _renderTransparent;
  19447. /** @hidden */
  19448. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19449. onBeforeTransparentRendering: () => void;
  19450. /**
  19451. * Set the opaque sort comparison function.
  19452. * If null the sub meshes will be render in the order they were created
  19453. */
  19454. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19455. /**
  19456. * Set the alpha test sort comparison function.
  19457. * If null the sub meshes will be render in the order they were created
  19458. */
  19459. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19460. /**
  19461. * Set the transparent sort comparison function.
  19462. * If null the sub meshes will be render in the order they were created
  19463. */
  19464. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19465. /**
  19466. * Creates a new rendering group.
  19467. * @param index The rendering group index
  19468. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19469. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19470. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19471. */
  19472. 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>);
  19473. /**
  19474. * Render all the sub meshes contained in the group.
  19475. * @param customRenderFunction Used to override the default render behaviour of the group.
  19476. * @returns true if rendered some submeshes.
  19477. */
  19478. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19479. /**
  19480. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19481. * @param subMeshes The submeshes to render
  19482. */
  19483. private renderOpaqueSorted;
  19484. /**
  19485. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19486. * @param subMeshes The submeshes to render
  19487. */
  19488. private renderAlphaTestSorted;
  19489. /**
  19490. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19491. * @param subMeshes The submeshes to render
  19492. */
  19493. private renderTransparentSorted;
  19494. /**
  19495. * Renders the submeshes in a specified order.
  19496. * @param subMeshes The submeshes to sort before render
  19497. * @param sortCompareFn The comparison function use to sort
  19498. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19499. * @param transparent Specifies to activate blending if true
  19500. */
  19501. private static renderSorted;
  19502. /**
  19503. * Renders the submeshes in the order they were dispatched (no sort applied).
  19504. * @param subMeshes The submeshes to render
  19505. */
  19506. private static renderUnsorted;
  19507. /**
  19508. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19509. * are rendered back to front if in the same alpha index.
  19510. *
  19511. * @param a The first submesh
  19512. * @param b The second submesh
  19513. * @returns The result of the comparison
  19514. */
  19515. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19516. /**
  19517. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19518. * are rendered back to front.
  19519. *
  19520. * @param a The first submesh
  19521. * @param b The second submesh
  19522. * @returns The result of the comparison
  19523. */
  19524. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19525. /**
  19526. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19527. * are rendered front to back (prevent overdraw).
  19528. *
  19529. * @param a The first submesh
  19530. * @param b The second submesh
  19531. * @returns The result of the comparison
  19532. */
  19533. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19534. /**
  19535. * Resets the different lists of submeshes to prepare a new frame.
  19536. */
  19537. prepare(): void;
  19538. dispose(): void;
  19539. /**
  19540. * Inserts the submesh in its correct queue depending on its material.
  19541. * @param subMesh The submesh to dispatch
  19542. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19543. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19544. */
  19545. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19546. dispatchSprites(spriteManager: ISpriteManager): void;
  19547. dispatchParticles(particleSystem: IParticleSystem): void;
  19548. private _renderParticles;
  19549. private _renderSprites;
  19550. }
  19551. }
  19552. declare module BABYLON {
  19553. /**
  19554. * Interface describing the different options available in the rendering manager
  19555. * regarding Auto Clear between groups.
  19556. */
  19557. export interface IRenderingManagerAutoClearSetup {
  19558. /**
  19559. * Defines whether or not autoclear is enable.
  19560. */
  19561. autoClear: boolean;
  19562. /**
  19563. * Defines whether or not to autoclear the depth buffer.
  19564. */
  19565. depth: boolean;
  19566. /**
  19567. * Defines whether or not to autoclear the stencil buffer.
  19568. */
  19569. stencil: boolean;
  19570. }
  19571. /**
  19572. * This class is used by the onRenderingGroupObservable
  19573. */
  19574. export class RenderingGroupInfo {
  19575. /**
  19576. * The Scene that being rendered
  19577. */
  19578. scene: Scene;
  19579. /**
  19580. * The camera currently used for the rendering pass
  19581. */
  19582. camera: Nullable<Camera>;
  19583. /**
  19584. * The ID of the renderingGroup being processed
  19585. */
  19586. renderingGroupId: number;
  19587. }
  19588. /**
  19589. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19590. * It is enable to manage the different groups as well as the different necessary sort functions.
  19591. * This should not be used directly aside of the few static configurations
  19592. */
  19593. export class RenderingManager {
  19594. /**
  19595. * The max id used for rendering groups (not included)
  19596. */
  19597. static MAX_RENDERINGGROUPS: number;
  19598. /**
  19599. * The min id used for rendering groups (included)
  19600. */
  19601. static MIN_RENDERINGGROUPS: number;
  19602. /**
  19603. * Used to globally prevent autoclearing scenes.
  19604. */
  19605. static AUTOCLEAR: boolean;
  19606. /**
  19607. * @hidden
  19608. */
  19609. _useSceneAutoClearSetup: boolean;
  19610. private _scene;
  19611. private _renderingGroups;
  19612. private _depthStencilBufferAlreadyCleaned;
  19613. private _autoClearDepthStencil;
  19614. private _customOpaqueSortCompareFn;
  19615. private _customAlphaTestSortCompareFn;
  19616. private _customTransparentSortCompareFn;
  19617. private _renderingGroupInfo;
  19618. /**
  19619. * Instantiates a new rendering group for a particular scene
  19620. * @param scene Defines the scene the groups belongs to
  19621. */
  19622. constructor(scene: Scene);
  19623. private _clearDepthStencilBuffer;
  19624. /**
  19625. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19626. * @hidden
  19627. */
  19628. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19629. /**
  19630. * Resets the different information of the group to prepare a new frame
  19631. * @hidden
  19632. */
  19633. reset(): void;
  19634. /**
  19635. * Dispose and release the group and its associated resources.
  19636. * @hidden
  19637. */
  19638. dispose(): void;
  19639. /**
  19640. * Clear the info related to rendering groups preventing retention points during dispose.
  19641. */
  19642. freeRenderingGroups(): void;
  19643. private _prepareRenderingGroup;
  19644. /**
  19645. * Add a sprite manager to the rendering manager in order to render it this frame.
  19646. * @param spriteManager Define the sprite manager to render
  19647. */
  19648. dispatchSprites(spriteManager: ISpriteManager): void;
  19649. /**
  19650. * Add a particle system to the rendering manager in order to render it this frame.
  19651. * @param particleSystem Define the particle system to render
  19652. */
  19653. dispatchParticles(particleSystem: IParticleSystem): void;
  19654. /**
  19655. * Add a submesh to the manager in order to render it this frame
  19656. * @param subMesh The submesh to dispatch
  19657. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19658. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19659. */
  19660. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19661. /**
  19662. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19663. * This allowed control for front to back rendering or reversly depending of the special needs.
  19664. *
  19665. * @param renderingGroupId The rendering group id corresponding to its index
  19666. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19667. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19668. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19669. */
  19670. 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;
  19671. /**
  19672. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19673. *
  19674. * @param renderingGroupId The rendering group id corresponding to its index
  19675. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19676. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19677. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19678. */
  19679. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19680. /**
  19681. * Gets the current auto clear configuration for one rendering group of the rendering
  19682. * manager.
  19683. * @param index the rendering group index to get the information for
  19684. * @returns The auto clear setup for the requested rendering group
  19685. */
  19686. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19687. }
  19688. }
  19689. declare module BABYLON {
  19690. /**
  19691. * This Helps creating a texture that will be created from a camera in your scene.
  19692. * It is basically a dynamic texture that could be used to create special effects for instance.
  19693. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19694. */
  19695. export class RenderTargetTexture extends Texture {
  19696. isCube: boolean;
  19697. /**
  19698. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19699. */
  19700. static readonly REFRESHRATE_RENDER_ONCE: number;
  19701. /**
  19702. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19703. */
  19704. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19705. /**
  19706. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19707. * the central point of your effect and can save a lot of performances.
  19708. */
  19709. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19710. /**
  19711. * Use this predicate to dynamically define the list of mesh you want to render.
  19712. * If set, the renderList property will be overwritten.
  19713. */
  19714. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19715. private _renderList;
  19716. /**
  19717. * Use this list to define the list of mesh you want to render.
  19718. */
  19719. renderList: Nullable<Array<AbstractMesh>>;
  19720. private _hookArray;
  19721. /**
  19722. * Define if particles should be rendered in your texture.
  19723. */
  19724. renderParticles: boolean;
  19725. /**
  19726. * Define if sprites should be rendered in your texture.
  19727. */
  19728. renderSprites: boolean;
  19729. /**
  19730. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19731. */
  19732. coordinatesMode: number;
  19733. /**
  19734. * Define the camera used to render the texture.
  19735. */
  19736. activeCamera: Nullable<Camera>;
  19737. /**
  19738. * Override the render function of the texture with your own one.
  19739. */
  19740. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19741. /**
  19742. * Define if camera post processes should be use while rendering the texture.
  19743. */
  19744. useCameraPostProcesses: boolean;
  19745. /**
  19746. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19747. */
  19748. ignoreCameraViewport: boolean;
  19749. private _postProcessManager;
  19750. private _postProcesses;
  19751. private _resizeObserver;
  19752. /**
  19753. * An event triggered when the texture is unbind.
  19754. */
  19755. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19756. /**
  19757. * An event triggered when the texture is unbind.
  19758. */
  19759. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19760. private _onAfterUnbindObserver;
  19761. /**
  19762. * Set a after unbind callback in the texture.
  19763. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19764. */
  19765. onAfterUnbind: () => void;
  19766. /**
  19767. * An event triggered before rendering the texture
  19768. */
  19769. onBeforeRenderObservable: Observable<number>;
  19770. private _onBeforeRenderObserver;
  19771. /**
  19772. * Set a before render callback in the texture.
  19773. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19774. */
  19775. onBeforeRender: (faceIndex: number) => void;
  19776. /**
  19777. * An event triggered after rendering the texture
  19778. */
  19779. onAfterRenderObservable: Observable<number>;
  19780. private _onAfterRenderObserver;
  19781. /**
  19782. * Set a after render callback in the texture.
  19783. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19784. */
  19785. onAfterRender: (faceIndex: number) => void;
  19786. /**
  19787. * An event triggered after the texture clear
  19788. */
  19789. onClearObservable: Observable<Engine>;
  19790. private _onClearObserver;
  19791. /**
  19792. * Set a clear callback in the texture.
  19793. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19794. */
  19795. onClear: (Engine: Engine) => void;
  19796. /**
  19797. * An event triggered when the texture is resized.
  19798. */
  19799. onResizeObservable: Observable<RenderTargetTexture>;
  19800. /**
  19801. * Define the clear color of the Render Target if it should be different from the scene.
  19802. */
  19803. clearColor: Color4;
  19804. protected _size: number | {
  19805. width: number;
  19806. height: number;
  19807. };
  19808. protected _initialSizeParameter: number | {
  19809. width: number;
  19810. height: number;
  19811. } | {
  19812. ratio: number;
  19813. };
  19814. protected _sizeRatio: Nullable<number>;
  19815. /** @hidden */
  19816. _generateMipMaps: boolean;
  19817. protected _renderingManager: RenderingManager;
  19818. /** @hidden */
  19819. _waitingRenderList: string[];
  19820. protected _doNotChangeAspectRatio: boolean;
  19821. protected _currentRefreshId: number;
  19822. protected _refreshRate: number;
  19823. protected _textureMatrix: Matrix;
  19824. protected _samples: number;
  19825. protected _renderTargetOptions: RenderTargetCreationOptions;
  19826. /**
  19827. * Gets render target creation options that were used.
  19828. */
  19829. readonly renderTargetOptions: RenderTargetCreationOptions;
  19830. protected _engine: Engine;
  19831. protected _onRatioRescale(): void;
  19832. /**
  19833. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19834. * It must define where the camera used to render the texture is set
  19835. */
  19836. boundingBoxPosition: Vector3;
  19837. private _boundingBoxSize;
  19838. /**
  19839. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19840. * When defined, the cubemap will switch to local mode
  19841. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19842. * @example https://www.babylonjs-playground.com/#RNASML
  19843. */
  19844. boundingBoxSize: Vector3;
  19845. /**
  19846. * In case the RTT has been created with a depth texture, get the associated
  19847. * depth texture.
  19848. * Otherwise, return null.
  19849. */
  19850. depthStencilTexture: Nullable<InternalTexture>;
  19851. /**
  19852. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19853. * or used a shadow, depth texture...
  19854. * @param name The friendly name of the texture
  19855. * @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)
  19856. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19857. * @param generateMipMaps True if mip maps need to be generated after render.
  19858. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19859. * @param type The type of the buffer in the RTT (int, half float, float...)
  19860. * @param isCube True if a cube texture needs to be created
  19861. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19862. * @param generateDepthBuffer True to generate a depth buffer
  19863. * @param generateStencilBuffer True to generate a stencil buffer
  19864. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19865. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19866. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19867. */
  19868. constructor(name: string, size: number | {
  19869. width: number;
  19870. height: number;
  19871. } | {
  19872. ratio: number;
  19873. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19874. /**
  19875. * Creates a depth stencil texture.
  19876. * This is only available in WebGL 2 or with the depth texture extension available.
  19877. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19878. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19879. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19880. */
  19881. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19882. private _processSizeParameter;
  19883. /**
  19884. * Define the number of samples to use in case of MSAA.
  19885. * It defaults to one meaning no MSAA has been enabled.
  19886. */
  19887. samples: number;
  19888. /**
  19889. * Resets the refresh counter of the texture and start bak from scratch.
  19890. * Could be useful to regenerate the texture if it is setup to render only once.
  19891. */
  19892. resetRefreshCounter(): void;
  19893. /**
  19894. * Define the refresh rate of the texture or the rendering frequency.
  19895. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19896. */
  19897. refreshRate: number;
  19898. /**
  19899. * Adds a post process to the render target rendering passes.
  19900. * @param postProcess define the post process to add
  19901. */
  19902. addPostProcess(postProcess: PostProcess): void;
  19903. /**
  19904. * Clear all the post processes attached to the render target
  19905. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19906. */
  19907. clearPostProcesses(dispose?: boolean): void;
  19908. /**
  19909. * Remove one of the post process from the list of attached post processes to the texture
  19910. * @param postProcess define the post process to remove from the list
  19911. */
  19912. removePostProcess(postProcess: PostProcess): void;
  19913. /** @hidden */
  19914. _shouldRender(): boolean;
  19915. /**
  19916. * Gets the actual render size of the texture.
  19917. * @returns the width of the render size
  19918. */
  19919. getRenderSize(): number;
  19920. /**
  19921. * Gets the actual render width of the texture.
  19922. * @returns the width of the render size
  19923. */
  19924. getRenderWidth(): number;
  19925. /**
  19926. * Gets the actual render height of the texture.
  19927. * @returns the height of the render size
  19928. */
  19929. getRenderHeight(): number;
  19930. /**
  19931. * Get if the texture can be rescaled or not.
  19932. */
  19933. readonly canRescale: boolean;
  19934. /**
  19935. * Resize the texture using a ratio.
  19936. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19937. */
  19938. scale(ratio: number): void;
  19939. /**
  19940. * Get the texture reflection matrix used to rotate/transform the reflection.
  19941. * @returns the reflection matrix
  19942. */
  19943. getReflectionTextureMatrix(): Matrix;
  19944. /**
  19945. * Resize the texture to a new desired size.
  19946. * Be carrefull as it will recreate all the data in the new texture.
  19947. * @param size Define the new size. It can be:
  19948. * - a number for squared texture,
  19949. * - an object containing { width: number, height: number }
  19950. * - or an object containing a ratio { ratio: number }
  19951. */
  19952. resize(size: number | {
  19953. width: number;
  19954. height: number;
  19955. } | {
  19956. ratio: number;
  19957. }): void;
  19958. /**
  19959. * Renders all the objects from the render list into the texture.
  19960. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19961. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19962. */
  19963. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19964. private _bestReflectionRenderTargetDimension;
  19965. /**
  19966. * @hidden
  19967. * @param faceIndex face index to bind to if this is a cubetexture
  19968. */
  19969. _bindFrameBuffer(faceIndex?: number): void;
  19970. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19971. private renderToTarget;
  19972. /**
  19973. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19974. * This allowed control for front to back rendering or reversly depending of the special needs.
  19975. *
  19976. * @param renderingGroupId The rendering group id corresponding to its index
  19977. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19978. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19979. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19980. */
  19981. 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;
  19982. /**
  19983. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19984. *
  19985. * @param renderingGroupId The rendering group id corresponding to its index
  19986. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19987. */
  19988. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19989. /**
  19990. * Clones the texture.
  19991. * @returns the cloned texture
  19992. */
  19993. clone(): RenderTargetTexture;
  19994. /**
  19995. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19996. * @returns The JSON representation of the texture
  19997. */
  19998. serialize(): any;
  19999. /**
  20000. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20001. */
  20002. disposeFramebufferObjects(): void;
  20003. /**
  20004. * Dispose the texture and release its associated resources.
  20005. */
  20006. dispose(): void;
  20007. /** @hidden */
  20008. _rebuild(): void;
  20009. /**
  20010. * Clear the info related to rendering groups preventing retention point in material dispose.
  20011. */
  20012. freeRenderingGroups(): void;
  20013. /**
  20014. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20015. * @returns the view count
  20016. */
  20017. getViewCount(): number;
  20018. }
  20019. }
  20020. declare module BABYLON {
  20021. /**
  20022. * Base class for the main features of a material in Babylon.js
  20023. */
  20024. export class Material implements IAnimatable {
  20025. /**
  20026. * Returns the triangle fill mode
  20027. */
  20028. static readonly TriangleFillMode: number;
  20029. /**
  20030. * Returns the wireframe mode
  20031. */
  20032. static readonly WireFrameFillMode: number;
  20033. /**
  20034. * Returns the point fill mode
  20035. */
  20036. static readonly PointFillMode: number;
  20037. /**
  20038. * Returns the point list draw mode
  20039. */
  20040. static readonly PointListDrawMode: number;
  20041. /**
  20042. * Returns the line list draw mode
  20043. */
  20044. static readonly LineListDrawMode: number;
  20045. /**
  20046. * Returns the line loop draw mode
  20047. */
  20048. static readonly LineLoopDrawMode: number;
  20049. /**
  20050. * Returns the line strip draw mode
  20051. */
  20052. static readonly LineStripDrawMode: number;
  20053. /**
  20054. * Returns the triangle strip draw mode
  20055. */
  20056. static readonly TriangleStripDrawMode: number;
  20057. /**
  20058. * Returns the triangle fan draw mode
  20059. */
  20060. static readonly TriangleFanDrawMode: number;
  20061. /**
  20062. * Stores the clock-wise side orientation
  20063. */
  20064. static readonly ClockWiseSideOrientation: number;
  20065. /**
  20066. * Stores the counter clock-wise side orientation
  20067. */
  20068. static readonly CounterClockWiseSideOrientation: number;
  20069. /**
  20070. * The dirty texture flag value
  20071. */
  20072. static readonly TextureDirtyFlag: number;
  20073. /**
  20074. * The dirty light flag value
  20075. */
  20076. static readonly LightDirtyFlag: number;
  20077. /**
  20078. * The dirty fresnel flag value
  20079. */
  20080. static readonly FresnelDirtyFlag: number;
  20081. /**
  20082. * The dirty attribute flag value
  20083. */
  20084. static readonly AttributesDirtyFlag: number;
  20085. /**
  20086. * The dirty misc flag value
  20087. */
  20088. static readonly MiscDirtyFlag: number;
  20089. /**
  20090. * The all dirty flag value
  20091. */
  20092. static readonly AllDirtyFlag: number;
  20093. /**
  20094. * The ID of the material
  20095. */
  20096. id: string;
  20097. /**
  20098. * Gets or sets the unique id of the material
  20099. */
  20100. uniqueId: number;
  20101. /**
  20102. * The name of the material
  20103. */
  20104. name: string;
  20105. /**
  20106. * Gets or sets user defined metadata
  20107. */
  20108. metadata: any;
  20109. /**
  20110. * For internal use only. Please do not use.
  20111. */
  20112. reservedDataStore: any;
  20113. /**
  20114. * Specifies if the ready state should be checked on each call
  20115. */
  20116. checkReadyOnEveryCall: boolean;
  20117. /**
  20118. * Specifies if the ready state should be checked once
  20119. */
  20120. checkReadyOnlyOnce: boolean;
  20121. /**
  20122. * The state of the material
  20123. */
  20124. state: string;
  20125. /**
  20126. * The alpha value of the material
  20127. */
  20128. protected _alpha: number;
  20129. /**
  20130. * List of inspectable custom properties (used by the Inspector)
  20131. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20132. */
  20133. inspectableCustomProperties: IInspectable[];
  20134. /**
  20135. * Sets the alpha value of the material
  20136. */
  20137. /**
  20138. * Gets the alpha value of the material
  20139. */
  20140. alpha: number;
  20141. /**
  20142. * Specifies if back face culling is enabled
  20143. */
  20144. protected _backFaceCulling: boolean;
  20145. /**
  20146. * Sets the back-face culling state
  20147. */
  20148. /**
  20149. * Gets the back-face culling state
  20150. */
  20151. backFaceCulling: boolean;
  20152. /**
  20153. * Stores the value for side orientation
  20154. */
  20155. sideOrientation: number;
  20156. /**
  20157. * Callback triggered when the material is compiled
  20158. */
  20159. onCompiled: Nullable<(effect: Effect) => void>;
  20160. /**
  20161. * Callback triggered when an error occurs
  20162. */
  20163. onError: Nullable<(effect: Effect, errors: string) => void>;
  20164. /**
  20165. * Callback triggered to get the render target textures
  20166. */
  20167. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20168. /**
  20169. * Gets a boolean indicating that current material needs to register RTT
  20170. */
  20171. readonly hasRenderTargetTextures: boolean;
  20172. /**
  20173. * Specifies if the material should be serialized
  20174. */
  20175. doNotSerialize: boolean;
  20176. /**
  20177. * @hidden
  20178. */
  20179. _storeEffectOnSubMeshes: boolean;
  20180. /**
  20181. * Stores the animations for the material
  20182. */
  20183. animations: Nullable<Array<Animation>>;
  20184. /**
  20185. * An event triggered when the material is disposed
  20186. */
  20187. onDisposeObservable: Observable<Material>;
  20188. /**
  20189. * An observer which watches for dispose events
  20190. */
  20191. private _onDisposeObserver;
  20192. private _onUnBindObservable;
  20193. /**
  20194. * Called during a dispose event
  20195. */
  20196. onDispose: () => void;
  20197. private _onBindObservable;
  20198. /**
  20199. * An event triggered when the material is bound
  20200. */
  20201. readonly onBindObservable: Observable<AbstractMesh>;
  20202. /**
  20203. * An observer which watches for bind events
  20204. */
  20205. private _onBindObserver;
  20206. /**
  20207. * Called during a bind event
  20208. */
  20209. onBind: (Mesh: AbstractMesh) => void;
  20210. /**
  20211. * An event triggered when the material is unbound
  20212. */
  20213. readonly onUnBindObservable: Observable<Material>;
  20214. /**
  20215. * Stores the value of the alpha mode
  20216. */
  20217. private _alphaMode;
  20218. /**
  20219. * Sets the value of the alpha mode.
  20220. *
  20221. * | Value | Type | Description |
  20222. * | --- | --- | --- |
  20223. * | 0 | ALPHA_DISABLE | |
  20224. * | 1 | ALPHA_ADD | |
  20225. * | 2 | ALPHA_COMBINE | |
  20226. * | 3 | ALPHA_SUBTRACT | |
  20227. * | 4 | ALPHA_MULTIPLY | |
  20228. * | 5 | ALPHA_MAXIMIZED | |
  20229. * | 6 | ALPHA_ONEONE | |
  20230. * | 7 | ALPHA_PREMULTIPLIED | |
  20231. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20232. * | 9 | ALPHA_INTERPOLATE | |
  20233. * | 10 | ALPHA_SCREENMODE | |
  20234. *
  20235. */
  20236. /**
  20237. * Gets the value of the alpha mode
  20238. */
  20239. alphaMode: number;
  20240. /**
  20241. * Stores the state of the need depth pre-pass value
  20242. */
  20243. private _needDepthPrePass;
  20244. /**
  20245. * Sets the need depth pre-pass value
  20246. */
  20247. /**
  20248. * Gets the depth pre-pass value
  20249. */
  20250. needDepthPrePass: boolean;
  20251. /**
  20252. * Specifies if depth writing should be disabled
  20253. */
  20254. disableDepthWrite: boolean;
  20255. /**
  20256. * Specifies if depth writing should be forced
  20257. */
  20258. forceDepthWrite: boolean;
  20259. /**
  20260. * Specifies if there should be a separate pass for culling
  20261. */
  20262. separateCullingPass: boolean;
  20263. /**
  20264. * Stores the state specifing if fog should be enabled
  20265. */
  20266. private _fogEnabled;
  20267. /**
  20268. * Sets the state for enabling fog
  20269. */
  20270. /**
  20271. * Gets the value of the fog enabled state
  20272. */
  20273. fogEnabled: boolean;
  20274. /**
  20275. * Stores the size of points
  20276. */
  20277. pointSize: number;
  20278. /**
  20279. * Stores the z offset value
  20280. */
  20281. zOffset: number;
  20282. /**
  20283. * Gets a value specifying if wireframe mode is enabled
  20284. */
  20285. /**
  20286. * Sets the state of wireframe mode
  20287. */
  20288. wireframe: boolean;
  20289. /**
  20290. * Gets the value specifying if point clouds are enabled
  20291. */
  20292. /**
  20293. * Sets the state of point cloud mode
  20294. */
  20295. pointsCloud: boolean;
  20296. /**
  20297. * Gets the material fill mode
  20298. */
  20299. /**
  20300. * Sets the material fill mode
  20301. */
  20302. fillMode: number;
  20303. /**
  20304. * @hidden
  20305. * Stores the effects for the material
  20306. */
  20307. _effect: Nullable<Effect>;
  20308. /**
  20309. * @hidden
  20310. * Specifies if the material was previously ready
  20311. */
  20312. _wasPreviouslyReady: boolean;
  20313. /**
  20314. * Specifies if uniform buffers should be used
  20315. */
  20316. private _useUBO;
  20317. /**
  20318. * Stores a reference to the scene
  20319. */
  20320. private _scene;
  20321. /**
  20322. * Stores the fill mode state
  20323. */
  20324. private _fillMode;
  20325. /**
  20326. * Specifies if the depth write state should be cached
  20327. */
  20328. private _cachedDepthWriteState;
  20329. /**
  20330. * Stores the uniform buffer
  20331. */
  20332. protected _uniformBuffer: UniformBuffer;
  20333. /** @hidden */
  20334. _indexInSceneMaterialArray: number;
  20335. /** @hidden */
  20336. meshMap: Nullable<{
  20337. [id: string]: AbstractMesh | undefined;
  20338. }>;
  20339. /**
  20340. * Creates a material instance
  20341. * @param name defines the name of the material
  20342. * @param scene defines the scene to reference
  20343. * @param doNotAdd specifies if the material should be added to the scene
  20344. */
  20345. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20346. /**
  20347. * Returns a string representation of the current material
  20348. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20349. * @returns a string with material information
  20350. */
  20351. toString(fullDetails?: boolean): string;
  20352. /**
  20353. * Gets the class name of the material
  20354. * @returns a string with the class name of the material
  20355. */
  20356. getClassName(): string;
  20357. /**
  20358. * Specifies if updates for the material been locked
  20359. */
  20360. readonly isFrozen: boolean;
  20361. /**
  20362. * Locks updates for the material
  20363. */
  20364. freeze(): void;
  20365. /**
  20366. * Unlocks updates for the material
  20367. */
  20368. unfreeze(): void;
  20369. /**
  20370. * Specifies if the material is ready to be used
  20371. * @param mesh defines the mesh to check
  20372. * @param useInstances specifies if instances should be used
  20373. * @returns a boolean indicating if the material is ready to be used
  20374. */
  20375. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20376. /**
  20377. * Specifies that the submesh is ready to be used
  20378. * @param mesh defines the mesh to check
  20379. * @param subMesh defines which submesh to check
  20380. * @param useInstances specifies that instances should be used
  20381. * @returns a boolean indicating that the submesh is ready or not
  20382. */
  20383. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20384. /**
  20385. * Returns the material effect
  20386. * @returns the effect associated with the material
  20387. */
  20388. getEffect(): Nullable<Effect>;
  20389. /**
  20390. * Returns the current scene
  20391. * @returns a Scene
  20392. */
  20393. getScene(): Scene;
  20394. /**
  20395. * Specifies if the material will require alpha blending
  20396. * @returns a boolean specifying if alpha blending is needed
  20397. */
  20398. needAlphaBlending(): boolean;
  20399. /**
  20400. * Specifies if the mesh will require alpha blending
  20401. * @param mesh defines the mesh to check
  20402. * @returns a boolean specifying if alpha blending is needed for the mesh
  20403. */
  20404. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20405. /**
  20406. * Specifies if this material should be rendered in alpha test mode
  20407. * @returns a boolean specifying if an alpha test is needed.
  20408. */
  20409. needAlphaTesting(): boolean;
  20410. /**
  20411. * Gets the texture used for the alpha test
  20412. * @returns the texture to use for alpha testing
  20413. */
  20414. getAlphaTestTexture(): Nullable<BaseTexture>;
  20415. /**
  20416. * Marks the material to indicate that it needs to be re-calculated
  20417. */
  20418. markDirty(): void;
  20419. /** @hidden */
  20420. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20421. /**
  20422. * Binds the material to the mesh
  20423. * @param world defines the world transformation matrix
  20424. * @param mesh defines the mesh to bind the material to
  20425. */
  20426. bind(world: Matrix, mesh?: Mesh): void;
  20427. /**
  20428. * Binds the submesh to the material
  20429. * @param world defines the world transformation matrix
  20430. * @param mesh defines the mesh containing the submesh
  20431. * @param subMesh defines the submesh to bind the material to
  20432. */
  20433. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20434. /**
  20435. * Binds the world matrix to the material
  20436. * @param world defines the world transformation matrix
  20437. */
  20438. bindOnlyWorldMatrix(world: Matrix): void;
  20439. /**
  20440. * Binds the scene's uniform buffer to the effect.
  20441. * @param effect defines the effect to bind to the scene uniform buffer
  20442. * @param sceneUbo defines the uniform buffer storing scene data
  20443. */
  20444. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20445. /**
  20446. * Binds the view matrix to the effect
  20447. * @param effect defines the effect to bind the view matrix to
  20448. */
  20449. bindView(effect: Effect): void;
  20450. /**
  20451. * Binds the view projection matrix to the effect
  20452. * @param effect defines the effect to bind the view projection matrix to
  20453. */
  20454. bindViewProjection(effect: Effect): void;
  20455. /**
  20456. * Specifies if material alpha testing should be turned on for the mesh
  20457. * @param mesh defines the mesh to check
  20458. */
  20459. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20460. /**
  20461. * Processes to execute after binding the material to a mesh
  20462. * @param mesh defines the rendered mesh
  20463. */
  20464. protected _afterBind(mesh?: Mesh): void;
  20465. /**
  20466. * Unbinds the material from the mesh
  20467. */
  20468. unbind(): void;
  20469. /**
  20470. * Gets the active textures from the material
  20471. * @returns an array of textures
  20472. */
  20473. getActiveTextures(): BaseTexture[];
  20474. /**
  20475. * Specifies if the material uses a texture
  20476. * @param texture defines the texture to check against the material
  20477. * @returns a boolean specifying if the material uses the texture
  20478. */
  20479. hasTexture(texture: BaseTexture): boolean;
  20480. /**
  20481. * Makes a duplicate of the material, and gives it a new name
  20482. * @param name defines the new name for the duplicated material
  20483. * @returns the cloned material
  20484. */
  20485. clone(name: string): Nullable<Material>;
  20486. /**
  20487. * Gets the meshes bound to the material
  20488. * @returns an array of meshes bound to the material
  20489. */
  20490. getBindedMeshes(): AbstractMesh[];
  20491. /**
  20492. * Force shader compilation
  20493. * @param mesh defines the mesh associated with this material
  20494. * @param onCompiled defines a function to execute once the material is compiled
  20495. * @param options defines the options to configure the compilation
  20496. */
  20497. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20498. clipPlane: boolean;
  20499. }>): void;
  20500. /**
  20501. * Force shader compilation
  20502. * @param mesh defines the mesh that will use this material
  20503. * @param options defines additional options for compiling the shaders
  20504. * @returns a promise that resolves when the compilation completes
  20505. */
  20506. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20507. clipPlane: boolean;
  20508. }>): Promise<void>;
  20509. private static readonly _AllDirtyCallBack;
  20510. private static readonly _ImageProcessingDirtyCallBack;
  20511. private static readonly _TextureDirtyCallBack;
  20512. private static readonly _FresnelDirtyCallBack;
  20513. private static readonly _MiscDirtyCallBack;
  20514. private static readonly _LightsDirtyCallBack;
  20515. private static readonly _AttributeDirtyCallBack;
  20516. private static _FresnelAndMiscDirtyCallBack;
  20517. private static _TextureAndMiscDirtyCallBack;
  20518. private static readonly _DirtyCallbackArray;
  20519. private static readonly _RunDirtyCallBacks;
  20520. /**
  20521. * Marks a define in the material to indicate that it needs to be re-computed
  20522. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20523. */
  20524. markAsDirty(flag: number): void;
  20525. /**
  20526. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20527. * @param func defines a function which checks material defines against the submeshes
  20528. */
  20529. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20530. /**
  20531. * Indicates that we need to re-calculated for all submeshes
  20532. */
  20533. protected _markAllSubMeshesAsAllDirty(): void;
  20534. /**
  20535. * Indicates that image processing needs to be re-calculated for all submeshes
  20536. */
  20537. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20538. /**
  20539. * Indicates that textures need to be re-calculated for all submeshes
  20540. */
  20541. protected _markAllSubMeshesAsTexturesDirty(): void;
  20542. /**
  20543. * Indicates that fresnel needs to be re-calculated for all submeshes
  20544. */
  20545. protected _markAllSubMeshesAsFresnelDirty(): void;
  20546. /**
  20547. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20548. */
  20549. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20550. /**
  20551. * Indicates that lights need to be re-calculated for all submeshes
  20552. */
  20553. protected _markAllSubMeshesAsLightsDirty(): void;
  20554. /**
  20555. * Indicates that attributes need to be re-calculated for all submeshes
  20556. */
  20557. protected _markAllSubMeshesAsAttributesDirty(): void;
  20558. /**
  20559. * Indicates that misc needs to be re-calculated for all submeshes
  20560. */
  20561. protected _markAllSubMeshesAsMiscDirty(): void;
  20562. /**
  20563. * Indicates that textures and misc need to be re-calculated for all submeshes
  20564. */
  20565. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20566. /**
  20567. * Disposes the material
  20568. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20569. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20570. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20571. */
  20572. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20573. /** @hidden */
  20574. private releaseVertexArrayObject;
  20575. /**
  20576. * Serializes this material
  20577. * @returns the serialized material object
  20578. */
  20579. serialize(): any;
  20580. /**
  20581. * Creates a material from parsed material data
  20582. * @param parsedMaterial defines parsed material data
  20583. * @param scene defines the hosting scene
  20584. * @param rootUrl defines the root URL to use to load textures
  20585. * @returns a new material
  20586. */
  20587. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20588. }
  20589. }
  20590. declare module BABYLON {
  20591. /**
  20592. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20593. * separate meshes. This can be use to improve performances.
  20594. * @see http://doc.babylonjs.com/how_to/multi_materials
  20595. */
  20596. export class MultiMaterial extends Material {
  20597. private _subMaterials;
  20598. /**
  20599. * Gets or Sets the list of Materials used within the multi material.
  20600. * They need to be ordered according to the submeshes order in the associated mesh
  20601. */
  20602. subMaterials: Nullable<Material>[];
  20603. /**
  20604. * Function used to align with Node.getChildren()
  20605. * @returns the list of Materials used within the multi material
  20606. */
  20607. getChildren(): Nullable<Material>[];
  20608. /**
  20609. * Instantiates a new Multi Material
  20610. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20611. * separate meshes. This can be use to improve performances.
  20612. * @see http://doc.babylonjs.com/how_to/multi_materials
  20613. * @param name Define the name in the scene
  20614. * @param scene Define the scene the material belongs to
  20615. */
  20616. constructor(name: string, scene: Scene);
  20617. private _hookArray;
  20618. /**
  20619. * Get one of the submaterial by its index in the submaterials array
  20620. * @param index The index to look the sub material at
  20621. * @returns The Material if the index has been defined
  20622. */
  20623. getSubMaterial(index: number): Nullable<Material>;
  20624. /**
  20625. * Get the list of active textures for the whole sub materials list.
  20626. * @returns All the textures that will be used during the rendering
  20627. */
  20628. getActiveTextures(): BaseTexture[];
  20629. /**
  20630. * Gets the current class name of the material e.g. "MultiMaterial"
  20631. * Mainly use in serialization.
  20632. * @returns the class name
  20633. */
  20634. getClassName(): string;
  20635. /**
  20636. * Checks if the material is ready to render the requested sub mesh
  20637. * @param mesh Define the mesh the submesh belongs to
  20638. * @param subMesh Define the sub mesh to look readyness for
  20639. * @param useInstances Define whether or not the material is used with instances
  20640. * @returns true if ready, otherwise false
  20641. */
  20642. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20643. /**
  20644. * Clones the current material and its related sub materials
  20645. * @param name Define the name of the newly cloned material
  20646. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20647. * @returns the cloned material
  20648. */
  20649. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20650. /**
  20651. * Serializes the materials into a JSON representation.
  20652. * @returns the JSON representation
  20653. */
  20654. serialize(): any;
  20655. /**
  20656. * Dispose the material and release its associated resources
  20657. * @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)
  20658. * @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)
  20659. * @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)
  20660. */
  20661. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20662. /**
  20663. * Creates a MultiMaterial from parsed MultiMaterial data.
  20664. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20665. * @param scene defines the hosting scene
  20666. * @returns a new MultiMaterial
  20667. */
  20668. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20669. }
  20670. }
  20671. declare module BABYLON {
  20672. /**
  20673. * Base class for submeshes
  20674. */
  20675. export class BaseSubMesh {
  20676. /** @hidden */
  20677. _materialDefines: Nullable<MaterialDefines>;
  20678. /** @hidden */
  20679. _materialEffect: Nullable<Effect>;
  20680. /**
  20681. * Gets associated effect
  20682. */
  20683. readonly effect: Nullable<Effect>;
  20684. /**
  20685. * Sets associated effect (effect used to render this submesh)
  20686. * @param effect defines the effect to associate with
  20687. * @param defines defines the set of defines used to compile this effect
  20688. */
  20689. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20690. }
  20691. /**
  20692. * Defines a subdivision inside a mesh
  20693. */
  20694. export class SubMesh extends BaseSubMesh implements ICullable {
  20695. /** the material index to use */
  20696. materialIndex: number;
  20697. /** vertex index start */
  20698. verticesStart: number;
  20699. /** vertices count */
  20700. verticesCount: number;
  20701. /** index start */
  20702. indexStart: number;
  20703. /** indices count */
  20704. indexCount: number;
  20705. /** @hidden */
  20706. _linesIndexCount: number;
  20707. private _mesh;
  20708. private _renderingMesh;
  20709. private _boundingInfo;
  20710. private _linesIndexBuffer;
  20711. /** @hidden */
  20712. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20713. /** @hidden */
  20714. _trianglePlanes: Plane[];
  20715. /** @hidden */
  20716. _lastColliderTransformMatrix: Nullable<Matrix>;
  20717. /** @hidden */
  20718. _renderId: number;
  20719. /** @hidden */
  20720. _alphaIndex: number;
  20721. /** @hidden */
  20722. _distanceToCamera: number;
  20723. /** @hidden */
  20724. _id: number;
  20725. private _currentMaterial;
  20726. /**
  20727. * Add a new submesh to a mesh
  20728. * @param materialIndex defines the material index to use
  20729. * @param verticesStart defines vertex index start
  20730. * @param verticesCount defines vertices count
  20731. * @param indexStart defines index start
  20732. * @param indexCount defines indices count
  20733. * @param mesh defines the parent mesh
  20734. * @param renderingMesh defines an optional rendering mesh
  20735. * @param createBoundingBox defines if bounding box should be created for this submesh
  20736. * @returns the new submesh
  20737. */
  20738. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20739. /**
  20740. * Creates a new submesh
  20741. * @param materialIndex defines the material index to use
  20742. * @param verticesStart defines vertex index start
  20743. * @param verticesCount defines vertices count
  20744. * @param indexStart defines index start
  20745. * @param indexCount defines indices count
  20746. * @param mesh defines the parent mesh
  20747. * @param renderingMesh defines an optional rendering mesh
  20748. * @param createBoundingBox defines if bounding box should be created for this submesh
  20749. */
  20750. constructor(
  20751. /** the material index to use */
  20752. materialIndex: number,
  20753. /** vertex index start */
  20754. verticesStart: number,
  20755. /** vertices count */
  20756. verticesCount: number,
  20757. /** index start */
  20758. indexStart: number,
  20759. /** indices count */
  20760. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20761. /**
  20762. * Returns true if this submesh covers the entire parent mesh
  20763. * @ignorenaming
  20764. */
  20765. readonly IsGlobal: boolean;
  20766. /**
  20767. * Returns the submesh BoudingInfo object
  20768. * @returns current bounding info (or mesh's one if the submesh is global)
  20769. */
  20770. getBoundingInfo(): BoundingInfo;
  20771. /**
  20772. * Sets the submesh BoundingInfo
  20773. * @param boundingInfo defines the new bounding info to use
  20774. * @returns the SubMesh
  20775. */
  20776. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20777. /**
  20778. * Returns the mesh of the current submesh
  20779. * @return the parent mesh
  20780. */
  20781. getMesh(): AbstractMesh;
  20782. /**
  20783. * Returns the rendering mesh of the submesh
  20784. * @returns the rendering mesh (could be different from parent mesh)
  20785. */
  20786. getRenderingMesh(): Mesh;
  20787. /**
  20788. * Returns the submesh material
  20789. * @returns null or the current material
  20790. */
  20791. getMaterial(): Nullable<Material>;
  20792. /**
  20793. * Sets a new updated BoundingInfo object to the submesh
  20794. * @param data defines an optional position array to use to determine the bounding info
  20795. * @returns the SubMesh
  20796. */
  20797. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20798. /** @hidden */
  20799. _checkCollision(collider: Collider): boolean;
  20800. /**
  20801. * Updates the submesh BoundingInfo
  20802. * @param world defines the world matrix to use to update the bounding info
  20803. * @returns the submesh
  20804. */
  20805. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20806. /**
  20807. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20808. * @param frustumPlanes defines the frustum planes
  20809. * @returns true if the submesh is intersecting with the frustum
  20810. */
  20811. isInFrustum(frustumPlanes: Plane[]): boolean;
  20812. /**
  20813. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20814. * @param frustumPlanes defines the frustum planes
  20815. * @returns true if the submesh is inside the frustum
  20816. */
  20817. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20818. /**
  20819. * Renders the submesh
  20820. * @param enableAlphaMode defines if alpha needs to be used
  20821. * @returns the submesh
  20822. */
  20823. render(enableAlphaMode: boolean): SubMesh;
  20824. /**
  20825. * @hidden
  20826. */
  20827. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20828. /**
  20829. * Checks if the submesh intersects with a ray
  20830. * @param ray defines the ray to test
  20831. * @returns true is the passed ray intersects the submesh bounding box
  20832. */
  20833. canIntersects(ray: Ray): boolean;
  20834. /**
  20835. * Intersects current submesh with a ray
  20836. * @param ray defines the ray to test
  20837. * @param positions defines mesh's positions array
  20838. * @param indices defines mesh's indices array
  20839. * @param fastCheck defines if only bounding info should be used
  20840. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20841. * @returns intersection info or null if no intersection
  20842. */
  20843. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20844. /** @hidden */
  20845. private _intersectLines;
  20846. /** @hidden */
  20847. private _intersectUnIndexedLines;
  20848. /** @hidden */
  20849. private _intersectTriangles;
  20850. /** @hidden */
  20851. private _intersectUnIndexedTriangles;
  20852. /** @hidden */
  20853. _rebuild(): void;
  20854. /**
  20855. * Creates a new submesh from the passed mesh
  20856. * @param newMesh defines the new hosting mesh
  20857. * @param newRenderingMesh defines an optional rendering mesh
  20858. * @returns the new submesh
  20859. */
  20860. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20861. /**
  20862. * Release associated resources
  20863. */
  20864. dispose(): void;
  20865. /**
  20866. * Gets the class name
  20867. * @returns the string "SubMesh".
  20868. */
  20869. getClassName(): string;
  20870. /**
  20871. * Creates a new submesh from indices data
  20872. * @param materialIndex the index of the main mesh material
  20873. * @param startIndex the index where to start the copy in the mesh indices array
  20874. * @param indexCount the number of indices to copy then from the startIndex
  20875. * @param mesh the main mesh to create the submesh from
  20876. * @param renderingMesh the optional rendering mesh
  20877. * @returns a new submesh
  20878. */
  20879. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20880. }
  20881. }
  20882. declare module BABYLON {
  20883. /**
  20884. * Class used to represent data loading progression
  20885. */
  20886. export class SceneLoaderFlags {
  20887. private static _ForceFullSceneLoadingForIncremental;
  20888. private static _ShowLoadingScreen;
  20889. private static _CleanBoneMatrixWeights;
  20890. private static _loggingLevel;
  20891. /**
  20892. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20893. */
  20894. static ForceFullSceneLoadingForIncremental: boolean;
  20895. /**
  20896. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20897. */
  20898. static ShowLoadingScreen: boolean;
  20899. /**
  20900. * Defines the current logging level (while loading the scene)
  20901. * @ignorenaming
  20902. */
  20903. static loggingLevel: number;
  20904. /**
  20905. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20906. */
  20907. static CleanBoneMatrixWeights: boolean;
  20908. }
  20909. }
  20910. declare module BABYLON {
  20911. /**
  20912. * Class used to store geometry data (vertex buffers + index buffer)
  20913. */
  20914. export class Geometry implements IGetSetVerticesData {
  20915. /**
  20916. * Gets or sets the ID of the geometry
  20917. */
  20918. id: string;
  20919. /**
  20920. * Gets or sets the unique ID of the geometry
  20921. */
  20922. uniqueId: number;
  20923. /**
  20924. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20925. */
  20926. delayLoadState: number;
  20927. /**
  20928. * Gets the file containing the data to load when running in delay load state
  20929. */
  20930. delayLoadingFile: Nullable<string>;
  20931. /**
  20932. * Callback called when the geometry is updated
  20933. */
  20934. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20935. private _scene;
  20936. private _engine;
  20937. private _meshes;
  20938. private _totalVertices;
  20939. /** @hidden */
  20940. _indices: IndicesArray;
  20941. /** @hidden */
  20942. _vertexBuffers: {
  20943. [key: string]: VertexBuffer;
  20944. };
  20945. private _isDisposed;
  20946. private _extend;
  20947. private _boundingBias;
  20948. /** @hidden */
  20949. _delayInfo: Array<string>;
  20950. private _indexBuffer;
  20951. private _indexBufferIsUpdatable;
  20952. /** @hidden */
  20953. _boundingInfo: Nullable<BoundingInfo>;
  20954. /** @hidden */
  20955. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20956. /** @hidden */
  20957. _softwareSkinningFrameId: number;
  20958. private _vertexArrayObjects;
  20959. private _updatable;
  20960. /** @hidden */
  20961. _positions: Nullable<Vector3[]>;
  20962. /**
  20963. * 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
  20964. */
  20965. /**
  20966. * 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
  20967. */
  20968. boundingBias: Vector2;
  20969. /**
  20970. * Static function used to attach a new empty geometry to a mesh
  20971. * @param mesh defines the mesh to attach the geometry to
  20972. * @returns the new Geometry
  20973. */
  20974. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20975. /**
  20976. * Creates a new geometry
  20977. * @param id defines the unique ID
  20978. * @param scene defines the hosting scene
  20979. * @param vertexData defines the VertexData used to get geometry data
  20980. * @param updatable defines if geometry must be updatable (false by default)
  20981. * @param mesh defines the mesh that will be associated with the geometry
  20982. */
  20983. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20984. /**
  20985. * Gets the current extend of the geometry
  20986. */
  20987. readonly extend: {
  20988. minimum: Vector3;
  20989. maximum: Vector3;
  20990. };
  20991. /**
  20992. * Gets the hosting scene
  20993. * @returns the hosting Scene
  20994. */
  20995. getScene(): Scene;
  20996. /**
  20997. * Gets the hosting engine
  20998. * @returns the hosting Engine
  20999. */
  21000. getEngine(): Engine;
  21001. /**
  21002. * Defines if the geometry is ready to use
  21003. * @returns true if the geometry is ready to be used
  21004. */
  21005. isReady(): boolean;
  21006. /**
  21007. * Gets a value indicating that the geometry should not be serialized
  21008. */
  21009. readonly doNotSerialize: boolean;
  21010. /** @hidden */
  21011. _rebuild(): void;
  21012. /**
  21013. * Affects all geometry data in one call
  21014. * @param vertexData defines the geometry data
  21015. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21016. */
  21017. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21018. /**
  21019. * Set specific vertex data
  21020. * @param kind defines the data kind (Position, normal, etc...)
  21021. * @param data defines the vertex data to use
  21022. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21023. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21024. */
  21025. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21026. /**
  21027. * Removes a specific vertex data
  21028. * @param kind defines the data kind (Position, normal, etc...)
  21029. */
  21030. removeVerticesData(kind: string): void;
  21031. /**
  21032. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21033. * @param buffer defines the vertex buffer to use
  21034. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21035. */
  21036. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21037. /**
  21038. * Update a specific vertex buffer
  21039. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21040. * It will do nothing if the buffer is not updatable
  21041. * @param kind defines the data kind (Position, normal, etc...)
  21042. * @param data defines the data to use
  21043. * @param offset defines the offset in the target buffer where to store the data
  21044. * @param useBytes set to true if the offset is in bytes
  21045. */
  21046. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21047. /**
  21048. * Update a specific vertex buffer
  21049. * This function will create a new buffer if the current one is not updatable
  21050. * @param kind defines the data kind (Position, normal, etc...)
  21051. * @param data defines the data to use
  21052. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21053. */
  21054. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21055. private _updateBoundingInfo;
  21056. /** @hidden */
  21057. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21058. /**
  21059. * Gets total number of vertices
  21060. * @returns the total number of vertices
  21061. */
  21062. getTotalVertices(): number;
  21063. /**
  21064. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21065. * @param kind defines the data kind (Position, normal, etc...)
  21066. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21067. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21068. * @returns a float array containing vertex data
  21069. */
  21070. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21071. /**
  21072. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21073. * @param kind defines the data kind (Position, normal, etc...)
  21074. * @returns true if the vertex buffer with the specified kind is updatable
  21075. */
  21076. isVertexBufferUpdatable(kind: string): boolean;
  21077. /**
  21078. * Gets a specific vertex buffer
  21079. * @param kind defines the data kind (Position, normal, etc...)
  21080. * @returns a VertexBuffer
  21081. */
  21082. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21083. /**
  21084. * Returns all vertex buffers
  21085. * @return an object holding all vertex buffers indexed by kind
  21086. */
  21087. getVertexBuffers(): Nullable<{
  21088. [key: string]: VertexBuffer;
  21089. }>;
  21090. /**
  21091. * Gets a boolean indicating if specific vertex buffer is present
  21092. * @param kind defines the data kind (Position, normal, etc...)
  21093. * @returns true if data is present
  21094. */
  21095. isVerticesDataPresent(kind: string): boolean;
  21096. /**
  21097. * Gets a list of all attached data kinds (Position, normal, etc...)
  21098. * @returns a list of string containing all kinds
  21099. */
  21100. getVerticesDataKinds(): string[];
  21101. /**
  21102. * Update index buffer
  21103. * @param indices defines the indices to store in the index buffer
  21104. * @param offset defines the offset in the target buffer where to store the data
  21105. * @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)
  21106. */
  21107. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21108. /**
  21109. * Creates a new index buffer
  21110. * @param indices defines the indices to store in the index buffer
  21111. * @param totalVertices defines the total number of vertices (could be null)
  21112. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21113. */
  21114. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21115. /**
  21116. * Return the total number of indices
  21117. * @returns the total number of indices
  21118. */
  21119. getTotalIndices(): number;
  21120. /**
  21121. * Gets the index buffer array
  21122. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21123. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21124. * @returns the index buffer array
  21125. */
  21126. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21127. /**
  21128. * Gets the index buffer
  21129. * @return the index buffer
  21130. */
  21131. getIndexBuffer(): Nullable<DataBuffer>;
  21132. /** @hidden */
  21133. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21134. /**
  21135. * Release the associated resources for a specific mesh
  21136. * @param mesh defines the source mesh
  21137. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21138. */
  21139. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21140. /**
  21141. * Apply current geometry to a given mesh
  21142. * @param mesh defines the mesh to apply geometry to
  21143. */
  21144. applyToMesh(mesh: Mesh): void;
  21145. private _updateExtend;
  21146. private _applyToMesh;
  21147. private notifyUpdate;
  21148. /**
  21149. * Load the geometry if it was flagged as delay loaded
  21150. * @param scene defines the hosting scene
  21151. * @param onLoaded defines a callback called when the geometry is loaded
  21152. */
  21153. load(scene: Scene, onLoaded?: () => void): void;
  21154. private _queueLoad;
  21155. /**
  21156. * Invert the geometry to move from a right handed system to a left handed one.
  21157. */
  21158. toLeftHanded(): void;
  21159. /** @hidden */
  21160. _resetPointsArrayCache(): void;
  21161. /** @hidden */
  21162. _generatePointsArray(): boolean;
  21163. /**
  21164. * Gets a value indicating if the geometry is disposed
  21165. * @returns true if the geometry was disposed
  21166. */
  21167. isDisposed(): boolean;
  21168. private _disposeVertexArrayObjects;
  21169. /**
  21170. * Free all associated resources
  21171. */
  21172. dispose(): void;
  21173. /**
  21174. * Clone the current geometry into a new geometry
  21175. * @param id defines the unique ID of the new geometry
  21176. * @returns a new geometry object
  21177. */
  21178. copy(id: string): Geometry;
  21179. /**
  21180. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21181. * @return a JSON representation of the current geometry data (without the vertices data)
  21182. */
  21183. serialize(): any;
  21184. private toNumberArray;
  21185. /**
  21186. * Serialize all vertices data into a JSON oject
  21187. * @returns a JSON representation of the current geometry data
  21188. */
  21189. serializeVerticeData(): any;
  21190. /**
  21191. * Extracts a clone of a mesh geometry
  21192. * @param mesh defines the source mesh
  21193. * @param id defines the unique ID of the new geometry object
  21194. * @returns the new geometry object
  21195. */
  21196. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21197. /**
  21198. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21199. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21200. * Be aware Math.random() could cause collisions, but:
  21201. * "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"
  21202. * @returns a string containing a new GUID
  21203. */
  21204. static RandomId(): string;
  21205. /** @hidden */
  21206. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21207. private static _CleanMatricesWeights;
  21208. /**
  21209. * Create a new geometry from persisted data (Using .babylon file format)
  21210. * @param parsedVertexData defines the persisted data
  21211. * @param scene defines the hosting scene
  21212. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21213. * @returns the new geometry object
  21214. */
  21215. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21216. }
  21217. }
  21218. declare module BABYLON {
  21219. /**
  21220. * Define an interface for all classes that will get and set the data on vertices
  21221. */
  21222. export interface IGetSetVerticesData {
  21223. /**
  21224. * Gets a boolean indicating if specific vertex data is present
  21225. * @param kind defines the vertex data kind to use
  21226. * @returns true is data kind is present
  21227. */
  21228. isVerticesDataPresent(kind: string): boolean;
  21229. /**
  21230. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21231. * @param kind defines the data kind (Position, normal, etc...)
  21232. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21233. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21234. * @returns a float array containing vertex data
  21235. */
  21236. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21237. /**
  21238. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21239. * @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.
  21240. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21241. * @returns the indices array or an empty array if the mesh has no geometry
  21242. */
  21243. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21244. /**
  21245. * Set specific vertex data
  21246. * @param kind defines the data kind (Position, normal, etc...)
  21247. * @param data defines the vertex data to use
  21248. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21249. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21250. */
  21251. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21252. /**
  21253. * Update a specific associated vertex buffer
  21254. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21255. * - VertexBuffer.PositionKind
  21256. * - VertexBuffer.UVKind
  21257. * - VertexBuffer.UV2Kind
  21258. * - VertexBuffer.UV3Kind
  21259. * - VertexBuffer.UV4Kind
  21260. * - VertexBuffer.UV5Kind
  21261. * - VertexBuffer.UV6Kind
  21262. * - VertexBuffer.ColorKind
  21263. * - VertexBuffer.MatricesIndicesKind
  21264. * - VertexBuffer.MatricesIndicesExtraKind
  21265. * - VertexBuffer.MatricesWeightsKind
  21266. * - VertexBuffer.MatricesWeightsExtraKind
  21267. * @param data defines the data source
  21268. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21269. * @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)
  21270. */
  21271. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21272. /**
  21273. * Creates a new index buffer
  21274. * @param indices defines the indices to store in the index buffer
  21275. * @param totalVertices defines the total number of vertices (could be null)
  21276. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21277. */
  21278. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21279. }
  21280. /**
  21281. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21282. */
  21283. export class VertexData {
  21284. /**
  21285. * Mesh side orientation : usually the external or front surface
  21286. */
  21287. static readonly FRONTSIDE: number;
  21288. /**
  21289. * Mesh side orientation : usually the internal or back surface
  21290. */
  21291. static readonly BACKSIDE: number;
  21292. /**
  21293. * Mesh side orientation : both internal and external or front and back surfaces
  21294. */
  21295. static readonly DOUBLESIDE: number;
  21296. /**
  21297. * Mesh side orientation : by default, `FRONTSIDE`
  21298. */
  21299. static readonly DEFAULTSIDE: number;
  21300. /**
  21301. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21302. */
  21303. positions: Nullable<FloatArray>;
  21304. /**
  21305. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21306. */
  21307. normals: Nullable<FloatArray>;
  21308. /**
  21309. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21310. */
  21311. tangents: Nullable<FloatArray>;
  21312. /**
  21313. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21314. */
  21315. uvs: Nullable<FloatArray>;
  21316. /**
  21317. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21318. */
  21319. uvs2: Nullable<FloatArray>;
  21320. /**
  21321. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21322. */
  21323. uvs3: Nullable<FloatArray>;
  21324. /**
  21325. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21326. */
  21327. uvs4: Nullable<FloatArray>;
  21328. /**
  21329. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21330. */
  21331. uvs5: Nullable<FloatArray>;
  21332. /**
  21333. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21334. */
  21335. uvs6: Nullable<FloatArray>;
  21336. /**
  21337. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21338. */
  21339. colors: Nullable<FloatArray>;
  21340. /**
  21341. * 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).
  21342. */
  21343. matricesIndices: Nullable<FloatArray>;
  21344. /**
  21345. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21346. */
  21347. matricesWeights: Nullable<FloatArray>;
  21348. /**
  21349. * An array extending the number of possible indices
  21350. */
  21351. matricesIndicesExtra: Nullable<FloatArray>;
  21352. /**
  21353. * An array extending the number of possible weights when the number of indices is extended
  21354. */
  21355. matricesWeightsExtra: Nullable<FloatArray>;
  21356. /**
  21357. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21358. */
  21359. indices: Nullable<IndicesArray>;
  21360. /**
  21361. * Uses the passed data array to set the set the values for the specified kind of data
  21362. * @param data a linear array of floating numbers
  21363. * @param kind the type of data that is being set, eg positions, colors etc
  21364. */
  21365. set(data: FloatArray, kind: string): void;
  21366. /**
  21367. * Associates the vertexData to the passed Mesh.
  21368. * Sets it as updatable or not (default `false`)
  21369. * @param mesh the mesh the vertexData is applied to
  21370. * @param updatable when used and having the value true allows new data to update the vertexData
  21371. * @returns the VertexData
  21372. */
  21373. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21374. /**
  21375. * Associates the vertexData to the passed Geometry.
  21376. * Sets it as updatable or not (default `false`)
  21377. * @param geometry the geometry the vertexData is applied to
  21378. * @param updatable when used and having the value true allows new data to update the vertexData
  21379. * @returns VertexData
  21380. */
  21381. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21382. /**
  21383. * Updates the associated mesh
  21384. * @param mesh the mesh to be updated
  21385. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21386. * @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
  21387. * @returns VertexData
  21388. */
  21389. updateMesh(mesh: Mesh): VertexData;
  21390. /**
  21391. * Updates the associated geometry
  21392. * @param geometry the geometry to be updated
  21393. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21394. * @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
  21395. * @returns VertexData.
  21396. */
  21397. updateGeometry(geometry: Geometry): VertexData;
  21398. private _applyTo;
  21399. private _update;
  21400. /**
  21401. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21402. * @param matrix the transforming matrix
  21403. * @returns the VertexData
  21404. */
  21405. transform(matrix: Matrix): VertexData;
  21406. /**
  21407. * Merges the passed VertexData into the current one
  21408. * @param other the VertexData to be merged into the current one
  21409. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21410. * @returns the modified VertexData
  21411. */
  21412. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21413. private _mergeElement;
  21414. private _validate;
  21415. /**
  21416. * Serializes the VertexData
  21417. * @returns a serialized object
  21418. */
  21419. serialize(): any;
  21420. /**
  21421. * Extracts the vertexData from a mesh
  21422. * @param mesh the mesh from which to extract the VertexData
  21423. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21424. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21425. * @returns the object VertexData associated to the passed mesh
  21426. */
  21427. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21428. /**
  21429. * Extracts the vertexData from the geometry
  21430. * @param geometry the geometry from which to extract the VertexData
  21431. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21432. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21433. * @returns the object VertexData associated to the passed mesh
  21434. */
  21435. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21436. private static _ExtractFrom;
  21437. /**
  21438. * Creates the VertexData for a Ribbon
  21439. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21440. * * pathArray array of paths, each of which an array of successive Vector3
  21441. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21442. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21443. * * 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
  21444. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21445. * * 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)
  21446. * * 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)
  21447. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21448. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21449. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21450. * @returns the VertexData of the ribbon
  21451. */
  21452. static CreateRibbon(options: {
  21453. pathArray: Vector3[][];
  21454. closeArray?: boolean;
  21455. closePath?: boolean;
  21456. offset?: number;
  21457. sideOrientation?: number;
  21458. frontUVs?: Vector4;
  21459. backUVs?: Vector4;
  21460. invertUV?: boolean;
  21461. uvs?: Vector2[];
  21462. colors?: Color4[];
  21463. }): VertexData;
  21464. /**
  21465. * Creates the VertexData for a box
  21466. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21467. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21468. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21469. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21470. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21471. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21472. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21473. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21474. * * 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)
  21475. * * 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)
  21476. * @returns the VertexData of the box
  21477. */
  21478. static CreateBox(options: {
  21479. size?: number;
  21480. width?: number;
  21481. height?: number;
  21482. depth?: number;
  21483. faceUV?: Vector4[];
  21484. faceColors?: Color4[];
  21485. sideOrientation?: number;
  21486. frontUVs?: Vector4;
  21487. backUVs?: Vector4;
  21488. }): VertexData;
  21489. /**
  21490. * Creates the VertexData for a tiled box
  21491. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21492. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21493. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21494. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21495. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21496. * @returns the VertexData of the box
  21497. */
  21498. static CreateTiledBox(options: {
  21499. pattern?: number;
  21500. width?: number;
  21501. height?: number;
  21502. depth?: number;
  21503. tileSize?: number;
  21504. tileWidth?: number;
  21505. tileHeight?: number;
  21506. alignHorizontal?: number;
  21507. alignVertical?: number;
  21508. faceUV?: Vector4[];
  21509. faceColors?: Color4[];
  21510. sideOrientation?: number;
  21511. }): VertexData;
  21512. /**
  21513. * Creates the VertexData for a tiled plane
  21514. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21515. * * pattern a limited pattern arrangement depending on the number
  21516. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21517. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21518. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21519. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21520. * * 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)
  21521. * * 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)
  21522. * @returns the VertexData of the tiled plane
  21523. */
  21524. static CreateTiledPlane(options: {
  21525. pattern?: number;
  21526. tileSize?: number;
  21527. tileWidth?: number;
  21528. tileHeight?: number;
  21529. size?: number;
  21530. width?: number;
  21531. height?: number;
  21532. alignHorizontal?: number;
  21533. alignVertical?: number;
  21534. sideOrientation?: number;
  21535. frontUVs?: Vector4;
  21536. backUVs?: Vector4;
  21537. }): VertexData;
  21538. /**
  21539. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21540. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21541. * * segments sets the number of horizontal strips optional, default 32
  21542. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21543. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21544. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21545. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21546. * * 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
  21547. * * 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
  21548. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21549. * * 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)
  21550. * * 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)
  21551. * @returns the VertexData of the ellipsoid
  21552. */
  21553. static CreateSphere(options: {
  21554. segments?: number;
  21555. diameter?: number;
  21556. diameterX?: number;
  21557. diameterY?: number;
  21558. diameterZ?: number;
  21559. arc?: number;
  21560. slice?: number;
  21561. sideOrientation?: number;
  21562. frontUVs?: Vector4;
  21563. backUVs?: Vector4;
  21564. }): VertexData;
  21565. /**
  21566. * Creates the VertexData for a cylinder, cone or prism
  21567. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21568. * * height sets the height (y direction) of the cylinder, optional, default 2
  21569. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21570. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21571. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21572. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21573. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21574. * * 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
  21575. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21576. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21577. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21578. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21579. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21580. * * 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)
  21581. * * 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)
  21582. * @returns the VertexData of the cylinder, cone or prism
  21583. */
  21584. static CreateCylinder(options: {
  21585. height?: number;
  21586. diameterTop?: number;
  21587. diameterBottom?: number;
  21588. diameter?: number;
  21589. tessellation?: number;
  21590. subdivisions?: number;
  21591. arc?: number;
  21592. faceColors?: Color4[];
  21593. faceUV?: Vector4[];
  21594. hasRings?: boolean;
  21595. enclose?: boolean;
  21596. sideOrientation?: number;
  21597. frontUVs?: Vector4;
  21598. backUVs?: Vector4;
  21599. }): VertexData;
  21600. /**
  21601. * Creates the VertexData for a torus
  21602. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21603. * * diameter the diameter of the torus, optional default 1
  21604. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21605. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21606. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21607. * * 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)
  21608. * * 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)
  21609. * @returns the VertexData of the torus
  21610. */
  21611. static CreateTorus(options: {
  21612. diameter?: number;
  21613. thickness?: number;
  21614. tessellation?: number;
  21615. sideOrientation?: number;
  21616. frontUVs?: Vector4;
  21617. backUVs?: Vector4;
  21618. }): VertexData;
  21619. /**
  21620. * Creates the VertexData of the LineSystem
  21621. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21622. * - lines an array of lines, each line being an array of successive Vector3
  21623. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21624. * @returns the VertexData of the LineSystem
  21625. */
  21626. static CreateLineSystem(options: {
  21627. lines: Vector3[][];
  21628. colors?: Nullable<Color4[][]>;
  21629. }): VertexData;
  21630. /**
  21631. * Create the VertexData for a DashedLines
  21632. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21633. * - points an array successive Vector3
  21634. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21635. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21636. * - dashNb the intended total number of dashes, optional, default 200
  21637. * @returns the VertexData for the DashedLines
  21638. */
  21639. static CreateDashedLines(options: {
  21640. points: Vector3[];
  21641. dashSize?: number;
  21642. gapSize?: number;
  21643. dashNb?: number;
  21644. }): VertexData;
  21645. /**
  21646. * Creates the VertexData for a Ground
  21647. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21648. * - width the width (x direction) of the ground, optional, default 1
  21649. * - height the height (z direction) of the ground, optional, default 1
  21650. * - subdivisions the number of subdivisions per side, optional, default 1
  21651. * @returns the VertexData of the Ground
  21652. */
  21653. static CreateGround(options: {
  21654. width?: number;
  21655. height?: number;
  21656. subdivisions?: number;
  21657. subdivisionsX?: number;
  21658. subdivisionsY?: number;
  21659. }): VertexData;
  21660. /**
  21661. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21662. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21663. * * xmin the ground minimum X coordinate, optional, default -1
  21664. * * zmin the ground minimum Z coordinate, optional, default -1
  21665. * * xmax the ground maximum X coordinate, optional, default 1
  21666. * * zmax the ground maximum Z coordinate, optional, default 1
  21667. * * 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}
  21668. * * 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}
  21669. * @returns the VertexData of the TiledGround
  21670. */
  21671. static CreateTiledGround(options: {
  21672. xmin: number;
  21673. zmin: number;
  21674. xmax: number;
  21675. zmax: number;
  21676. subdivisions?: {
  21677. w: number;
  21678. h: number;
  21679. };
  21680. precision?: {
  21681. w: number;
  21682. h: number;
  21683. };
  21684. }): VertexData;
  21685. /**
  21686. * Creates the VertexData of the Ground designed from a heightmap
  21687. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21688. * * width the width (x direction) of the ground
  21689. * * height the height (z direction) of the ground
  21690. * * subdivisions the number of subdivisions per side
  21691. * * minHeight the minimum altitude on the ground, optional, default 0
  21692. * * maxHeight the maximum altitude on the ground, optional default 1
  21693. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21694. * * buffer the array holding the image color data
  21695. * * bufferWidth the width of image
  21696. * * bufferHeight the height of image
  21697. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21698. * @returns the VertexData of the Ground designed from a heightmap
  21699. */
  21700. static CreateGroundFromHeightMap(options: {
  21701. width: number;
  21702. height: number;
  21703. subdivisions: number;
  21704. minHeight: number;
  21705. maxHeight: number;
  21706. colorFilter: Color3;
  21707. buffer: Uint8Array;
  21708. bufferWidth: number;
  21709. bufferHeight: number;
  21710. alphaFilter: number;
  21711. }): VertexData;
  21712. /**
  21713. * Creates the VertexData for a Plane
  21714. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21715. * * size sets the width and height of the plane to the value of size, optional default 1
  21716. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21717. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21718. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21719. * * 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)
  21720. * * 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)
  21721. * @returns the VertexData of the box
  21722. */
  21723. static CreatePlane(options: {
  21724. size?: number;
  21725. width?: number;
  21726. height?: number;
  21727. sideOrientation?: number;
  21728. frontUVs?: Vector4;
  21729. backUVs?: Vector4;
  21730. }): VertexData;
  21731. /**
  21732. * Creates the VertexData of the Disc or regular Polygon
  21733. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21734. * * radius the radius of the disc, optional default 0.5
  21735. * * tessellation the number of polygon sides, optional, default 64
  21736. * * 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
  21737. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21738. * * 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)
  21739. * * 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)
  21740. * @returns the VertexData of the box
  21741. */
  21742. static CreateDisc(options: {
  21743. radius?: number;
  21744. tessellation?: number;
  21745. arc?: number;
  21746. sideOrientation?: number;
  21747. frontUVs?: Vector4;
  21748. backUVs?: Vector4;
  21749. }): VertexData;
  21750. /**
  21751. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21752. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21753. * @param polygon a mesh built from polygonTriangulation.build()
  21754. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21755. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21756. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21757. * @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)
  21758. * @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)
  21759. * @returns the VertexData of the Polygon
  21760. */
  21761. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21762. /**
  21763. * Creates the VertexData of the IcoSphere
  21764. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21765. * * radius the radius of the IcoSphere, optional default 1
  21766. * * radiusX allows stretching in the x direction, optional, default radius
  21767. * * radiusY allows stretching in the y direction, optional, default radius
  21768. * * radiusZ allows stretching in the z direction, optional, default radius
  21769. * * flat when true creates a flat shaded mesh, optional, default true
  21770. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21771. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21772. * * 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)
  21773. * * 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)
  21774. * @returns the VertexData of the IcoSphere
  21775. */
  21776. static CreateIcoSphere(options: {
  21777. radius?: number;
  21778. radiusX?: number;
  21779. radiusY?: number;
  21780. radiusZ?: number;
  21781. flat?: boolean;
  21782. subdivisions?: number;
  21783. sideOrientation?: number;
  21784. frontUVs?: Vector4;
  21785. backUVs?: Vector4;
  21786. }): VertexData;
  21787. /**
  21788. * Creates the VertexData for a Polyhedron
  21789. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21790. * * type provided types are:
  21791. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21792. * * 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)
  21793. * * size the size of the IcoSphere, optional default 1
  21794. * * sizeX allows stretching in the x direction, optional, default size
  21795. * * sizeY allows stretching in the y direction, optional, default size
  21796. * * sizeZ allows stretching in the z direction, optional, default size
  21797. * * 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
  21798. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21799. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21800. * * flat when true creates a flat shaded mesh, optional, default true
  21801. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21802. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21803. * * 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)
  21804. * * 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)
  21805. * @returns the VertexData of the Polyhedron
  21806. */
  21807. static CreatePolyhedron(options: {
  21808. type?: number;
  21809. size?: number;
  21810. sizeX?: number;
  21811. sizeY?: number;
  21812. sizeZ?: number;
  21813. custom?: any;
  21814. faceUV?: Vector4[];
  21815. faceColors?: Color4[];
  21816. flat?: boolean;
  21817. sideOrientation?: number;
  21818. frontUVs?: Vector4;
  21819. backUVs?: Vector4;
  21820. }): VertexData;
  21821. /**
  21822. * Creates the VertexData for a TorusKnot
  21823. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21824. * * radius the radius of the torus knot, optional, default 2
  21825. * * tube the thickness of the tube, optional, default 0.5
  21826. * * radialSegments the number of sides on each tube segments, optional, default 32
  21827. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21828. * * p the number of windings around the z axis, optional, default 2
  21829. * * q the number of windings around the x axis, optional, default 3
  21830. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21831. * * 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)
  21832. * * 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)
  21833. * @returns the VertexData of the Torus Knot
  21834. */
  21835. static CreateTorusKnot(options: {
  21836. radius?: number;
  21837. tube?: number;
  21838. radialSegments?: number;
  21839. tubularSegments?: number;
  21840. p?: number;
  21841. q?: number;
  21842. sideOrientation?: number;
  21843. frontUVs?: Vector4;
  21844. backUVs?: Vector4;
  21845. }): VertexData;
  21846. /**
  21847. * Compute normals for given positions and indices
  21848. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21849. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21850. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21851. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21852. * * facetNormals : optional array of facet normals (vector3)
  21853. * * facetPositions : optional array of facet positions (vector3)
  21854. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21855. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21856. * * bInfo : optional bounding info, required for facetPartitioning computation
  21857. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21858. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21859. * * useRightHandedSystem: optional boolean to for right handed system computation
  21860. * * depthSort : optional boolean to enable the facet depth sort computation
  21861. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21862. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21863. */
  21864. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21865. facetNormals?: any;
  21866. facetPositions?: any;
  21867. facetPartitioning?: any;
  21868. ratio?: number;
  21869. bInfo?: any;
  21870. bbSize?: Vector3;
  21871. subDiv?: any;
  21872. useRightHandedSystem?: boolean;
  21873. depthSort?: boolean;
  21874. distanceTo?: Vector3;
  21875. depthSortedFacets?: any;
  21876. }): void;
  21877. /** @hidden */
  21878. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21879. /**
  21880. * Applies VertexData created from the imported parameters to the geometry
  21881. * @param parsedVertexData the parsed data from an imported file
  21882. * @param geometry the geometry to apply the VertexData to
  21883. */
  21884. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21885. }
  21886. }
  21887. declare module BABYLON {
  21888. /**
  21889. * Defines a target to use with MorphTargetManager
  21890. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21891. */
  21892. export class MorphTarget implements IAnimatable {
  21893. /** defines the name of the target */
  21894. name: string;
  21895. /**
  21896. * Gets or sets the list of animations
  21897. */
  21898. animations: Animation[];
  21899. private _scene;
  21900. private _positions;
  21901. private _normals;
  21902. private _tangents;
  21903. private _uvs;
  21904. private _influence;
  21905. /**
  21906. * Observable raised when the influence changes
  21907. */
  21908. onInfluenceChanged: Observable<boolean>;
  21909. /** @hidden */
  21910. _onDataLayoutChanged: Observable<void>;
  21911. /**
  21912. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21913. */
  21914. influence: number;
  21915. /**
  21916. * Gets or sets the id of the morph Target
  21917. */
  21918. id: string;
  21919. private _animationPropertiesOverride;
  21920. /**
  21921. * Gets or sets the animation properties override
  21922. */
  21923. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21924. /**
  21925. * Creates a new MorphTarget
  21926. * @param name defines the name of the target
  21927. * @param influence defines the influence to use
  21928. * @param scene defines the scene the morphtarget belongs to
  21929. */
  21930. constructor(
  21931. /** defines the name of the target */
  21932. name: string, influence?: number, scene?: Nullable<Scene>);
  21933. /**
  21934. * Gets a boolean defining if the target contains position data
  21935. */
  21936. readonly hasPositions: boolean;
  21937. /**
  21938. * Gets a boolean defining if the target contains normal data
  21939. */
  21940. readonly hasNormals: boolean;
  21941. /**
  21942. * Gets a boolean defining if the target contains tangent data
  21943. */
  21944. readonly hasTangents: boolean;
  21945. /**
  21946. * Gets a boolean defining if the target contains texture coordinates data
  21947. */
  21948. readonly hasUVs: boolean;
  21949. /**
  21950. * Affects position data to this target
  21951. * @param data defines the position data to use
  21952. */
  21953. setPositions(data: Nullable<FloatArray>): void;
  21954. /**
  21955. * Gets the position data stored in this target
  21956. * @returns a FloatArray containing the position data (or null if not present)
  21957. */
  21958. getPositions(): Nullable<FloatArray>;
  21959. /**
  21960. * Affects normal data to this target
  21961. * @param data defines the normal data to use
  21962. */
  21963. setNormals(data: Nullable<FloatArray>): void;
  21964. /**
  21965. * Gets the normal data stored in this target
  21966. * @returns a FloatArray containing the normal data (or null if not present)
  21967. */
  21968. getNormals(): Nullable<FloatArray>;
  21969. /**
  21970. * Affects tangent data to this target
  21971. * @param data defines the tangent data to use
  21972. */
  21973. setTangents(data: Nullable<FloatArray>): void;
  21974. /**
  21975. * Gets the tangent data stored in this target
  21976. * @returns a FloatArray containing the tangent data (or null if not present)
  21977. */
  21978. getTangents(): Nullable<FloatArray>;
  21979. /**
  21980. * Affects texture coordinates data to this target
  21981. * @param data defines the texture coordinates data to use
  21982. */
  21983. setUVs(data: Nullable<FloatArray>): void;
  21984. /**
  21985. * Gets the texture coordinates data stored in this target
  21986. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21987. */
  21988. getUVs(): Nullable<FloatArray>;
  21989. /**
  21990. * Serializes the current target into a Serialization object
  21991. * @returns the serialized object
  21992. */
  21993. serialize(): any;
  21994. /**
  21995. * Returns the string "MorphTarget"
  21996. * @returns "MorphTarget"
  21997. */
  21998. getClassName(): string;
  21999. /**
  22000. * Creates a new target from serialized data
  22001. * @param serializationObject defines the serialized data to use
  22002. * @returns a new MorphTarget
  22003. */
  22004. static Parse(serializationObject: any): MorphTarget;
  22005. /**
  22006. * Creates a MorphTarget from mesh data
  22007. * @param mesh defines the source mesh
  22008. * @param name defines the name to use for the new target
  22009. * @param influence defines the influence to attach to the target
  22010. * @returns a new MorphTarget
  22011. */
  22012. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22013. }
  22014. }
  22015. declare module BABYLON {
  22016. /**
  22017. * This class is used to deform meshes using morphing between different targets
  22018. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22019. */
  22020. export class MorphTargetManager {
  22021. private _targets;
  22022. private _targetInfluenceChangedObservers;
  22023. private _targetDataLayoutChangedObservers;
  22024. private _activeTargets;
  22025. private _scene;
  22026. private _influences;
  22027. private _supportsNormals;
  22028. private _supportsTangents;
  22029. private _supportsUVs;
  22030. private _vertexCount;
  22031. private _uniqueId;
  22032. private _tempInfluences;
  22033. /**
  22034. * Gets or sets a boolean indicating if normals must be morphed
  22035. */
  22036. enableNormalMorphing: boolean;
  22037. /**
  22038. * Gets or sets a boolean indicating if tangents must be morphed
  22039. */
  22040. enableTangentMorphing: boolean;
  22041. /**
  22042. * Gets or sets a boolean indicating if UV must be morphed
  22043. */
  22044. enableUVMorphing: boolean;
  22045. /**
  22046. * Creates a new MorphTargetManager
  22047. * @param scene defines the current scene
  22048. */
  22049. constructor(scene?: Nullable<Scene>);
  22050. /**
  22051. * Gets the unique ID of this manager
  22052. */
  22053. readonly uniqueId: number;
  22054. /**
  22055. * Gets the number of vertices handled by this manager
  22056. */
  22057. readonly vertexCount: number;
  22058. /**
  22059. * Gets a boolean indicating if this manager supports morphing of normals
  22060. */
  22061. readonly supportsNormals: boolean;
  22062. /**
  22063. * Gets a boolean indicating if this manager supports morphing of tangents
  22064. */
  22065. readonly supportsTangents: boolean;
  22066. /**
  22067. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22068. */
  22069. readonly supportsUVs: boolean;
  22070. /**
  22071. * Gets the number of targets stored in this manager
  22072. */
  22073. readonly numTargets: number;
  22074. /**
  22075. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22076. */
  22077. readonly numInfluencers: number;
  22078. /**
  22079. * Gets the list of influences (one per target)
  22080. */
  22081. readonly influences: Float32Array;
  22082. /**
  22083. * Gets the active target at specified index. An active target is a target with an influence > 0
  22084. * @param index defines the index to check
  22085. * @returns the requested target
  22086. */
  22087. getActiveTarget(index: number): MorphTarget;
  22088. /**
  22089. * Gets the target at specified index
  22090. * @param index defines the index to check
  22091. * @returns the requested target
  22092. */
  22093. getTarget(index: number): MorphTarget;
  22094. /**
  22095. * Add a new target to this manager
  22096. * @param target defines the target to add
  22097. */
  22098. addTarget(target: MorphTarget): void;
  22099. /**
  22100. * Removes a target from the manager
  22101. * @param target defines the target to remove
  22102. */
  22103. removeTarget(target: MorphTarget): void;
  22104. /**
  22105. * Serializes the current manager into a Serialization object
  22106. * @returns the serialized object
  22107. */
  22108. serialize(): any;
  22109. private _syncActiveTargets;
  22110. /**
  22111. * Syncrhonize the targets with all the meshes using this morph target manager
  22112. */
  22113. synchronize(): void;
  22114. /**
  22115. * Creates a new MorphTargetManager from serialized data
  22116. * @param serializationObject defines the serialized data
  22117. * @param scene defines the hosting scene
  22118. * @returns the new MorphTargetManager
  22119. */
  22120. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22121. }
  22122. }
  22123. declare module BABYLON {
  22124. /**
  22125. * Class used to represent a specific level of detail of a mesh
  22126. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22127. */
  22128. export class MeshLODLevel {
  22129. /** Defines the distance where this level should start being displayed */
  22130. distance: number;
  22131. /** Defines the mesh to use to render this level */
  22132. mesh: Nullable<Mesh>;
  22133. /**
  22134. * Creates a new LOD level
  22135. * @param distance defines the distance where this level should star being displayed
  22136. * @param mesh defines the mesh to use to render this level
  22137. */
  22138. constructor(
  22139. /** Defines the distance where this level should start being displayed */
  22140. distance: number,
  22141. /** Defines the mesh to use to render this level */
  22142. mesh: Nullable<Mesh>);
  22143. }
  22144. }
  22145. declare module BABYLON {
  22146. /**
  22147. * Mesh representing the gorund
  22148. */
  22149. export class GroundMesh extends Mesh {
  22150. /** If octree should be generated */
  22151. generateOctree: boolean;
  22152. private _heightQuads;
  22153. /** @hidden */
  22154. _subdivisionsX: number;
  22155. /** @hidden */
  22156. _subdivisionsY: number;
  22157. /** @hidden */
  22158. _width: number;
  22159. /** @hidden */
  22160. _height: number;
  22161. /** @hidden */
  22162. _minX: number;
  22163. /** @hidden */
  22164. _maxX: number;
  22165. /** @hidden */
  22166. _minZ: number;
  22167. /** @hidden */
  22168. _maxZ: number;
  22169. constructor(name: string, scene: Scene);
  22170. /**
  22171. * "GroundMesh"
  22172. * @returns "GroundMesh"
  22173. */
  22174. getClassName(): string;
  22175. /**
  22176. * The minimum of x and y subdivisions
  22177. */
  22178. readonly subdivisions: number;
  22179. /**
  22180. * X subdivisions
  22181. */
  22182. readonly subdivisionsX: number;
  22183. /**
  22184. * Y subdivisions
  22185. */
  22186. readonly subdivisionsY: number;
  22187. /**
  22188. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22189. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22190. * @param chunksCount the number of subdivisions for x and y
  22191. * @param octreeBlocksSize (Default: 32)
  22192. */
  22193. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22194. /**
  22195. * Returns a height (y) value in the Worl system :
  22196. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22197. * @param x x coordinate
  22198. * @param z z coordinate
  22199. * @returns the ground y position if (x, z) are outside the ground surface.
  22200. */
  22201. getHeightAtCoordinates(x: number, z: number): number;
  22202. /**
  22203. * Returns a normalized vector (Vector3) orthogonal to the ground
  22204. * at the ground coordinates (x, z) expressed in the World system.
  22205. * @param x x coordinate
  22206. * @param z z coordinate
  22207. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22208. */
  22209. getNormalAtCoordinates(x: number, z: number): Vector3;
  22210. /**
  22211. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22212. * at the ground coordinates (x, z) expressed in the World system.
  22213. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22214. * @param x x coordinate
  22215. * @param z z coordinate
  22216. * @param ref vector to store the result
  22217. * @returns the GroundMesh.
  22218. */
  22219. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22220. /**
  22221. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22222. * if the ground has been updated.
  22223. * This can be used in the render loop.
  22224. * @returns the GroundMesh.
  22225. */
  22226. updateCoordinateHeights(): GroundMesh;
  22227. private _getFacetAt;
  22228. private _initHeightQuads;
  22229. private _computeHeightQuads;
  22230. /**
  22231. * Serializes this ground mesh
  22232. * @param serializationObject object to write serialization to
  22233. */
  22234. serialize(serializationObject: any): void;
  22235. /**
  22236. * Parses a serialized ground mesh
  22237. * @param parsedMesh the serialized mesh
  22238. * @param scene the scene to create the ground mesh in
  22239. * @returns the created ground mesh
  22240. */
  22241. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22242. }
  22243. }
  22244. declare module BABYLON {
  22245. /**
  22246. * Interface for Physics-Joint data
  22247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22248. */
  22249. export interface PhysicsJointData {
  22250. /**
  22251. * The main pivot of the joint
  22252. */
  22253. mainPivot?: Vector3;
  22254. /**
  22255. * The connected pivot of the joint
  22256. */
  22257. connectedPivot?: Vector3;
  22258. /**
  22259. * The main axis of the joint
  22260. */
  22261. mainAxis?: Vector3;
  22262. /**
  22263. * The connected axis of the joint
  22264. */
  22265. connectedAxis?: Vector3;
  22266. /**
  22267. * The collision of the joint
  22268. */
  22269. collision?: boolean;
  22270. /**
  22271. * Native Oimo/Cannon/Energy data
  22272. */
  22273. nativeParams?: any;
  22274. }
  22275. /**
  22276. * This is a holder class for the physics joint created by the physics plugin
  22277. * It holds a set of functions to control the underlying joint
  22278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22279. */
  22280. export class PhysicsJoint {
  22281. /**
  22282. * The type of the physics joint
  22283. */
  22284. type: number;
  22285. /**
  22286. * The data for the physics joint
  22287. */
  22288. jointData: PhysicsJointData;
  22289. private _physicsJoint;
  22290. protected _physicsPlugin: IPhysicsEnginePlugin;
  22291. /**
  22292. * Initializes the physics joint
  22293. * @param type The type of the physics joint
  22294. * @param jointData The data for the physics joint
  22295. */
  22296. constructor(
  22297. /**
  22298. * The type of the physics joint
  22299. */
  22300. type: number,
  22301. /**
  22302. * The data for the physics joint
  22303. */
  22304. jointData: PhysicsJointData);
  22305. /**
  22306. * Gets the physics joint
  22307. */
  22308. /**
  22309. * Sets the physics joint
  22310. */
  22311. physicsJoint: any;
  22312. /**
  22313. * Sets the physics plugin
  22314. */
  22315. physicsPlugin: IPhysicsEnginePlugin;
  22316. /**
  22317. * Execute a function that is physics-plugin specific.
  22318. * @param {Function} func the function that will be executed.
  22319. * It accepts two parameters: the physics world and the physics joint
  22320. */
  22321. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22322. /**
  22323. * Distance-Joint type
  22324. */
  22325. static DistanceJoint: number;
  22326. /**
  22327. * Hinge-Joint type
  22328. */
  22329. static HingeJoint: number;
  22330. /**
  22331. * Ball-and-Socket joint type
  22332. */
  22333. static BallAndSocketJoint: number;
  22334. /**
  22335. * Wheel-Joint type
  22336. */
  22337. static WheelJoint: number;
  22338. /**
  22339. * Slider-Joint type
  22340. */
  22341. static SliderJoint: number;
  22342. /**
  22343. * Prismatic-Joint type
  22344. */
  22345. static PrismaticJoint: number;
  22346. /**
  22347. * Universal-Joint type
  22348. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22349. */
  22350. static UniversalJoint: number;
  22351. /**
  22352. * Hinge-Joint 2 type
  22353. */
  22354. static Hinge2Joint: number;
  22355. /**
  22356. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22357. */
  22358. static PointToPointJoint: number;
  22359. /**
  22360. * Spring-Joint type
  22361. */
  22362. static SpringJoint: number;
  22363. /**
  22364. * Lock-Joint type
  22365. */
  22366. static LockJoint: number;
  22367. }
  22368. /**
  22369. * A class representing a physics distance joint
  22370. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22371. */
  22372. export class DistanceJoint extends PhysicsJoint {
  22373. /**
  22374. *
  22375. * @param jointData The data for the Distance-Joint
  22376. */
  22377. constructor(jointData: DistanceJointData);
  22378. /**
  22379. * Update the predefined distance.
  22380. * @param maxDistance The maximum preferred distance
  22381. * @param minDistance The minimum preferred distance
  22382. */
  22383. updateDistance(maxDistance: number, minDistance?: number): void;
  22384. }
  22385. /**
  22386. * Represents a Motor-Enabled Joint
  22387. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22388. */
  22389. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22390. /**
  22391. * Initializes the Motor-Enabled Joint
  22392. * @param type The type of the joint
  22393. * @param jointData The physica joint data for the joint
  22394. */
  22395. constructor(type: number, jointData: PhysicsJointData);
  22396. /**
  22397. * Set the motor values.
  22398. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22399. * @param force the force to apply
  22400. * @param maxForce max force for this motor.
  22401. */
  22402. setMotor(force?: number, maxForce?: number): void;
  22403. /**
  22404. * Set the motor's limits.
  22405. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22406. * @param upperLimit The upper limit of the motor
  22407. * @param lowerLimit The lower limit of the motor
  22408. */
  22409. setLimit(upperLimit: number, lowerLimit?: number): void;
  22410. }
  22411. /**
  22412. * This class represents a single physics Hinge-Joint
  22413. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22414. */
  22415. export class HingeJoint extends MotorEnabledJoint {
  22416. /**
  22417. * Initializes the Hinge-Joint
  22418. * @param jointData The joint data for the Hinge-Joint
  22419. */
  22420. constructor(jointData: PhysicsJointData);
  22421. /**
  22422. * Set the motor values.
  22423. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22424. * @param {number} force the force to apply
  22425. * @param {number} maxForce max force for this motor.
  22426. */
  22427. setMotor(force?: number, maxForce?: number): void;
  22428. /**
  22429. * Set the motor's limits.
  22430. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22431. * @param upperLimit The upper limit of the motor
  22432. * @param lowerLimit The lower limit of the motor
  22433. */
  22434. setLimit(upperLimit: number, lowerLimit?: number): void;
  22435. }
  22436. /**
  22437. * This class represents a dual hinge physics joint (same as wheel joint)
  22438. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22439. */
  22440. export class Hinge2Joint extends MotorEnabledJoint {
  22441. /**
  22442. * Initializes the Hinge2-Joint
  22443. * @param jointData The joint data for the Hinge2-Joint
  22444. */
  22445. constructor(jointData: PhysicsJointData);
  22446. /**
  22447. * Set the motor values.
  22448. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22449. * @param {number} targetSpeed the speed the motor is to reach
  22450. * @param {number} maxForce max force for this motor.
  22451. * @param {motorIndex} the motor's index, 0 or 1.
  22452. */
  22453. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22454. /**
  22455. * Set the motor limits.
  22456. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22457. * @param {number} upperLimit the upper limit
  22458. * @param {number} lowerLimit lower limit
  22459. * @param {motorIndex} the motor's index, 0 or 1.
  22460. */
  22461. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22462. }
  22463. /**
  22464. * Interface for a motor enabled joint
  22465. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22466. */
  22467. export interface IMotorEnabledJoint {
  22468. /**
  22469. * Physics joint
  22470. */
  22471. physicsJoint: any;
  22472. /**
  22473. * Sets the motor of the motor-enabled joint
  22474. * @param force The force of the motor
  22475. * @param maxForce The maximum force of the motor
  22476. * @param motorIndex The index of the motor
  22477. */
  22478. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22479. /**
  22480. * Sets the limit of the motor
  22481. * @param upperLimit The upper limit of the motor
  22482. * @param lowerLimit The lower limit of the motor
  22483. * @param motorIndex The index of the motor
  22484. */
  22485. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22486. }
  22487. /**
  22488. * Joint data for a Distance-Joint
  22489. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22490. */
  22491. export interface DistanceJointData extends PhysicsJointData {
  22492. /**
  22493. * Max distance the 2 joint objects can be apart
  22494. */
  22495. maxDistance: number;
  22496. }
  22497. /**
  22498. * Joint data from a spring joint
  22499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22500. */
  22501. export interface SpringJointData extends PhysicsJointData {
  22502. /**
  22503. * Length of the spring
  22504. */
  22505. length: number;
  22506. /**
  22507. * Stiffness of the spring
  22508. */
  22509. stiffness: number;
  22510. /**
  22511. * Damping of the spring
  22512. */
  22513. damping: number;
  22514. /** this callback will be called when applying the force to the impostors. */
  22515. forceApplicationCallback: () => void;
  22516. }
  22517. }
  22518. declare module BABYLON {
  22519. /**
  22520. * Holds the data for the raycast result
  22521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22522. */
  22523. export class PhysicsRaycastResult {
  22524. private _hasHit;
  22525. private _hitDistance;
  22526. private _hitNormalWorld;
  22527. private _hitPointWorld;
  22528. private _rayFromWorld;
  22529. private _rayToWorld;
  22530. /**
  22531. * Gets if there was a hit
  22532. */
  22533. readonly hasHit: boolean;
  22534. /**
  22535. * Gets the distance from the hit
  22536. */
  22537. readonly hitDistance: number;
  22538. /**
  22539. * Gets the hit normal/direction in the world
  22540. */
  22541. readonly hitNormalWorld: Vector3;
  22542. /**
  22543. * Gets the hit point in the world
  22544. */
  22545. readonly hitPointWorld: Vector3;
  22546. /**
  22547. * Gets the ray "start point" of the ray in the world
  22548. */
  22549. readonly rayFromWorld: Vector3;
  22550. /**
  22551. * Gets the ray "end point" of the ray in the world
  22552. */
  22553. readonly rayToWorld: Vector3;
  22554. /**
  22555. * Sets the hit data (normal & point in world space)
  22556. * @param hitNormalWorld defines the normal in world space
  22557. * @param hitPointWorld defines the point in world space
  22558. */
  22559. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22560. /**
  22561. * Sets the distance from the start point to the hit point
  22562. * @param distance
  22563. */
  22564. setHitDistance(distance: number): void;
  22565. /**
  22566. * Calculates the distance manually
  22567. */
  22568. calculateHitDistance(): void;
  22569. /**
  22570. * Resets all the values to default
  22571. * @param from The from point on world space
  22572. * @param to The to point on world space
  22573. */
  22574. reset(from?: Vector3, to?: Vector3): void;
  22575. }
  22576. /**
  22577. * Interface for the size containing width and height
  22578. */
  22579. interface IXYZ {
  22580. /**
  22581. * X
  22582. */
  22583. x: number;
  22584. /**
  22585. * Y
  22586. */
  22587. y: number;
  22588. /**
  22589. * Z
  22590. */
  22591. z: number;
  22592. }
  22593. }
  22594. declare module BABYLON {
  22595. /**
  22596. * Interface used to describe a physics joint
  22597. */
  22598. export interface PhysicsImpostorJoint {
  22599. /** Defines the main impostor to which the joint is linked */
  22600. mainImpostor: PhysicsImpostor;
  22601. /** Defines the impostor that is connected to the main impostor using this joint */
  22602. connectedImpostor: PhysicsImpostor;
  22603. /** Defines the joint itself */
  22604. joint: PhysicsJoint;
  22605. }
  22606. /** @hidden */
  22607. export interface IPhysicsEnginePlugin {
  22608. world: any;
  22609. name: string;
  22610. setGravity(gravity: Vector3): void;
  22611. setTimeStep(timeStep: number): void;
  22612. getTimeStep(): number;
  22613. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22614. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22615. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22616. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22617. removePhysicsBody(impostor: PhysicsImpostor): void;
  22618. generateJoint(joint: PhysicsImpostorJoint): void;
  22619. removeJoint(joint: PhysicsImpostorJoint): void;
  22620. isSupported(): boolean;
  22621. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22622. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22623. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22624. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22625. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22626. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22627. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22628. getBodyMass(impostor: PhysicsImpostor): number;
  22629. getBodyFriction(impostor: PhysicsImpostor): number;
  22630. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22631. getBodyRestitution(impostor: PhysicsImpostor): number;
  22632. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22633. getBodyPressure?(impostor: PhysicsImpostor): number;
  22634. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22635. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22636. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22637. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22638. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22639. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22640. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22641. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22642. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22643. sleepBody(impostor: PhysicsImpostor): void;
  22644. wakeUpBody(impostor: PhysicsImpostor): void;
  22645. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22646. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22647. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22648. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22649. getRadius(impostor: PhysicsImpostor): number;
  22650. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22651. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22652. dispose(): void;
  22653. }
  22654. /**
  22655. * Interface used to define a physics engine
  22656. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22657. */
  22658. export interface IPhysicsEngine {
  22659. /**
  22660. * Gets the gravity vector used by the simulation
  22661. */
  22662. gravity: Vector3;
  22663. /**
  22664. * Sets the gravity vector used by the simulation
  22665. * @param gravity defines the gravity vector to use
  22666. */
  22667. setGravity(gravity: Vector3): void;
  22668. /**
  22669. * Set the time step of the physics engine.
  22670. * Default is 1/60.
  22671. * To slow it down, enter 1/600 for example.
  22672. * To speed it up, 1/30
  22673. * @param newTimeStep the new timestep to apply to this world.
  22674. */
  22675. setTimeStep(newTimeStep: number): void;
  22676. /**
  22677. * Get the time step of the physics engine.
  22678. * @returns the current time step
  22679. */
  22680. getTimeStep(): number;
  22681. /**
  22682. * Release all resources
  22683. */
  22684. dispose(): void;
  22685. /**
  22686. * Gets the name of the current physics plugin
  22687. * @returns the name of the plugin
  22688. */
  22689. getPhysicsPluginName(): string;
  22690. /**
  22691. * Adding a new impostor for the impostor tracking.
  22692. * This will be done by the impostor itself.
  22693. * @param impostor the impostor to add
  22694. */
  22695. addImpostor(impostor: PhysicsImpostor): void;
  22696. /**
  22697. * Remove an impostor from the engine.
  22698. * This impostor and its mesh will not longer be updated by the physics engine.
  22699. * @param impostor the impostor to remove
  22700. */
  22701. removeImpostor(impostor: PhysicsImpostor): void;
  22702. /**
  22703. * Add a joint to the physics engine
  22704. * @param mainImpostor defines the main impostor to which the joint is added.
  22705. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22706. * @param joint defines the joint that will connect both impostors.
  22707. */
  22708. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22709. /**
  22710. * Removes a joint from the simulation
  22711. * @param mainImpostor defines the impostor used with the joint
  22712. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22713. * @param joint defines the joint to remove
  22714. */
  22715. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22716. /**
  22717. * Gets the current plugin used to run the simulation
  22718. * @returns current plugin
  22719. */
  22720. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22721. /**
  22722. * Gets the list of physic impostors
  22723. * @returns an array of PhysicsImpostor
  22724. */
  22725. getImpostors(): Array<PhysicsImpostor>;
  22726. /**
  22727. * Gets the impostor for a physics enabled object
  22728. * @param object defines the object impersonated by the impostor
  22729. * @returns the PhysicsImpostor or null if not found
  22730. */
  22731. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22732. /**
  22733. * Gets the impostor for a physics body object
  22734. * @param body defines physics body used by the impostor
  22735. * @returns the PhysicsImpostor or null if not found
  22736. */
  22737. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22738. /**
  22739. * Does a raycast in the physics world
  22740. * @param from when should the ray start?
  22741. * @param to when should the ray end?
  22742. * @returns PhysicsRaycastResult
  22743. */
  22744. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22745. /**
  22746. * Called by the scene. No need to call it.
  22747. * @param delta defines the timespam between frames
  22748. */
  22749. _step(delta: number): void;
  22750. }
  22751. }
  22752. declare module BABYLON {
  22753. /**
  22754. * The interface for the physics imposter parameters
  22755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22756. */
  22757. export interface PhysicsImpostorParameters {
  22758. /**
  22759. * The mass of the physics imposter
  22760. */
  22761. mass: number;
  22762. /**
  22763. * The friction of the physics imposter
  22764. */
  22765. friction?: number;
  22766. /**
  22767. * The coefficient of restitution of the physics imposter
  22768. */
  22769. restitution?: number;
  22770. /**
  22771. * The native options of the physics imposter
  22772. */
  22773. nativeOptions?: any;
  22774. /**
  22775. * Specifies if the parent should be ignored
  22776. */
  22777. ignoreParent?: boolean;
  22778. /**
  22779. * Specifies if bi-directional transformations should be disabled
  22780. */
  22781. disableBidirectionalTransformation?: boolean;
  22782. /**
  22783. * The pressure inside the physics imposter, soft object only
  22784. */
  22785. pressure?: number;
  22786. /**
  22787. * The stiffness the physics imposter, soft object only
  22788. */
  22789. stiffness?: number;
  22790. /**
  22791. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22792. */
  22793. velocityIterations?: number;
  22794. /**
  22795. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22796. */
  22797. positionIterations?: number;
  22798. /**
  22799. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22800. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22801. * Add to fix multiple points
  22802. */
  22803. fixedPoints?: number;
  22804. /**
  22805. * The collision margin around a soft object
  22806. */
  22807. margin?: number;
  22808. /**
  22809. * The collision margin around a soft object
  22810. */
  22811. damping?: number;
  22812. /**
  22813. * The path for a rope based on an extrusion
  22814. */
  22815. path?: any;
  22816. /**
  22817. * The shape of an extrusion used for a rope based on an extrusion
  22818. */
  22819. shape?: any;
  22820. }
  22821. /**
  22822. * Interface for a physics-enabled object
  22823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22824. */
  22825. export interface IPhysicsEnabledObject {
  22826. /**
  22827. * The position of the physics-enabled object
  22828. */
  22829. position: Vector3;
  22830. /**
  22831. * The rotation of the physics-enabled object
  22832. */
  22833. rotationQuaternion: Nullable<Quaternion>;
  22834. /**
  22835. * The scale of the physics-enabled object
  22836. */
  22837. scaling: Vector3;
  22838. /**
  22839. * The rotation of the physics-enabled object
  22840. */
  22841. rotation?: Vector3;
  22842. /**
  22843. * The parent of the physics-enabled object
  22844. */
  22845. parent?: any;
  22846. /**
  22847. * The bounding info of the physics-enabled object
  22848. * @returns The bounding info of the physics-enabled object
  22849. */
  22850. getBoundingInfo(): BoundingInfo;
  22851. /**
  22852. * Computes the world matrix
  22853. * @param force Specifies if the world matrix should be computed by force
  22854. * @returns A world matrix
  22855. */
  22856. computeWorldMatrix(force: boolean): Matrix;
  22857. /**
  22858. * Gets the world matrix
  22859. * @returns A world matrix
  22860. */
  22861. getWorldMatrix?(): Matrix;
  22862. /**
  22863. * Gets the child meshes
  22864. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22865. * @returns An array of abstract meshes
  22866. */
  22867. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22868. /**
  22869. * Gets the vertex data
  22870. * @param kind The type of vertex data
  22871. * @returns A nullable array of numbers, or a float32 array
  22872. */
  22873. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22874. /**
  22875. * Gets the indices from the mesh
  22876. * @returns A nullable array of index arrays
  22877. */
  22878. getIndices?(): Nullable<IndicesArray>;
  22879. /**
  22880. * Gets the scene from the mesh
  22881. * @returns the indices array or null
  22882. */
  22883. getScene?(): Scene;
  22884. /**
  22885. * Gets the absolute position from the mesh
  22886. * @returns the absolute position
  22887. */
  22888. getAbsolutePosition(): Vector3;
  22889. /**
  22890. * Gets the absolute pivot point from the mesh
  22891. * @returns the absolute pivot point
  22892. */
  22893. getAbsolutePivotPoint(): Vector3;
  22894. /**
  22895. * Rotates the mesh
  22896. * @param axis The axis of rotation
  22897. * @param amount The amount of rotation
  22898. * @param space The space of the rotation
  22899. * @returns The rotation transform node
  22900. */
  22901. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22902. /**
  22903. * Translates the mesh
  22904. * @param axis The axis of translation
  22905. * @param distance The distance of translation
  22906. * @param space The space of the translation
  22907. * @returns The transform node
  22908. */
  22909. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22910. /**
  22911. * Sets the absolute position of the mesh
  22912. * @param absolutePosition The absolute position of the mesh
  22913. * @returns The transform node
  22914. */
  22915. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22916. /**
  22917. * Gets the class name of the mesh
  22918. * @returns The class name
  22919. */
  22920. getClassName(): string;
  22921. }
  22922. /**
  22923. * Represents a physics imposter
  22924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22925. */
  22926. export class PhysicsImpostor {
  22927. /**
  22928. * The physics-enabled object used as the physics imposter
  22929. */
  22930. object: IPhysicsEnabledObject;
  22931. /**
  22932. * The type of the physics imposter
  22933. */
  22934. type: number;
  22935. private _options;
  22936. private _scene?;
  22937. /**
  22938. * The default object size of the imposter
  22939. */
  22940. static DEFAULT_OBJECT_SIZE: Vector3;
  22941. /**
  22942. * The identity quaternion of the imposter
  22943. */
  22944. static IDENTITY_QUATERNION: Quaternion;
  22945. /** @hidden */
  22946. _pluginData: any;
  22947. private _physicsEngine;
  22948. private _physicsBody;
  22949. private _bodyUpdateRequired;
  22950. private _onBeforePhysicsStepCallbacks;
  22951. private _onAfterPhysicsStepCallbacks;
  22952. /** @hidden */
  22953. _onPhysicsCollideCallbacks: Array<{
  22954. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22955. otherImpostors: Array<PhysicsImpostor>;
  22956. }>;
  22957. private _deltaPosition;
  22958. private _deltaRotation;
  22959. private _deltaRotationConjugated;
  22960. /** @hidden */
  22961. _isFromLine: boolean;
  22962. private _parent;
  22963. private _isDisposed;
  22964. private static _tmpVecs;
  22965. private static _tmpQuat;
  22966. /**
  22967. * Specifies if the physics imposter is disposed
  22968. */
  22969. readonly isDisposed: boolean;
  22970. /**
  22971. * Gets the mass of the physics imposter
  22972. */
  22973. mass: number;
  22974. /**
  22975. * Gets the coefficient of friction
  22976. */
  22977. /**
  22978. * Sets the coefficient of friction
  22979. */
  22980. friction: number;
  22981. /**
  22982. * Gets the coefficient of restitution
  22983. */
  22984. /**
  22985. * Sets the coefficient of restitution
  22986. */
  22987. restitution: number;
  22988. /**
  22989. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22990. */
  22991. /**
  22992. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22993. */
  22994. pressure: number;
  22995. /**
  22996. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22997. */
  22998. /**
  22999. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23000. */
  23001. stiffness: number;
  23002. /**
  23003. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23004. */
  23005. /**
  23006. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23007. */
  23008. velocityIterations: number;
  23009. /**
  23010. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23011. */
  23012. /**
  23013. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23014. */
  23015. positionIterations: number;
  23016. /**
  23017. * The unique id of the physics imposter
  23018. * set by the physics engine when adding this impostor to the array
  23019. */
  23020. uniqueId: number;
  23021. /**
  23022. * @hidden
  23023. */
  23024. soft: boolean;
  23025. /**
  23026. * @hidden
  23027. */
  23028. segments: number;
  23029. private _joints;
  23030. /**
  23031. * Initializes the physics imposter
  23032. * @param object The physics-enabled object used as the physics imposter
  23033. * @param type The type of the physics imposter
  23034. * @param _options The options for the physics imposter
  23035. * @param _scene The Babylon scene
  23036. */
  23037. constructor(
  23038. /**
  23039. * The physics-enabled object used as the physics imposter
  23040. */
  23041. object: IPhysicsEnabledObject,
  23042. /**
  23043. * The type of the physics imposter
  23044. */
  23045. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23046. /**
  23047. * This function will completly initialize this impostor.
  23048. * It will create a new body - but only if this mesh has no parent.
  23049. * If it has, this impostor will not be used other than to define the impostor
  23050. * of the child mesh.
  23051. * @hidden
  23052. */
  23053. _init(): void;
  23054. private _getPhysicsParent;
  23055. /**
  23056. * Should a new body be generated.
  23057. * @returns boolean specifying if body initialization is required
  23058. */
  23059. isBodyInitRequired(): boolean;
  23060. /**
  23061. * Sets the updated scaling
  23062. * @param updated Specifies if the scaling is updated
  23063. */
  23064. setScalingUpdated(): void;
  23065. /**
  23066. * Force a regeneration of this or the parent's impostor's body.
  23067. * Use under cautious - This will remove all joints already implemented.
  23068. */
  23069. forceUpdate(): void;
  23070. /**
  23071. * Gets the body that holds this impostor. Either its own, or its parent.
  23072. */
  23073. /**
  23074. * Set the physics body. Used mainly by the physics engine/plugin
  23075. */
  23076. physicsBody: any;
  23077. /**
  23078. * Get the parent of the physics imposter
  23079. * @returns Physics imposter or null
  23080. */
  23081. /**
  23082. * Sets the parent of the physics imposter
  23083. */
  23084. parent: Nullable<PhysicsImpostor>;
  23085. /**
  23086. * Resets the update flags
  23087. */
  23088. resetUpdateFlags(): void;
  23089. /**
  23090. * Gets the object extend size
  23091. * @returns the object extend size
  23092. */
  23093. getObjectExtendSize(): Vector3;
  23094. /**
  23095. * Gets the object center
  23096. * @returns The object center
  23097. */
  23098. getObjectCenter(): Vector3;
  23099. /**
  23100. * Get a specific parametes from the options parameter
  23101. * @param paramName The object parameter name
  23102. * @returns The object parameter
  23103. */
  23104. getParam(paramName: string): any;
  23105. /**
  23106. * Sets a specific parameter in the options given to the physics plugin
  23107. * @param paramName The parameter name
  23108. * @param value The value of the parameter
  23109. */
  23110. setParam(paramName: string, value: number): void;
  23111. /**
  23112. * Specifically change the body's mass option. Won't recreate the physics body object
  23113. * @param mass The mass of the physics imposter
  23114. */
  23115. setMass(mass: number): void;
  23116. /**
  23117. * Gets the linear velocity
  23118. * @returns linear velocity or null
  23119. */
  23120. getLinearVelocity(): Nullable<Vector3>;
  23121. /**
  23122. * Sets the linear velocity
  23123. * @param velocity linear velocity or null
  23124. */
  23125. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23126. /**
  23127. * Gets the angular velocity
  23128. * @returns angular velocity or null
  23129. */
  23130. getAngularVelocity(): Nullable<Vector3>;
  23131. /**
  23132. * Sets the angular velocity
  23133. * @param velocity The velocity or null
  23134. */
  23135. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23136. /**
  23137. * Execute a function with the physics plugin native code
  23138. * Provide a function the will have two variables - the world object and the physics body object
  23139. * @param func The function to execute with the physics plugin native code
  23140. */
  23141. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23142. /**
  23143. * Register a function that will be executed before the physics world is stepping forward
  23144. * @param func The function to execute before the physics world is stepped forward
  23145. */
  23146. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23147. /**
  23148. * Unregister a function that will be executed before the physics world is stepping forward
  23149. * @param func The function to execute before the physics world is stepped forward
  23150. */
  23151. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23152. /**
  23153. * Register a function that will be executed after the physics step
  23154. * @param func The function to execute after physics step
  23155. */
  23156. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23157. /**
  23158. * Unregisters a function that will be executed after the physics step
  23159. * @param func The function to execute after physics step
  23160. */
  23161. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23162. /**
  23163. * register a function that will be executed when this impostor collides against a different body
  23164. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23165. * @param func Callback that is executed on collision
  23166. */
  23167. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23168. /**
  23169. * Unregisters the physics imposter on contact
  23170. * @param collideAgainst The physics object to collide against
  23171. * @param func Callback to execute on collision
  23172. */
  23173. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23174. private _tmpQuat;
  23175. private _tmpQuat2;
  23176. /**
  23177. * Get the parent rotation
  23178. * @returns The parent rotation
  23179. */
  23180. getParentsRotation(): Quaternion;
  23181. /**
  23182. * this function is executed by the physics engine.
  23183. */
  23184. beforeStep: () => void;
  23185. /**
  23186. * this function is executed by the physics engine
  23187. */
  23188. afterStep: () => void;
  23189. /**
  23190. * Legacy collision detection event support
  23191. */
  23192. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23193. /**
  23194. * event and body object due to cannon's event-based architecture.
  23195. */
  23196. onCollide: (e: {
  23197. body: any;
  23198. }) => void;
  23199. /**
  23200. * Apply a force
  23201. * @param force The force to apply
  23202. * @param contactPoint The contact point for the force
  23203. * @returns The physics imposter
  23204. */
  23205. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23206. /**
  23207. * Apply an impulse
  23208. * @param force The impulse force
  23209. * @param contactPoint The contact point for the impulse force
  23210. * @returns The physics imposter
  23211. */
  23212. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23213. /**
  23214. * A help function to create a joint
  23215. * @param otherImpostor A physics imposter used to create a joint
  23216. * @param jointType The type of joint
  23217. * @param jointData The data for the joint
  23218. * @returns The physics imposter
  23219. */
  23220. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23221. /**
  23222. * Add a joint to this impostor with a different impostor
  23223. * @param otherImpostor A physics imposter used to add a joint
  23224. * @param joint The joint to add
  23225. * @returns The physics imposter
  23226. */
  23227. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23228. /**
  23229. * Add an anchor to a cloth impostor
  23230. * @param otherImpostor rigid impostor to anchor to
  23231. * @param width ratio across width from 0 to 1
  23232. * @param height ratio up height from 0 to 1
  23233. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23234. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23235. * @returns impostor the soft imposter
  23236. */
  23237. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23238. /**
  23239. * Add a hook to a rope impostor
  23240. * @param otherImpostor rigid impostor to anchor to
  23241. * @param length ratio across rope from 0 to 1
  23242. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23243. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23244. * @returns impostor the rope imposter
  23245. */
  23246. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23247. /**
  23248. * Will keep this body still, in a sleep mode.
  23249. * @returns the physics imposter
  23250. */
  23251. sleep(): PhysicsImpostor;
  23252. /**
  23253. * Wake the body up.
  23254. * @returns The physics imposter
  23255. */
  23256. wakeUp(): PhysicsImpostor;
  23257. /**
  23258. * Clones the physics imposter
  23259. * @param newObject The physics imposter clones to this physics-enabled object
  23260. * @returns A nullable physics imposter
  23261. */
  23262. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23263. /**
  23264. * Disposes the physics imposter
  23265. */
  23266. dispose(): void;
  23267. /**
  23268. * Sets the delta position
  23269. * @param position The delta position amount
  23270. */
  23271. setDeltaPosition(position: Vector3): void;
  23272. /**
  23273. * Sets the delta rotation
  23274. * @param rotation The delta rotation amount
  23275. */
  23276. setDeltaRotation(rotation: Quaternion): void;
  23277. /**
  23278. * Gets the box size of the physics imposter and stores the result in the input parameter
  23279. * @param result Stores the box size
  23280. * @returns The physics imposter
  23281. */
  23282. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23283. /**
  23284. * Gets the radius of the physics imposter
  23285. * @returns Radius of the physics imposter
  23286. */
  23287. getRadius(): number;
  23288. /**
  23289. * Sync a bone with this impostor
  23290. * @param bone The bone to sync to the impostor.
  23291. * @param boneMesh The mesh that the bone is influencing.
  23292. * @param jointPivot The pivot of the joint / bone in local space.
  23293. * @param distToJoint Optional distance from the impostor to the joint.
  23294. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23295. */
  23296. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23297. /**
  23298. * Sync impostor to a bone
  23299. * @param bone The bone that the impostor will be synced to.
  23300. * @param boneMesh The mesh that the bone is influencing.
  23301. * @param jointPivot The pivot of the joint / bone in local space.
  23302. * @param distToJoint Optional distance from the impostor to the joint.
  23303. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23304. * @param boneAxis Optional vector3 axis the bone is aligned with
  23305. */
  23306. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23307. /**
  23308. * No-Imposter type
  23309. */
  23310. static NoImpostor: number;
  23311. /**
  23312. * Sphere-Imposter type
  23313. */
  23314. static SphereImpostor: number;
  23315. /**
  23316. * Box-Imposter type
  23317. */
  23318. static BoxImpostor: number;
  23319. /**
  23320. * Plane-Imposter type
  23321. */
  23322. static PlaneImpostor: number;
  23323. /**
  23324. * Mesh-imposter type
  23325. */
  23326. static MeshImpostor: number;
  23327. /**
  23328. * Capsule-Impostor type (Ammo.js plugin only)
  23329. */
  23330. static CapsuleImpostor: number;
  23331. /**
  23332. * Cylinder-Imposter type
  23333. */
  23334. static CylinderImpostor: number;
  23335. /**
  23336. * Particle-Imposter type
  23337. */
  23338. static ParticleImpostor: number;
  23339. /**
  23340. * Heightmap-Imposter type
  23341. */
  23342. static HeightmapImpostor: number;
  23343. /**
  23344. * ConvexHull-Impostor type (Ammo.js plugin only)
  23345. */
  23346. static ConvexHullImpostor: number;
  23347. /**
  23348. * Rope-Imposter type
  23349. */
  23350. static RopeImpostor: number;
  23351. /**
  23352. * Cloth-Imposter type
  23353. */
  23354. static ClothImpostor: number;
  23355. /**
  23356. * Softbody-Imposter type
  23357. */
  23358. static SoftbodyImpostor: number;
  23359. }
  23360. }
  23361. declare module BABYLON {
  23362. /**
  23363. * @hidden
  23364. **/
  23365. export class _CreationDataStorage {
  23366. closePath?: boolean;
  23367. closeArray?: boolean;
  23368. idx: number[];
  23369. dashSize: number;
  23370. gapSize: number;
  23371. path3D: Path3D;
  23372. pathArray: Vector3[][];
  23373. arc: number;
  23374. radius: number;
  23375. cap: number;
  23376. tessellation: number;
  23377. }
  23378. /**
  23379. * @hidden
  23380. **/
  23381. class _InstanceDataStorage {
  23382. visibleInstances: any;
  23383. batchCache: _InstancesBatch;
  23384. instancesBufferSize: number;
  23385. instancesBuffer: Nullable<Buffer>;
  23386. instancesData: Float32Array;
  23387. overridenInstanceCount: number;
  23388. isFrozen: boolean;
  23389. previousBatch: Nullable<_InstancesBatch>;
  23390. hardwareInstancedRendering: boolean;
  23391. sideOrientation: number;
  23392. }
  23393. /**
  23394. * @hidden
  23395. **/
  23396. export class _InstancesBatch {
  23397. mustReturn: boolean;
  23398. visibleInstances: Nullable<InstancedMesh[]>[];
  23399. renderSelf: boolean[];
  23400. hardwareInstancedRendering: boolean[];
  23401. }
  23402. /**
  23403. * Class used to represent renderable models
  23404. */
  23405. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23406. /**
  23407. * Mesh side orientation : usually the external or front surface
  23408. */
  23409. static readonly FRONTSIDE: number;
  23410. /**
  23411. * Mesh side orientation : usually the internal or back surface
  23412. */
  23413. static readonly BACKSIDE: number;
  23414. /**
  23415. * Mesh side orientation : both internal and external or front and back surfaces
  23416. */
  23417. static readonly DOUBLESIDE: number;
  23418. /**
  23419. * Mesh side orientation : by default, `FRONTSIDE`
  23420. */
  23421. static readonly DEFAULTSIDE: number;
  23422. /**
  23423. * Mesh cap setting : no cap
  23424. */
  23425. static readonly NO_CAP: number;
  23426. /**
  23427. * Mesh cap setting : one cap at the beginning of the mesh
  23428. */
  23429. static readonly CAP_START: number;
  23430. /**
  23431. * Mesh cap setting : one cap at the end of the mesh
  23432. */
  23433. static readonly CAP_END: number;
  23434. /**
  23435. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23436. */
  23437. static readonly CAP_ALL: number;
  23438. /**
  23439. * Mesh pattern setting : no flip or rotate
  23440. */
  23441. static readonly NO_FLIP: number;
  23442. /**
  23443. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23444. */
  23445. static readonly FLIP_TILE: number;
  23446. /**
  23447. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23448. */
  23449. static readonly ROTATE_TILE: number;
  23450. /**
  23451. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23452. */
  23453. static readonly FLIP_ROW: number;
  23454. /**
  23455. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23456. */
  23457. static readonly ROTATE_ROW: number;
  23458. /**
  23459. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23460. */
  23461. static readonly FLIP_N_ROTATE_TILE: number;
  23462. /**
  23463. * Mesh pattern setting : rotate pattern and rotate
  23464. */
  23465. static readonly FLIP_N_ROTATE_ROW: number;
  23466. /**
  23467. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23468. */
  23469. static readonly CENTER: number;
  23470. /**
  23471. * Mesh tile positioning : part tiles on left
  23472. */
  23473. static readonly LEFT: number;
  23474. /**
  23475. * Mesh tile positioning : part tiles on right
  23476. */
  23477. static readonly RIGHT: number;
  23478. /**
  23479. * Mesh tile positioning : part tiles on top
  23480. */
  23481. static readonly TOP: number;
  23482. /**
  23483. * Mesh tile positioning : part tiles on bottom
  23484. */
  23485. static readonly BOTTOM: number;
  23486. /**
  23487. * Gets the default side orientation.
  23488. * @param orientation the orientation to value to attempt to get
  23489. * @returns the default orientation
  23490. * @hidden
  23491. */
  23492. static _GetDefaultSideOrientation(orientation?: number): number;
  23493. private _internalMeshDataInfo;
  23494. /**
  23495. * An event triggered before rendering the mesh
  23496. */
  23497. readonly onBeforeRenderObservable: Observable<Mesh>;
  23498. /**
  23499. * An event triggered before binding the mesh
  23500. */
  23501. readonly onBeforeBindObservable: Observable<Mesh>;
  23502. /**
  23503. * An event triggered after rendering the mesh
  23504. */
  23505. readonly onAfterRenderObservable: Observable<Mesh>;
  23506. /**
  23507. * An event triggered before drawing the mesh
  23508. */
  23509. readonly onBeforeDrawObservable: Observable<Mesh>;
  23510. private _onBeforeDrawObserver;
  23511. /**
  23512. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23513. */
  23514. onBeforeDraw: () => void;
  23515. readonly hasInstances: boolean;
  23516. /**
  23517. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23518. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23519. */
  23520. delayLoadState: number;
  23521. /**
  23522. * Gets the list of instances created from this mesh
  23523. * it is not supposed to be modified manually.
  23524. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23525. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23526. */
  23527. instances: InstancedMesh[];
  23528. /**
  23529. * Gets the file containing delay loading data for this mesh
  23530. */
  23531. delayLoadingFile: string;
  23532. /** @hidden */
  23533. _binaryInfo: any;
  23534. /**
  23535. * User defined function used to change how LOD level selection is done
  23536. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23537. */
  23538. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23539. /**
  23540. * Gets or sets the morph target manager
  23541. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23542. */
  23543. morphTargetManager: Nullable<MorphTargetManager>;
  23544. /** @hidden */
  23545. _creationDataStorage: Nullable<_CreationDataStorage>;
  23546. /** @hidden */
  23547. _geometry: Nullable<Geometry>;
  23548. /** @hidden */
  23549. _delayInfo: Array<string>;
  23550. /** @hidden */
  23551. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23552. /** @hidden */
  23553. _instanceDataStorage: _InstanceDataStorage;
  23554. private _effectiveMaterial;
  23555. /** @hidden */
  23556. _shouldGenerateFlatShading: boolean;
  23557. /** @hidden */
  23558. _originalBuilderSideOrientation: number;
  23559. /**
  23560. * Use this property to change the original side orientation defined at construction time
  23561. */
  23562. overrideMaterialSideOrientation: Nullable<number>;
  23563. /**
  23564. * Gets the source mesh (the one used to clone this one from)
  23565. */
  23566. readonly source: Nullable<Mesh>;
  23567. /**
  23568. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23569. */
  23570. isUnIndexed: boolean;
  23571. /**
  23572. * @constructor
  23573. * @param name The value used by scene.getMeshByName() to do a lookup.
  23574. * @param scene The scene to add this mesh to.
  23575. * @param parent The parent of this mesh, if it has one
  23576. * @param source An optional Mesh from which geometry is shared, cloned.
  23577. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23578. * When false, achieved by calling a clone(), also passing False.
  23579. * This will make creation of children, recursive.
  23580. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23581. */
  23582. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23583. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23584. /**
  23585. * Gets the class name
  23586. * @returns the string "Mesh".
  23587. */
  23588. getClassName(): string;
  23589. /** @hidden */
  23590. readonly _isMesh: boolean;
  23591. /**
  23592. * Returns a description of this mesh
  23593. * @param fullDetails define if full details about this mesh must be used
  23594. * @returns a descriptive string representing this mesh
  23595. */
  23596. toString(fullDetails?: boolean): string;
  23597. /** @hidden */
  23598. _unBindEffect(): void;
  23599. /**
  23600. * Gets a boolean indicating if this mesh has LOD
  23601. */
  23602. readonly hasLODLevels: boolean;
  23603. /**
  23604. * Gets the list of MeshLODLevel associated with the current mesh
  23605. * @returns an array of MeshLODLevel
  23606. */
  23607. getLODLevels(): MeshLODLevel[];
  23608. private _sortLODLevels;
  23609. /**
  23610. * Add a mesh as LOD level triggered at the given distance.
  23611. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23612. * @param distance The distance from the center of the object to show this level
  23613. * @param mesh The mesh to be added as LOD level (can be null)
  23614. * @return This mesh (for chaining)
  23615. */
  23616. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23617. /**
  23618. * Returns the LOD level mesh at the passed distance or null if not found.
  23619. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23620. * @param distance The distance from the center of the object to show this level
  23621. * @returns a Mesh or `null`
  23622. */
  23623. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23624. /**
  23625. * Remove a mesh from the LOD array
  23626. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23627. * @param mesh defines the mesh to be removed
  23628. * @return This mesh (for chaining)
  23629. */
  23630. removeLODLevel(mesh: Mesh): Mesh;
  23631. /**
  23632. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23633. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23634. * @param camera defines the camera to use to compute distance
  23635. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23636. * @return This mesh (for chaining)
  23637. */
  23638. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23639. /**
  23640. * Gets the mesh internal Geometry object
  23641. */
  23642. readonly geometry: Nullable<Geometry>;
  23643. /**
  23644. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23645. * @returns the total number of vertices
  23646. */
  23647. getTotalVertices(): number;
  23648. /**
  23649. * Returns the content of an associated vertex buffer
  23650. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23651. * - VertexBuffer.PositionKind
  23652. * - VertexBuffer.UVKind
  23653. * - VertexBuffer.UV2Kind
  23654. * - VertexBuffer.UV3Kind
  23655. * - VertexBuffer.UV4Kind
  23656. * - VertexBuffer.UV5Kind
  23657. * - VertexBuffer.UV6Kind
  23658. * - VertexBuffer.ColorKind
  23659. * - VertexBuffer.MatricesIndicesKind
  23660. * - VertexBuffer.MatricesIndicesExtraKind
  23661. * - VertexBuffer.MatricesWeightsKind
  23662. * - VertexBuffer.MatricesWeightsExtraKind
  23663. * @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
  23664. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23665. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23666. */
  23667. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23668. /**
  23669. * Returns the mesh VertexBuffer object from the requested `kind`
  23670. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23671. * - VertexBuffer.PositionKind
  23672. * - VertexBuffer.NormalKind
  23673. * - VertexBuffer.UVKind
  23674. * - VertexBuffer.UV2Kind
  23675. * - VertexBuffer.UV3Kind
  23676. * - VertexBuffer.UV4Kind
  23677. * - VertexBuffer.UV5Kind
  23678. * - VertexBuffer.UV6Kind
  23679. * - VertexBuffer.ColorKind
  23680. * - VertexBuffer.MatricesIndicesKind
  23681. * - VertexBuffer.MatricesIndicesExtraKind
  23682. * - VertexBuffer.MatricesWeightsKind
  23683. * - VertexBuffer.MatricesWeightsExtraKind
  23684. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23685. */
  23686. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23687. /**
  23688. * Tests if a specific vertex buffer is associated with this mesh
  23689. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23690. * - VertexBuffer.PositionKind
  23691. * - VertexBuffer.NormalKind
  23692. * - VertexBuffer.UVKind
  23693. * - VertexBuffer.UV2Kind
  23694. * - VertexBuffer.UV3Kind
  23695. * - VertexBuffer.UV4Kind
  23696. * - VertexBuffer.UV5Kind
  23697. * - VertexBuffer.UV6Kind
  23698. * - VertexBuffer.ColorKind
  23699. * - VertexBuffer.MatricesIndicesKind
  23700. * - VertexBuffer.MatricesIndicesExtraKind
  23701. * - VertexBuffer.MatricesWeightsKind
  23702. * - VertexBuffer.MatricesWeightsExtraKind
  23703. * @returns a boolean
  23704. */
  23705. isVerticesDataPresent(kind: string): boolean;
  23706. /**
  23707. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23708. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23709. * - VertexBuffer.PositionKind
  23710. * - VertexBuffer.UVKind
  23711. * - VertexBuffer.UV2Kind
  23712. * - VertexBuffer.UV3Kind
  23713. * - VertexBuffer.UV4Kind
  23714. * - VertexBuffer.UV5Kind
  23715. * - VertexBuffer.UV6Kind
  23716. * - VertexBuffer.ColorKind
  23717. * - VertexBuffer.MatricesIndicesKind
  23718. * - VertexBuffer.MatricesIndicesExtraKind
  23719. * - VertexBuffer.MatricesWeightsKind
  23720. * - VertexBuffer.MatricesWeightsExtraKind
  23721. * @returns a boolean
  23722. */
  23723. isVertexBufferUpdatable(kind: string): boolean;
  23724. /**
  23725. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23726. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23727. * - VertexBuffer.PositionKind
  23728. * - VertexBuffer.NormalKind
  23729. * - VertexBuffer.UVKind
  23730. * - VertexBuffer.UV2Kind
  23731. * - VertexBuffer.UV3Kind
  23732. * - VertexBuffer.UV4Kind
  23733. * - VertexBuffer.UV5Kind
  23734. * - VertexBuffer.UV6Kind
  23735. * - VertexBuffer.ColorKind
  23736. * - VertexBuffer.MatricesIndicesKind
  23737. * - VertexBuffer.MatricesIndicesExtraKind
  23738. * - VertexBuffer.MatricesWeightsKind
  23739. * - VertexBuffer.MatricesWeightsExtraKind
  23740. * @returns an array of strings
  23741. */
  23742. getVerticesDataKinds(): string[];
  23743. /**
  23744. * Returns a positive integer : the total number of indices in this mesh geometry.
  23745. * @returns the numner of indices or zero if the mesh has no geometry.
  23746. */
  23747. getTotalIndices(): number;
  23748. /**
  23749. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23750. * @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.
  23751. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23752. * @returns the indices array or an empty array if the mesh has no geometry
  23753. */
  23754. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23755. readonly isBlocked: boolean;
  23756. /**
  23757. * Determine if the current mesh is ready to be rendered
  23758. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23759. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23760. * @returns true if all associated assets are ready (material, textures, shaders)
  23761. */
  23762. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23763. /**
  23764. * 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.
  23765. */
  23766. readonly areNormalsFrozen: boolean;
  23767. /**
  23768. * 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.
  23769. * @returns the current mesh
  23770. */
  23771. freezeNormals(): Mesh;
  23772. /**
  23773. * 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
  23774. * @returns the current mesh
  23775. */
  23776. unfreezeNormals(): Mesh;
  23777. /**
  23778. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23779. */
  23780. overridenInstanceCount: number;
  23781. /** @hidden */
  23782. _preActivate(): Mesh;
  23783. /** @hidden */
  23784. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23785. /** @hidden */
  23786. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23787. /**
  23788. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23789. * This means the mesh underlying bounding box and sphere are recomputed.
  23790. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23791. * @returns the current mesh
  23792. */
  23793. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23794. /** @hidden */
  23795. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23796. /**
  23797. * This function will subdivide the mesh into multiple submeshes
  23798. * @param count defines the expected number of submeshes
  23799. */
  23800. subdivide(count: number): void;
  23801. /**
  23802. * Copy a FloatArray into a specific associated vertex buffer
  23803. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23804. * - VertexBuffer.PositionKind
  23805. * - VertexBuffer.UVKind
  23806. * - VertexBuffer.UV2Kind
  23807. * - VertexBuffer.UV3Kind
  23808. * - VertexBuffer.UV4Kind
  23809. * - VertexBuffer.UV5Kind
  23810. * - VertexBuffer.UV6Kind
  23811. * - VertexBuffer.ColorKind
  23812. * - VertexBuffer.MatricesIndicesKind
  23813. * - VertexBuffer.MatricesIndicesExtraKind
  23814. * - VertexBuffer.MatricesWeightsKind
  23815. * - VertexBuffer.MatricesWeightsExtraKind
  23816. * @param data defines the data source
  23817. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23818. * @param stride defines the data stride size (can be null)
  23819. * @returns the current mesh
  23820. */
  23821. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23822. /**
  23823. * Flags an associated vertex buffer as updatable
  23824. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23825. * - VertexBuffer.PositionKind
  23826. * - VertexBuffer.UVKind
  23827. * - VertexBuffer.UV2Kind
  23828. * - VertexBuffer.UV3Kind
  23829. * - VertexBuffer.UV4Kind
  23830. * - VertexBuffer.UV5Kind
  23831. * - VertexBuffer.UV6Kind
  23832. * - VertexBuffer.ColorKind
  23833. * - VertexBuffer.MatricesIndicesKind
  23834. * - VertexBuffer.MatricesIndicesExtraKind
  23835. * - VertexBuffer.MatricesWeightsKind
  23836. * - VertexBuffer.MatricesWeightsExtraKind
  23837. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23838. */
  23839. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23840. /**
  23841. * Sets the mesh global Vertex Buffer
  23842. * @param buffer defines the buffer to use
  23843. * @returns the current mesh
  23844. */
  23845. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23846. /**
  23847. * Update a specific associated vertex buffer
  23848. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23849. * - VertexBuffer.PositionKind
  23850. * - VertexBuffer.UVKind
  23851. * - VertexBuffer.UV2Kind
  23852. * - VertexBuffer.UV3Kind
  23853. * - VertexBuffer.UV4Kind
  23854. * - VertexBuffer.UV5Kind
  23855. * - VertexBuffer.UV6Kind
  23856. * - VertexBuffer.ColorKind
  23857. * - VertexBuffer.MatricesIndicesKind
  23858. * - VertexBuffer.MatricesIndicesExtraKind
  23859. * - VertexBuffer.MatricesWeightsKind
  23860. * - VertexBuffer.MatricesWeightsExtraKind
  23861. * @param data defines the data source
  23862. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23863. * @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)
  23864. * @returns the current mesh
  23865. */
  23866. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23867. /**
  23868. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23869. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23870. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23871. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23872. * @returns the current mesh
  23873. */
  23874. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23875. /**
  23876. * Creates a un-shared specific occurence of the geometry for the mesh.
  23877. * @returns the current mesh
  23878. */
  23879. makeGeometryUnique(): Mesh;
  23880. /**
  23881. * Set the index buffer of this mesh
  23882. * @param indices defines the source data
  23883. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23884. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23885. * @returns the current mesh
  23886. */
  23887. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23888. /**
  23889. * Update the current index buffer
  23890. * @param indices defines the source data
  23891. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23892. * @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)
  23893. * @returns the current mesh
  23894. */
  23895. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23896. /**
  23897. * Invert the geometry to move from a right handed system to a left handed one.
  23898. * @returns the current mesh
  23899. */
  23900. toLeftHanded(): Mesh;
  23901. /** @hidden */
  23902. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23903. /** @hidden */
  23904. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23905. /**
  23906. * Registers for this mesh a javascript function called just before the rendering process
  23907. * @param func defines the function to call before rendering this mesh
  23908. * @returns the current mesh
  23909. */
  23910. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23911. /**
  23912. * Disposes a previously registered javascript function called before the rendering
  23913. * @param func defines the function to remove
  23914. * @returns the current mesh
  23915. */
  23916. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23917. /**
  23918. * Registers for this mesh a javascript function called just after the rendering is complete
  23919. * @param func defines the function to call after rendering this mesh
  23920. * @returns the current mesh
  23921. */
  23922. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23923. /**
  23924. * Disposes a previously registered javascript function called after the rendering.
  23925. * @param func defines the function to remove
  23926. * @returns the current mesh
  23927. */
  23928. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23929. /** @hidden */
  23930. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23931. /** @hidden */
  23932. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23933. /** @hidden */
  23934. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23935. /** @hidden */
  23936. _rebuild(): void;
  23937. /** @hidden */
  23938. _freeze(): void;
  23939. /** @hidden */
  23940. _unFreeze(): void;
  23941. /**
  23942. * 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
  23943. * @param subMesh defines the subMesh to render
  23944. * @param enableAlphaMode defines if alpha mode can be changed
  23945. * @returns the current mesh
  23946. */
  23947. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23948. private _onBeforeDraw;
  23949. /**
  23950. * Renormalize the mesh and patch it up if there are no weights
  23951. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23952. * However in the case of zero weights then we set just a single influence to 1.
  23953. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23954. */
  23955. cleanMatrixWeights(): void;
  23956. private normalizeSkinFourWeights;
  23957. private normalizeSkinWeightsAndExtra;
  23958. /**
  23959. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23960. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23961. * the user know there was an issue with importing the mesh
  23962. * @returns a validation object with skinned, valid and report string
  23963. */
  23964. validateSkinning(): {
  23965. skinned: boolean;
  23966. valid: boolean;
  23967. report: string;
  23968. };
  23969. /** @hidden */
  23970. _checkDelayState(): Mesh;
  23971. private _queueLoad;
  23972. /**
  23973. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23974. * A mesh is in the frustum if its bounding box intersects the frustum
  23975. * @param frustumPlanes defines the frustum to test
  23976. * @returns true if the mesh is in the frustum planes
  23977. */
  23978. isInFrustum(frustumPlanes: Plane[]): boolean;
  23979. /**
  23980. * Sets the mesh material by the material or multiMaterial `id` property
  23981. * @param id is a string identifying the material or the multiMaterial
  23982. * @returns the current mesh
  23983. */
  23984. setMaterialByID(id: string): Mesh;
  23985. /**
  23986. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23987. * @returns an array of IAnimatable
  23988. */
  23989. getAnimatables(): IAnimatable[];
  23990. /**
  23991. * Modifies the mesh geometry according to the passed transformation matrix.
  23992. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23993. * The mesh normals are modified using the same transformation.
  23994. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23995. * @param transform defines the transform matrix to use
  23996. * @see http://doc.babylonjs.com/resources/baking_transformations
  23997. * @returns the current mesh
  23998. */
  23999. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24000. /**
  24001. * Modifies the mesh geometry according to its own current World Matrix.
  24002. * The mesh World Matrix is then reset.
  24003. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24004. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24005. * @see http://doc.babylonjs.com/resources/baking_transformations
  24006. * @returns the current mesh
  24007. */
  24008. bakeCurrentTransformIntoVertices(): Mesh;
  24009. /** @hidden */
  24010. readonly _positions: Nullable<Vector3[]>;
  24011. /** @hidden */
  24012. _resetPointsArrayCache(): Mesh;
  24013. /** @hidden */
  24014. _generatePointsArray(): boolean;
  24015. /**
  24016. * Returns a new Mesh object generated from the current mesh properties.
  24017. * This method must not get confused with createInstance()
  24018. * @param name is a string, the name given to the new mesh
  24019. * @param newParent can be any Node object (default `null`)
  24020. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24021. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24022. * @returns a new mesh
  24023. */
  24024. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24025. /**
  24026. * Releases resources associated with this mesh.
  24027. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24028. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24029. */
  24030. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24031. /**
  24032. * Modifies the mesh geometry according to a displacement map.
  24033. * 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.
  24034. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24035. * @param url is a string, the URL from the image file is to be downloaded.
  24036. * @param minHeight is the lower limit of the displacement.
  24037. * @param maxHeight is the upper limit of the displacement.
  24038. * @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.
  24039. * @param uvOffset is an optional vector2 used to offset UV.
  24040. * @param uvScale is an optional vector2 used to scale UV.
  24041. * @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.
  24042. * @returns the Mesh.
  24043. */
  24044. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24045. /**
  24046. * Modifies the mesh geometry according to a displacementMap buffer.
  24047. * 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.
  24048. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24049. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24050. * @param heightMapWidth is the width of the buffer image.
  24051. * @param heightMapHeight is the height of the buffer image.
  24052. * @param minHeight is the lower limit of the displacement.
  24053. * @param maxHeight is the upper limit of the displacement.
  24054. * @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.
  24055. * @param uvOffset is an optional vector2 used to offset UV.
  24056. * @param uvScale is an optional vector2 used to scale UV.
  24057. * @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.
  24058. * @returns the Mesh.
  24059. */
  24060. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24061. /**
  24062. * Modify the mesh to get a flat shading rendering.
  24063. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24064. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24065. * @returns current mesh
  24066. */
  24067. convertToFlatShadedMesh(): Mesh;
  24068. /**
  24069. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24070. * In other words, more vertices, no more indices and a single bigger VBO.
  24071. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24072. * @returns current mesh
  24073. */
  24074. convertToUnIndexedMesh(): Mesh;
  24075. /**
  24076. * Inverses facet orientations.
  24077. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24078. * @param flipNormals will also inverts the normals
  24079. * @returns current mesh
  24080. */
  24081. flipFaces(flipNormals?: boolean): Mesh;
  24082. /**
  24083. * Increase the number of facets and hence vertices in a mesh
  24084. * Vertex normals are interpolated from existing vertex normals
  24085. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24086. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24087. */
  24088. increaseVertices(numberPerEdge: number): void;
  24089. /**
  24090. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24091. * This will undo any application of covertToFlatShadedMesh
  24092. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24093. */
  24094. forceSharedVertices(): void;
  24095. /** @hidden */
  24096. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24097. /** @hidden */
  24098. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24099. /**
  24100. * Creates a new InstancedMesh object from the mesh model.
  24101. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24102. * @param name defines the name of the new instance
  24103. * @returns a new InstancedMesh
  24104. */
  24105. createInstance(name: string): InstancedMesh;
  24106. /**
  24107. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24108. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24109. * @returns the current mesh
  24110. */
  24111. synchronizeInstances(): Mesh;
  24112. /**
  24113. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24114. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24115. * This should be used together with the simplification to avoid disappearing triangles.
  24116. * @param successCallback an optional success callback to be called after the optimization finished.
  24117. * @returns the current mesh
  24118. */
  24119. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24120. /**
  24121. * Serialize current mesh
  24122. * @param serializationObject defines the object which will receive the serialization data
  24123. */
  24124. serialize(serializationObject: any): void;
  24125. /** @hidden */
  24126. _syncGeometryWithMorphTargetManager(): void;
  24127. /** @hidden */
  24128. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24129. /**
  24130. * Returns a new Mesh object parsed from the source provided.
  24131. * @param parsedMesh is the source
  24132. * @param scene defines the hosting scene
  24133. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24134. * @returns a new Mesh
  24135. */
  24136. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24137. /**
  24138. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24139. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24140. * @param name defines the name of the mesh to create
  24141. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24142. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24143. * @param closePath creates a seam between the first and the last points of each path of the path array
  24144. * @param offset is taken in account only if the `pathArray` is containing a single path
  24145. * @param scene defines the hosting scene
  24146. * @param updatable defines if the mesh must be flagged as updatable
  24147. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24148. * @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)
  24149. * @returns a new Mesh
  24150. */
  24151. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24152. /**
  24153. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24154. * @param name defines the name of the mesh to create
  24155. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24156. * @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
  24157. * @param scene defines the hosting scene
  24158. * @param updatable defines if the mesh must be flagged as updatable
  24159. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24160. * @returns a new Mesh
  24161. */
  24162. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24163. /**
  24164. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24165. * @param name defines the name of the mesh to create
  24166. * @param size sets the size (float) of each box side (default 1)
  24167. * @param scene defines the hosting scene
  24168. * @param updatable defines if the mesh must be flagged as updatable
  24169. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24170. * @returns a new Mesh
  24171. */
  24172. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24173. /**
  24174. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24175. * @param name defines the name of the mesh to create
  24176. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24177. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24178. * @param scene defines the hosting scene
  24179. * @param updatable defines if the mesh must be flagged as updatable
  24180. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24181. * @returns a new Mesh
  24182. */
  24183. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24184. /**
  24185. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24186. * @param name defines the name of the mesh to create
  24187. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24188. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24189. * @param scene defines the hosting scene
  24190. * @returns a new Mesh
  24191. */
  24192. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24193. /**
  24194. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24195. * @param name defines the name of the mesh to create
  24196. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24197. * @param diameterTop set the top cap diameter (floats, default 1)
  24198. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24199. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24200. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24201. * @param scene defines the hosting scene
  24202. * @param updatable defines if the mesh must be flagged as updatable
  24203. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24204. * @returns a new Mesh
  24205. */
  24206. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24207. /**
  24208. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24209. * @param name defines the name of the mesh to create
  24210. * @param diameter sets the diameter size (float) of the torus (default 1)
  24211. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24212. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24213. * @param scene defines the hosting scene
  24214. * @param updatable defines if the mesh must be flagged as updatable
  24215. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24216. * @returns a new Mesh
  24217. */
  24218. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24219. /**
  24220. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24221. * @param name defines the name of the mesh to create
  24222. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24223. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24224. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24225. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24226. * @param p the number of windings on X axis (positive integers, default 2)
  24227. * @param q the number of windings on Y axis (positive integers, default 3)
  24228. * @param scene defines the hosting scene
  24229. * @param updatable defines if the mesh must be flagged as updatable
  24230. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24231. * @returns a new Mesh
  24232. */
  24233. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24234. /**
  24235. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24236. * @param name defines the name of the mesh to create
  24237. * @param points is an array successive Vector3
  24238. * @param scene defines the hosting scene
  24239. * @param updatable defines if the mesh must be flagged as updatable
  24240. * @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).
  24241. * @returns a new Mesh
  24242. */
  24243. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24244. /**
  24245. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24246. * @param name defines the name of the mesh to create
  24247. * @param points is an array successive Vector3
  24248. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24249. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24250. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24251. * @param scene defines the hosting scene
  24252. * @param updatable defines if the mesh must be flagged as updatable
  24253. * @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)
  24254. * @returns a new Mesh
  24255. */
  24256. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24257. /**
  24258. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24259. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24260. * 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.
  24261. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24262. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24263. * Remember you can only change the shape positions, not their number when updating a polygon.
  24264. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24265. * @param name defines the name of the mesh to create
  24266. * @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
  24267. * @param scene defines the hosting scene
  24268. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24269. * @param updatable defines if the mesh must be flagged as updatable
  24270. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24271. * @param earcutInjection can be used to inject your own earcut reference
  24272. * @returns a new Mesh
  24273. */
  24274. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24275. /**
  24276. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24277. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24278. * @param name defines the name of the mesh to create
  24279. * @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
  24280. * @param depth defines the height of extrusion
  24281. * @param scene defines the hosting scene
  24282. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24283. * @param updatable defines if the mesh must be flagged as updatable
  24284. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24285. * @param earcutInjection can be used to inject your own earcut reference
  24286. * @returns a new Mesh
  24287. */
  24288. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24289. /**
  24290. * Creates an extruded shape mesh.
  24291. * 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
  24292. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24293. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24294. * @param name defines the name of the mesh to create
  24295. * @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
  24296. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24297. * @param scale is the value to scale the shape
  24298. * @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
  24299. * @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
  24300. * @param scene defines the hosting scene
  24301. * @param updatable defines if the mesh must be flagged as updatable
  24302. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24303. * @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)
  24304. * @returns a new Mesh
  24305. */
  24306. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24307. /**
  24308. * Creates an custom extruded shape mesh.
  24309. * The custom extrusion is a parametric shape.
  24310. * It has no predefined shape. Its final shape will depend on the input parameters.
  24311. * Please consider using the same method from the MeshBuilder class instead
  24312. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24313. * @param name defines the name of the mesh to create
  24314. * @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
  24315. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24316. * @param scaleFunction is a custom Javascript function called on each path point
  24317. * @param rotationFunction is a custom Javascript function called on each path point
  24318. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24319. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24320. * @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
  24321. * @param scene defines the hosting scene
  24322. * @param updatable defines if the mesh must be flagged as updatable
  24323. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24324. * @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)
  24325. * @returns a new Mesh
  24326. */
  24327. 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;
  24328. /**
  24329. * Creates lathe mesh.
  24330. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24331. * Please consider using the same method from the MeshBuilder class instead
  24332. * @param name defines the name of the mesh to create
  24333. * @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
  24334. * @param radius is the radius value of the lathe
  24335. * @param tessellation is the side number of the lathe.
  24336. * @param scene defines the hosting scene
  24337. * @param updatable defines if the mesh must be flagged as updatable
  24338. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24339. * @returns a new Mesh
  24340. */
  24341. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24342. /**
  24343. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24344. * @param name defines the name of the mesh to create
  24345. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24346. * @param scene defines the hosting scene
  24347. * @param updatable defines if the mesh must be flagged as updatable
  24348. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24349. * @returns a new Mesh
  24350. */
  24351. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24352. /**
  24353. * Creates a ground mesh.
  24354. * Please consider using the same method from the MeshBuilder class instead
  24355. * @param name defines the name of the mesh to create
  24356. * @param width set the width of the ground
  24357. * @param height set the height of the ground
  24358. * @param subdivisions sets the number of subdivisions per side
  24359. * @param scene defines the hosting scene
  24360. * @param updatable defines if the mesh must be flagged as updatable
  24361. * @returns a new Mesh
  24362. */
  24363. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24364. /**
  24365. * Creates a tiled ground mesh.
  24366. * Please consider using the same method from the MeshBuilder class instead
  24367. * @param name defines the name of the mesh to create
  24368. * @param xmin set the ground minimum X coordinate
  24369. * @param zmin set the ground minimum Y coordinate
  24370. * @param xmax set the ground maximum X coordinate
  24371. * @param zmax set the ground maximum Z coordinate
  24372. * @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
  24373. * @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
  24374. * @param scene defines the hosting scene
  24375. * @param updatable defines if the mesh must be flagged as updatable
  24376. * @returns a new Mesh
  24377. */
  24378. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24379. w: number;
  24380. h: number;
  24381. }, precision: {
  24382. w: number;
  24383. h: number;
  24384. }, scene: Scene, updatable?: boolean): Mesh;
  24385. /**
  24386. * Creates a ground mesh from a height map.
  24387. * Please consider using the same method from the MeshBuilder class instead
  24388. * @see http://doc.babylonjs.com/babylon101/height_map
  24389. * @param name defines the name of the mesh to create
  24390. * @param url sets the URL of the height map image resource
  24391. * @param width set the ground width size
  24392. * @param height set the ground height size
  24393. * @param subdivisions sets the number of subdivision per side
  24394. * @param minHeight is the minimum altitude on the ground
  24395. * @param maxHeight is the maximum altitude on the ground
  24396. * @param scene defines the hosting scene
  24397. * @param updatable defines if the mesh must be flagged as updatable
  24398. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24399. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24400. * @returns a new Mesh
  24401. */
  24402. 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;
  24403. /**
  24404. * Creates a tube mesh.
  24405. * The tube is a parametric shape.
  24406. * It has no predefined shape. Its final shape will depend on the input parameters.
  24407. * Please consider using the same method from the MeshBuilder class instead
  24408. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24409. * @param name defines the name of the mesh to create
  24410. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24411. * @param radius sets the tube radius size
  24412. * @param tessellation is the number of sides on the tubular surface
  24413. * @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
  24414. * @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
  24415. * @param scene defines the hosting scene
  24416. * @param updatable defines if the mesh must be flagged as updatable
  24417. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24418. * @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)
  24419. * @returns a new Mesh
  24420. */
  24421. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24422. (i: number, distance: number): number;
  24423. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24424. /**
  24425. * Creates a polyhedron mesh.
  24426. * Please consider using the same method from the MeshBuilder class instead.
  24427. * * 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
  24428. * * The parameter `size` (positive float, default 1) sets the polygon size
  24429. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24430. * * 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`
  24431. * * 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
  24432. * * 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)`)
  24433. * * 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
  24434. * * 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
  24435. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24436. * * 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
  24437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24438. * @param name defines the name of the mesh to create
  24439. * @param options defines the options used to create the mesh
  24440. * @param scene defines the hosting scene
  24441. * @returns a new Mesh
  24442. */
  24443. static CreatePolyhedron(name: string, options: {
  24444. type?: number;
  24445. size?: number;
  24446. sizeX?: number;
  24447. sizeY?: number;
  24448. sizeZ?: number;
  24449. custom?: any;
  24450. faceUV?: Vector4[];
  24451. faceColors?: Color4[];
  24452. updatable?: boolean;
  24453. sideOrientation?: number;
  24454. }, scene: Scene): Mesh;
  24455. /**
  24456. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24457. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24458. * * 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`)
  24459. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24460. * * 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
  24461. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24462. * * 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
  24463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24464. * @param name defines the name of the mesh
  24465. * @param options defines the options used to create the mesh
  24466. * @param scene defines the hosting scene
  24467. * @returns a new Mesh
  24468. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24469. */
  24470. static CreateIcoSphere(name: string, options: {
  24471. radius?: number;
  24472. flat?: boolean;
  24473. subdivisions?: number;
  24474. sideOrientation?: number;
  24475. updatable?: boolean;
  24476. }, scene: Scene): Mesh;
  24477. /**
  24478. * Creates a decal mesh.
  24479. * Please consider using the same method from the MeshBuilder class instead.
  24480. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24481. * @param name defines the name of the mesh
  24482. * @param sourceMesh defines the mesh receiving the decal
  24483. * @param position sets the position of the decal in world coordinates
  24484. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24485. * @param size sets the decal scaling
  24486. * @param angle sets the angle to rotate the decal
  24487. * @returns a new Mesh
  24488. */
  24489. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24490. /**
  24491. * Prepare internal position array for software CPU skinning
  24492. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24493. */
  24494. setPositionsForCPUSkinning(): Float32Array;
  24495. /**
  24496. * Prepare internal normal array for software CPU skinning
  24497. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24498. */
  24499. setNormalsForCPUSkinning(): Float32Array;
  24500. /**
  24501. * Updates the vertex buffer by applying transformation from the bones
  24502. * @param skeleton defines the skeleton to apply to current mesh
  24503. * @returns the current mesh
  24504. */
  24505. applySkeleton(skeleton: Skeleton): Mesh;
  24506. /**
  24507. * 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
  24508. * @param meshes defines the list of meshes to scan
  24509. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24510. */
  24511. static MinMax(meshes: AbstractMesh[]): {
  24512. min: Vector3;
  24513. max: Vector3;
  24514. };
  24515. /**
  24516. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24517. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24518. * @returns a vector3
  24519. */
  24520. static Center(meshesOrMinMaxVector: {
  24521. min: Vector3;
  24522. max: Vector3;
  24523. } | AbstractMesh[]): Vector3;
  24524. /**
  24525. * Merge the array of meshes into a single mesh for performance reasons.
  24526. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24527. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24528. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24529. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24530. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24531. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24532. * @returns a new mesh
  24533. */
  24534. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24535. /** @hidden */
  24536. addInstance(instance: InstancedMesh): void;
  24537. /** @hidden */
  24538. removeInstance(instance: InstancedMesh): void;
  24539. }
  24540. }
  24541. declare module BABYLON {
  24542. /**
  24543. * This is the base class of all the camera used in the application.
  24544. * @see http://doc.babylonjs.com/features/cameras
  24545. */
  24546. export class Camera extends Node {
  24547. /** @hidden */
  24548. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24549. /**
  24550. * This is the default projection mode used by the cameras.
  24551. * It helps recreating a feeling of perspective and better appreciate depth.
  24552. * This is the best way to simulate real life cameras.
  24553. */
  24554. static readonly PERSPECTIVE_CAMERA: number;
  24555. /**
  24556. * This helps creating camera with an orthographic mode.
  24557. * 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.
  24558. */
  24559. static readonly ORTHOGRAPHIC_CAMERA: number;
  24560. /**
  24561. * This is the default FOV mode for perspective cameras.
  24562. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24563. */
  24564. static readonly FOVMODE_VERTICAL_FIXED: number;
  24565. /**
  24566. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24567. */
  24568. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24569. /**
  24570. * This specifies ther is no need for a camera rig.
  24571. * Basically only one eye is rendered corresponding to the camera.
  24572. */
  24573. static readonly RIG_MODE_NONE: number;
  24574. /**
  24575. * Simulates a camera Rig with one blue eye and one red eye.
  24576. * This can be use with 3d blue and red glasses.
  24577. */
  24578. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24579. /**
  24580. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24581. */
  24582. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24583. /**
  24584. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24585. */
  24586. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24587. /**
  24588. * Defines that both eyes of the camera will be rendered over under each other.
  24589. */
  24590. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24591. /**
  24592. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24593. */
  24594. static readonly RIG_MODE_VR: number;
  24595. /**
  24596. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24597. */
  24598. static readonly RIG_MODE_WEBVR: number;
  24599. /**
  24600. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24601. */
  24602. static readonly RIG_MODE_CUSTOM: number;
  24603. /**
  24604. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24605. */
  24606. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24607. /**
  24608. * Define the input manager associated with the camera.
  24609. */
  24610. inputs: CameraInputsManager<Camera>;
  24611. /** @hidden */
  24612. _position: Vector3;
  24613. /**
  24614. * Define the current local position of the camera in the scene
  24615. */
  24616. position: Vector3;
  24617. /**
  24618. * The vector the camera should consider as up.
  24619. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24620. */
  24621. upVector: Vector3;
  24622. /**
  24623. * Define the current limit on the left side for an orthographic camera
  24624. * In scene unit
  24625. */
  24626. orthoLeft: Nullable<number>;
  24627. /**
  24628. * Define the current limit on the right side for an orthographic camera
  24629. * In scene unit
  24630. */
  24631. orthoRight: Nullable<number>;
  24632. /**
  24633. * Define the current limit on the bottom side for an orthographic camera
  24634. * In scene unit
  24635. */
  24636. orthoBottom: Nullable<number>;
  24637. /**
  24638. * Define the current limit on the top side for an orthographic camera
  24639. * In scene unit
  24640. */
  24641. orthoTop: Nullable<number>;
  24642. /**
  24643. * Field Of View is set in Radians. (default is 0.8)
  24644. */
  24645. fov: number;
  24646. /**
  24647. * Define the minimum distance the camera can see from.
  24648. * This is important to note that the depth buffer are not infinite and the closer it starts
  24649. * the more your scene might encounter depth fighting issue.
  24650. */
  24651. minZ: number;
  24652. /**
  24653. * Define the maximum distance the camera can see to.
  24654. * This is important to note that the depth buffer are not infinite and the further it end
  24655. * the more your scene might encounter depth fighting issue.
  24656. */
  24657. maxZ: number;
  24658. /**
  24659. * Define the default inertia of the camera.
  24660. * This helps giving a smooth feeling to the camera movement.
  24661. */
  24662. inertia: number;
  24663. /**
  24664. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24665. */
  24666. mode: number;
  24667. /**
  24668. * Define wether the camera is intermediate.
  24669. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24670. */
  24671. isIntermediate: boolean;
  24672. /**
  24673. * Define the viewport of the camera.
  24674. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24675. */
  24676. viewport: Viewport;
  24677. /**
  24678. * Restricts the camera to viewing objects with the same layerMask.
  24679. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24680. */
  24681. layerMask: number;
  24682. /**
  24683. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24684. */
  24685. fovMode: number;
  24686. /**
  24687. * Rig mode of the camera.
  24688. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24689. * This is normally controlled byt the camera themselves as internal use.
  24690. */
  24691. cameraRigMode: number;
  24692. /**
  24693. * Defines the distance between both "eyes" in case of a RIG
  24694. */
  24695. interaxialDistance: number;
  24696. /**
  24697. * Defines if stereoscopic rendering is done side by side or over under.
  24698. */
  24699. isStereoscopicSideBySide: boolean;
  24700. /**
  24701. * 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
  24702. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24703. * else in the scene. (Eg. security camera)
  24704. *
  24705. * 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)
  24706. */
  24707. customRenderTargets: RenderTargetTexture[];
  24708. /**
  24709. * When set, the camera will render to this render target instead of the default canvas
  24710. *
  24711. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24712. */
  24713. outputRenderTarget: Nullable<RenderTargetTexture>;
  24714. /**
  24715. * Observable triggered when the camera view matrix has changed.
  24716. */
  24717. onViewMatrixChangedObservable: Observable<Camera>;
  24718. /**
  24719. * Observable triggered when the camera Projection matrix has changed.
  24720. */
  24721. onProjectionMatrixChangedObservable: Observable<Camera>;
  24722. /**
  24723. * Observable triggered when the inputs have been processed.
  24724. */
  24725. onAfterCheckInputsObservable: Observable<Camera>;
  24726. /**
  24727. * Observable triggered when reset has been called and applied to the camera.
  24728. */
  24729. onRestoreStateObservable: Observable<Camera>;
  24730. /** @hidden */
  24731. _cameraRigParams: any;
  24732. /** @hidden */
  24733. _rigCameras: Camera[];
  24734. /** @hidden */
  24735. _rigPostProcess: Nullable<PostProcess>;
  24736. protected _webvrViewMatrix: Matrix;
  24737. /** @hidden */
  24738. _skipRendering: boolean;
  24739. /** @hidden */
  24740. _projectionMatrix: Matrix;
  24741. /** @hidden */
  24742. _postProcesses: Nullable<PostProcess>[];
  24743. /** @hidden */
  24744. _activeMeshes: SmartArray<AbstractMesh>;
  24745. protected _globalPosition: Vector3;
  24746. /** @hidden */
  24747. _computedViewMatrix: Matrix;
  24748. private _doNotComputeProjectionMatrix;
  24749. private _transformMatrix;
  24750. private _frustumPlanes;
  24751. private _refreshFrustumPlanes;
  24752. private _storedFov;
  24753. private _stateStored;
  24754. /**
  24755. * Instantiates a new camera object.
  24756. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24757. * @see http://doc.babylonjs.com/features/cameras
  24758. * @param name Defines the name of the camera in the scene
  24759. * @param position Defines the position of the camera
  24760. * @param scene Defines the scene the camera belongs too
  24761. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24762. */
  24763. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24764. /**
  24765. * Store current camera state (fov, position, etc..)
  24766. * @returns the camera
  24767. */
  24768. storeState(): Camera;
  24769. /**
  24770. * Restores the camera state values if it has been stored. You must call storeState() first
  24771. */
  24772. protected _restoreStateValues(): boolean;
  24773. /**
  24774. * Restored camera state. You must call storeState() first.
  24775. * @returns true if restored and false otherwise
  24776. */
  24777. restoreState(): boolean;
  24778. /**
  24779. * Gets the class name of the camera.
  24780. * @returns the class name
  24781. */
  24782. getClassName(): string;
  24783. /** @hidden */
  24784. readonly _isCamera: boolean;
  24785. /**
  24786. * Gets a string representation of the camera useful for debug purpose.
  24787. * @param fullDetails Defines that a more verboe level of logging is required
  24788. * @returns the string representation
  24789. */
  24790. toString(fullDetails?: boolean): string;
  24791. /**
  24792. * Gets the current world space position of the camera.
  24793. */
  24794. readonly globalPosition: Vector3;
  24795. /**
  24796. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24797. * @returns the active meshe list
  24798. */
  24799. getActiveMeshes(): SmartArray<AbstractMesh>;
  24800. /**
  24801. * Check wether a mesh is part of the current active mesh list of the camera
  24802. * @param mesh Defines the mesh to check
  24803. * @returns true if active, false otherwise
  24804. */
  24805. isActiveMesh(mesh: Mesh): boolean;
  24806. /**
  24807. * Is this camera ready to be used/rendered
  24808. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24809. * @return true if the camera is ready
  24810. */
  24811. isReady(completeCheck?: boolean): boolean;
  24812. /** @hidden */
  24813. _initCache(): void;
  24814. /** @hidden */
  24815. _updateCache(ignoreParentClass?: boolean): void;
  24816. /** @hidden */
  24817. _isSynchronized(): boolean;
  24818. /** @hidden */
  24819. _isSynchronizedViewMatrix(): boolean;
  24820. /** @hidden */
  24821. _isSynchronizedProjectionMatrix(): boolean;
  24822. /**
  24823. * Attach the input controls to a specific dom element to get the input from.
  24824. * @param element Defines the element the controls should be listened from
  24825. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24826. */
  24827. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24828. /**
  24829. * Detach the current controls from the specified dom element.
  24830. * @param element Defines the element to stop listening the inputs from
  24831. */
  24832. detachControl(element: HTMLElement): void;
  24833. /**
  24834. * Update the camera state according to the different inputs gathered during the frame.
  24835. */
  24836. update(): void;
  24837. /** @hidden */
  24838. _checkInputs(): void;
  24839. /** @hidden */
  24840. readonly rigCameras: Camera[];
  24841. /**
  24842. * Gets the post process used by the rig cameras
  24843. */
  24844. readonly rigPostProcess: Nullable<PostProcess>;
  24845. /**
  24846. * Internal, gets the first post proces.
  24847. * @returns the first post process to be run on this camera.
  24848. */
  24849. _getFirstPostProcess(): Nullable<PostProcess>;
  24850. private _cascadePostProcessesToRigCams;
  24851. /**
  24852. * Attach a post process to the camera.
  24853. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24854. * @param postProcess The post process to attach to the camera
  24855. * @param insertAt The position of the post process in case several of them are in use in the scene
  24856. * @returns the position the post process has been inserted at
  24857. */
  24858. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24859. /**
  24860. * Detach a post process to the camera.
  24861. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24862. * @param postProcess The post process to detach from the camera
  24863. */
  24864. detachPostProcess(postProcess: PostProcess): void;
  24865. /**
  24866. * Gets the current world matrix of the camera
  24867. */
  24868. getWorldMatrix(): Matrix;
  24869. /** @hidden */
  24870. _getViewMatrix(): Matrix;
  24871. /**
  24872. * Gets the current view matrix of the camera.
  24873. * @param force forces the camera to recompute the matrix without looking at the cached state
  24874. * @returns the view matrix
  24875. */
  24876. getViewMatrix(force?: boolean): Matrix;
  24877. /**
  24878. * Freeze the projection matrix.
  24879. * It will prevent the cache check of the camera projection compute and can speed up perf
  24880. * if no parameter of the camera are meant to change
  24881. * @param projection Defines manually a projection if necessary
  24882. */
  24883. freezeProjectionMatrix(projection?: Matrix): void;
  24884. /**
  24885. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24886. */
  24887. unfreezeProjectionMatrix(): void;
  24888. /**
  24889. * Gets the current projection matrix of the camera.
  24890. * @param force forces the camera to recompute the matrix without looking at the cached state
  24891. * @returns the projection matrix
  24892. */
  24893. getProjectionMatrix(force?: boolean): Matrix;
  24894. /**
  24895. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24896. * @returns a Matrix
  24897. */
  24898. getTransformationMatrix(): Matrix;
  24899. private _updateFrustumPlanes;
  24900. /**
  24901. * Checks if a cullable object (mesh...) is in the camera frustum
  24902. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24903. * @param target The object to check
  24904. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24905. * @returns true if the object is in frustum otherwise false
  24906. */
  24907. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24908. /**
  24909. * Checks if a cullable object (mesh...) is in the camera frustum
  24910. * Unlike isInFrustum this cheks the full bounding box
  24911. * @param target The object to check
  24912. * @returns true if the object is in frustum otherwise false
  24913. */
  24914. isCompletelyInFrustum(target: ICullable): boolean;
  24915. /**
  24916. * Gets a ray in the forward direction from the camera.
  24917. * @param length Defines the length of the ray to create
  24918. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24919. * @param origin Defines the start point of the ray which defaults to the camera position
  24920. * @returns the forward ray
  24921. */
  24922. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24923. /**
  24924. * Releases resources associated with this node.
  24925. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24926. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24927. */
  24928. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24929. /** @hidden */
  24930. _isLeftCamera: boolean;
  24931. /**
  24932. * Gets the left camera of a rig setup in case of Rigged Camera
  24933. */
  24934. readonly isLeftCamera: boolean;
  24935. /** @hidden */
  24936. _isRightCamera: boolean;
  24937. /**
  24938. * Gets the right camera of a rig setup in case of Rigged Camera
  24939. */
  24940. readonly isRightCamera: boolean;
  24941. /**
  24942. * Gets the left camera of a rig setup in case of Rigged Camera
  24943. */
  24944. readonly leftCamera: Nullable<FreeCamera>;
  24945. /**
  24946. * Gets the right camera of a rig setup in case of Rigged Camera
  24947. */
  24948. readonly rightCamera: Nullable<FreeCamera>;
  24949. /**
  24950. * Gets the left camera target of a rig setup in case of Rigged Camera
  24951. * @returns the target position
  24952. */
  24953. getLeftTarget(): Nullable<Vector3>;
  24954. /**
  24955. * Gets the right camera target of a rig setup in case of Rigged Camera
  24956. * @returns the target position
  24957. */
  24958. getRightTarget(): Nullable<Vector3>;
  24959. /**
  24960. * @hidden
  24961. */
  24962. setCameraRigMode(mode: number, rigParams: any): void;
  24963. /** @hidden */
  24964. static _setStereoscopicRigMode(camera: Camera): void;
  24965. /** @hidden */
  24966. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24967. /** @hidden */
  24968. static _setVRRigMode(camera: Camera, rigParams: any): void;
  24969. /** @hidden */
  24970. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24971. /** @hidden */
  24972. _getVRProjectionMatrix(): Matrix;
  24973. protected _updateCameraRotationMatrix(): void;
  24974. protected _updateWebVRCameraRotationMatrix(): void;
  24975. /**
  24976. * This function MUST be overwritten by the different WebVR cameras available.
  24977. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24978. * @hidden
  24979. */
  24980. _getWebVRProjectionMatrix(): Matrix;
  24981. /**
  24982. * This function MUST be overwritten by the different WebVR cameras available.
  24983. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24984. * @hidden
  24985. */
  24986. _getWebVRViewMatrix(): Matrix;
  24987. /** @hidden */
  24988. setCameraRigParameter(name: string, value: any): void;
  24989. /**
  24990. * needs to be overridden by children so sub has required properties to be copied
  24991. * @hidden
  24992. */
  24993. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24994. /**
  24995. * May need to be overridden by children
  24996. * @hidden
  24997. */
  24998. _updateRigCameras(): void;
  24999. /** @hidden */
  25000. _setupInputs(): void;
  25001. /**
  25002. * Serialiaze the camera setup to a json represention
  25003. * @returns the JSON representation
  25004. */
  25005. serialize(): any;
  25006. /**
  25007. * Clones the current camera.
  25008. * @param name The cloned camera name
  25009. * @returns the cloned camera
  25010. */
  25011. clone(name: string): Camera;
  25012. /**
  25013. * Gets the direction of the camera relative to a given local axis.
  25014. * @param localAxis Defines the reference axis to provide a relative direction.
  25015. * @return the direction
  25016. */
  25017. getDirection(localAxis: Vector3): Vector3;
  25018. /**
  25019. * Returns the current camera absolute rotation
  25020. */
  25021. readonly absoluteRotation: Quaternion;
  25022. /**
  25023. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25024. * @param localAxis Defines the reference axis to provide a relative direction.
  25025. * @param result Defines the vector to store the result in
  25026. */
  25027. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25028. /**
  25029. * Gets a camera constructor for a given camera type
  25030. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25031. * @param name The name of the camera the result will be able to instantiate
  25032. * @param scene The scene the result will construct the camera in
  25033. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25034. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25035. * @returns a factory method to construc the camera
  25036. */
  25037. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25038. /**
  25039. * Compute the world matrix of the camera.
  25040. * @returns the camera workd matrix
  25041. */
  25042. computeWorldMatrix(): Matrix;
  25043. /**
  25044. * Parse a JSON and creates the camera from the parsed information
  25045. * @param parsedCamera The JSON to parse
  25046. * @param scene The scene to instantiate the camera in
  25047. * @returns the newly constructed camera
  25048. */
  25049. static Parse(parsedCamera: any, scene: Scene): Camera;
  25050. }
  25051. }
  25052. declare module BABYLON {
  25053. /**
  25054. * Class containing static functions to help procedurally build meshes
  25055. */
  25056. export class DiscBuilder {
  25057. /**
  25058. * Creates a plane polygonal mesh. By default, this is a disc
  25059. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25060. * * 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
  25061. * * 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
  25062. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25063. * * 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
  25064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25065. * @param name defines the name of the mesh
  25066. * @param options defines the options used to create the mesh
  25067. * @param scene defines the hosting scene
  25068. * @returns the plane polygonal mesh
  25069. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25070. */
  25071. static CreateDisc(name: string, options: {
  25072. radius?: number;
  25073. tessellation?: number;
  25074. arc?: number;
  25075. updatable?: boolean;
  25076. sideOrientation?: number;
  25077. frontUVs?: Vector4;
  25078. backUVs?: Vector4;
  25079. }, scene?: Nullable<Scene>): Mesh;
  25080. }
  25081. }
  25082. declare module BABYLON {
  25083. /**
  25084. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25085. *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.
  25086. * The SPS is also a particle system. It provides some methods to manage the particles.
  25087. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25088. *
  25089. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25090. */
  25091. export class SolidParticleSystem implements IDisposable {
  25092. /**
  25093. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25094. * Example : var p = SPS.particles[i];
  25095. */
  25096. particles: SolidParticle[];
  25097. /**
  25098. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25099. */
  25100. nbParticles: number;
  25101. /**
  25102. * If the particles must ever face the camera (default false). Useful for planar particles.
  25103. */
  25104. billboard: boolean;
  25105. /**
  25106. * Recompute normals when adding a shape
  25107. */
  25108. recomputeNormals: boolean;
  25109. /**
  25110. * This a counter ofr your own usage. It's not set by any SPS functions.
  25111. */
  25112. counter: number;
  25113. /**
  25114. * The SPS name. This name is also given to the underlying mesh.
  25115. */
  25116. name: string;
  25117. /**
  25118. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25119. */
  25120. mesh: Mesh;
  25121. /**
  25122. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25123. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25124. */
  25125. vars: any;
  25126. /**
  25127. * This array is populated when the SPS is set as 'pickable'.
  25128. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25129. * Each element of this array is an object `{idx: int, faceId: int}`.
  25130. * `idx` is the picked particle index in the `SPS.particles` array
  25131. * `faceId` is the picked face index counted within this particle.
  25132. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25133. */
  25134. pickedParticles: {
  25135. idx: number;
  25136. faceId: number;
  25137. }[];
  25138. /**
  25139. * This array is populated when `enableDepthSort` is set to true.
  25140. * Each element of this array is an instance of the class DepthSortedParticle.
  25141. */
  25142. depthSortedParticles: DepthSortedParticle[];
  25143. /**
  25144. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25145. * @hidden
  25146. */
  25147. _bSphereOnly: boolean;
  25148. /**
  25149. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25150. * @hidden
  25151. */
  25152. _bSphereRadiusFactor: number;
  25153. private _scene;
  25154. private _positions;
  25155. private _indices;
  25156. private _normals;
  25157. private _colors;
  25158. private _uvs;
  25159. private _indices32;
  25160. private _positions32;
  25161. private _normals32;
  25162. private _fixedNormal32;
  25163. private _colors32;
  25164. private _uvs32;
  25165. private _index;
  25166. private _updatable;
  25167. private _pickable;
  25168. private _isVisibilityBoxLocked;
  25169. private _alwaysVisible;
  25170. private _depthSort;
  25171. private _shapeCounter;
  25172. private _copy;
  25173. private _color;
  25174. private _computeParticleColor;
  25175. private _computeParticleTexture;
  25176. private _computeParticleRotation;
  25177. private _computeParticleVertex;
  25178. private _computeBoundingBox;
  25179. private _depthSortParticles;
  25180. private _camera;
  25181. private _mustUnrotateFixedNormals;
  25182. private _particlesIntersect;
  25183. private _needs32Bits;
  25184. /**
  25185. * Creates a SPS (Solid Particle System) object.
  25186. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25187. * @param scene (Scene) is the scene in which the SPS is added.
  25188. * @param options defines the options of the sps e.g.
  25189. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25190. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25191. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25192. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25193. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25194. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25195. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25196. */
  25197. constructor(name: string, scene: Scene, options?: {
  25198. updatable?: boolean;
  25199. isPickable?: boolean;
  25200. enableDepthSort?: boolean;
  25201. particleIntersection?: boolean;
  25202. boundingSphereOnly?: boolean;
  25203. bSphereRadiusFactor?: number;
  25204. });
  25205. /**
  25206. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25207. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25208. * @returns the created mesh
  25209. */
  25210. buildMesh(): Mesh;
  25211. /**
  25212. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25213. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25214. * Thus the particles generated from `digest()` have their property `position` set yet.
  25215. * @param mesh ( Mesh ) is the mesh to be digested
  25216. * @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
  25217. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25218. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25219. * @returns the current SPS
  25220. */
  25221. digest(mesh: Mesh, options?: {
  25222. facetNb?: number;
  25223. number?: number;
  25224. delta?: number;
  25225. }): SolidParticleSystem;
  25226. private _unrotateFixedNormals;
  25227. private _resetCopy;
  25228. private _meshBuilder;
  25229. private _posToShape;
  25230. private _uvsToShapeUV;
  25231. private _addParticle;
  25232. /**
  25233. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25234. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25235. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25236. * @param nb (positive integer) the number of particles to be created from this model
  25237. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25238. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25239. * @returns the number of shapes in the system
  25240. */
  25241. addShape(mesh: Mesh, nb: number, options?: {
  25242. positionFunction?: any;
  25243. vertexFunction?: any;
  25244. }): number;
  25245. private _rebuildParticle;
  25246. /**
  25247. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25248. * @returns the SPS.
  25249. */
  25250. rebuildMesh(): SolidParticleSystem;
  25251. /**
  25252. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25253. * This method calls `updateParticle()` for each particle of the SPS.
  25254. * For an animated SPS, it is usually called within the render loop.
  25255. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25256. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25257. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25258. * @returns the SPS.
  25259. */
  25260. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25261. /**
  25262. * Disposes the SPS.
  25263. */
  25264. dispose(): void;
  25265. /**
  25266. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25267. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25268. * @returns the SPS.
  25269. */
  25270. refreshVisibleSize(): SolidParticleSystem;
  25271. /**
  25272. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25273. * @param size the size (float) of the visibility box
  25274. * note : this doesn't lock the SPS mesh bounding box.
  25275. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25276. */
  25277. setVisibilityBox(size: number): void;
  25278. /**
  25279. * Gets whether the SPS as always visible or not
  25280. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25281. */
  25282. /**
  25283. * Sets the SPS as always visible or not
  25284. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25285. */
  25286. isAlwaysVisible: boolean;
  25287. /**
  25288. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25289. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25290. */
  25291. /**
  25292. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25293. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25294. */
  25295. isVisibilityBoxLocked: boolean;
  25296. /**
  25297. * Tells to `setParticles()` to compute the particle rotations or not.
  25298. * Default value : true. The SPS is faster when it's set to false.
  25299. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25300. */
  25301. /**
  25302. * Gets if `setParticles()` computes the particle rotations or not.
  25303. * Default value : true. The SPS is faster when it's set to false.
  25304. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25305. */
  25306. computeParticleRotation: boolean;
  25307. /**
  25308. * Tells to `setParticles()` to compute the particle colors or not.
  25309. * Default value : true. The SPS is faster when it's set to false.
  25310. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25311. */
  25312. /**
  25313. * Gets if `setParticles()` computes the particle colors or not.
  25314. * Default value : true. The SPS is faster when it's set to false.
  25315. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25316. */
  25317. computeParticleColor: boolean;
  25318. /**
  25319. * Gets if `setParticles()` computes the particle textures or not.
  25320. * Default value : true. The SPS is faster when it's set to false.
  25321. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25322. */
  25323. computeParticleTexture: boolean;
  25324. /**
  25325. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25326. * Default value : false. The SPS is faster when it's set to false.
  25327. * Note : the particle custom vertex positions aren't stored values.
  25328. */
  25329. /**
  25330. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25331. * Default value : false. The SPS is faster when it's set to false.
  25332. * Note : the particle custom vertex positions aren't stored values.
  25333. */
  25334. computeParticleVertex: boolean;
  25335. /**
  25336. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25337. */
  25338. /**
  25339. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25340. */
  25341. computeBoundingBox: boolean;
  25342. /**
  25343. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25344. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25345. * Default : `true`
  25346. */
  25347. /**
  25348. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25349. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25350. * Default : `true`
  25351. */
  25352. depthSortParticles: boolean;
  25353. /**
  25354. * This function does nothing. It may be overwritten to set all the particle first values.
  25355. * The SPS doesn't call this function, you may have to call it by your own.
  25356. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25357. */
  25358. initParticles(): void;
  25359. /**
  25360. * This function does nothing. It may be overwritten to recycle a particle.
  25361. * The SPS doesn't call this function, you may have to call it by your own.
  25362. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25363. * @param particle The particle to recycle
  25364. * @returns the recycled particle
  25365. */
  25366. recycleParticle(particle: SolidParticle): SolidParticle;
  25367. /**
  25368. * Updates a particle : this function should be overwritten by the user.
  25369. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25370. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25371. * @example : just set a particle position or velocity and recycle conditions
  25372. * @param particle The particle to update
  25373. * @returns the updated particle
  25374. */
  25375. updateParticle(particle: SolidParticle): SolidParticle;
  25376. /**
  25377. * Updates a vertex of a particle : it can be overwritten by the user.
  25378. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25379. * @param particle the current particle
  25380. * @param vertex the current index of the current particle
  25381. * @param pt the index of the current vertex in the particle shape
  25382. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25383. * @example : just set a vertex particle position
  25384. * @returns the updated vertex
  25385. */
  25386. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25387. /**
  25388. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25389. * This does nothing and may be overwritten by the user.
  25390. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25391. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25392. * @param update the boolean update value actually passed to setParticles()
  25393. */
  25394. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25395. /**
  25396. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25397. * This will be passed three parameters.
  25398. * This does nothing and may be overwritten by the user.
  25399. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25400. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25401. * @param update the boolean update value actually passed to setParticles()
  25402. */
  25403. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25404. }
  25405. }
  25406. declare module BABYLON {
  25407. /**
  25408. * Represents one particle of a solid particle system.
  25409. */
  25410. export class SolidParticle {
  25411. /**
  25412. * particle global index
  25413. */
  25414. idx: number;
  25415. /**
  25416. * The color of the particle
  25417. */
  25418. color: Nullable<Color4>;
  25419. /**
  25420. * The world space position of the particle.
  25421. */
  25422. position: Vector3;
  25423. /**
  25424. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25425. */
  25426. rotation: Vector3;
  25427. /**
  25428. * The world space rotation quaternion of the particle.
  25429. */
  25430. rotationQuaternion: Nullable<Quaternion>;
  25431. /**
  25432. * The scaling of the particle.
  25433. */
  25434. scaling: Vector3;
  25435. /**
  25436. * The uvs of the particle.
  25437. */
  25438. uvs: Vector4;
  25439. /**
  25440. * The current speed of the particle.
  25441. */
  25442. velocity: Vector3;
  25443. /**
  25444. * The pivot point in the particle local space.
  25445. */
  25446. pivot: Vector3;
  25447. /**
  25448. * Must the particle be translated from its pivot point in its local space ?
  25449. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25450. * Default : false
  25451. */
  25452. translateFromPivot: boolean;
  25453. /**
  25454. * Is the particle active or not ?
  25455. */
  25456. alive: boolean;
  25457. /**
  25458. * Is the particle visible or not ?
  25459. */
  25460. isVisible: boolean;
  25461. /**
  25462. * Index of this particle in the global "positions" array (Internal use)
  25463. * @hidden
  25464. */
  25465. _pos: number;
  25466. /**
  25467. * @hidden Index of this particle in the global "indices" array (Internal use)
  25468. */
  25469. _ind: number;
  25470. /**
  25471. * @hidden ModelShape of this particle (Internal use)
  25472. */
  25473. _model: ModelShape;
  25474. /**
  25475. * ModelShape id of this particle
  25476. */
  25477. shapeId: number;
  25478. /**
  25479. * Index of the particle in its shape id
  25480. */
  25481. idxInShape: number;
  25482. /**
  25483. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25484. */
  25485. _modelBoundingInfo: BoundingInfo;
  25486. /**
  25487. * @hidden Particle BoundingInfo object (Internal use)
  25488. */
  25489. _boundingInfo: BoundingInfo;
  25490. /**
  25491. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25492. */
  25493. _sps: SolidParticleSystem;
  25494. /**
  25495. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25496. */
  25497. _stillInvisible: boolean;
  25498. /**
  25499. * @hidden Last computed particle rotation matrix
  25500. */
  25501. _rotationMatrix: number[];
  25502. /**
  25503. * Parent particle Id, if any.
  25504. * Default null.
  25505. */
  25506. parentId: Nullable<number>;
  25507. /**
  25508. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25509. * The possible values are :
  25510. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25511. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25512. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25513. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25514. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25515. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25516. * */
  25517. cullingStrategy: number;
  25518. /**
  25519. * @hidden Internal global position in the SPS.
  25520. */
  25521. _globalPosition: Vector3;
  25522. /**
  25523. * Creates a Solid Particle object.
  25524. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25525. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25526. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25527. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25528. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25529. * @param shapeId (integer) is the model shape identifier in the SPS.
  25530. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25531. * @param sps defines the sps it is associated to
  25532. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25533. */
  25534. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25535. /**
  25536. * Legacy support, changed scale to scaling
  25537. */
  25538. /**
  25539. * Legacy support, changed scale to scaling
  25540. */
  25541. scale: Vector3;
  25542. /**
  25543. * Legacy support, changed quaternion to rotationQuaternion
  25544. */
  25545. /**
  25546. * Legacy support, changed quaternion to rotationQuaternion
  25547. */
  25548. quaternion: Nullable<Quaternion>;
  25549. /**
  25550. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25551. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25552. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25553. * @returns true if it intersects
  25554. */
  25555. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25556. /**
  25557. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25558. * A particle is in the frustum if its bounding box intersects the frustum
  25559. * @param frustumPlanes defines the frustum to test
  25560. * @returns true if the particle is in the frustum planes
  25561. */
  25562. isInFrustum(frustumPlanes: Plane[]): boolean;
  25563. /**
  25564. * get the rotation matrix of the particle
  25565. * @hidden
  25566. */
  25567. getRotationMatrix(m: Matrix): void;
  25568. }
  25569. /**
  25570. * Represents the shape of the model used by one particle of a solid particle system.
  25571. * SPS internal tool, don't use it manually.
  25572. */
  25573. export class ModelShape {
  25574. /**
  25575. * The shape id
  25576. * @hidden
  25577. */
  25578. shapeID: number;
  25579. /**
  25580. * flat array of model positions (internal use)
  25581. * @hidden
  25582. */
  25583. _shape: Vector3[];
  25584. /**
  25585. * flat array of model UVs (internal use)
  25586. * @hidden
  25587. */
  25588. _shapeUV: number[];
  25589. /**
  25590. * length of the shape in the model indices array (internal use)
  25591. * @hidden
  25592. */
  25593. _indicesLength: number;
  25594. /**
  25595. * Custom position function (internal use)
  25596. * @hidden
  25597. */
  25598. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25599. /**
  25600. * Custom vertex function (internal use)
  25601. * @hidden
  25602. */
  25603. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25604. /**
  25605. * 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.
  25606. * SPS internal tool, don't use it manually.
  25607. * @hidden
  25608. */
  25609. 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>);
  25610. }
  25611. /**
  25612. * Represents a Depth Sorted Particle in the solid particle system.
  25613. */
  25614. export class DepthSortedParticle {
  25615. /**
  25616. * Index of the particle in the "indices" array
  25617. */
  25618. ind: number;
  25619. /**
  25620. * Length of the particle shape in the "indices" array
  25621. */
  25622. indicesLength: number;
  25623. /**
  25624. * Squared distance from the particle to the camera
  25625. */
  25626. sqDistance: number;
  25627. }
  25628. }
  25629. declare module BABYLON {
  25630. /**
  25631. * @hidden
  25632. */
  25633. export class _MeshCollisionData {
  25634. _checkCollisions: boolean;
  25635. _collisionMask: number;
  25636. _collisionGroup: number;
  25637. _collider: Nullable<Collider>;
  25638. _oldPositionForCollisions: Vector3;
  25639. _diffPositionForCollisions: Vector3;
  25640. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25641. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25642. }
  25643. }
  25644. declare module BABYLON {
  25645. /** @hidden */
  25646. class _FacetDataStorage {
  25647. facetPositions: Vector3[];
  25648. facetNormals: Vector3[];
  25649. facetPartitioning: number[][];
  25650. facetNb: number;
  25651. partitioningSubdivisions: number;
  25652. partitioningBBoxRatio: number;
  25653. facetDataEnabled: boolean;
  25654. facetParameters: any;
  25655. bbSize: Vector3;
  25656. subDiv: {
  25657. max: number;
  25658. X: number;
  25659. Y: number;
  25660. Z: number;
  25661. };
  25662. facetDepthSort: boolean;
  25663. facetDepthSortEnabled: boolean;
  25664. depthSortedIndices: IndicesArray;
  25665. depthSortedFacets: {
  25666. ind: number;
  25667. sqDistance: number;
  25668. }[];
  25669. facetDepthSortFunction: (f1: {
  25670. ind: number;
  25671. sqDistance: number;
  25672. }, f2: {
  25673. ind: number;
  25674. sqDistance: number;
  25675. }) => number;
  25676. facetDepthSortFrom: Vector3;
  25677. facetDepthSortOrigin: Vector3;
  25678. invertedMatrix: Matrix;
  25679. }
  25680. /**
  25681. * @hidden
  25682. **/
  25683. class _InternalAbstractMeshDataInfo {
  25684. _hasVertexAlpha: boolean;
  25685. _useVertexColors: boolean;
  25686. _numBoneInfluencers: number;
  25687. _applyFog: boolean;
  25688. _receiveShadows: boolean;
  25689. _facetData: _FacetDataStorage;
  25690. _visibility: number;
  25691. _skeleton: Nullable<Skeleton>;
  25692. _layerMask: number;
  25693. _computeBonesUsingShaders: boolean;
  25694. _isActive: boolean;
  25695. _onlyForInstances: boolean;
  25696. _isActiveIntermediate: boolean;
  25697. _onlyForInstancesIntermediate: boolean;
  25698. }
  25699. /**
  25700. * Class used to store all common mesh properties
  25701. */
  25702. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25703. /** No occlusion */
  25704. static OCCLUSION_TYPE_NONE: number;
  25705. /** Occlusion set to optimisitic */
  25706. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25707. /** Occlusion set to strict */
  25708. static OCCLUSION_TYPE_STRICT: number;
  25709. /** Use an accurante occlusion algorithm */
  25710. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25711. /** Use a conservative occlusion algorithm */
  25712. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25713. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25714. * Test order :
  25715. * Is the bounding sphere outside the frustum ?
  25716. * If not, are the bounding box vertices outside the frustum ?
  25717. * It not, then the cullable object is in the frustum.
  25718. */
  25719. static readonly CULLINGSTRATEGY_STANDARD: number;
  25720. /** Culling strategy : Bounding Sphere Only.
  25721. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25722. * It's also less accurate than the standard because some not visible objects can still be selected.
  25723. * Test : is the bounding sphere outside the frustum ?
  25724. * If not, then the cullable object is in the frustum.
  25725. */
  25726. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25727. /** Culling strategy : Optimistic Inclusion.
  25728. * This in an inclusion test first, then the standard exclusion test.
  25729. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25730. * 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.
  25731. * Anyway, it's as accurate as the standard strategy.
  25732. * Test :
  25733. * Is the cullable object bounding sphere center in the frustum ?
  25734. * If not, apply the default culling strategy.
  25735. */
  25736. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25737. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25738. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25739. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25740. * 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.
  25741. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25742. * Test :
  25743. * Is the cullable object bounding sphere center in the frustum ?
  25744. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25745. */
  25746. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25747. /**
  25748. * No billboard
  25749. */
  25750. static readonly BILLBOARDMODE_NONE: number;
  25751. /** Billboard on X axis */
  25752. static readonly BILLBOARDMODE_X: number;
  25753. /** Billboard on Y axis */
  25754. static readonly BILLBOARDMODE_Y: number;
  25755. /** Billboard on Z axis */
  25756. static readonly BILLBOARDMODE_Z: number;
  25757. /** Billboard on all axes */
  25758. static readonly BILLBOARDMODE_ALL: number;
  25759. /** Billboard on using position instead of orientation */
  25760. static readonly BILLBOARDMODE_USE_POSITION: number;
  25761. /** @hidden */
  25762. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25763. /**
  25764. * The culling strategy to use to check whether the mesh must be rendered or not.
  25765. * This value can be changed at any time and will be used on the next render mesh selection.
  25766. * The possible values are :
  25767. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25768. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25769. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25770. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25771. * Please read each static variable documentation to get details about the culling process.
  25772. * */
  25773. cullingStrategy: number;
  25774. /**
  25775. * Gets the number of facets in the mesh
  25776. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25777. */
  25778. readonly facetNb: number;
  25779. /**
  25780. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25781. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25782. */
  25783. partitioningSubdivisions: number;
  25784. /**
  25785. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25786. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25787. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25788. */
  25789. partitioningBBoxRatio: number;
  25790. /**
  25791. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25792. * Works only for updatable meshes.
  25793. * Doesn't work with multi-materials
  25794. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25795. */
  25796. mustDepthSortFacets: boolean;
  25797. /**
  25798. * The location (Vector3) where the facet depth sort must be computed from.
  25799. * By default, the active camera position.
  25800. * Used only when facet depth sort is enabled
  25801. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25802. */
  25803. facetDepthSortFrom: Vector3;
  25804. /**
  25805. * gets a boolean indicating if facetData is enabled
  25806. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25807. */
  25808. readonly isFacetDataEnabled: boolean;
  25809. /** @hidden */
  25810. _updateNonUniformScalingState(value: boolean): boolean;
  25811. /**
  25812. * An event triggered when this mesh collides with another one
  25813. */
  25814. onCollideObservable: Observable<AbstractMesh>;
  25815. /** Set a function to call when this mesh collides with another one */
  25816. onCollide: () => void;
  25817. /**
  25818. * An event triggered when the collision's position changes
  25819. */
  25820. onCollisionPositionChangeObservable: Observable<Vector3>;
  25821. /** Set a function to call when the collision's position changes */
  25822. onCollisionPositionChange: () => void;
  25823. /**
  25824. * An event triggered when material is changed
  25825. */
  25826. onMaterialChangedObservable: Observable<AbstractMesh>;
  25827. /**
  25828. * Gets or sets the orientation for POV movement & rotation
  25829. */
  25830. definedFacingForward: boolean;
  25831. /** @hidden */
  25832. _occlusionQuery: Nullable<WebGLQuery>;
  25833. /** @hidden */
  25834. _renderingGroup: Nullable<RenderingGroup>;
  25835. /**
  25836. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25837. */
  25838. /**
  25839. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25840. */
  25841. visibility: number;
  25842. /** Gets or sets the alpha index used to sort transparent meshes
  25843. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25844. */
  25845. alphaIndex: number;
  25846. /**
  25847. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25848. */
  25849. isVisible: boolean;
  25850. /**
  25851. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25852. */
  25853. isPickable: boolean;
  25854. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25855. showSubMeshesBoundingBox: boolean;
  25856. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25857. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25858. */
  25859. isBlocker: boolean;
  25860. /**
  25861. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25862. */
  25863. enablePointerMoveEvents: boolean;
  25864. /**
  25865. * Specifies the rendering group id for this mesh (0 by default)
  25866. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25867. */
  25868. renderingGroupId: number;
  25869. private _material;
  25870. /** Gets or sets current material */
  25871. material: Nullable<Material>;
  25872. /**
  25873. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25874. * @see http://doc.babylonjs.com/babylon101/shadows
  25875. */
  25876. receiveShadows: boolean;
  25877. /** Defines color to use when rendering outline */
  25878. outlineColor: Color3;
  25879. /** Define width to use when rendering outline */
  25880. outlineWidth: number;
  25881. /** Defines color to use when rendering overlay */
  25882. overlayColor: Color3;
  25883. /** Defines alpha to use when rendering overlay */
  25884. overlayAlpha: number;
  25885. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25886. hasVertexAlpha: boolean;
  25887. /** 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) */
  25888. useVertexColors: boolean;
  25889. /**
  25890. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25891. */
  25892. computeBonesUsingShaders: boolean;
  25893. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25894. numBoneInfluencers: number;
  25895. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25896. applyFog: boolean;
  25897. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25898. useOctreeForRenderingSelection: boolean;
  25899. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25900. useOctreeForPicking: boolean;
  25901. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25902. useOctreeForCollisions: boolean;
  25903. /**
  25904. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25905. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25906. */
  25907. layerMask: number;
  25908. /**
  25909. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25910. */
  25911. alwaysSelectAsActiveMesh: boolean;
  25912. /**
  25913. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25914. */
  25915. doNotSyncBoundingInfo: boolean;
  25916. /**
  25917. * Gets or sets the current action manager
  25918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25919. */
  25920. actionManager: Nullable<AbstractActionManager>;
  25921. private _meshCollisionData;
  25922. /**
  25923. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25924. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25925. */
  25926. ellipsoid: Vector3;
  25927. /**
  25928. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25929. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25930. */
  25931. ellipsoidOffset: Vector3;
  25932. /**
  25933. * Gets or sets a collision mask used to mask collisions (default is -1).
  25934. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25935. */
  25936. collisionMask: number;
  25937. /**
  25938. * Gets or sets the current collision group mask (-1 by default).
  25939. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25940. */
  25941. collisionGroup: number;
  25942. /**
  25943. * Defines edge width used when edgesRenderer is enabled
  25944. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25945. */
  25946. edgesWidth: number;
  25947. /**
  25948. * Defines edge color used when edgesRenderer is enabled
  25949. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25950. */
  25951. edgesColor: Color4;
  25952. /** @hidden */
  25953. _edgesRenderer: Nullable<IEdgesRenderer>;
  25954. /** @hidden */
  25955. _masterMesh: Nullable<AbstractMesh>;
  25956. /** @hidden */
  25957. _boundingInfo: Nullable<BoundingInfo>;
  25958. /** @hidden */
  25959. _renderId: number;
  25960. /**
  25961. * Gets or sets the list of subMeshes
  25962. * @see http://doc.babylonjs.com/how_to/multi_materials
  25963. */
  25964. subMeshes: SubMesh[];
  25965. /** @hidden */
  25966. _intersectionsInProgress: AbstractMesh[];
  25967. /** @hidden */
  25968. _unIndexed: boolean;
  25969. /** @hidden */
  25970. _lightSources: Light[];
  25971. /** Gets the list of lights affecting that mesh */
  25972. readonly lightSources: Light[];
  25973. /** @hidden */
  25974. readonly _positions: Nullable<Vector3[]>;
  25975. /** @hidden */
  25976. _waitingData: {
  25977. lods: Nullable<any>;
  25978. actions: Nullable<any>;
  25979. freezeWorldMatrix: Nullable<boolean>;
  25980. };
  25981. /** @hidden */
  25982. _bonesTransformMatrices: Nullable<Float32Array>;
  25983. /** @hidden */
  25984. _transformMatrixTexture: Nullable<RawTexture>;
  25985. /**
  25986. * Gets or sets a skeleton to apply skining transformations
  25987. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25988. */
  25989. skeleton: Nullable<Skeleton>;
  25990. /**
  25991. * An event triggered when the mesh is rebuilt.
  25992. */
  25993. onRebuildObservable: Observable<AbstractMesh>;
  25994. /**
  25995. * Creates a new AbstractMesh
  25996. * @param name defines the name of the mesh
  25997. * @param scene defines the hosting scene
  25998. */
  25999. constructor(name: string, scene?: Nullable<Scene>);
  26000. /**
  26001. * Returns the string "AbstractMesh"
  26002. * @returns "AbstractMesh"
  26003. */
  26004. getClassName(): string;
  26005. /**
  26006. * Gets a string representation of the current mesh
  26007. * @param fullDetails defines a boolean indicating if full details must be included
  26008. * @returns a string representation of the current mesh
  26009. */
  26010. toString(fullDetails?: boolean): string;
  26011. /**
  26012. * @hidden
  26013. */
  26014. protected _getEffectiveParent(): Nullable<Node>;
  26015. /** @hidden */
  26016. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26017. /** @hidden */
  26018. _rebuild(): void;
  26019. /** @hidden */
  26020. _resyncLightSources(): void;
  26021. /** @hidden */
  26022. _resyncLighSource(light: Light): void;
  26023. /** @hidden */
  26024. _unBindEffect(): void;
  26025. /** @hidden */
  26026. _removeLightSource(light: Light, dispose: boolean): void;
  26027. private _markSubMeshesAsDirty;
  26028. /** @hidden */
  26029. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26030. /** @hidden */
  26031. _markSubMeshesAsAttributesDirty(): void;
  26032. /** @hidden */
  26033. _markSubMeshesAsMiscDirty(): void;
  26034. /**
  26035. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26036. */
  26037. scaling: Vector3;
  26038. /**
  26039. * Returns true if the mesh is blocked. Implemented by child classes
  26040. */
  26041. readonly isBlocked: boolean;
  26042. /**
  26043. * Returns the mesh itself by default. Implemented by child classes
  26044. * @param camera defines the camera to use to pick the right LOD level
  26045. * @returns the currentAbstractMesh
  26046. */
  26047. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26048. /**
  26049. * Returns 0 by default. Implemented by child classes
  26050. * @returns an integer
  26051. */
  26052. getTotalVertices(): number;
  26053. /**
  26054. * Returns a positive integer : the total number of indices in this mesh geometry.
  26055. * @returns the numner of indices or zero if the mesh has no geometry.
  26056. */
  26057. getTotalIndices(): number;
  26058. /**
  26059. * Returns null by default. Implemented by child classes
  26060. * @returns null
  26061. */
  26062. getIndices(): Nullable<IndicesArray>;
  26063. /**
  26064. * Returns the array of the requested vertex data kind. Implemented by child classes
  26065. * @param kind defines the vertex data kind to use
  26066. * @returns null
  26067. */
  26068. getVerticesData(kind: string): Nullable<FloatArray>;
  26069. /**
  26070. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26071. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26072. * Note that a new underlying VertexBuffer object is created each call.
  26073. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26074. * @param kind defines vertex data kind:
  26075. * * VertexBuffer.PositionKind
  26076. * * VertexBuffer.UVKind
  26077. * * VertexBuffer.UV2Kind
  26078. * * VertexBuffer.UV3Kind
  26079. * * VertexBuffer.UV4Kind
  26080. * * VertexBuffer.UV5Kind
  26081. * * VertexBuffer.UV6Kind
  26082. * * VertexBuffer.ColorKind
  26083. * * VertexBuffer.MatricesIndicesKind
  26084. * * VertexBuffer.MatricesIndicesExtraKind
  26085. * * VertexBuffer.MatricesWeightsKind
  26086. * * VertexBuffer.MatricesWeightsExtraKind
  26087. * @param data defines the data source
  26088. * @param updatable defines if the data must be flagged as updatable (or static)
  26089. * @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
  26090. * @returns the current mesh
  26091. */
  26092. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26093. /**
  26094. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26095. * If the mesh has no geometry, it is simply returned as it is.
  26096. * @param kind defines vertex data kind:
  26097. * * VertexBuffer.PositionKind
  26098. * * VertexBuffer.UVKind
  26099. * * VertexBuffer.UV2Kind
  26100. * * VertexBuffer.UV3Kind
  26101. * * VertexBuffer.UV4Kind
  26102. * * VertexBuffer.UV5Kind
  26103. * * VertexBuffer.UV6Kind
  26104. * * VertexBuffer.ColorKind
  26105. * * VertexBuffer.MatricesIndicesKind
  26106. * * VertexBuffer.MatricesIndicesExtraKind
  26107. * * VertexBuffer.MatricesWeightsKind
  26108. * * VertexBuffer.MatricesWeightsExtraKind
  26109. * @param data defines the data source
  26110. * @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
  26111. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26112. * @returns the current mesh
  26113. */
  26114. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26115. /**
  26116. * Sets the mesh indices,
  26117. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26118. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26119. * @param totalVertices Defines the total number of vertices
  26120. * @returns the current mesh
  26121. */
  26122. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26123. /**
  26124. * Gets a boolean indicating if specific vertex data is present
  26125. * @param kind defines the vertex data kind to use
  26126. * @returns true is data kind is present
  26127. */
  26128. isVerticesDataPresent(kind: string): boolean;
  26129. /**
  26130. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26131. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26132. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26133. * @returns a BoundingInfo
  26134. */
  26135. getBoundingInfo(): BoundingInfo;
  26136. /**
  26137. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26138. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26139. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26140. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26141. * @returns the current mesh
  26142. */
  26143. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26144. /**
  26145. * Overwrite the current bounding info
  26146. * @param boundingInfo defines the new bounding info
  26147. * @returns the current mesh
  26148. */
  26149. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26150. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26151. readonly useBones: boolean;
  26152. /** @hidden */
  26153. _preActivate(): void;
  26154. /** @hidden */
  26155. _preActivateForIntermediateRendering(renderId: number): void;
  26156. /** @hidden */
  26157. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26158. /** @hidden */
  26159. _postActivate(): void;
  26160. /** @hidden */
  26161. _freeze(): void;
  26162. /** @hidden */
  26163. _unFreeze(): void;
  26164. /**
  26165. * Gets the current world matrix
  26166. * @returns a Matrix
  26167. */
  26168. getWorldMatrix(): Matrix;
  26169. /** @hidden */
  26170. _getWorldMatrixDeterminant(): number;
  26171. /**
  26172. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26173. */
  26174. readonly isAnInstance: boolean;
  26175. /**
  26176. * Gets a boolean indicating if this mesh has instances
  26177. */
  26178. readonly hasInstances: boolean;
  26179. /**
  26180. * Perform relative position change from the point of view of behind the front of the mesh.
  26181. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26182. * Supports definition of mesh facing forward or backward
  26183. * @param amountRight defines the distance on the right axis
  26184. * @param amountUp defines the distance on the up axis
  26185. * @param amountForward defines the distance on the forward axis
  26186. * @returns the current mesh
  26187. */
  26188. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26189. /**
  26190. * Calculate relative position change from the point of view of behind the front of the mesh.
  26191. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26192. * Supports definition of mesh facing forward or backward
  26193. * @param amountRight defines the distance on the right axis
  26194. * @param amountUp defines the distance on the up axis
  26195. * @param amountForward defines the distance on the forward axis
  26196. * @returns the new displacement vector
  26197. */
  26198. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26199. /**
  26200. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26201. * Supports definition of mesh facing forward or backward
  26202. * @param flipBack defines the flip
  26203. * @param twirlClockwise defines the twirl
  26204. * @param tiltRight defines the tilt
  26205. * @returns the current mesh
  26206. */
  26207. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26208. /**
  26209. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26210. * Supports definition of mesh facing forward or backward.
  26211. * @param flipBack defines the flip
  26212. * @param twirlClockwise defines the twirl
  26213. * @param tiltRight defines the tilt
  26214. * @returns the new rotation vector
  26215. */
  26216. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26217. /**
  26218. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26219. * This means the mesh underlying bounding box and sphere are recomputed.
  26220. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26221. * @returns the current mesh
  26222. */
  26223. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26224. /** @hidden */
  26225. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26226. /** @hidden */
  26227. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26228. /** @hidden */
  26229. _updateBoundingInfo(): AbstractMesh;
  26230. /** @hidden */
  26231. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26232. /** @hidden */
  26233. protected _afterComputeWorldMatrix(): void;
  26234. /** @hidden */
  26235. readonly _effectiveMesh: AbstractMesh;
  26236. /**
  26237. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26238. * A mesh is in the frustum if its bounding box intersects the frustum
  26239. * @param frustumPlanes defines the frustum to test
  26240. * @returns true if the mesh is in the frustum planes
  26241. */
  26242. isInFrustum(frustumPlanes: Plane[]): boolean;
  26243. /**
  26244. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26245. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26246. * @param frustumPlanes defines the frustum to test
  26247. * @returns true if the mesh is completely in the frustum planes
  26248. */
  26249. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26250. /**
  26251. * True if the mesh intersects another mesh or a SolidParticle object
  26252. * @param mesh defines a target mesh or SolidParticle to test
  26253. * @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)
  26254. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26255. * @returns true if there is an intersection
  26256. */
  26257. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26258. /**
  26259. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26260. * @param point defines the point to test
  26261. * @returns true if there is an intersection
  26262. */
  26263. intersectsPoint(point: Vector3): boolean;
  26264. /**
  26265. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26266. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26267. */
  26268. checkCollisions: boolean;
  26269. /**
  26270. * Gets Collider object used to compute collisions (not physics)
  26271. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26272. */
  26273. readonly collider: Nullable<Collider>;
  26274. /**
  26275. * Move the mesh using collision engine
  26276. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26277. * @param displacement defines the requested displacement vector
  26278. * @returns the current mesh
  26279. */
  26280. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26281. private _onCollisionPositionChange;
  26282. /** @hidden */
  26283. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26284. /** @hidden */
  26285. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26286. /** @hidden */
  26287. _checkCollision(collider: Collider): AbstractMesh;
  26288. /** @hidden */
  26289. _generatePointsArray(): boolean;
  26290. /**
  26291. * Checks if the passed Ray intersects with the mesh
  26292. * @param ray defines the ray to use
  26293. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26294. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26295. * @returns the picking info
  26296. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26297. */
  26298. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26299. /**
  26300. * Clones the current mesh
  26301. * @param name defines the mesh name
  26302. * @param newParent defines the new mesh parent
  26303. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26304. * @returns the new mesh
  26305. */
  26306. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26307. /**
  26308. * Disposes all the submeshes of the current meshnp
  26309. * @returns the current mesh
  26310. */
  26311. releaseSubMeshes(): AbstractMesh;
  26312. /**
  26313. * Releases resources associated with this abstract mesh.
  26314. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26315. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26316. */
  26317. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26318. /**
  26319. * Adds the passed mesh as a child to the current mesh
  26320. * @param mesh defines the child mesh
  26321. * @returns the current mesh
  26322. */
  26323. addChild(mesh: AbstractMesh): AbstractMesh;
  26324. /**
  26325. * Removes the passed mesh from the current mesh children list
  26326. * @param mesh defines the child mesh
  26327. * @returns the current mesh
  26328. */
  26329. removeChild(mesh: AbstractMesh): AbstractMesh;
  26330. /** @hidden */
  26331. private _initFacetData;
  26332. /**
  26333. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26334. * This method can be called within the render loop.
  26335. * 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
  26336. * @returns the current mesh
  26337. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26338. */
  26339. updateFacetData(): AbstractMesh;
  26340. /**
  26341. * Returns the facetLocalNormals array.
  26342. * The normals are expressed in the mesh local spac
  26343. * @returns an array of Vector3
  26344. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26345. */
  26346. getFacetLocalNormals(): Vector3[];
  26347. /**
  26348. * Returns the facetLocalPositions array.
  26349. * The facet positions are expressed in the mesh local space
  26350. * @returns an array of Vector3
  26351. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26352. */
  26353. getFacetLocalPositions(): Vector3[];
  26354. /**
  26355. * Returns the facetLocalPartioning array
  26356. * @returns an array of array of numbers
  26357. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26358. */
  26359. getFacetLocalPartitioning(): number[][];
  26360. /**
  26361. * Returns the i-th facet position in the world system.
  26362. * This method allocates a new Vector3 per call
  26363. * @param i defines the facet index
  26364. * @returns a new Vector3
  26365. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26366. */
  26367. getFacetPosition(i: number): Vector3;
  26368. /**
  26369. * Sets the reference Vector3 with the i-th facet position in the world system
  26370. * @param i defines the facet index
  26371. * @param ref defines the target vector
  26372. * @returns the current mesh
  26373. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26374. */
  26375. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26376. /**
  26377. * Returns the i-th facet normal in the world system.
  26378. * This method allocates a new Vector3 per call
  26379. * @param i defines the facet index
  26380. * @returns a new Vector3
  26381. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26382. */
  26383. getFacetNormal(i: number): Vector3;
  26384. /**
  26385. * Sets the reference Vector3 with the i-th facet normal in the world system
  26386. * @param i defines the facet index
  26387. * @param ref defines the target vector
  26388. * @returns the current mesh
  26389. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26390. */
  26391. getFacetNormalToRef(i: number, ref: Vector3): this;
  26392. /**
  26393. * 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)
  26394. * @param x defines x coordinate
  26395. * @param y defines y coordinate
  26396. * @param z defines z coordinate
  26397. * @returns the array of facet indexes
  26398. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26399. */
  26400. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26401. /**
  26402. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26403. * @param projected sets as the (x,y,z) world projection on the facet
  26404. * @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
  26405. * @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
  26406. * @param x defines x coordinate
  26407. * @param y defines y coordinate
  26408. * @param z defines z coordinate
  26409. * @returns the face index if found (or null instead)
  26410. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26411. */
  26412. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26413. /**
  26414. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26415. * @param projected sets as the (x,y,z) local projection on the facet
  26416. * @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
  26417. * @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
  26418. * @param x defines x coordinate
  26419. * @param y defines y coordinate
  26420. * @param z defines z coordinate
  26421. * @returns the face index if found (or null instead)
  26422. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26423. */
  26424. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26425. /**
  26426. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26427. * @returns the parameters
  26428. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26429. */
  26430. getFacetDataParameters(): any;
  26431. /**
  26432. * Disables the feature FacetData and frees the related memory
  26433. * @returns the current mesh
  26434. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26435. */
  26436. disableFacetData(): AbstractMesh;
  26437. /**
  26438. * Updates the AbstractMesh indices array
  26439. * @param indices defines the data source
  26440. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26441. * @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)
  26442. * @returns the current mesh
  26443. */
  26444. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26445. /**
  26446. * Creates new normals data for the mesh
  26447. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26448. * @returns the current mesh
  26449. */
  26450. createNormals(updatable: boolean): AbstractMesh;
  26451. /**
  26452. * Align the mesh with a normal
  26453. * @param normal defines the normal to use
  26454. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26455. * @returns the current mesh
  26456. */
  26457. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26458. /** @hidden */
  26459. _checkOcclusionQuery(): boolean;
  26460. /**
  26461. * Disables the mesh edge rendering mode
  26462. * @returns the currentAbstractMesh
  26463. */
  26464. disableEdgesRendering(): AbstractMesh;
  26465. /**
  26466. * Enables the edge rendering mode on the mesh.
  26467. * This mode makes the mesh edges visible
  26468. * @param epsilon defines the maximal distance between two angles to detect a face
  26469. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26470. * @returns the currentAbstractMesh
  26471. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26472. */
  26473. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26474. }
  26475. }
  26476. declare module BABYLON {
  26477. /**
  26478. * Interface used to define ActionEvent
  26479. */
  26480. export interface IActionEvent {
  26481. /** The mesh or sprite that triggered the action */
  26482. source: any;
  26483. /** The X mouse cursor position at the time of the event */
  26484. pointerX: number;
  26485. /** The Y mouse cursor position at the time of the event */
  26486. pointerY: number;
  26487. /** The mesh that is currently pointed at (can be null) */
  26488. meshUnderPointer: Nullable<AbstractMesh>;
  26489. /** the original (browser) event that triggered the ActionEvent */
  26490. sourceEvent?: any;
  26491. /** additional data for the event */
  26492. additionalData?: any;
  26493. }
  26494. /**
  26495. * ActionEvent is the event being sent when an action is triggered.
  26496. */
  26497. export class ActionEvent implements IActionEvent {
  26498. /** The mesh or sprite that triggered the action */
  26499. source: any;
  26500. /** The X mouse cursor position at the time of the event */
  26501. pointerX: number;
  26502. /** The Y mouse cursor position at the time of the event */
  26503. pointerY: number;
  26504. /** The mesh that is currently pointed at (can be null) */
  26505. meshUnderPointer: Nullable<AbstractMesh>;
  26506. /** the original (browser) event that triggered the ActionEvent */
  26507. sourceEvent?: any;
  26508. /** additional data for the event */
  26509. additionalData?: any;
  26510. /**
  26511. * Creates a new ActionEvent
  26512. * @param source The mesh or sprite that triggered the action
  26513. * @param pointerX The X mouse cursor position at the time of the event
  26514. * @param pointerY The Y mouse cursor position at the time of the event
  26515. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26516. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26517. * @param additionalData additional data for the event
  26518. */
  26519. constructor(
  26520. /** The mesh or sprite that triggered the action */
  26521. source: any,
  26522. /** The X mouse cursor position at the time of the event */
  26523. pointerX: number,
  26524. /** The Y mouse cursor position at the time of the event */
  26525. pointerY: number,
  26526. /** The mesh that is currently pointed at (can be null) */
  26527. meshUnderPointer: Nullable<AbstractMesh>,
  26528. /** the original (browser) event that triggered the ActionEvent */
  26529. sourceEvent?: any,
  26530. /** additional data for the event */
  26531. additionalData?: any);
  26532. /**
  26533. * Helper function to auto-create an ActionEvent from a source mesh.
  26534. * @param source The source mesh that triggered the event
  26535. * @param evt The original (browser) event
  26536. * @param additionalData additional data for the event
  26537. * @returns the new ActionEvent
  26538. */
  26539. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26540. /**
  26541. * Helper function to auto-create an ActionEvent from a source sprite
  26542. * @param source The source sprite that triggered the event
  26543. * @param scene Scene associated with the sprite
  26544. * @param evt The original (browser) event
  26545. * @param additionalData additional data for the event
  26546. * @returns the new ActionEvent
  26547. */
  26548. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26549. /**
  26550. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26551. * @param scene the scene where the event occurred
  26552. * @param evt The original (browser) event
  26553. * @returns the new ActionEvent
  26554. */
  26555. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26556. /**
  26557. * Helper function to auto-create an ActionEvent from a primitive
  26558. * @param prim defines the target primitive
  26559. * @param pointerPos defines the pointer position
  26560. * @param evt The original (browser) event
  26561. * @param additionalData additional data for the event
  26562. * @returns the new ActionEvent
  26563. */
  26564. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26565. }
  26566. }
  26567. declare module BABYLON {
  26568. /**
  26569. * Abstract class used to decouple action Manager from scene and meshes.
  26570. * Do not instantiate.
  26571. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26572. */
  26573. export abstract class AbstractActionManager implements IDisposable {
  26574. /** Gets the list of active triggers */
  26575. static Triggers: {
  26576. [key: string]: number;
  26577. };
  26578. /** Gets the cursor to use when hovering items */
  26579. hoverCursor: string;
  26580. /** Gets the list of actions */
  26581. actions: IAction[];
  26582. /**
  26583. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26584. */
  26585. isRecursive: boolean;
  26586. /**
  26587. * Releases all associated resources
  26588. */
  26589. abstract dispose(): void;
  26590. /**
  26591. * Does this action manager has pointer triggers
  26592. */
  26593. abstract readonly hasPointerTriggers: boolean;
  26594. /**
  26595. * Does this action manager has pick triggers
  26596. */
  26597. abstract readonly hasPickTriggers: boolean;
  26598. /**
  26599. * Process a specific trigger
  26600. * @param trigger defines the trigger to process
  26601. * @param evt defines the event details to be processed
  26602. */
  26603. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26604. /**
  26605. * Does this action manager handles actions of any of the given triggers
  26606. * @param triggers defines the triggers to be tested
  26607. * @return a boolean indicating whether one (or more) of the triggers is handled
  26608. */
  26609. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26610. /**
  26611. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26612. * speed.
  26613. * @param triggerA defines the trigger to be tested
  26614. * @param triggerB defines the trigger to be tested
  26615. * @return a boolean indicating whether one (or more) of the triggers is handled
  26616. */
  26617. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26618. /**
  26619. * Does this action manager handles actions of a given trigger
  26620. * @param trigger defines the trigger to be tested
  26621. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26622. * @return whether the trigger is handled
  26623. */
  26624. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26625. /**
  26626. * Serialize this manager to a JSON object
  26627. * @param name defines the property name to store this manager
  26628. * @returns a JSON representation of this manager
  26629. */
  26630. abstract serialize(name: string): any;
  26631. /**
  26632. * Registers an action to this action manager
  26633. * @param action defines the action to be registered
  26634. * @return the action amended (prepared) after registration
  26635. */
  26636. abstract registerAction(action: IAction): Nullable<IAction>;
  26637. /**
  26638. * Unregisters an action to this action manager
  26639. * @param action defines the action to be unregistered
  26640. * @return a boolean indicating whether the action has been unregistered
  26641. */
  26642. abstract unregisterAction(action: IAction): Boolean;
  26643. /**
  26644. * Does exist one action manager with at least one trigger
  26645. **/
  26646. static readonly HasTriggers: boolean;
  26647. /**
  26648. * Does exist one action manager with at least one pick trigger
  26649. **/
  26650. static readonly HasPickTriggers: boolean;
  26651. /**
  26652. * Does exist one action manager that handles actions of a given trigger
  26653. * @param trigger defines the trigger to be tested
  26654. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26655. **/
  26656. static HasSpecificTrigger(trigger: number): boolean;
  26657. }
  26658. }
  26659. declare module BABYLON {
  26660. /**
  26661. * Defines how a node can be built from a string name.
  26662. */
  26663. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26664. /**
  26665. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26666. */
  26667. export class Node implements IBehaviorAware<Node> {
  26668. /** @hidden */
  26669. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26670. private static _NodeConstructors;
  26671. /**
  26672. * Add a new node constructor
  26673. * @param type defines the type name of the node to construct
  26674. * @param constructorFunc defines the constructor function
  26675. */
  26676. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26677. /**
  26678. * Returns a node constructor based on type name
  26679. * @param type defines the type name
  26680. * @param name defines the new node name
  26681. * @param scene defines the hosting scene
  26682. * @param options defines optional options to transmit to constructors
  26683. * @returns the new constructor or null
  26684. */
  26685. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26686. /**
  26687. * Gets or sets the name of the node
  26688. */
  26689. name: string;
  26690. /**
  26691. * Gets or sets the id of the node
  26692. */
  26693. id: string;
  26694. /**
  26695. * Gets or sets the unique id of the node
  26696. */
  26697. uniqueId: number;
  26698. /**
  26699. * Gets or sets a string used to store user defined state for the node
  26700. */
  26701. state: string;
  26702. /**
  26703. * Gets or sets an object used to store user defined information for the node
  26704. */
  26705. metadata: any;
  26706. /**
  26707. * For internal use only. Please do not use.
  26708. */
  26709. reservedDataStore: any;
  26710. /**
  26711. * List of inspectable custom properties (used by the Inspector)
  26712. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26713. */
  26714. inspectableCustomProperties: IInspectable[];
  26715. /**
  26716. * Gets or sets a boolean used to define if the node must be serialized
  26717. */
  26718. doNotSerialize: boolean;
  26719. /** @hidden */
  26720. _isDisposed: boolean;
  26721. /**
  26722. * Gets a list of Animations associated with the node
  26723. */
  26724. animations: Animation[];
  26725. protected _ranges: {
  26726. [name: string]: Nullable<AnimationRange>;
  26727. };
  26728. /**
  26729. * Callback raised when the node is ready to be used
  26730. */
  26731. onReady: Nullable<(node: Node) => void>;
  26732. private _isEnabled;
  26733. private _isParentEnabled;
  26734. private _isReady;
  26735. /** @hidden */
  26736. _currentRenderId: number;
  26737. private _parentUpdateId;
  26738. /** @hidden */
  26739. _childUpdateId: number;
  26740. /** @hidden */
  26741. _waitingParentId: Nullable<string>;
  26742. /** @hidden */
  26743. _scene: Scene;
  26744. /** @hidden */
  26745. _cache: any;
  26746. private _parentNode;
  26747. private _children;
  26748. /** @hidden */
  26749. _worldMatrix: Matrix;
  26750. /** @hidden */
  26751. _worldMatrixDeterminant: number;
  26752. /** @hidden */
  26753. _worldMatrixDeterminantIsDirty: boolean;
  26754. /** @hidden */
  26755. private _sceneRootNodesIndex;
  26756. /**
  26757. * Gets a boolean indicating if the node has been disposed
  26758. * @returns true if the node was disposed
  26759. */
  26760. isDisposed(): boolean;
  26761. /**
  26762. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26763. * @see https://doc.babylonjs.com/how_to/parenting
  26764. */
  26765. parent: Nullable<Node>;
  26766. private addToSceneRootNodes;
  26767. private removeFromSceneRootNodes;
  26768. private _animationPropertiesOverride;
  26769. /**
  26770. * Gets or sets the animation properties override
  26771. */
  26772. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26773. /**
  26774. * Gets a string idenfifying the name of the class
  26775. * @returns "Node" string
  26776. */
  26777. getClassName(): string;
  26778. /** @hidden */
  26779. readonly _isNode: boolean;
  26780. /**
  26781. * An event triggered when the mesh is disposed
  26782. */
  26783. onDisposeObservable: Observable<Node>;
  26784. private _onDisposeObserver;
  26785. /**
  26786. * Sets a callback that will be raised when the node will be disposed
  26787. */
  26788. onDispose: () => void;
  26789. /**
  26790. * Creates a new Node
  26791. * @param name the name and id to be given to this node
  26792. * @param scene the scene this node will be added to
  26793. * @param addToRootNodes the node will be added to scene.rootNodes
  26794. */
  26795. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26796. /**
  26797. * Gets the scene of the node
  26798. * @returns a scene
  26799. */
  26800. getScene(): Scene;
  26801. /**
  26802. * Gets the engine of the node
  26803. * @returns a Engine
  26804. */
  26805. getEngine(): Engine;
  26806. private _behaviors;
  26807. /**
  26808. * Attach a behavior to the node
  26809. * @see http://doc.babylonjs.com/features/behaviour
  26810. * @param behavior defines the behavior to attach
  26811. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26812. * @returns the current Node
  26813. */
  26814. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26815. /**
  26816. * Remove an attached behavior
  26817. * @see http://doc.babylonjs.com/features/behaviour
  26818. * @param behavior defines the behavior to attach
  26819. * @returns the current Node
  26820. */
  26821. removeBehavior(behavior: Behavior<Node>): Node;
  26822. /**
  26823. * Gets the list of attached behaviors
  26824. * @see http://doc.babylonjs.com/features/behaviour
  26825. */
  26826. readonly behaviors: Behavior<Node>[];
  26827. /**
  26828. * Gets an attached behavior by name
  26829. * @param name defines the name of the behavior to look for
  26830. * @see http://doc.babylonjs.com/features/behaviour
  26831. * @returns null if behavior was not found else the requested behavior
  26832. */
  26833. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26834. /**
  26835. * Returns the latest update of the World matrix
  26836. * @returns a Matrix
  26837. */
  26838. getWorldMatrix(): Matrix;
  26839. /** @hidden */
  26840. _getWorldMatrixDeterminant(): number;
  26841. /**
  26842. * Returns directly the latest state of the mesh World matrix.
  26843. * A Matrix is returned.
  26844. */
  26845. readonly worldMatrixFromCache: Matrix;
  26846. /** @hidden */
  26847. _initCache(): void;
  26848. /** @hidden */
  26849. updateCache(force?: boolean): void;
  26850. /** @hidden */
  26851. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26852. /** @hidden */
  26853. _updateCache(ignoreParentClass?: boolean): void;
  26854. /** @hidden */
  26855. _isSynchronized(): boolean;
  26856. /** @hidden */
  26857. _markSyncedWithParent(): void;
  26858. /** @hidden */
  26859. isSynchronizedWithParent(): boolean;
  26860. /** @hidden */
  26861. isSynchronized(): boolean;
  26862. /**
  26863. * Is this node ready to be used/rendered
  26864. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26865. * @return true if the node is ready
  26866. */
  26867. isReady(completeCheck?: boolean): boolean;
  26868. /**
  26869. * Is this node enabled?
  26870. * 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
  26871. * @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
  26872. * @return whether this node (and its parent) is enabled
  26873. */
  26874. isEnabled(checkAncestors?: boolean): boolean;
  26875. /** @hidden */
  26876. protected _syncParentEnabledState(): void;
  26877. /**
  26878. * Set the enabled state of this node
  26879. * @param value defines the new enabled state
  26880. */
  26881. setEnabled(value: boolean): void;
  26882. /**
  26883. * Is this node a descendant of the given node?
  26884. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26885. * @param ancestor defines the parent node to inspect
  26886. * @returns a boolean indicating if this node is a descendant of the given node
  26887. */
  26888. isDescendantOf(ancestor: Node): boolean;
  26889. /** @hidden */
  26890. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26891. /**
  26892. * Will return all nodes that have this node as ascendant
  26893. * @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
  26894. * @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
  26895. * @return all children nodes of all types
  26896. */
  26897. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26898. /**
  26899. * Get all child-meshes of this node
  26900. * @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)
  26901. * @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
  26902. * @returns an array of AbstractMesh
  26903. */
  26904. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26905. /**
  26906. * Get all direct children of this node
  26907. * @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
  26908. * @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)
  26909. * @returns an array of Node
  26910. */
  26911. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26912. /** @hidden */
  26913. _setReady(state: boolean): void;
  26914. /**
  26915. * Get an animation by name
  26916. * @param name defines the name of the animation to look for
  26917. * @returns null if not found else the requested animation
  26918. */
  26919. getAnimationByName(name: string): Nullable<Animation>;
  26920. /**
  26921. * Creates an animation range for this node
  26922. * @param name defines the name of the range
  26923. * @param from defines the starting key
  26924. * @param to defines the end key
  26925. */
  26926. createAnimationRange(name: string, from: number, to: number): void;
  26927. /**
  26928. * Delete a specific animation range
  26929. * @param name defines the name of the range to delete
  26930. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26931. */
  26932. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26933. /**
  26934. * Get an animation range by name
  26935. * @param name defines the name of the animation range to look for
  26936. * @returns null if not found else the requested animation range
  26937. */
  26938. getAnimationRange(name: string): Nullable<AnimationRange>;
  26939. /**
  26940. * Gets the list of all animation ranges defined on this node
  26941. * @returns an array
  26942. */
  26943. getAnimationRanges(): Nullable<AnimationRange>[];
  26944. /**
  26945. * Will start the animation sequence
  26946. * @param name defines the range frames for animation sequence
  26947. * @param loop defines if the animation should loop (false by default)
  26948. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26949. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26950. * @returns the object created for this animation. If range does not exist, it will return null
  26951. */
  26952. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26953. /**
  26954. * Serialize animation ranges into a JSON compatible object
  26955. * @returns serialization object
  26956. */
  26957. serializeAnimationRanges(): any;
  26958. /**
  26959. * Computes the world matrix of the node
  26960. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26961. * @returns the world matrix
  26962. */
  26963. computeWorldMatrix(force?: boolean): Matrix;
  26964. /**
  26965. * Releases resources associated with this node.
  26966. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26967. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26968. */
  26969. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26970. /**
  26971. * Parse animation range data from a serialization object and store them into a given node
  26972. * @param node defines where to store the animation ranges
  26973. * @param parsedNode defines the serialization object to read data from
  26974. * @param scene defines the hosting scene
  26975. */
  26976. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26977. /**
  26978. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26979. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26980. * @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
  26981. * @returns the new bounding vectors
  26982. */
  26983. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26984. min: Vector3;
  26985. max: Vector3;
  26986. };
  26987. }
  26988. }
  26989. declare module BABYLON {
  26990. /**
  26991. * @hidden
  26992. */
  26993. export class _IAnimationState {
  26994. key: number;
  26995. repeatCount: number;
  26996. workValue?: any;
  26997. loopMode?: number;
  26998. offsetValue?: any;
  26999. highLimitValue?: any;
  27000. }
  27001. /**
  27002. * Class used to store any kind of animation
  27003. */
  27004. export class Animation {
  27005. /**Name of the animation */
  27006. name: string;
  27007. /**Property to animate */
  27008. targetProperty: string;
  27009. /**The frames per second of the animation */
  27010. framePerSecond: number;
  27011. /**The data type of the animation */
  27012. dataType: number;
  27013. /**The loop mode of the animation */
  27014. loopMode?: number | undefined;
  27015. /**Specifies if blending should be enabled */
  27016. enableBlending?: boolean | undefined;
  27017. /**
  27018. * Use matrix interpolation instead of using direct key value when animating matrices
  27019. */
  27020. static AllowMatricesInterpolation: boolean;
  27021. /**
  27022. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27023. */
  27024. static AllowMatrixDecomposeForInterpolation: boolean;
  27025. /**
  27026. * Stores the key frames of the animation
  27027. */
  27028. private _keys;
  27029. /**
  27030. * Stores the easing function of the animation
  27031. */
  27032. private _easingFunction;
  27033. /**
  27034. * @hidden Internal use only
  27035. */
  27036. _runtimeAnimations: RuntimeAnimation[];
  27037. /**
  27038. * The set of event that will be linked to this animation
  27039. */
  27040. private _events;
  27041. /**
  27042. * Stores an array of target property paths
  27043. */
  27044. targetPropertyPath: string[];
  27045. /**
  27046. * Stores the blending speed of the animation
  27047. */
  27048. blendingSpeed: number;
  27049. /**
  27050. * Stores the animation ranges for the animation
  27051. */
  27052. private _ranges;
  27053. /**
  27054. * @hidden Internal use
  27055. */
  27056. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27057. /**
  27058. * Sets up an animation
  27059. * @param property The property to animate
  27060. * @param animationType The animation type to apply
  27061. * @param framePerSecond The frames per second of the animation
  27062. * @param easingFunction The easing function used in the animation
  27063. * @returns The created animation
  27064. */
  27065. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27066. /**
  27067. * Create and start an animation on a node
  27068. * @param name defines the name of the global animation that will be run on all nodes
  27069. * @param node defines the root node where the animation will take place
  27070. * @param targetProperty defines property to animate
  27071. * @param framePerSecond defines the number of frame per second yo use
  27072. * @param totalFrame defines the number of frames in total
  27073. * @param from defines the initial value
  27074. * @param to defines the final value
  27075. * @param loopMode defines which loop mode you want to use (off by default)
  27076. * @param easingFunction defines the easing function to use (linear by default)
  27077. * @param onAnimationEnd defines the callback to call when animation end
  27078. * @returns the animatable created for this animation
  27079. */
  27080. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27081. /**
  27082. * Create and start an animation on a node and its descendants
  27083. * @param name defines the name of the global animation that will be run on all nodes
  27084. * @param node defines the root node where the animation will take place
  27085. * @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
  27086. * @param targetProperty defines property to animate
  27087. * @param framePerSecond defines the number of frame per second to use
  27088. * @param totalFrame defines the number of frames in total
  27089. * @param from defines the initial value
  27090. * @param to defines the final value
  27091. * @param loopMode defines which loop mode you want to use (off by default)
  27092. * @param easingFunction defines the easing function to use (linear by default)
  27093. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27094. * @returns the list of animatables created for all nodes
  27095. * @example https://www.babylonjs-playground.com/#MH0VLI
  27096. */
  27097. 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[]>;
  27098. /**
  27099. * Creates a new animation, merges it with the existing animations and starts it
  27100. * @param name Name of the animation
  27101. * @param node Node which contains the scene that begins the animations
  27102. * @param targetProperty Specifies which property to animate
  27103. * @param framePerSecond The frames per second of the animation
  27104. * @param totalFrame The total number of frames
  27105. * @param from The frame at the beginning of the animation
  27106. * @param to The frame at the end of the animation
  27107. * @param loopMode Specifies the loop mode of the animation
  27108. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27109. * @param onAnimationEnd Callback to run once the animation is complete
  27110. * @returns Nullable animation
  27111. */
  27112. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27113. /**
  27114. * Transition property of an host to the target Value
  27115. * @param property The property to transition
  27116. * @param targetValue The target Value of the property
  27117. * @param host The object where the property to animate belongs
  27118. * @param scene Scene used to run the animation
  27119. * @param frameRate Framerate (in frame/s) to use
  27120. * @param transition The transition type we want to use
  27121. * @param duration The duration of the animation, in milliseconds
  27122. * @param onAnimationEnd Callback trigger at the end of the animation
  27123. * @returns Nullable animation
  27124. */
  27125. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27126. /**
  27127. * Return the array of runtime animations currently using this animation
  27128. */
  27129. readonly runtimeAnimations: RuntimeAnimation[];
  27130. /**
  27131. * Specifies if any of the runtime animations are currently running
  27132. */
  27133. readonly hasRunningRuntimeAnimations: boolean;
  27134. /**
  27135. * Initializes the animation
  27136. * @param name Name of the animation
  27137. * @param targetProperty Property to animate
  27138. * @param framePerSecond The frames per second of the animation
  27139. * @param dataType The data type of the animation
  27140. * @param loopMode The loop mode of the animation
  27141. * @param enableBlending Specifies if blending should be enabled
  27142. */
  27143. constructor(
  27144. /**Name of the animation */
  27145. name: string,
  27146. /**Property to animate */
  27147. targetProperty: string,
  27148. /**The frames per second of the animation */
  27149. framePerSecond: number,
  27150. /**The data type of the animation */
  27151. dataType: number,
  27152. /**The loop mode of the animation */
  27153. loopMode?: number | undefined,
  27154. /**Specifies if blending should be enabled */
  27155. enableBlending?: boolean | undefined);
  27156. /**
  27157. * Converts the animation to a string
  27158. * @param fullDetails support for multiple levels of logging within scene loading
  27159. * @returns String form of the animation
  27160. */
  27161. toString(fullDetails?: boolean): string;
  27162. /**
  27163. * Add an event to this animation
  27164. * @param event Event to add
  27165. */
  27166. addEvent(event: AnimationEvent): void;
  27167. /**
  27168. * Remove all events found at the given frame
  27169. * @param frame The frame to remove events from
  27170. */
  27171. removeEvents(frame: number): void;
  27172. /**
  27173. * Retrieves all the events from the animation
  27174. * @returns Events from the animation
  27175. */
  27176. getEvents(): AnimationEvent[];
  27177. /**
  27178. * Creates an animation range
  27179. * @param name Name of the animation range
  27180. * @param from Starting frame of the animation range
  27181. * @param to Ending frame of the animation
  27182. */
  27183. createRange(name: string, from: number, to: number): void;
  27184. /**
  27185. * Deletes an animation range by name
  27186. * @param name Name of the animation range to delete
  27187. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27188. */
  27189. deleteRange(name: string, deleteFrames?: boolean): void;
  27190. /**
  27191. * Gets the animation range by name, or null if not defined
  27192. * @param name Name of the animation range
  27193. * @returns Nullable animation range
  27194. */
  27195. getRange(name: string): Nullable<AnimationRange>;
  27196. /**
  27197. * Gets the key frames from the animation
  27198. * @returns The key frames of the animation
  27199. */
  27200. getKeys(): Array<IAnimationKey>;
  27201. /**
  27202. * Gets the highest frame rate of the animation
  27203. * @returns Highest frame rate of the animation
  27204. */
  27205. getHighestFrame(): number;
  27206. /**
  27207. * Gets the easing function of the animation
  27208. * @returns Easing function of the animation
  27209. */
  27210. getEasingFunction(): IEasingFunction;
  27211. /**
  27212. * Sets the easing function of the animation
  27213. * @param easingFunction A custom mathematical formula for animation
  27214. */
  27215. setEasingFunction(easingFunction: EasingFunction): void;
  27216. /**
  27217. * Interpolates a scalar linearly
  27218. * @param startValue Start value of the animation curve
  27219. * @param endValue End value of the animation curve
  27220. * @param gradient Scalar amount to interpolate
  27221. * @returns Interpolated scalar value
  27222. */
  27223. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27224. /**
  27225. * Interpolates a scalar cubically
  27226. * @param startValue Start value of the animation curve
  27227. * @param outTangent End tangent of the animation
  27228. * @param endValue End value of the animation curve
  27229. * @param inTangent Start tangent of the animation curve
  27230. * @param gradient Scalar amount to interpolate
  27231. * @returns Interpolated scalar value
  27232. */
  27233. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27234. /**
  27235. * Interpolates a quaternion using a spherical linear interpolation
  27236. * @param startValue Start value of the animation curve
  27237. * @param endValue End value of the animation curve
  27238. * @param gradient Scalar amount to interpolate
  27239. * @returns Interpolated quaternion value
  27240. */
  27241. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27242. /**
  27243. * Interpolates a quaternion cubically
  27244. * @param startValue Start value of the animation curve
  27245. * @param outTangent End tangent of the animation curve
  27246. * @param endValue End value of the animation curve
  27247. * @param inTangent Start tangent of the animation curve
  27248. * @param gradient Scalar amount to interpolate
  27249. * @returns Interpolated quaternion value
  27250. */
  27251. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27252. /**
  27253. * Interpolates a Vector3 linearl
  27254. * @param startValue Start value of the animation curve
  27255. * @param endValue End value of the animation curve
  27256. * @param gradient Scalar amount to interpolate
  27257. * @returns Interpolated scalar value
  27258. */
  27259. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27260. /**
  27261. * Interpolates a Vector3 cubically
  27262. * @param startValue Start value of the animation curve
  27263. * @param outTangent End tangent of the animation
  27264. * @param endValue End value of the animation curve
  27265. * @param inTangent Start tangent of the animation curve
  27266. * @param gradient Scalar amount to interpolate
  27267. * @returns InterpolatedVector3 value
  27268. */
  27269. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27270. /**
  27271. * Interpolates a Vector2 linearly
  27272. * @param startValue Start value of the animation curve
  27273. * @param endValue End value of the animation curve
  27274. * @param gradient Scalar amount to interpolate
  27275. * @returns Interpolated Vector2 value
  27276. */
  27277. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27278. /**
  27279. * Interpolates a Vector2 cubically
  27280. * @param startValue Start value of the animation curve
  27281. * @param outTangent End tangent of the animation
  27282. * @param endValue End value of the animation curve
  27283. * @param inTangent Start tangent of the animation curve
  27284. * @param gradient Scalar amount to interpolate
  27285. * @returns Interpolated Vector2 value
  27286. */
  27287. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27288. /**
  27289. * Interpolates a size linearly
  27290. * @param startValue Start value of the animation curve
  27291. * @param endValue End value of the animation curve
  27292. * @param gradient Scalar amount to interpolate
  27293. * @returns Interpolated Size value
  27294. */
  27295. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27296. /**
  27297. * Interpolates a Color3 linearly
  27298. * @param startValue Start value of the animation curve
  27299. * @param endValue End value of the animation curve
  27300. * @param gradient Scalar amount to interpolate
  27301. * @returns Interpolated Color3 value
  27302. */
  27303. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27304. /**
  27305. * @hidden Internal use only
  27306. */
  27307. _getKeyValue(value: any): any;
  27308. /**
  27309. * @hidden Internal use only
  27310. */
  27311. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27312. /**
  27313. * Defines the function to use to interpolate matrices
  27314. * @param startValue defines the start matrix
  27315. * @param endValue defines the end matrix
  27316. * @param gradient defines the gradient between both matrices
  27317. * @param result defines an optional target matrix where to store the interpolation
  27318. * @returns the interpolated matrix
  27319. */
  27320. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27321. /**
  27322. * Makes a copy of the animation
  27323. * @returns Cloned animation
  27324. */
  27325. clone(): Animation;
  27326. /**
  27327. * Sets the key frames of the animation
  27328. * @param values The animation key frames to set
  27329. */
  27330. setKeys(values: Array<IAnimationKey>): void;
  27331. /**
  27332. * Serializes the animation to an object
  27333. * @returns Serialized object
  27334. */
  27335. serialize(): any;
  27336. /**
  27337. * Float animation type
  27338. */
  27339. private static _ANIMATIONTYPE_FLOAT;
  27340. /**
  27341. * Vector3 animation type
  27342. */
  27343. private static _ANIMATIONTYPE_VECTOR3;
  27344. /**
  27345. * Quaternion animation type
  27346. */
  27347. private static _ANIMATIONTYPE_QUATERNION;
  27348. /**
  27349. * Matrix animation type
  27350. */
  27351. private static _ANIMATIONTYPE_MATRIX;
  27352. /**
  27353. * Color3 animation type
  27354. */
  27355. private static _ANIMATIONTYPE_COLOR3;
  27356. /**
  27357. * Vector2 animation type
  27358. */
  27359. private static _ANIMATIONTYPE_VECTOR2;
  27360. /**
  27361. * Size animation type
  27362. */
  27363. private static _ANIMATIONTYPE_SIZE;
  27364. /**
  27365. * Relative Loop Mode
  27366. */
  27367. private static _ANIMATIONLOOPMODE_RELATIVE;
  27368. /**
  27369. * Cycle Loop Mode
  27370. */
  27371. private static _ANIMATIONLOOPMODE_CYCLE;
  27372. /**
  27373. * Constant Loop Mode
  27374. */
  27375. private static _ANIMATIONLOOPMODE_CONSTANT;
  27376. /**
  27377. * Get the float animation type
  27378. */
  27379. static readonly ANIMATIONTYPE_FLOAT: number;
  27380. /**
  27381. * Get the Vector3 animation type
  27382. */
  27383. static readonly ANIMATIONTYPE_VECTOR3: number;
  27384. /**
  27385. * Get the Vector2 animation type
  27386. */
  27387. static readonly ANIMATIONTYPE_VECTOR2: number;
  27388. /**
  27389. * Get the Size animation type
  27390. */
  27391. static readonly ANIMATIONTYPE_SIZE: number;
  27392. /**
  27393. * Get the Quaternion animation type
  27394. */
  27395. static readonly ANIMATIONTYPE_QUATERNION: number;
  27396. /**
  27397. * Get the Matrix animation type
  27398. */
  27399. static readonly ANIMATIONTYPE_MATRIX: number;
  27400. /**
  27401. * Get the Color3 animation type
  27402. */
  27403. static readonly ANIMATIONTYPE_COLOR3: number;
  27404. /**
  27405. * Get the Relative Loop Mode
  27406. */
  27407. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27408. /**
  27409. * Get the Cycle Loop Mode
  27410. */
  27411. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27412. /**
  27413. * Get the Constant Loop Mode
  27414. */
  27415. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27416. /** @hidden */
  27417. static _UniversalLerp(left: any, right: any, amount: number): any;
  27418. /**
  27419. * Parses an animation object and creates an animation
  27420. * @param parsedAnimation Parsed animation object
  27421. * @returns Animation object
  27422. */
  27423. static Parse(parsedAnimation: any): Animation;
  27424. /**
  27425. * Appends the serialized animations from the source animations
  27426. * @param source Source containing the animations
  27427. * @param destination Target to store the animations
  27428. */
  27429. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27430. }
  27431. }
  27432. declare module BABYLON {
  27433. /**
  27434. * Interface containing an array of animations
  27435. */
  27436. export interface IAnimatable {
  27437. /**
  27438. * Array of animations
  27439. */
  27440. animations: Nullable<Array<Animation>>;
  27441. }
  27442. }
  27443. declare module BABYLON {
  27444. /**
  27445. * This represents all the required information to add a fresnel effect on a material:
  27446. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27447. */
  27448. export class FresnelParameters {
  27449. private _isEnabled;
  27450. /**
  27451. * Define if the fresnel effect is enable or not.
  27452. */
  27453. isEnabled: boolean;
  27454. /**
  27455. * Define the color used on edges (grazing angle)
  27456. */
  27457. leftColor: Color3;
  27458. /**
  27459. * Define the color used on center
  27460. */
  27461. rightColor: Color3;
  27462. /**
  27463. * Define bias applied to computed fresnel term
  27464. */
  27465. bias: number;
  27466. /**
  27467. * Defined the power exponent applied to fresnel term
  27468. */
  27469. power: number;
  27470. /**
  27471. * Clones the current fresnel and its valuues
  27472. * @returns a clone fresnel configuration
  27473. */
  27474. clone(): FresnelParameters;
  27475. /**
  27476. * Serializes the current fresnel parameters to a JSON representation.
  27477. * @return the JSON serialization
  27478. */
  27479. serialize(): any;
  27480. /**
  27481. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27482. * @param parsedFresnelParameters Define the JSON representation
  27483. * @returns the parsed parameters
  27484. */
  27485. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27486. }
  27487. }
  27488. declare module BABYLON {
  27489. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27490. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27491. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27492. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27493. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27494. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27495. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27496. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27497. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27498. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27499. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27500. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27501. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27502. /**
  27503. * Decorator used to define property that can be serialized as reference to a camera
  27504. * @param sourceName defines the name of the property to decorate
  27505. */
  27506. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27507. /**
  27508. * Class used to help serialization objects
  27509. */
  27510. export class SerializationHelper {
  27511. /** @hidden */
  27512. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27513. /** @hidden */
  27514. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27515. /** @hidden */
  27516. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27517. /** @hidden */
  27518. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27519. /**
  27520. * Appends the serialized animations from the source animations
  27521. * @param source Source containing the animations
  27522. * @param destination Target to store the animations
  27523. */
  27524. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27525. /**
  27526. * Static function used to serialized a specific entity
  27527. * @param entity defines the entity to serialize
  27528. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27529. * @returns a JSON compatible object representing the serialization of the entity
  27530. */
  27531. static Serialize<T>(entity: T, serializationObject?: any): any;
  27532. /**
  27533. * Creates a new entity from a serialization data object
  27534. * @param creationFunction defines a function used to instanciated the new entity
  27535. * @param source defines the source serialization data
  27536. * @param scene defines the hosting scene
  27537. * @param rootUrl defines the root url for resources
  27538. * @returns a new entity
  27539. */
  27540. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27541. /**
  27542. * Clones an object
  27543. * @param creationFunction defines the function used to instanciate the new object
  27544. * @param source defines the source object
  27545. * @returns the cloned object
  27546. */
  27547. static Clone<T>(creationFunction: () => T, source: T): T;
  27548. /**
  27549. * Instanciates a new object based on a source one (some data will be shared between both object)
  27550. * @param creationFunction defines the function used to instanciate the new object
  27551. * @param source defines the source object
  27552. * @returns the new object
  27553. */
  27554. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27555. }
  27556. }
  27557. declare module BABYLON {
  27558. /**
  27559. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27560. */
  27561. export interface CubeMapInfo {
  27562. /**
  27563. * The pixel array for the front face.
  27564. * This is stored in format, left to right, up to down format.
  27565. */
  27566. front: Nullable<ArrayBufferView>;
  27567. /**
  27568. * The pixel array for the back face.
  27569. * This is stored in format, left to right, up to down format.
  27570. */
  27571. back: Nullable<ArrayBufferView>;
  27572. /**
  27573. * The pixel array for the left face.
  27574. * This is stored in format, left to right, up to down format.
  27575. */
  27576. left: Nullable<ArrayBufferView>;
  27577. /**
  27578. * The pixel array for the right face.
  27579. * This is stored in format, left to right, up to down format.
  27580. */
  27581. right: Nullable<ArrayBufferView>;
  27582. /**
  27583. * The pixel array for the up face.
  27584. * This is stored in format, left to right, up to down format.
  27585. */
  27586. up: Nullable<ArrayBufferView>;
  27587. /**
  27588. * The pixel array for the down face.
  27589. * This is stored in format, left to right, up to down format.
  27590. */
  27591. down: Nullable<ArrayBufferView>;
  27592. /**
  27593. * The size of the cubemap stored.
  27594. *
  27595. * Each faces will be size * size pixels.
  27596. */
  27597. size: number;
  27598. /**
  27599. * The format of the texture.
  27600. *
  27601. * RGBA, RGB.
  27602. */
  27603. format: number;
  27604. /**
  27605. * The type of the texture data.
  27606. *
  27607. * UNSIGNED_INT, FLOAT.
  27608. */
  27609. type: number;
  27610. /**
  27611. * Specifies whether the texture is in gamma space.
  27612. */
  27613. gammaSpace: boolean;
  27614. }
  27615. /**
  27616. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27617. */
  27618. export class PanoramaToCubeMapTools {
  27619. private static FACE_FRONT;
  27620. private static FACE_BACK;
  27621. private static FACE_RIGHT;
  27622. private static FACE_LEFT;
  27623. private static FACE_DOWN;
  27624. private static FACE_UP;
  27625. /**
  27626. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27627. *
  27628. * @param float32Array The source data.
  27629. * @param inputWidth The width of the input panorama.
  27630. * @param inputHeight The height of the input panorama.
  27631. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27632. * @return The cubemap data
  27633. */
  27634. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27635. private static CreateCubemapTexture;
  27636. private static CalcProjectionSpherical;
  27637. }
  27638. }
  27639. declare module BABYLON {
  27640. /**
  27641. * Helper class dealing with the extraction of spherical polynomial dataArray
  27642. * from a cube map.
  27643. */
  27644. export class CubeMapToSphericalPolynomialTools {
  27645. private static FileFaces;
  27646. /**
  27647. * Converts a texture to the according Spherical Polynomial data.
  27648. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27649. *
  27650. * @param texture The texture to extract the information from.
  27651. * @return The Spherical Polynomial data.
  27652. */
  27653. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27654. /**
  27655. * Converts a cubemap to the according Spherical Polynomial data.
  27656. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27657. *
  27658. * @param cubeInfo The Cube map to extract the information from.
  27659. * @return The Spherical Polynomial data.
  27660. */
  27661. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27662. }
  27663. }
  27664. declare module BABYLON {
  27665. /**
  27666. * Class used to manipulate GUIDs
  27667. */
  27668. export class GUID {
  27669. /**
  27670. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27671. * Be aware Math.random() could cause collisions, but:
  27672. * "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"
  27673. * @returns a pseudo random id
  27674. */
  27675. static RandomId(): string;
  27676. }
  27677. }
  27678. declare module BABYLON {
  27679. /**
  27680. * Base class of all the textures in babylon.
  27681. * It groups all the common properties the materials, post process, lights... might need
  27682. * in order to make a correct use of the texture.
  27683. */
  27684. export class BaseTexture implements IAnimatable {
  27685. /**
  27686. * Default anisotropic filtering level for the application.
  27687. * It is set to 4 as a good tradeoff between perf and quality.
  27688. */
  27689. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27690. /**
  27691. * Gets or sets the unique id of the texture
  27692. */
  27693. uniqueId: number;
  27694. /**
  27695. * Define the name of the texture.
  27696. */
  27697. name: string;
  27698. /**
  27699. * Gets or sets an object used to store user defined information.
  27700. */
  27701. metadata: any;
  27702. /**
  27703. * For internal use only. Please do not use.
  27704. */
  27705. reservedDataStore: any;
  27706. private _hasAlpha;
  27707. /**
  27708. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27709. */
  27710. hasAlpha: boolean;
  27711. /**
  27712. * Defines if the alpha value should be determined via the rgb values.
  27713. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27714. */
  27715. getAlphaFromRGB: boolean;
  27716. /**
  27717. * Intensity or strength of the texture.
  27718. * It is commonly used by materials to fine tune the intensity of the texture
  27719. */
  27720. level: number;
  27721. /**
  27722. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27723. * This is part of the texture as textures usually maps to one uv set.
  27724. */
  27725. coordinatesIndex: number;
  27726. private _coordinatesMode;
  27727. /**
  27728. * How a texture is mapped.
  27729. *
  27730. * | Value | Type | Description |
  27731. * | ----- | ----------------------------------- | ----------- |
  27732. * | 0 | EXPLICIT_MODE | |
  27733. * | 1 | SPHERICAL_MODE | |
  27734. * | 2 | PLANAR_MODE | |
  27735. * | 3 | CUBIC_MODE | |
  27736. * | 4 | PROJECTION_MODE | |
  27737. * | 5 | SKYBOX_MODE | |
  27738. * | 6 | INVCUBIC_MODE | |
  27739. * | 7 | EQUIRECTANGULAR_MODE | |
  27740. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27741. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27742. */
  27743. coordinatesMode: number;
  27744. /**
  27745. * | Value | Type | Description |
  27746. * | ----- | ------------------ | ----------- |
  27747. * | 0 | CLAMP_ADDRESSMODE | |
  27748. * | 1 | WRAP_ADDRESSMODE | |
  27749. * | 2 | MIRROR_ADDRESSMODE | |
  27750. */
  27751. wrapU: number;
  27752. /**
  27753. * | Value | Type | Description |
  27754. * | ----- | ------------------ | ----------- |
  27755. * | 0 | CLAMP_ADDRESSMODE | |
  27756. * | 1 | WRAP_ADDRESSMODE | |
  27757. * | 2 | MIRROR_ADDRESSMODE | |
  27758. */
  27759. wrapV: number;
  27760. /**
  27761. * | Value | Type | Description |
  27762. * | ----- | ------------------ | ----------- |
  27763. * | 0 | CLAMP_ADDRESSMODE | |
  27764. * | 1 | WRAP_ADDRESSMODE | |
  27765. * | 2 | MIRROR_ADDRESSMODE | |
  27766. */
  27767. wrapR: number;
  27768. /**
  27769. * With compliant hardware and browser (supporting anisotropic filtering)
  27770. * this defines the level of anisotropic filtering in the texture.
  27771. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27772. */
  27773. anisotropicFilteringLevel: number;
  27774. /**
  27775. * Define if the texture is a cube texture or if false a 2d texture.
  27776. */
  27777. isCube: boolean;
  27778. /**
  27779. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27780. */
  27781. is3D: boolean;
  27782. /**
  27783. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27784. * HDR texture are usually stored in linear space.
  27785. * This only impacts the PBR and Background materials
  27786. */
  27787. gammaSpace: boolean;
  27788. /**
  27789. * Gets or sets whether or not the texture contains RGBD data.
  27790. */
  27791. isRGBD: boolean;
  27792. /**
  27793. * Is Z inverted in the texture (useful in a cube texture).
  27794. */
  27795. invertZ: boolean;
  27796. /**
  27797. * Are mip maps generated for this texture or not.
  27798. */
  27799. readonly noMipmap: boolean;
  27800. /**
  27801. * @hidden
  27802. */
  27803. lodLevelInAlpha: boolean;
  27804. /**
  27805. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27806. */
  27807. lodGenerationOffset: number;
  27808. /**
  27809. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27810. */
  27811. lodGenerationScale: number;
  27812. /**
  27813. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27814. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27815. * average roughness values.
  27816. */
  27817. linearSpecularLOD: boolean;
  27818. /**
  27819. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27820. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27821. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27822. */
  27823. irradianceTexture: Nullable<BaseTexture>;
  27824. /**
  27825. * Define if the texture is a render target.
  27826. */
  27827. isRenderTarget: boolean;
  27828. /**
  27829. * Define the unique id of the texture in the scene.
  27830. */
  27831. readonly uid: string;
  27832. /**
  27833. * Return a string representation of the texture.
  27834. * @returns the texture as a string
  27835. */
  27836. toString(): string;
  27837. /**
  27838. * Get the class name of the texture.
  27839. * @returns "BaseTexture"
  27840. */
  27841. getClassName(): string;
  27842. /**
  27843. * Define the list of animation attached to the texture.
  27844. */
  27845. animations: Animation[];
  27846. /**
  27847. * An event triggered when the texture is disposed.
  27848. */
  27849. onDisposeObservable: Observable<BaseTexture>;
  27850. private _onDisposeObserver;
  27851. /**
  27852. * Callback triggered when the texture has been disposed.
  27853. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27854. */
  27855. onDispose: () => void;
  27856. /**
  27857. * Define the current state of the loading sequence when in delayed load mode.
  27858. */
  27859. delayLoadState: number;
  27860. private _scene;
  27861. /** @hidden */
  27862. _texture: Nullable<InternalTexture>;
  27863. private _uid;
  27864. /**
  27865. * Define if the texture is preventinga material to render or not.
  27866. * If not and the texture is not ready, the engine will use a default black texture instead.
  27867. */
  27868. readonly isBlocking: boolean;
  27869. /**
  27870. * Instantiates a new BaseTexture.
  27871. * Base class of all the textures in babylon.
  27872. * It groups all the common properties the materials, post process, lights... might need
  27873. * in order to make a correct use of the texture.
  27874. * @param scene Define the scene the texture blongs to
  27875. */
  27876. constructor(scene: Nullable<Scene>);
  27877. /**
  27878. * Get the scene the texture belongs to.
  27879. * @returns the scene or null if undefined
  27880. */
  27881. getScene(): Nullable<Scene>;
  27882. /**
  27883. * Get the texture transform matrix used to offset tile the texture for istance.
  27884. * @returns the transformation matrix
  27885. */
  27886. getTextureMatrix(): Matrix;
  27887. /**
  27888. * Get the texture reflection matrix used to rotate/transform the reflection.
  27889. * @returns the reflection matrix
  27890. */
  27891. getReflectionTextureMatrix(): Matrix;
  27892. /**
  27893. * Get the underlying lower level texture from Babylon.
  27894. * @returns the insternal texture
  27895. */
  27896. getInternalTexture(): Nullable<InternalTexture>;
  27897. /**
  27898. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27899. * @returns true if ready or not blocking
  27900. */
  27901. isReadyOrNotBlocking(): boolean;
  27902. /**
  27903. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27904. * @returns true if fully ready
  27905. */
  27906. isReady(): boolean;
  27907. private _cachedSize;
  27908. /**
  27909. * Get the size of the texture.
  27910. * @returns the texture size.
  27911. */
  27912. getSize(): ISize;
  27913. /**
  27914. * Get the base size of the texture.
  27915. * It can be different from the size if the texture has been resized for POT for instance
  27916. * @returns the base size
  27917. */
  27918. getBaseSize(): ISize;
  27919. /**
  27920. * Update the sampling mode of the texture.
  27921. * Default is Trilinear mode.
  27922. *
  27923. * | Value | Type | Description |
  27924. * | ----- | ------------------ | ----------- |
  27925. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27926. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27927. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27928. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27929. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27930. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27931. * | 7 | NEAREST_LINEAR | |
  27932. * | 8 | NEAREST_NEAREST | |
  27933. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27934. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27935. * | 11 | LINEAR_LINEAR | |
  27936. * | 12 | LINEAR_NEAREST | |
  27937. *
  27938. * > _mag_: magnification filter (close to the viewer)
  27939. * > _min_: minification filter (far from the viewer)
  27940. * > _mip_: filter used between mip map levels
  27941. *@param samplingMode Define the new sampling mode of the texture
  27942. */
  27943. updateSamplingMode(samplingMode: number): void;
  27944. /**
  27945. * Scales the texture if is `canRescale()`
  27946. * @param ratio the resize factor we want to use to rescale
  27947. */
  27948. scale(ratio: number): void;
  27949. /**
  27950. * Get if the texture can rescale.
  27951. */
  27952. readonly canRescale: boolean;
  27953. /** @hidden */
  27954. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27955. /** @hidden */
  27956. _rebuild(): void;
  27957. /**
  27958. * Triggers the load sequence in delayed load mode.
  27959. */
  27960. delayLoad(): void;
  27961. /**
  27962. * Clones the texture.
  27963. * @returns the cloned texture
  27964. */
  27965. clone(): Nullable<BaseTexture>;
  27966. /**
  27967. * Get the texture underlying type (INT, FLOAT...)
  27968. */
  27969. readonly textureType: number;
  27970. /**
  27971. * Get the texture underlying format (RGB, RGBA...)
  27972. */
  27973. readonly textureFormat: number;
  27974. /**
  27975. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27976. * This will returns an RGBA array buffer containing either in values (0-255) or
  27977. * float values (0-1) depending of the underlying buffer type.
  27978. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27979. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27980. * @param buffer defines a user defined buffer to fill with data (can be null)
  27981. * @returns The Array buffer containing the pixels data.
  27982. */
  27983. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27984. /**
  27985. * Release and destroy the underlying lower level texture aka internalTexture.
  27986. */
  27987. releaseInternalTexture(): void;
  27988. /**
  27989. * Get the polynomial representation of the texture data.
  27990. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27991. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27992. */
  27993. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27994. /** @hidden */
  27995. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27996. /** @hidden */
  27997. readonly _lodTextureMid: Nullable<BaseTexture>;
  27998. /** @hidden */
  27999. readonly _lodTextureLow: Nullable<BaseTexture>;
  28000. /**
  28001. * Dispose the texture and release its associated resources.
  28002. */
  28003. dispose(): void;
  28004. /**
  28005. * Serialize the texture into a JSON representation that can be parsed later on.
  28006. * @returns the JSON representation of the texture
  28007. */
  28008. serialize(): any;
  28009. /**
  28010. * Helper function to be called back once a list of texture contains only ready textures.
  28011. * @param textures Define the list of textures to wait for
  28012. * @param callback Define the callback triggered once the entire list will be ready
  28013. */
  28014. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28015. }
  28016. }
  28017. declare module BABYLON {
  28018. /**
  28019. * Class used to store data associated with WebGL texture data for the engine
  28020. * This class should not be used directly
  28021. */
  28022. export class InternalTexture {
  28023. /** @hidden */
  28024. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28025. /**
  28026. * The source of the texture data is unknown
  28027. */
  28028. static DATASOURCE_UNKNOWN: number;
  28029. /**
  28030. * Texture data comes from an URL
  28031. */
  28032. static DATASOURCE_URL: number;
  28033. /**
  28034. * Texture data is only used for temporary storage
  28035. */
  28036. static DATASOURCE_TEMP: number;
  28037. /**
  28038. * Texture data comes from raw data (ArrayBuffer)
  28039. */
  28040. static DATASOURCE_RAW: number;
  28041. /**
  28042. * Texture content is dynamic (video or dynamic texture)
  28043. */
  28044. static DATASOURCE_DYNAMIC: number;
  28045. /**
  28046. * Texture content is generated by rendering to it
  28047. */
  28048. static DATASOURCE_RENDERTARGET: number;
  28049. /**
  28050. * Texture content is part of a multi render target process
  28051. */
  28052. static DATASOURCE_MULTIRENDERTARGET: number;
  28053. /**
  28054. * Texture data comes from a cube data file
  28055. */
  28056. static DATASOURCE_CUBE: number;
  28057. /**
  28058. * Texture data comes from a raw cube data
  28059. */
  28060. static DATASOURCE_CUBERAW: number;
  28061. /**
  28062. * Texture data come from a prefiltered cube data file
  28063. */
  28064. static DATASOURCE_CUBEPREFILTERED: number;
  28065. /**
  28066. * Texture content is raw 3D data
  28067. */
  28068. static DATASOURCE_RAW3D: number;
  28069. /**
  28070. * Texture content is a depth texture
  28071. */
  28072. static DATASOURCE_DEPTHTEXTURE: number;
  28073. /**
  28074. * Texture data comes from a raw cube data encoded with RGBD
  28075. */
  28076. static DATASOURCE_CUBERAW_RGBD: number;
  28077. /**
  28078. * Defines if the texture is ready
  28079. */
  28080. isReady: boolean;
  28081. /**
  28082. * Defines if the texture is a cube texture
  28083. */
  28084. isCube: boolean;
  28085. /**
  28086. * Defines if the texture contains 3D data
  28087. */
  28088. is3D: boolean;
  28089. /**
  28090. * Defines if the texture contains multiview data
  28091. */
  28092. isMultiview: boolean;
  28093. /**
  28094. * Gets the URL used to load this texture
  28095. */
  28096. url: string;
  28097. /**
  28098. * Gets the sampling mode of the texture
  28099. */
  28100. samplingMode: number;
  28101. /**
  28102. * Gets a boolean indicating if the texture needs mipmaps generation
  28103. */
  28104. generateMipMaps: boolean;
  28105. /**
  28106. * Gets the number of samples used by the texture (WebGL2+ only)
  28107. */
  28108. samples: number;
  28109. /**
  28110. * Gets the type of the texture (int, float...)
  28111. */
  28112. type: number;
  28113. /**
  28114. * Gets the format of the texture (RGB, RGBA...)
  28115. */
  28116. format: number;
  28117. /**
  28118. * Observable called when the texture is loaded
  28119. */
  28120. onLoadedObservable: Observable<InternalTexture>;
  28121. /**
  28122. * Gets the width of the texture
  28123. */
  28124. width: number;
  28125. /**
  28126. * Gets the height of the texture
  28127. */
  28128. height: number;
  28129. /**
  28130. * Gets the depth of the texture
  28131. */
  28132. depth: number;
  28133. /**
  28134. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28135. */
  28136. baseWidth: number;
  28137. /**
  28138. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28139. */
  28140. baseHeight: number;
  28141. /**
  28142. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28143. */
  28144. baseDepth: number;
  28145. /**
  28146. * Gets a boolean indicating if the texture is inverted on Y axis
  28147. */
  28148. invertY: boolean;
  28149. /** @hidden */
  28150. _invertVScale: boolean;
  28151. /** @hidden */
  28152. _associatedChannel: number;
  28153. /** @hidden */
  28154. _dataSource: number;
  28155. /** @hidden */
  28156. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  28157. /** @hidden */
  28158. _bufferView: Nullable<ArrayBufferView>;
  28159. /** @hidden */
  28160. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28161. /** @hidden */
  28162. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28163. /** @hidden */
  28164. _size: number;
  28165. /** @hidden */
  28166. _extension: string;
  28167. /** @hidden */
  28168. _files: Nullable<string[]>;
  28169. /** @hidden */
  28170. _workingCanvas: Nullable<HTMLCanvasElement>;
  28171. /** @hidden */
  28172. _workingContext: Nullable<CanvasRenderingContext2D>;
  28173. /** @hidden */
  28174. _framebuffer: Nullable<WebGLFramebuffer>;
  28175. /** @hidden */
  28176. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28177. /** @hidden */
  28178. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28179. /** @hidden */
  28180. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28181. /** @hidden */
  28182. _attachments: Nullable<number[]>;
  28183. /** @hidden */
  28184. _cachedCoordinatesMode: Nullable<number>;
  28185. /** @hidden */
  28186. _cachedWrapU: Nullable<number>;
  28187. /** @hidden */
  28188. _cachedWrapV: Nullable<number>;
  28189. /** @hidden */
  28190. _cachedWrapR: Nullable<number>;
  28191. /** @hidden */
  28192. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28193. /** @hidden */
  28194. _isDisabled: boolean;
  28195. /** @hidden */
  28196. _compression: Nullable<string>;
  28197. /** @hidden */
  28198. _generateStencilBuffer: boolean;
  28199. /** @hidden */
  28200. _generateDepthBuffer: boolean;
  28201. /** @hidden */
  28202. _comparisonFunction: number;
  28203. /** @hidden */
  28204. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28205. /** @hidden */
  28206. _lodGenerationScale: number;
  28207. /** @hidden */
  28208. _lodGenerationOffset: number;
  28209. /** @hidden */
  28210. _colorTextureArray: Nullable<WebGLTexture>;
  28211. /** @hidden */
  28212. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28213. /** @hidden */
  28214. _lodTextureHigh: Nullable<BaseTexture>;
  28215. /** @hidden */
  28216. _lodTextureMid: Nullable<BaseTexture>;
  28217. /** @hidden */
  28218. _lodTextureLow: Nullable<BaseTexture>;
  28219. /** @hidden */
  28220. _isRGBD: boolean;
  28221. /** @hidden */
  28222. _linearSpecularLOD: boolean;
  28223. /** @hidden */
  28224. _irradianceTexture: Nullable<BaseTexture>;
  28225. /** @hidden */
  28226. _webGLTexture: Nullable<WebGLTexture>;
  28227. /** @hidden */
  28228. _references: number;
  28229. private _engine;
  28230. /**
  28231. * Gets the Engine the texture belongs to.
  28232. * @returns The babylon engine
  28233. */
  28234. getEngine(): Engine;
  28235. /**
  28236. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28237. */
  28238. readonly dataSource: number;
  28239. /**
  28240. * Creates a new InternalTexture
  28241. * @param engine defines the engine to use
  28242. * @param dataSource defines the type of data that will be used
  28243. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28244. */
  28245. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28246. /**
  28247. * Increments the number of references (ie. the number of Texture that point to it)
  28248. */
  28249. incrementReferences(): void;
  28250. /**
  28251. * Change the size of the texture (not the size of the content)
  28252. * @param width defines the new width
  28253. * @param height defines the new height
  28254. * @param depth defines the new depth (1 by default)
  28255. */
  28256. updateSize(width: int, height: int, depth?: int): void;
  28257. /** @hidden */
  28258. _rebuild(): void;
  28259. /** @hidden */
  28260. _swapAndDie(target: InternalTexture): void;
  28261. /**
  28262. * Dispose the current allocated resources
  28263. */
  28264. dispose(): void;
  28265. }
  28266. }
  28267. declare module BABYLON {
  28268. /**
  28269. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28270. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28271. */
  28272. export class EffectFallbacks {
  28273. private _defines;
  28274. private _currentRank;
  28275. private _maxRank;
  28276. private _mesh;
  28277. /**
  28278. * Removes the fallback from the bound mesh.
  28279. */
  28280. unBindMesh(): void;
  28281. /**
  28282. * Adds a fallback on the specified property.
  28283. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28284. * @param define The name of the define in the shader
  28285. */
  28286. addFallback(rank: number, define: string): void;
  28287. /**
  28288. * Sets the mesh to use CPU skinning when needing to fallback.
  28289. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28290. * @param mesh The mesh to use the fallbacks.
  28291. */
  28292. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28293. /**
  28294. * Checks to see if more fallbacks are still availible.
  28295. */
  28296. readonly hasMoreFallbacks: boolean;
  28297. /**
  28298. * Removes the defines that should be removed when falling back.
  28299. * @param currentDefines defines the current define statements for the shader.
  28300. * @param effect defines the current effect we try to compile
  28301. * @returns The resulting defines with defines of the current rank removed.
  28302. */
  28303. reduce(currentDefines: string, effect: Effect): string;
  28304. }
  28305. /**
  28306. * Options to be used when creating an effect.
  28307. */
  28308. export class EffectCreationOptions {
  28309. /**
  28310. * Atrributes that will be used in the shader.
  28311. */
  28312. attributes: string[];
  28313. /**
  28314. * Uniform varible names that will be set in the shader.
  28315. */
  28316. uniformsNames: string[];
  28317. /**
  28318. * Uniform buffer varible names that will be set in the shader.
  28319. */
  28320. uniformBuffersNames: string[];
  28321. /**
  28322. * Sampler texture variable names that will be set in the shader.
  28323. */
  28324. samplers: string[];
  28325. /**
  28326. * Define statements that will be set in the shader.
  28327. */
  28328. defines: any;
  28329. /**
  28330. * Possible fallbacks for this effect to improve performance when needed.
  28331. */
  28332. fallbacks: Nullable<EffectFallbacks>;
  28333. /**
  28334. * Callback that will be called when the shader is compiled.
  28335. */
  28336. onCompiled: Nullable<(effect: Effect) => void>;
  28337. /**
  28338. * Callback that will be called if an error occurs during shader compilation.
  28339. */
  28340. onError: Nullable<(effect: Effect, errors: string) => void>;
  28341. /**
  28342. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28343. */
  28344. indexParameters: any;
  28345. /**
  28346. * Max number of lights that can be used in the shader.
  28347. */
  28348. maxSimultaneousLights: number;
  28349. /**
  28350. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28351. */
  28352. transformFeedbackVaryings: Nullable<string[]>;
  28353. }
  28354. /**
  28355. * Effect containing vertex and fragment shader that can be executed on an object.
  28356. */
  28357. export class Effect implements IDisposable {
  28358. /**
  28359. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28360. */
  28361. static ShadersRepository: string;
  28362. /**
  28363. * Name of the effect.
  28364. */
  28365. name: any;
  28366. /**
  28367. * String container all the define statements that should be set on the shader.
  28368. */
  28369. defines: string;
  28370. /**
  28371. * Callback that will be called when the shader is compiled.
  28372. */
  28373. onCompiled: Nullable<(effect: Effect) => void>;
  28374. /**
  28375. * Callback that will be called if an error occurs during shader compilation.
  28376. */
  28377. onError: Nullable<(effect: Effect, errors: string) => void>;
  28378. /**
  28379. * Callback that will be called when effect is bound.
  28380. */
  28381. onBind: Nullable<(effect: Effect) => void>;
  28382. /**
  28383. * Unique ID of the effect.
  28384. */
  28385. uniqueId: number;
  28386. /**
  28387. * Observable that will be called when the shader is compiled.
  28388. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28389. */
  28390. onCompileObservable: Observable<Effect>;
  28391. /**
  28392. * Observable that will be called if an error occurs during shader compilation.
  28393. */
  28394. onErrorObservable: Observable<Effect>;
  28395. /** @hidden */
  28396. _onBindObservable: Nullable<Observable<Effect>>;
  28397. /**
  28398. * Observable that will be called when effect is bound.
  28399. */
  28400. readonly onBindObservable: Observable<Effect>;
  28401. /** @hidden */
  28402. _bonesComputationForcedToCPU: boolean;
  28403. private static _uniqueIdSeed;
  28404. private _engine;
  28405. private _uniformBuffersNames;
  28406. private _uniformsNames;
  28407. private _samplerList;
  28408. private _samplers;
  28409. private _isReady;
  28410. private _compilationError;
  28411. private _attributesNames;
  28412. private _attributes;
  28413. private _uniforms;
  28414. /**
  28415. * Key for the effect.
  28416. * @hidden
  28417. */
  28418. _key: string;
  28419. private _indexParameters;
  28420. private _fallbacks;
  28421. private _vertexSourceCode;
  28422. private _fragmentSourceCode;
  28423. private _vertexSourceCodeOverride;
  28424. private _fragmentSourceCodeOverride;
  28425. private _transformFeedbackVaryings;
  28426. /**
  28427. * Compiled shader to webGL program.
  28428. * @hidden
  28429. */
  28430. _pipelineContext: Nullable<IPipelineContext>;
  28431. private _valueCache;
  28432. private static _baseCache;
  28433. /**
  28434. * Instantiates an effect.
  28435. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28436. * @param baseName Name of the effect.
  28437. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28438. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28439. * @param samplers List of sampler variables that will be passed to the shader.
  28440. * @param engine Engine to be used to render the effect
  28441. * @param defines Define statements to be added to the shader.
  28442. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28443. * @param onCompiled Callback that will be called when the shader is compiled.
  28444. * @param onError Callback that will be called if an error occurs during shader compilation.
  28445. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28446. */
  28447. 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);
  28448. private _useFinalCode;
  28449. /**
  28450. * Unique key for this effect
  28451. */
  28452. readonly key: string;
  28453. /**
  28454. * If the effect has been compiled and prepared.
  28455. * @returns if the effect is compiled and prepared.
  28456. */
  28457. isReady(): boolean;
  28458. private _isReadyInternal;
  28459. /**
  28460. * The engine the effect was initialized with.
  28461. * @returns the engine.
  28462. */
  28463. getEngine(): Engine;
  28464. /**
  28465. * The pipeline context for this effect
  28466. * @returns the associated pipeline context
  28467. */
  28468. getPipelineContext(): Nullable<IPipelineContext>;
  28469. /**
  28470. * The set of names of attribute variables for the shader.
  28471. * @returns An array of attribute names.
  28472. */
  28473. getAttributesNames(): string[];
  28474. /**
  28475. * Returns the attribute at the given index.
  28476. * @param index The index of the attribute.
  28477. * @returns The location of the attribute.
  28478. */
  28479. getAttributeLocation(index: number): number;
  28480. /**
  28481. * Returns the attribute based on the name of the variable.
  28482. * @param name of the attribute to look up.
  28483. * @returns the attribute location.
  28484. */
  28485. getAttributeLocationByName(name: string): number;
  28486. /**
  28487. * The number of attributes.
  28488. * @returns the numnber of attributes.
  28489. */
  28490. getAttributesCount(): number;
  28491. /**
  28492. * Gets the index of a uniform variable.
  28493. * @param uniformName of the uniform to look up.
  28494. * @returns the index.
  28495. */
  28496. getUniformIndex(uniformName: string): number;
  28497. /**
  28498. * Returns the attribute based on the name of the variable.
  28499. * @param uniformName of the uniform to look up.
  28500. * @returns the location of the uniform.
  28501. */
  28502. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28503. /**
  28504. * Returns an array of sampler variable names
  28505. * @returns The array of sampler variable neames.
  28506. */
  28507. getSamplers(): string[];
  28508. /**
  28509. * The error from the last compilation.
  28510. * @returns the error string.
  28511. */
  28512. getCompilationError(): string;
  28513. /**
  28514. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28515. * @param func The callback to be used.
  28516. */
  28517. executeWhenCompiled(func: (effect: Effect) => void): void;
  28518. private _checkIsReady;
  28519. /** @hidden */
  28520. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28521. /** @hidden */
  28522. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28523. /** @hidden */
  28524. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28525. /**
  28526. * Recompiles the webGL program
  28527. * @param vertexSourceCode The source code for the vertex shader.
  28528. * @param fragmentSourceCode The source code for the fragment shader.
  28529. * @param onCompiled Callback called when completed.
  28530. * @param onError Callback called on error.
  28531. * @hidden
  28532. */
  28533. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28534. /**
  28535. * Prepares the effect
  28536. * @hidden
  28537. */
  28538. _prepareEffect(): void;
  28539. private _processCompilationErrors;
  28540. /**
  28541. * Checks if the effect is supported. (Must be called after compilation)
  28542. */
  28543. readonly isSupported: boolean;
  28544. /**
  28545. * Binds a texture to the engine to be used as output of the shader.
  28546. * @param channel Name of the output variable.
  28547. * @param texture Texture to bind.
  28548. * @hidden
  28549. */
  28550. _bindTexture(channel: string, texture: InternalTexture): void;
  28551. /**
  28552. * Sets a texture on the engine to be used in the shader.
  28553. * @param channel Name of the sampler variable.
  28554. * @param texture Texture to set.
  28555. */
  28556. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28557. /**
  28558. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28559. * @param channel Name of the sampler variable.
  28560. * @param texture Texture to set.
  28561. */
  28562. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28563. /**
  28564. * Sets an array of textures on the engine to be used in the shader.
  28565. * @param channel Name of the variable.
  28566. * @param textures Textures to set.
  28567. */
  28568. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28569. /**
  28570. * 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)
  28571. * @param channel Name of the sampler variable.
  28572. * @param postProcess Post process to get the input texture from.
  28573. */
  28574. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28575. /**
  28576. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28577. * 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)
  28578. * @param channel Name of the sampler variable.
  28579. * @param postProcess Post process to get the output texture from.
  28580. */
  28581. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28582. /** @hidden */
  28583. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28584. /** @hidden */
  28585. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28586. /** @hidden */
  28587. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28588. /** @hidden */
  28589. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28590. /**
  28591. * Binds a buffer to a uniform.
  28592. * @param buffer Buffer to bind.
  28593. * @param name Name of the uniform variable to bind to.
  28594. */
  28595. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28596. /**
  28597. * Binds block to a uniform.
  28598. * @param blockName Name of the block to bind.
  28599. * @param index Index to bind.
  28600. */
  28601. bindUniformBlock(blockName: string, index: number): void;
  28602. /**
  28603. * Sets an interger value on a uniform variable.
  28604. * @param uniformName Name of the variable.
  28605. * @param value Value to be set.
  28606. * @returns this effect.
  28607. */
  28608. setInt(uniformName: string, value: number): Effect;
  28609. /**
  28610. * Sets an int array on a uniform variable.
  28611. * @param uniformName Name of the variable.
  28612. * @param array array to be set.
  28613. * @returns this effect.
  28614. */
  28615. setIntArray(uniformName: string, array: Int32Array): Effect;
  28616. /**
  28617. * 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)
  28618. * @param uniformName Name of the variable.
  28619. * @param array array to be set.
  28620. * @returns this effect.
  28621. */
  28622. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28623. /**
  28624. * 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)
  28625. * @param uniformName Name of the variable.
  28626. * @param array array to be set.
  28627. * @returns this effect.
  28628. */
  28629. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28630. /**
  28631. * 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)
  28632. * @param uniformName Name of the variable.
  28633. * @param array array to be set.
  28634. * @returns this effect.
  28635. */
  28636. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28637. /**
  28638. * Sets an float array on a uniform variable.
  28639. * @param uniformName Name of the variable.
  28640. * @param array array to be set.
  28641. * @returns this effect.
  28642. */
  28643. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28644. /**
  28645. * 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)
  28646. * @param uniformName Name of the variable.
  28647. * @param array array to be set.
  28648. * @returns this effect.
  28649. */
  28650. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28651. /**
  28652. * 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)
  28653. * @param uniformName Name of the variable.
  28654. * @param array array to be set.
  28655. * @returns this effect.
  28656. */
  28657. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28658. /**
  28659. * 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)
  28660. * @param uniformName Name of the variable.
  28661. * @param array array to be set.
  28662. * @returns this effect.
  28663. */
  28664. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28665. /**
  28666. * Sets an array on a uniform variable.
  28667. * @param uniformName Name of the variable.
  28668. * @param array array to be set.
  28669. * @returns this effect.
  28670. */
  28671. setArray(uniformName: string, array: number[]): Effect;
  28672. /**
  28673. * 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)
  28674. * @param uniformName Name of the variable.
  28675. * @param array array to be set.
  28676. * @returns this effect.
  28677. */
  28678. setArray2(uniformName: string, array: number[]): Effect;
  28679. /**
  28680. * 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)
  28681. * @param uniformName Name of the variable.
  28682. * @param array array to be set.
  28683. * @returns this effect.
  28684. */
  28685. setArray3(uniformName: string, array: number[]): Effect;
  28686. /**
  28687. * 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)
  28688. * @param uniformName Name of the variable.
  28689. * @param array array to be set.
  28690. * @returns this effect.
  28691. */
  28692. setArray4(uniformName: string, array: number[]): Effect;
  28693. /**
  28694. * Sets matrices on a uniform variable.
  28695. * @param uniformName Name of the variable.
  28696. * @param matrices matrices to be set.
  28697. * @returns this effect.
  28698. */
  28699. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28700. /**
  28701. * Sets matrix on a uniform variable.
  28702. * @param uniformName Name of the variable.
  28703. * @param matrix matrix to be set.
  28704. * @returns this effect.
  28705. */
  28706. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28707. /**
  28708. * 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)
  28709. * @param uniformName Name of the variable.
  28710. * @param matrix matrix to be set.
  28711. * @returns this effect.
  28712. */
  28713. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28714. /**
  28715. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28716. * @param uniformName Name of the variable.
  28717. * @param matrix matrix to be set.
  28718. * @returns this effect.
  28719. */
  28720. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28721. /**
  28722. * Sets a float on a uniform variable.
  28723. * @param uniformName Name of the variable.
  28724. * @param value value to be set.
  28725. * @returns this effect.
  28726. */
  28727. setFloat(uniformName: string, value: number): Effect;
  28728. /**
  28729. * Sets a boolean on a uniform variable.
  28730. * @param uniformName Name of the variable.
  28731. * @param bool value to be set.
  28732. * @returns this effect.
  28733. */
  28734. setBool(uniformName: string, bool: boolean): Effect;
  28735. /**
  28736. * Sets a Vector2 on a uniform variable.
  28737. * @param uniformName Name of the variable.
  28738. * @param vector2 vector2 to be set.
  28739. * @returns this effect.
  28740. */
  28741. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28742. /**
  28743. * Sets a float2 on a uniform variable.
  28744. * @param uniformName Name of the variable.
  28745. * @param x First float in float2.
  28746. * @param y Second float in float2.
  28747. * @returns this effect.
  28748. */
  28749. setFloat2(uniformName: string, x: number, y: number): Effect;
  28750. /**
  28751. * Sets a Vector3 on a uniform variable.
  28752. * @param uniformName Name of the variable.
  28753. * @param vector3 Value to be set.
  28754. * @returns this effect.
  28755. */
  28756. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28757. /**
  28758. * Sets a float3 on a uniform variable.
  28759. * @param uniformName Name of the variable.
  28760. * @param x First float in float3.
  28761. * @param y Second float in float3.
  28762. * @param z Third float in float3.
  28763. * @returns this effect.
  28764. */
  28765. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28766. /**
  28767. * Sets a Vector4 on a uniform variable.
  28768. * @param uniformName Name of the variable.
  28769. * @param vector4 Value to be set.
  28770. * @returns this effect.
  28771. */
  28772. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28773. /**
  28774. * Sets a float4 on a uniform variable.
  28775. * @param uniformName Name of the variable.
  28776. * @param x First float in float4.
  28777. * @param y Second float in float4.
  28778. * @param z Third float in float4.
  28779. * @param w Fourth float in float4.
  28780. * @returns this effect.
  28781. */
  28782. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28783. /**
  28784. * Sets a Color3 on a uniform variable.
  28785. * @param uniformName Name of the variable.
  28786. * @param color3 Value to be set.
  28787. * @returns this effect.
  28788. */
  28789. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28790. /**
  28791. * Sets a Color4 on a uniform variable.
  28792. * @param uniformName Name of the variable.
  28793. * @param color3 Value to be set.
  28794. * @param alpha Alpha value to be set.
  28795. * @returns this effect.
  28796. */
  28797. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28798. /**
  28799. * Sets a Color4 on a uniform variable
  28800. * @param uniformName defines the name of the variable
  28801. * @param color4 defines the value to be set
  28802. * @returns this effect.
  28803. */
  28804. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28805. /** Release all associated resources */
  28806. dispose(): void;
  28807. /**
  28808. * This function will add a new shader to the shader store
  28809. * @param name the name of the shader
  28810. * @param pixelShader optional pixel shader content
  28811. * @param vertexShader optional vertex shader content
  28812. */
  28813. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28814. /**
  28815. * Store of each shader (The can be looked up using effect.key)
  28816. */
  28817. static ShadersStore: {
  28818. [key: string]: string;
  28819. };
  28820. /**
  28821. * Store of each included file for a shader (The can be looked up using effect.key)
  28822. */
  28823. static IncludesShadersStore: {
  28824. [key: string]: string;
  28825. };
  28826. /**
  28827. * Resets the cache of effects.
  28828. */
  28829. static ResetCache(): void;
  28830. }
  28831. }
  28832. declare module BABYLON {
  28833. /**
  28834. * Uniform buffer objects.
  28835. *
  28836. * Handles blocks of uniform on the GPU.
  28837. *
  28838. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28839. *
  28840. * For more information, please refer to :
  28841. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28842. */
  28843. export class UniformBuffer {
  28844. private _engine;
  28845. private _buffer;
  28846. private _data;
  28847. private _bufferData;
  28848. private _dynamic?;
  28849. private _uniformLocations;
  28850. private _uniformSizes;
  28851. private _uniformLocationPointer;
  28852. private _needSync;
  28853. private _noUBO;
  28854. private _currentEffect;
  28855. private static _MAX_UNIFORM_SIZE;
  28856. private static _tempBuffer;
  28857. /**
  28858. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  28859. * This is dynamic to allow compat with webgl 1 and 2.
  28860. * You will need to pass the name of the uniform as well as the value.
  28861. */
  28862. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  28863. /**
  28864. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  28865. * This is dynamic to allow compat with webgl 1 and 2.
  28866. * You will need to pass the name of the uniform as well as the value.
  28867. */
  28868. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  28869. /**
  28870. * Lambda to Update a single float in a uniform buffer.
  28871. * This is dynamic to allow compat with webgl 1 and 2.
  28872. * You will need to pass the name of the uniform as well as the value.
  28873. */
  28874. updateFloat: (name: string, x: number) => void;
  28875. /**
  28876. * Lambda to Update a vec2 of float in a uniform buffer.
  28877. * This is dynamic to allow compat with webgl 1 and 2.
  28878. * You will need to pass the name of the uniform as well as the value.
  28879. */
  28880. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  28881. /**
  28882. * Lambda to Update a vec3 of float in a uniform buffer.
  28883. * This is dynamic to allow compat with webgl 1 and 2.
  28884. * You will need to pass the name of the uniform as well as the value.
  28885. */
  28886. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  28887. /**
  28888. * Lambda to Update a vec4 of float in a uniform buffer.
  28889. * This is dynamic to allow compat with webgl 1 and 2.
  28890. * You will need to pass the name of the uniform as well as the value.
  28891. */
  28892. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  28893. /**
  28894. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  28895. * This is dynamic to allow compat with webgl 1 and 2.
  28896. * You will need to pass the name of the uniform as well as the value.
  28897. */
  28898. updateMatrix: (name: string, mat: Matrix) => void;
  28899. /**
  28900. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  28901. * This is dynamic to allow compat with webgl 1 and 2.
  28902. * You will need to pass the name of the uniform as well as the value.
  28903. */
  28904. updateVector3: (name: string, vector: Vector3) => void;
  28905. /**
  28906. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  28907. * This is dynamic to allow compat with webgl 1 and 2.
  28908. * You will need to pass the name of the uniform as well as the value.
  28909. */
  28910. updateVector4: (name: string, vector: Vector4) => void;
  28911. /**
  28912. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  28913. * This is dynamic to allow compat with webgl 1 and 2.
  28914. * You will need to pass the name of the uniform as well as the value.
  28915. */
  28916. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  28917. /**
  28918. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  28919. * This is dynamic to allow compat with webgl 1 and 2.
  28920. * You will need to pass the name of the uniform as well as the value.
  28921. */
  28922. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  28923. /**
  28924. * Instantiates a new Uniform buffer objects.
  28925. *
  28926. * Handles blocks of uniform on the GPU.
  28927. *
  28928. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28929. *
  28930. * For more information, please refer to :
  28931. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28932. * @param engine Define the engine the buffer is associated with
  28933. * @param data Define the data contained in the buffer
  28934. * @param dynamic Define if the buffer is updatable
  28935. */
  28936. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  28937. /**
  28938. * Indicates if the buffer is using the WebGL2 UBO implementation,
  28939. * or just falling back on setUniformXXX calls.
  28940. */
  28941. readonly useUbo: boolean;
  28942. /**
  28943. * Indicates if the WebGL underlying uniform buffer is in sync
  28944. * with the javascript cache data.
  28945. */
  28946. readonly isSync: boolean;
  28947. /**
  28948. * Indicates if the WebGL underlying uniform buffer is dynamic.
  28949. * Also, a dynamic UniformBuffer will disable cache verification and always
  28950. * update the underlying WebGL uniform buffer to the GPU.
  28951. * @returns if Dynamic, otherwise false
  28952. */
  28953. isDynamic(): boolean;
  28954. /**
  28955. * The data cache on JS side.
  28956. * @returns the underlying data as a float array
  28957. */
  28958. getData(): Float32Array;
  28959. /**
  28960. * The underlying WebGL Uniform buffer.
  28961. * @returns the webgl buffer
  28962. */
  28963. getBuffer(): Nullable<DataBuffer>;
  28964. /**
  28965. * std140 layout specifies how to align data within an UBO structure.
  28966. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  28967. * for specs.
  28968. */
  28969. private _fillAlignment;
  28970. /**
  28971. * Adds an uniform in the buffer.
  28972. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  28973. * for the layout to be correct !
  28974. * @param name Name of the uniform, as used in the uniform block in the shader.
  28975. * @param size Data size, or data directly.
  28976. */
  28977. addUniform(name: string, size: number | number[]): void;
  28978. /**
  28979. * Adds a Matrix 4x4 to the uniform buffer.
  28980. * @param name Name of the uniform, as used in the uniform block in the shader.
  28981. * @param mat A 4x4 matrix.
  28982. */
  28983. addMatrix(name: string, mat: Matrix): void;
  28984. /**
  28985. * Adds a vec2 to the uniform buffer.
  28986. * @param name Name of the uniform, as used in the uniform block in the shader.
  28987. * @param x Define the x component value of the vec2
  28988. * @param y Define the y component value of the vec2
  28989. */
  28990. addFloat2(name: string, x: number, y: number): void;
  28991. /**
  28992. * Adds a vec3 to the uniform buffer.
  28993. * @param name Name of the uniform, as used in the uniform block in the shader.
  28994. * @param x Define the x component value of the vec3
  28995. * @param y Define the y component value of the vec3
  28996. * @param z Define the z component value of the vec3
  28997. */
  28998. addFloat3(name: string, x: number, y: number, z: number): void;
  28999. /**
  29000. * Adds a vec3 to the uniform buffer.
  29001. * @param name Name of the uniform, as used in the uniform block in the shader.
  29002. * @param color Define the vec3 from a Color
  29003. */
  29004. addColor3(name: string, color: Color3): void;
  29005. /**
  29006. * Adds a vec4 to the uniform buffer.
  29007. * @param name Name of the uniform, as used in the uniform block in the shader.
  29008. * @param color Define the rgb components from a Color
  29009. * @param alpha Define the a component of the vec4
  29010. */
  29011. addColor4(name: string, color: Color3, alpha: number): void;
  29012. /**
  29013. * Adds a vec3 to the uniform buffer.
  29014. * @param name Name of the uniform, as used in the uniform block in the shader.
  29015. * @param vector Define the vec3 components from a Vector
  29016. */
  29017. addVector3(name: string, vector: Vector3): void;
  29018. /**
  29019. * Adds a Matrix 3x3 to the uniform buffer.
  29020. * @param name Name of the uniform, as used in the uniform block in the shader.
  29021. */
  29022. addMatrix3x3(name: string): void;
  29023. /**
  29024. * Adds a Matrix 2x2 to the uniform buffer.
  29025. * @param name Name of the uniform, as used in the uniform block in the shader.
  29026. */
  29027. addMatrix2x2(name: string): void;
  29028. /**
  29029. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29030. */
  29031. create(): void;
  29032. /** @hidden */
  29033. _rebuild(): void;
  29034. /**
  29035. * Updates the WebGL Uniform Buffer on the GPU.
  29036. * If the `dynamic` flag is set to true, no cache comparison is done.
  29037. * Otherwise, the buffer will be updated only if the cache differs.
  29038. */
  29039. update(): void;
  29040. /**
  29041. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29042. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29043. * @param data Define the flattened data
  29044. * @param size Define the size of the data.
  29045. */
  29046. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29047. private _valueCache;
  29048. private _cacheMatrix;
  29049. private _updateMatrix3x3ForUniform;
  29050. private _updateMatrix3x3ForEffect;
  29051. private _updateMatrix2x2ForEffect;
  29052. private _updateMatrix2x2ForUniform;
  29053. private _updateFloatForEffect;
  29054. private _updateFloatForUniform;
  29055. private _updateFloat2ForEffect;
  29056. private _updateFloat2ForUniform;
  29057. private _updateFloat3ForEffect;
  29058. private _updateFloat3ForUniform;
  29059. private _updateFloat4ForEffect;
  29060. private _updateFloat4ForUniform;
  29061. private _updateMatrixForEffect;
  29062. private _updateMatrixForUniform;
  29063. private _updateVector3ForEffect;
  29064. private _updateVector3ForUniform;
  29065. private _updateVector4ForEffect;
  29066. private _updateVector4ForUniform;
  29067. private _updateColor3ForEffect;
  29068. private _updateColor3ForUniform;
  29069. private _updateColor4ForEffect;
  29070. private _updateColor4ForUniform;
  29071. /**
  29072. * Sets a sampler uniform on the effect.
  29073. * @param name Define the name of the sampler.
  29074. * @param texture Define the texture to set in the sampler
  29075. */
  29076. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29077. /**
  29078. * Directly updates the value of the uniform in the cache AND on the GPU.
  29079. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29080. * @param data Define the flattened data
  29081. */
  29082. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29083. /**
  29084. * Binds this uniform buffer to an effect.
  29085. * @param effect Define the effect to bind the buffer to
  29086. * @param name Name of the uniform block in the shader.
  29087. */
  29088. bindToEffect(effect: Effect, name: string): void;
  29089. /**
  29090. * Disposes the uniform buffer.
  29091. */
  29092. dispose(): void;
  29093. }
  29094. }
  29095. declare module BABYLON {
  29096. /**
  29097. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29098. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29099. */
  29100. export class Analyser {
  29101. /**
  29102. * Gets or sets the smoothing
  29103. * @ignorenaming
  29104. */
  29105. SMOOTHING: number;
  29106. /**
  29107. * Gets or sets the FFT table size
  29108. * @ignorenaming
  29109. */
  29110. FFT_SIZE: number;
  29111. /**
  29112. * Gets or sets the bar graph amplitude
  29113. * @ignorenaming
  29114. */
  29115. BARGRAPHAMPLITUDE: number;
  29116. /**
  29117. * Gets or sets the position of the debug canvas
  29118. * @ignorenaming
  29119. */
  29120. DEBUGCANVASPOS: {
  29121. x: number;
  29122. y: number;
  29123. };
  29124. /**
  29125. * Gets or sets the debug canvas size
  29126. * @ignorenaming
  29127. */
  29128. DEBUGCANVASSIZE: {
  29129. width: number;
  29130. height: number;
  29131. };
  29132. private _byteFreqs;
  29133. private _byteTime;
  29134. private _floatFreqs;
  29135. private _webAudioAnalyser;
  29136. private _debugCanvas;
  29137. private _debugCanvasContext;
  29138. private _scene;
  29139. private _registerFunc;
  29140. private _audioEngine;
  29141. /**
  29142. * Creates a new analyser
  29143. * @param scene defines hosting scene
  29144. */
  29145. constructor(scene: Scene);
  29146. /**
  29147. * Get the number of data values you will have to play with for the visualization
  29148. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29149. * @returns a number
  29150. */
  29151. getFrequencyBinCount(): number;
  29152. /**
  29153. * Gets the current frequency data as a byte array
  29154. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29155. * @returns a Uint8Array
  29156. */
  29157. getByteFrequencyData(): Uint8Array;
  29158. /**
  29159. * Gets the current waveform as a byte array
  29160. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29161. * @returns a Uint8Array
  29162. */
  29163. getByteTimeDomainData(): Uint8Array;
  29164. /**
  29165. * Gets the current frequency data as a float array
  29166. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29167. * @returns a Float32Array
  29168. */
  29169. getFloatFrequencyData(): Float32Array;
  29170. /**
  29171. * Renders the debug canvas
  29172. */
  29173. drawDebugCanvas(): void;
  29174. /**
  29175. * Stops rendering the debug canvas and removes it
  29176. */
  29177. stopDebugCanvas(): void;
  29178. /**
  29179. * Connects two audio nodes
  29180. * @param inputAudioNode defines first node to connect
  29181. * @param outputAudioNode defines second node to connect
  29182. */
  29183. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29184. /**
  29185. * Releases all associated resources
  29186. */
  29187. dispose(): void;
  29188. }
  29189. }
  29190. declare module BABYLON {
  29191. /**
  29192. * This represents an audio engine and it is responsible
  29193. * to play, synchronize and analyse sounds throughout the application.
  29194. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29195. */
  29196. export interface IAudioEngine extends IDisposable {
  29197. /**
  29198. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29199. */
  29200. readonly canUseWebAudio: boolean;
  29201. /**
  29202. * Gets the current AudioContext if available.
  29203. */
  29204. readonly audioContext: Nullable<AudioContext>;
  29205. /**
  29206. * The master gain node defines the global audio volume of your audio engine.
  29207. */
  29208. readonly masterGain: GainNode;
  29209. /**
  29210. * Gets whether or not mp3 are supported by your browser.
  29211. */
  29212. readonly isMP3supported: boolean;
  29213. /**
  29214. * Gets whether or not ogg are supported by your browser.
  29215. */
  29216. readonly isOGGsupported: boolean;
  29217. /**
  29218. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29219. * @ignoreNaming
  29220. */
  29221. WarnedWebAudioUnsupported: boolean;
  29222. /**
  29223. * Defines if the audio engine relies on a custom unlocked button.
  29224. * In this case, the embedded button will not be displayed.
  29225. */
  29226. useCustomUnlockedButton: boolean;
  29227. /**
  29228. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29229. */
  29230. readonly unlocked: boolean;
  29231. /**
  29232. * Event raised when audio has been unlocked on the browser.
  29233. */
  29234. onAudioUnlockedObservable: Observable<AudioEngine>;
  29235. /**
  29236. * Event raised when audio has been locked on the browser.
  29237. */
  29238. onAudioLockedObservable: Observable<AudioEngine>;
  29239. /**
  29240. * Flags the audio engine in Locked state.
  29241. * This happens due to new browser policies preventing audio to autoplay.
  29242. */
  29243. lock(): void;
  29244. /**
  29245. * Unlocks the audio engine once a user action has been done on the dom.
  29246. * This is helpful to resume play once browser policies have been satisfied.
  29247. */
  29248. unlock(): void;
  29249. }
  29250. /**
  29251. * This represents the default audio engine used in babylon.
  29252. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29254. */
  29255. export class AudioEngine implements IAudioEngine {
  29256. private _audioContext;
  29257. private _audioContextInitialized;
  29258. private _muteButton;
  29259. private _hostElement;
  29260. /**
  29261. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29262. */
  29263. canUseWebAudio: boolean;
  29264. /**
  29265. * The master gain node defines the global audio volume of your audio engine.
  29266. */
  29267. masterGain: GainNode;
  29268. /**
  29269. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29270. * @ignoreNaming
  29271. */
  29272. WarnedWebAudioUnsupported: boolean;
  29273. /**
  29274. * Gets whether or not mp3 are supported by your browser.
  29275. */
  29276. isMP3supported: boolean;
  29277. /**
  29278. * Gets whether or not ogg are supported by your browser.
  29279. */
  29280. isOGGsupported: boolean;
  29281. /**
  29282. * Gets whether audio has been unlocked on the device.
  29283. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29284. * a user interaction has happened.
  29285. */
  29286. unlocked: boolean;
  29287. /**
  29288. * Defines if the audio engine relies on a custom unlocked button.
  29289. * In this case, the embedded button will not be displayed.
  29290. */
  29291. useCustomUnlockedButton: boolean;
  29292. /**
  29293. * Event raised when audio has been unlocked on the browser.
  29294. */
  29295. onAudioUnlockedObservable: Observable<AudioEngine>;
  29296. /**
  29297. * Event raised when audio has been locked on the browser.
  29298. */
  29299. onAudioLockedObservable: Observable<AudioEngine>;
  29300. /**
  29301. * Gets the current AudioContext if available.
  29302. */
  29303. readonly audioContext: Nullable<AudioContext>;
  29304. private _connectedAnalyser;
  29305. /**
  29306. * Instantiates a new audio engine.
  29307. *
  29308. * There should be only one per page as some browsers restrict the number
  29309. * of audio contexts you can create.
  29310. * @param hostElement defines the host element where to display the mute icon if necessary
  29311. */
  29312. constructor(hostElement?: Nullable<HTMLElement>);
  29313. /**
  29314. * Flags the audio engine in Locked state.
  29315. * This happens due to new browser policies preventing audio to autoplay.
  29316. */
  29317. lock(): void;
  29318. /**
  29319. * Unlocks the audio engine once a user action has been done on the dom.
  29320. * This is helpful to resume play once browser policies have been satisfied.
  29321. */
  29322. unlock(): void;
  29323. private _resumeAudioContext;
  29324. private _initializeAudioContext;
  29325. private _tryToRun;
  29326. private _triggerRunningState;
  29327. private _triggerSuspendedState;
  29328. private _displayMuteButton;
  29329. private _moveButtonToTopLeft;
  29330. private _onResize;
  29331. private _hideMuteButton;
  29332. /**
  29333. * Destroy and release the resources associated with the audio ccontext.
  29334. */
  29335. dispose(): void;
  29336. /**
  29337. * Gets the global volume sets on the master gain.
  29338. * @returns the global volume if set or -1 otherwise
  29339. */
  29340. getGlobalVolume(): number;
  29341. /**
  29342. * Sets the global volume of your experience (sets on the master gain).
  29343. * @param newVolume Defines the new global volume of the application
  29344. */
  29345. setGlobalVolume(newVolume: number): void;
  29346. /**
  29347. * Connect the audio engine to an audio analyser allowing some amazing
  29348. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29349. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29350. * @param analyser The analyser to connect to the engine
  29351. */
  29352. connectToAnalyser(analyser: Analyser): void;
  29353. }
  29354. }
  29355. declare module BABYLON {
  29356. /**
  29357. * Interface used to present a loading screen while loading a scene
  29358. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29359. */
  29360. export interface ILoadingScreen {
  29361. /**
  29362. * Function called to display the loading screen
  29363. */
  29364. displayLoadingUI: () => void;
  29365. /**
  29366. * Function called to hide the loading screen
  29367. */
  29368. hideLoadingUI: () => void;
  29369. /**
  29370. * Gets or sets the color to use for the background
  29371. */
  29372. loadingUIBackgroundColor: string;
  29373. /**
  29374. * Gets or sets the text to display while loading
  29375. */
  29376. loadingUIText: string;
  29377. }
  29378. /**
  29379. * Class used for the default loading screen
  29380. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29381. */
  29382. export class DefaultLoadingScreen implements ILoadingScreen {
  29383. private _renderingCanvas;
  29384. private _loadingText;
  29385. private _loadingDivBackgroundColor;
  29386. private _loadingDiv;
  29387. private _loadingTextDiv;
  29388. /** Gets or sets the logo url to use for the default loading screen */
  29389. static DefaultLogoUrl: string;
  29390. /** Gets or sets the spinner url to use for the default loading screen */
  29391. static DefaultSpinnerUrl: string;
  29392. /**
  29393. * Creates a new default loading screen
  29394. * @param _renderingCanvas defines the canvas used to render the scene
  29395. * @param _loadingText defines the default text to display
  29396. * @param _loadingDivBackgroundColor defines the default background color
  29397. */
  29398. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  29399. /**
  29400. * Function called to display the loading screen
  29401. */
  29402. displayLoadingUI(): void;
  29403. /**
  29404. * Function called to hide the loading screen
  29405. */
  29406. hideLoadingUI(): void;
  29407. /**
  29408. * Gets or sets the text to display while loading
  29409. */
  29410. loadingUIText: string;
  29411. /**
  29412. * Gets or sets the color to use for the background
  29413. */
  29414. loadingUIBackgroundColor: string;
  29415. private _resizeLoadingUI;
  29416. }
  29417. }
  29418. declare module BABYLON {
  29419. /** @hidden */
  29420. export class WebGLPipelineContext implements IPipelineContext {
  29421. engine: Engine;
  29422. program: Nullable<WebGLProgram>;
  29423. context?: WebGLRenderingContext;
  29424. vertexShader?: WebGLShader;
  29425. fragmentShader?: WebGLShader;
  29426. isParallelCompiled: boolean;
  29427. onCompiled?: () => void;
  29428. transformFeedback?: WebGLTransformFeedback | null;
  29429. readonly isAsync: boolean;
  29430. readonly isReady: boolean;
  29431. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  29432. }
  29433. }
  29434. declare module BABYLON {
  29435. /** @hidden */
  29436. export class WebGLDataBuffer extends DataBuffer {
  29437. private _buffer;
  29438. constructor(resource: WebGLBuffer);
  29439. readonly underlyingResource: any;
  29440. }
  29441. }
  29442. declare module BABYLON {
  29443. /** @hidden */
  29444. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29445. attributeProcessor(attribute: string): string;
  29446. varyingProcessor(varying: string, isFragment: boolean): string;
  29447. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29448. }
  29449. }
  29450. declare module BABYLON {
  29451. /**
  29452. * This class is used to track a performance counter which is number based.
  29453. * The user has access to many properties which give statistics of different nature.
  29454. *
  29455. * The implementer can track two kinds of Performance Counter: time and count.
  29456. * 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.
  29457. * 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.
  29458. */
  29459. export class PerfCounter {
  29460. /**
  29461. * Gets or sets a global boolean to turn on and off all the counters
  29462. */
  29463. static Enabled: boolean;
  29464. /**
  29465. * Returns the smallest value ever
  29466. */
  29467. readonly min: number;
  29468. /**
  29469. * Returns the biggest value ever
  29470. */
  29471. readonly max: number;
  29472. /**
  29473. * Returns the average value since the performance counter is running
  29474. */
  29475. readonly average: number;
  29476. /**
  29477. * Returns the average value of the last second the counter was monitored
  29478. */
  29479. readonly lastSecAverage: number;
  29480. /**
  29481. * Returns the current value
  29482. */
  29483. readonly current: number;
  29484. /**
  29485. * Gets the accumulated total
  29486. */
  29487. readonly total: number;
  29488. /**
  29489. * Gets the total value count
  29490. */
  29491. readonly count: number;
  29492. /**
  29493. * Creates a new counter
  29494. */
  29495. constructor();
  29496. /**
  29497. * Call this method to start monitoring a new frame.
  29498. * 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.
  29499. */
  29500. fetchNewFrame(): void;
  29501. /**
  29502. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29503. * @param newCount the count value to add to the monitored count
  29504. * @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.
  29505. */
  29506. addCount(newCount: number, fetchResult: boolean): void;
  29507. /**
  29508. * Start monitoring this performance counter
  29509. */
  29510. beginMonitoring(): void;
  29511. /**
  29512. * Compute the time lapsed since the previous beginMonitoring() call.
  29513. * @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
  29514. */
  29515. endMonitoring(newFrame?: boolean): void;
  29516. private _fetchResult;
  29517. private _startMonitoringTime;
  29518. private _min;
  29519. private _max;
  29520. private _average;
  29521. private _current;
  29522. private _totalValueCount;
  29523. private _totalAccumulated;
  29524. private _lastSecAverage;
  29525. private _lastSecAccumulated;
  29526. private _lastSecTime;
  29527. private _lastSecValueCount;
  29528. }
  29529. }
  29530. declare module BABYLON {
  29531. /**
  29532. * Interface for any object that can request an animation frame
  29533. */
  29534. export interface ICustomAnimationFrameRequester {
  29535. /**
  29536. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29537. */
  29538. renderFunction?: Function;
  29539. /**
  29540. * Called to request the next frame to render to
  29541. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29542. */
  29543. requestAnimationFrame: Function;
  29544. /**
  29545. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29546. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29547. */
  29548. requestID?: number;
  29549. }
  29550. }
  29551. declare module BABYLON {
  29552. /**
  29553. * Settings for finer control over video usage
  29554. */
  29555. export interface VideoTextureSettings {
  29556. /**
  29557. * Applies `autoplay` to video, if specified
  29558. */
  29559. autoPlay?: boolean;
  29560. /**
  29561. * Applies `loop` to video, if specified
  29562. */
  29563. loop?: boolean;
  29564. /**
  29565. * Automatically updates internal texture from video at every frame in the render loop
  29566. */
  29567. autoUpdateTexture: boolean;
  29568. /**
  29569. * Image src displayed during the video loading or until the user interacts with the video.
  29570. */
  29571. poster?: string;
  29572. }
  29573. /**
  29574. * If you want to display a video in your scene, this is the special texture for that.
  29575. * This special texture works similar to other textures, with the exception of a few parameters.
  29576. * @see https://doc.babylonjs.com/how_to/video_texture
  29577. */
  29578. export class VideoTexture extends Texture {
  29579. /**
  29580. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29581. */
  29582. readonly autoUpdateTexture: boolean;
  29583. /**
  29584. * The video instance used by the texture internally
  29585. */
  29586. readonly video: HTMLVideoElement;
  29587. private _onUserActionRequestedObservable;
  29588. /**
  29589. * Event triggerd when a dom action is required by the user to play the video.
  29590. * This happens due to recent changes in browser policies preventing video to auto start.
  29591. */
  29592. readonly onUserActionRequestedObservable: Observable<Texture>;
  29593. private _generateMipMaps;
  29594. private _engine;
  29595. private _stillImageCaptured;
  29596. private _displayingPosterTexture;
  29597. private _settings;
  29598. private _createInternalTextureOnEvent;
  29599. private _frameId;
  29600. /**
  29601. * Creates a video texture.
  29602. * If you want to display a video in your scene, this is the special texture for that.
  29603. * This special texture works similar to other textures, with the exception of a few parameters.
  29604. * @see https://doc.babylonjs.com/how_to/video_texture
  29605. * @param name optional name, will detect from video source, if not defined
  29606. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29607. * @param scene is obviously the current scene.
  29608. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29609. * @param invertY is false by default but can be used to invert video on Y axis
  29610. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29611. * @param settings allows finer control over video usage
  29612. */
  29613. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29614. private _getName;
  29615. private _getVideo;
  29616. private _createInternalTexture;
  29617. private reset;
  29618. /**
  29619. * @hidden Internal method to initiate `update`.
  29620. */
  29621. _rebuild(): void;
  29622. /**
  29623. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29624. */
  29625. update(): void;
  29626. /**
  29627. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29628. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29629. */
  29630. updateTexture(isVisible: boolean): void;
  29631. protected _updateInternalTexture: () => void;
  29632. /**
  29633. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29634. * @param url New url.
  29635. */
  29636. updateURL(url: string): void;
  29637. /**
  29638. * Dispose the texture and release its associated resources.
  29639. */
  29640. dispose(): void;
  29641. /**
  29642. * Creates a video texture straight from a stream.
  29643. * @param scene Define the scene the texture should be created in
  29644. * @param stream Define the stream the texture should be created from
  29645. * @returns The created video texture as a promise
  29646. */
  29647. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29648. /**
  29649. * Creates a video texture straight from your WebCam video feed.
  29650. * @param scene Define the scene the texture should be created in
  29651. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29652. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29653. * @returns The created video texture as a promise
  29654. */
  29655. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29656. minWidth: number;
  29657. maxWidth: number;
  29658. minHeight: number;
  29659. maxHeight: number;
  29660. deviceId: string;
  29661. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29662. /**
  29663. * Creates a video texture straight from your WebCam video feed.
  29664. * @param scene Define the scene the texture should be created in
  29665. * @param onReady Define a callback to triggered once the texture will be ready
  29666. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29667. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29668. */
  29669. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29670. minWidth: number;
  29671. maxWidth: number;
  29672. minHeight: number;
  29673. maxHeight: number;
  29674. deviceId: string;
  29675. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29676. }
  29677. }
  29678. declare module BABYLON {
  29679. /**
  29680. * Defines the interface used by objects containing a viewport (like a camera)
  29681. */
  29682. interface IViewportOwnerLike {
  29683. /**
  29684. * Gets or sets the viewport
  29685. */
  29686. viewport: IViewportLike;
  29687. }
  29688. /**
  29689. * Interface for attribute information associated with buffer instanciation
  29690. */
  29691. export class InstancingAttributeInfo {
  29692. /**
  29693. * Index/offset of the attribute in the vertex shader
  29694. */
  29695. index: number;
  29696. /**
  29697. * size of the attribute, 1, 2, 3 or 4
  29698. */
  29699. attributeSize: number;
  29700. /**
  29701. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29702. * default is FLOAT
  29703. */
  29704. attribyteType: number;
  29705. /**
  29706. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29707. */
  29708. normalized: boolean;
  29709. /**
  29710. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29711. */
  29712. offset: number;
  29713. /**
  29714. * Name of the GLSL attribute, for debugging purpose only
  29715. */
  29716. attributeName: string;
  29717. }
  29718. /**
  29719. * Define options used to create a depth texture
  29720. */
  29721. export class DepthTextureCreationOptions {
  29722. /** Specifies whether or not a stencil should be allocated in the texture */
  29723. generateStencil?: boolean;
  29724. /** Specifies whether or not bilinear filtering is enable on the texture */
  29725. bilinearFiltering?: boolean;
  29726. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  29727. comparisonFunction?: number;
  29728. /** Specifies if the created texture is a cube texture */
  29729. isCube?: boolean;
  29730. }
  29731. /**
  29732. * Class used to describe the capabilities of the engine relatively to the current browser
  29733. */
  29734. export class EngineCapabilities {
  29735. /** Maximum textures units per fragment shader */
  29736. maxTexturesImageUnits: number;
  29737. /** Maximum texture units per vertex shader */
  29738. maxVertexTextureImageUnits: number;
  29739. /** Maximum textures units in the entire pipeline */
  29740. maxCombinedTexturesImageUnits: number;
  29741. /** Maximum texture size */
  29742. maxTextureSize: number;
  29743. /** Maximum cube texture size */
  29744. maxCubemapTextureSize: number;
  29745. /** Maximum render texture size */
  29746. maxRenderTextureSize: number;
  29747. /** Maximum number of vertex attributes */
  29748. maxVertexAttribs: number;
  29749. /** Maximum number of varyings */
  29750. maxVaryingVectors: number;
  29751. /** Maximum number of uniforms per vertex shader */
  29752. maxVertexUniformVectors: number;
  29753. /** Maximum number of uniforms per fragment shader */
  29754. maxFragmentUniformVectors: number;
  29755. /** Defines if standard derivates (dx/dy) are supported */
  29756. standardDerivatives: boolean;
  29757. /** Defines if s3tc texture compression is supported */
  29758. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29759. /** Defines if pvrtc texture compression is supported */
  29760. pvrtc: any;
  29761. /** Defines if etc1 texture compression is supported */
  29762. etc1: any;
  29763. /** Defines if etc2 texture compression is supported */
  29764. etc2: any;
  29765. /** Defines if astc texture compression is supported */
  29766. astc: any;
  29767. /** Defines if float textures are supported */
  29768. textureFloat: boolean;
  29769. /** Defines if vertex array objects are supported */
  29770. vertexArrayObject: boolean;
  29771. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29772. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29773. /** Gets the maximum level of anisotropy supported */
  29774. maxAnisotropy: number;
  29775. /** Defines if instancing is supported */
  29776. instancedArrays: boolean;
  29777. /** Defines if 32 bits indices are supported */
  29778. uintIndices: boolean;
  29779. /** Defines if high precision shaders are supported */
  29780. highPrecisionShaderSupported: boolean;
  29781. /** Defines if depth reading in the fragment shader is supported */
  29782. fragmentDepthSupported: boolean;
  29783. /** Defines if float texture linear filtering is supported*/
  29784. textureFloatLinearFiltering: boolean;
  29785. /** Defines if rendering to float textures is supported */
  29786. textureFloatRender: boolean;
  29787. /** Defines if half float textures are supported*/
  29788. textureHalfFloat: boolean;
  29789. /** Defines if half float texture linear filtering is supported*/
  29790. textureHalfFloatLinearFiltering: boolean;
  29791. /** Defines if rendering to half float textures is supported */
  29792. textureHalfFloatRender: boolean;
  29793. /** Defines if textureLOD shader command is supported */
  29794. textureLOD: boolean;
  29795. /** Defines if draw buffers extension is supported */
  29796. drawBuffersExtension: boolean;
  29797. /** Defines if depth textures are supported */
  29798. depthTextureExtension: boolean;
  29799. /** Defines if float color buffer are supported */
  29800. colorBufferFloat: boolean;
  29801. /** Gets disjoint timer query extension (null if not supported) */
  29802. timerQuery: EXT_disjoint_timer_query;
  29803. /** Defines if timestamp can be used with timer query */
  29804. canUseTimestampForTimerQuery: boolean;
  29805. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29806. multiview: any;
  29807. /** Function used to let the system compiles shaders in background */
  29808. parallelShaderCompile: {
  29809. COMPLETION_STATUS_KHR: number;
  29810. };
  29811. /** Max number of texture samples for MSAA */
  29812. maxMSAASamples: number;
  29813. }
  29814. /** Interface defining initialization parameters for Engine class */
  29815. export interface EngineOptions extends WebGLContextAttributes {
  29816. /**
  29817. * Defines if the engine should no exceed a specified device ratio
  29818. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29819. */
  29820. limitDeviceRatio?: number;
  29821. /**
  29822. * Defines if webvr should be enabled automatically
  29823. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29824. */
  29825. autoEnableWebVR?: boolean;
  29826. /**
  29827. * Defines if webgl2 should be turned off even if supported
  29828. * @see http://doc.babylonjs.com/features/webgl2
  29829. */
  29830. disableWebGL2Support?: boolean;
  29831. /**
  29832. * Defines if webaudio should be initialized as well
  29833. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29834. */
  29835. audioEngine?: boolean;
  29836. /**
  29837. * Defines if animations should run using a deterministic lock step
  29838. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29839. */
  29840. deterministicLockstep?: boolean;
  29841. /** Defines the maximum steps to use with deterministic lock step mode */
  29842. lockstepMaxSteps?: number;
  29843. /**
  29844. * Defines that engine should ignore context lost events
  29845. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29846. */
  29847. doNotHandleContextLost?: boolean;
  29848. /**
  29849. * Defines that engine should ignore modifying touch action attribute and style
  29850. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29851. */
  29852. doNotHandleTouchAction?: boolean;
  29853. /**
  29854. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29855. */
  29856. useHighPrecisionFloats?: boolean;
  29857. }
  29858. /**
  29859. * Defines the interface used by display changed events
  29860. */
  29861. export interface IDisplayChangedEventArgs {
  29862. /** Gets the vrDisplay object (if any) */
  29863. vrDisplay: Nullable<any>;
  29864. /** Gets a boolean indicating if webVR is supported */
  29865. vrSupported: boolean;
  29866. }
  29867. /**
  29868. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29869. */
  29870. export class Engine {
  29871. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29872. static ExceptionList: ({
  29873. key: string;
  29874. capture: string;
  29875. captureConstraint: number;
  29876. targets: string[];
  29877. } | {
  29878. key: string;
  29879. capture: null;
  29880. captureConstraint: null;
  29881. targets: string[];
  29882. })[];
  29883. /** Gets the list of created engines */
  29884. static readonly Instances: Engine[];
  29885. /**
  29886. * Gets the latest created engine
  29887. */
  29888. static readonly LastCreatedEngine: Nullable<Engine>;
  29889. /**
  29890. * Gets the latest created scene
  29891. */
  29892. static readonly LastCreatedScene: Nullable<Scene>;
  29893. /**
  29894. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29895. * @param flag defines which part of the materials must be marked as dirty
  29896. * @param predicate defines a predicate used to filter which materials should be affected
  29897. */
  29898. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29899. /** @hidden */
  29900. static _TextureLoaders: IInternalTextureLoader[];
  29901. /** Defines that alpha blending is disabled */
  29902. static readonly ALPHA_DISABLE: number;
  29903. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29904. static readonly ALPHA_ADD: number;
  29905. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29906. static readonly ALPHA_COMBINE: number;
  29907. /** Defines that alpha blending to DEST - SRC * DEST */
  29908. static readonly ALPHA_SUBTRACT: number;
  29909. /** Defines that alpha blending to SRC * DEST */
  29910. static readonly ALPHA_MULTIPLY: number;
  29911. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29912. static readonly ALPHA_MAXIMIZED: number;
  29913. /** Defines that alpha blending to SRC + DEST */
  29914. static readonly ALPHA_ONEONE: number;
  29915. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29916. static readonly ALPHA_PREMULTIPLIED: number;
  29917. /**
  29918. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29919. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29920. */
  29921. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29922. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29923. static readonly ALPHA_INTERPOLATE: number;
  29924. /**
  29925. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29926. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29927. */
  29928. static readonly ALPHA_SCREENMODE: number;
  29929. /** Defines that the ressource is not delayed*/
  29930. static readonly DELAYLOADSTATE_NONE: number;
  29931. /** Defines that the ressource was successfully delay loaded */
  29932. static readonly DELAYLOADSTATE_LOADED: number;
  29933. /** Defines that the ressource is currently delay loading */
  29934. static readonly DELAYLOADSTATE_LOADING: number;
  29935. /** Defines that the ressource is delayed and has not started loading */
  29936. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29937. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29938. static readonly NEVER: number;
  29939. /** 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 */
  29940. static readonly ALWAYS: number;
  29941. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29942. static readonly LESS: number;
  29943. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29944. static readonly EQUAL: number;
  29945. /** 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 */
  29946. static readonly LEQUAL: number;
  29947. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29948. static readonly GREATER: number;
  29949. /** 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 */
  29950. static readonly GEQUAL: number;
  29951. /** 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 */
  29952. static readonly NOTEQUAL: number;
  29953. /** Passed to stencilOperation to specify that stencil value must be kept */
  29954. static readonly KEEP: number;
  29955. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29956. static readonly REPLACE: number;
  29957. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29958. static readonly INCR: number;
  29959. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29960. static readonly DECR: number;
  29961. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29962. static readonly INVERT: number;
  29963. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29964. static readonly INCR_WRAP: number;
  29965. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29966. static readonly DECR_WRAP: number;
  29967. /** Texture is not repeating outside of 0..1 UVs */
  29968. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  29969. /** Texture is repeating outside of 0..1 UVs */
  29970. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  29971. /** Texture is repeating and mirrored */
  29972. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  29973. /** ALPHA */
  29974. static readonly TEXTUREFORMAT_ALPHA: number;
  29975. /** LUMINANCE */
  29976. static readonly TEXTUREFORMAT_LUMINANCE: number;
  29977. /** LUMINANCE_ALPHA */
  29978. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  29979. /** RGB */
  29980. static readonly TEXTUREFORMAT_RGB: number;
  29981. /** RGBA */
  29982. static readonly TEXTUREFORMAT_RGBA: number;
  29983. /** RED */
  29984. static readonly TEXTUREFORMAT_RED: number;
  29985. /** RED (2nd reference) */
  29986. static readonly TEXTUREFORMAT_R: number;
  29987. /** RG */
  29988. static readonly TEXTUREFORMAT_RG: number;
  29989. /** RED_INTEGER */
  29990. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  29991. /** RED_INTEGER (2nd reference) */
  29992. static readonly TEXTUREFORMAT_R_INTEGER: number;
  29993. /** RG_INTEGER */
  29994. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  29995. /** RGB_INTEGER */
  29996. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  29997. /** RGBA_INTEGER */
  29998. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  29999. /** UNSIGNED_BYTE */
  30000. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30001. /** UNSIGNED_BYTE (2nd reference) */
  30002. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30003. /** FLOAT */
  30004. static readonly TEXTURETYPE_FLOAT: number;
  30005. /** HALF_FLOAT */
  30006. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30007. /** BYTE */
  30008. static readonly TEXTURETYPE_BYTE: number;
  30009. /** SHORT */
  30010. static readonly TEXTURETYPE_SHORT: number;
  30011. /** UNSIGNED_SHORT */
  30012. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30013. /** INT */
  30014. static readonly TEXTURETYPE_INT: number;
  30015. /** UNSIGNED_INT */
  30016. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30017. /** UNSIGNED_SHORT_4_4_4_4 */
  30018. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30019. /** UNSIGNED_SHORT_5_5_5_1 */
  30020. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30021. /** UNSIGNED_SHORT_5_6_5 */
  30022. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30023. /** UNSIGNED_INT_2_10_10_10_REV */
  30024. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30025. /** UNSIGNED_INT_24_8 */
  30026. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30027. /** UNSIGNED_INT_10F_11F_11F_REV */
  30028. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30029. /** UNSIGNED_INT_5_9_9_9_REV */
  30030. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30031. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30032. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30033. /** nearest is mag = nearest and min = nearest and mip = linear */
  30034. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30035. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30036. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30037. /** Trilinear is mag = linear and min = linear and mip = linear */
  30038. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30039. /** nearest is mag = nearest and min = nearest and mip = linear */
  30040. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30041. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30042. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30043. /** Trilinear is mag = linear and min = linear and mip = linear */
  30044. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30045. /** mag = nearest and min = nearest and mip = nearest */
  30046. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30047. /** mag = nearest and min = linear and mip = nearest */
  30048. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30049. /** mag = nearest and min = linear and mip = linear */
  30050. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30051. /** mag = nearest and min = linear and mip = none */
  30052. static readonly TEXTURE_NEAREST_LINEAR: number;
  30053. /** mag = nearest and min = nearest and mip = none */
  30054. static readonly TEXTURE_NEAREST_NEAREST: number;
  30055. /** mag = linear and min = nearest and mip = nearest */
  30056. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30057. /** mag = linear and min = nearest and mip = linear */
  30058. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30059. /** mag = linear and min = linear and mip = none */
  30060. static readonly TEXTURE_LINEAR_LINEAR: number;
  30061. /** mag = linear and min = nearest and mip = none */
  30062. static readonly TEXTURE_LINEAR_NEAREST: number;
  30063. /** Explicit coordinates mode */
  30064. static readonly TEXTURE_EXPLICIT_MODE: number;
  30065. /** Spherical coordinates mode */
  30066. static readonly TEXTURE_SPHERICAL_MODE: number;
  30067. /** Planar coordinates mode */
  30068. static readonly TEXTURE_PLANAR_MODE: number;
  30069. /** Cubic coordinates mode */
  30070. static readonly TEXTURE_CUBIC_MODE: number;
  30071. /** Projection coordinates mode */
  30072. static readonly TEXTURE_PROJECTION_MODE: number;
  30073. /** Skybox coordinates mode */
  30074. static readonly TEXTURE_SKYBOX_MODE: number;
  30075. /** Inverse Cubic coordinates mode */
  30076. static readonly TEXTURE_INVCUBIC_MODE: number;
  30077. /** Equirectangular coordinates mode */
  30078. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30079. /** Equirectangular Fixed coordinates mode */
  30080. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30081. /** Equirectangular Fixed Mirrored coordinates mode */
  30082. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30083. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30084. static readonly SCALEMODE_FLOOR: number;
  30085. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30086. static readonly SCALEMODE_NEAREST: number;
  30087. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30088. static readonly SCALEMODE_CEILING: number;
  30089. /**
  30090. * Returns the current npm package of the sdk
  30091. */
  30092. static readonly NpmPackage: string;
  30093. /**
  30094. * Returns the current version of the framework
  30095. */
  30096. static readonly Version: string;
  30097. /**
  30098. * Returns a string describing the current engine
  30099. */
  30100. readonly description: string;
  30101. /**
  30102. * Gets or sets the epsilon value used by collision engine
  30103. */
  30104. static CollisionsEpsilon: number;
  30105. /**
  30106. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30107. */
  30108. static ShadersRepository: string;
  30109. /**
  30110. * Method called to create the default loading screen.
  30111. * This can be overriden in your own app.
  30112. * @param canvas The rendering canvas element
  30113. * @returns The loading screen
  30114. */
  30115. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30116. /**
  30117. * Method called to create the default rescale post process on each engine.
  30118. */
  30119. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30120. /** @hidden */
  30121. _shaderProcessor: IShaderProcessor;
  30122. /**
  30123. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30124. */
  30125. forcePOTTextures: boolean;
  30126. /**
  30127. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30128. */
  30129. isFullscreen: boolean;
  30130. /**
  30131. * Gets a boolean indicating if the pointer is currently locked
  30132. */
  30133. isPointerLock: boolean;
  30134. /**
  30135. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30136. */
  30137. cullBackFaces: boolean;
  30138. /**
  30139. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30140. */
  30141. renderEvenInBackground: boolean;
  30142. /**
  30143. * Gets or sets a boolean indicating that cache can be kept between frames
  30144. */
  30145. preventCacheWipeBetweenFrames: boolean;
  30146. /**
  30147. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30148. **/
  30149. enableOfflineSupport: boolean;
  30150. /**
  30151. * 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)
  30152. **/
  30153. disableManifestCheck: boolean;
  30154. /**
  30155. * Gets the list of created scenes
  30156. */
  30157. scenes: Scene[];
  30158. /**
  30159. * Event raised when a new scene is created
  30160. */
  30161. onNewSceneAddedObservable: Observable<Scene>;
  30162. /**
  30163. * Gets the list of created postprocesses
  30164. */
  30165. postProcesses: PostProcess[];
  30166. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30167. validateShaderPrograms: boolean;
  30168. /**
  30169. * Observable event triggered each time the rendering canvas is resized
  30170. */
  30171. onResizeObservable: Observable<Engine>;
  30172. /**
  30173. * Observable event triggered each time the canvas loses focus
  30174. */
  30175. onCanvasBlurObservable: Observable<Engine>;
  30176. /**
  30177. * Observable event triggered each time the canvas gains focus
  30178. */
  30179. onCanvasFocusObservable: Observable<Engine>;
  30180. /**
  30181. * Observable event triggered each time the canvas receives pointerout event
  30182. */
  30183. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30184. /**
  30185. * Observable event triggered before each texture is initialized
  30186. */
  30187. onBeforeTextureInitObservable: Observable<Texture>;
  30188. /**
  30189. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30190. */
  30191. disableUniformBuffers: boolean;
  30192. /** @hidden */
  30193. _uniformBuffers: UniformBuffer[];
  30194. /**
  30195. * Gets a boolean indicating that the engine supports uniform buffers
  30196. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30197. */
  30198. readonly supportsUniformBuffers: boolean;
  30199. /**
  30200. * Observable raised when the engine begins a new frame
  30201. */
  30202. onBeginFrameObservable: Observable<Engine>;
  30203. /**
  30204. * If set, will be used to request the next animation frame for the render loop
  30205. */
  30206. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30207. /**
  30208. * Observable raised when the engine ends the current frame
  30209. */
  30210. onEndFrameObservable: Observable<Engine>;
  30211. /**
  30212. * Observable raised when the engine is about to compile a shader
  30213. */
  30214. onBeforeShaderCompilationObservable: Observable<Engine>;
  30215. /**
  30216. * Observable raised when the engine has jsut compiled a shader
  30217. */
  30218. onAfterShaderCompilationObservable: Observable<Engine>;
  30219. /** @hidden */
  30220. _gl: WebGLRenderingContext;
  30221. private _renderingCanvas;
  30222. private _windowIsBackground;
  30223. protected _webGLVersion: number;
  30224. protected _highPrecisionShadersAllowed: boolean;
  30225. /** @hidden */
  30226. readonly _shouldUseHighPrecisionShader: boolean;
  30227. /**
  30228. * Gets a boolean indicating that only power of 2 textures are supported
  30229. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30230. */
  30231. readonly needPOTTextures: boolean;
  30232. /** @hidden */
  30233. _badOS: boolean;
  30234. /** @hidden */
  30235. _badDesktopOS: boolean;
  30236. /**
  30237. * Gets the audio engine
  30238. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30239. * @ignorenaming
  30240. */
  30241. static audioEngine: IAudioEngine;
  30242. /**
  30243. * Default AudioEngine factory responsible of creating the Audio Engine.
  30244. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30245. */
  30246. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30247. /**
  30248. * Default offline support factory responsible of creating a tool used to store data locally.
  30249. * By default, this will create a Database object if the workload has been embedded.
  30250. */
  30251. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30252. private _onFocus;
  30253. private _onBlur;
  30254. private _onCanvasPointerOut;
  30255. private _onCanvasBlur;
  30256. private _onCanvasFocus;
  30257. private _onFullscreenChange;
  30258. private _onPointerLockChange;
  30259. private _hardwareScalingLevel;
  30260. /** @hidden */
  30261. _caps: EngineCapabilities;
  30262. private _pointerLockRequested;
  30263. private _isStencilEnable;
  30264. protected _colorWrite: boolean;
  30265. private _loadingScreen;
  30266. /** @hidden */
  30267. _drawCalls: PerfCounter;
  30268. private _glVersion;
  30269. private _glRenderer;
  30270. private _glVendor;
  30271. private _videoTextureSupported;
  30272. private _renderingQueueLaunched;
  30273. private _activeRenderLoops;
  30274. private _deterministicLockstep;
  30275. private _lockstepMaxSteps;
  30276. /**
  30277. * Observable signaled when a context lost event is raised
  30278. */
  30279. onContextLostObservable: Observable<Engine>;
  30280. /**
  30281. * Observable signaled when a context restored event is raised
  30282. */
  30283. onContextRestoredObservable: Observable<Engine>;
  30284. private _onContextLost;
  30285. private _onContextRestored;
  30286. private _contextWasLost;
  30287. /** @hidden */
  30288. _doNotHandleContextLost: boolean;
  30289. /**
  30290. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30291. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30292. */
  30293. doNotHandleContextLost: boolean;
  30294. private _performanceMonitor;
  30295. private _fps;
  30296. private _deltaTime;
  30297. /**
  30298. * Turn this value on if you want to pause FPS computation when in background
  30299. */
  30300. disablePerformanceMonitorInBackground: boolean;
  30301. /**
  30302. * Gets the performance monitor attached to this engine
  30303. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30304. */
  30305. readonly performanceMonitor: PerformanceMonitor;
  30306. /**
  30307. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30308. */
  30309. disableVertexArrayObjects: boolean;
  30310. /** @hidden */
  30311. protected _depthCullingState: _DepthCullingState;
  30312. /** @hidden */
  30313. protected _stencilState: _StencilState;
  30314. /** @hidden */
  30315. protected _alphaState: _AlphaState;
  30316. /** @hidden */
  30317. protected _alphaMode: number;
  30318. /** @hidden */
  30319. _internalTexturesCache: InternalTexture[];
  30320. /** @hidden */
  30321. protected _activeChannel: number;
  30322. private _currentTextureChannel;
  30323. /** @hidden */
  30324. protected _boundTexturesCache: {
  30325. [key: string]: Nullable<InternalTexture>;
  30326. };
  30327. /** @hidden */
  30328. protected _currentEffect: Nullable<Effect>;
  30329. /** @hidden */
  30330. protected _currentProgram: Nullable<WebGLProgram>;
  30331. private _compiledEffects;
  30332. private _vertexAttribArraysEnabled;
  30333. /** @hidden */
  30334. protected _cachedViewport: Nullable<IViewportLike>;
  30335. private _cachedVertexArrayObject;
  30336. /** @hidden */
  30337. protected _cachedVertexBuffers: any;
  30338. /** @hidden */
  30339. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30340. /** @hidden */
  30341. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30342. /** @hidden */
  30343. _currentRenderTarget: Nullable<InternalTexture>;
  30344. private _uintIndicesCurrentlySet;
  30345. private _currentBoundBuffer;
  30346. /** @hidden */
  30347. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30348. private _currentBufferPointers;
  30349. private _currentInstanceLocations;
  30350. private _currentInstanceBuffers;
  30351. private _textureUnits;
  30352. /** @hidden */
  30353. _workingCanvas: Nullable<HTMLCanvasElement>;
  30354. /** @hidden */
  30355. _workingContext: Nullable<CanvasRenderingContext2D>;
  30356. private _rescalePostProcess;
  30357. private _dummyFramebuffer;
  30358. private _externalData;
  30359. /** @hidden */
  30360. _bindedRenderFunction: any;
  30361. private _vaoRecordInProgress;
  30362. private _mustWipeVertexAttributes;
  30363. private _emptyTexture;
  30364. private _emptyCubeTexture;
  30365. private _emptyTexture3D;
  30366. /** @hidden */
  30367. _frameHandler: number;
  30368. private _nextFreeTextureSlots;
  30369. private _maxSimultaneousTextures;
  30370. private _activeRequests;
  30371. private _texturesSupported;
  30372. /** @hidden */
  30373. _textureFormatInUse: Nullable<string>;
  30374. /**
  30375. * Gets the list of texture formats supported
  30376. */
  30377. readonly texturesSupported: Array<string>;
  30378. /**
  30379. * Gets the list of texture formats in use
  30380. */
  30381. readonly textureFormatInUse: Nullable<string>;
  30382. /**
  30383. * Gets the current viewport
  30384. */
  30385. readonly currentViewport: Nullable<IViewportLike>;
  30386. /**
  30387. * Gets the default empty texture
  30388. */
  30389. readonly emptyTexture: InternalTexture;
  30390. /**
  30391. * Gets the default empty 3D texture
  30392. */
  30393. readonly emptyTexture3D: InternalTexture;
  30394. /**
  30395. * Gets the default empty cube texture
  30396. */
  30397. readonly emptyCubeTexture: InternalTexture;
  30398. /**
  30399. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30400. */
  30401. readonly premultipliedAlpha: boolean;
  30402. /**
  30403. * Creates a new engine
  30404. * @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
  30405. * @param antialias defines enable antialiasing (default: false)
  30406. * @param options defines further options to be sent to the getContext() function
  30407. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30408. */
  30409. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30410. /**
  30411. * Initializes a webVR display and starts listening to display change events
  30412. * The onVRDisplayChangedObservable will be notified upon these changes
  30413. * @returns The onVRDisplayChangedObservable
  30414. */
  30415. initWebVR(): Observable<IDisplayChangedEventArgs>;
  30416. /** @hidden */
  30417. _prepareVRComponent(): void;
  30418. /** @hidden */
  30419. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  30420. /** @hidden */
  30421. _submitVRFrame(): void;
  30422. /**
  30423. * Call this function to leave webVR mode
  30424. * Will do nothing if webVR is not supported or if there is no webVR device
  30425. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30426. */
  30427. disableVR(): void;
  30428. /**
  30429. * Gets a boolean indicating that the system is in VR mode and is presenting
  30430. * @returns true if VR mode is engaged
  30431. */
  30432. isVRPresenting(): boolean;
  30433. /** @hidden */
  30434. _requestVRFrame(): void;
  30435. private _disableTouchAction;
  30436. private _rebuildInternalTextures;
  30437. private _rebuildEffects;
  30438. /**
  30439. * Gets a boolean indicating if all created effects are ready
  30440. * @returns true if all effects are ready
  30441. */
  30442. areAllEffectsReady(): boolean;
  30443. private _rebuildBuffers;
  30444. private _initGLContext;
  30445. /**
  30446. * Gets version of the current webGL context
  30447. */
  30448. readonly webGLVersion: number;
  30449. /**
  30450. * Gets a string idenfifying the name of the class
  30451. * @returns "Engine" string
  30452. */
  30453. getClassName(): string;
  30454. /**
  30455. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30456. */
  30457. readonly isStencilEnable: boolean;
  30458. /** @hidden */
  30459. _prepareWorkingCanvas(): void;
  30460. /**
  30461. * Reset the texture cache to empty state
  30462. */
  30463. resetTextureCache(): void;
  30464. /**
  30465. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30466. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30467. * @returns true if engine is in deterministic lock step mode
  30468. */
  30469. isDeterministicLockStep(): boolean;
  30470. /**
  30471. * Gets the max steps when engine is running in deterministic lock step
  30472. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30473. * @returns the max steps
  30474. */
  30475. getLockstepMaxSteps(): number;
  30476. /**
  30477. * Gets an object containing information about the current webGL context
  30478. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30479. */
  30480. getGlInfo(): {
  30481. vendor: string;
  30482. renderer: string;
  30483. version: string;
  30484. };
  30485. /**
  30486. * Gets current aspect ratio
  30487. * @param viewportOwner defines the camera to use to get the aspect ratio
  30488. * @param useScreen defines if screen size must be used (or the current render target if any)
  30489. * @returns a number defining the aspect ratio
  30490. */
  30491. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30492. /**
  30493. * Gets current screen aspect ratio
  30494. * @returns a number defining the aspect ratio
  30495. */
  30496. getScreenAspectRatio(): number;
  30497. /**
  30498. * Gets the current render width
  30499. * @param useScreen defines if screen size must be used (or the current render target if any)
  30500. * @returns a number defining the current render width
  30501. */
  30502. getRenderWidth(useScreen?: boolean): number;
  30503. /**
  30504. * Gets the current render height
  30505. * @param useScreen defines if screen size must be used (or the current render target if any)
  30506. * @returns a number defining the current render height
  30507. */
  30508. getRenderHeight(useScreen?: boolean): number;
  30509. /**
  30510. * Gets the HTML canvas attached with the current webGL context
  30511. * @returns a HTML canvas
  30512. */
  30513. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30514. /**
  30515. * Gets host window
  30516. * @returns the host window object
  30517. */
  30518. getHostWindow(): Window;
  30519. /**
  30520. * Gets host document
  30521. * @returns the host document object
  30522. */
  30523. getHostDocument(): Document;
  30524. /**
  30525. * Gets the client rect of the HTML canvas attached with the current webGL context
  30526. * @returns a client rectanglee
  30527. */
  30528. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30529. /**
  30530. * Defines the hardware scaling level.
  30531. * By default the hardware scaling level is computed from the window device ratio.
  30532. * 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.
  30533. * @param level defines the level to use
  30534. */
  30535. setHardwareScalingLevel(level: number): void;
  30536. /**
  30537. * Gets the current hardware scaling level.
  30538. * By default the hardware scaling level is computed from the window device ratio.
  30539. * 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.
  30540. * @returns a number indicating the current hardware scaling level
  30541. */
  30542. getHardwareScalingLevel(): number;
  30543. /**
  30544. * Gets the list of loaded textures
  30545. * @returns an array containing all loaded textures
  30546. */
  30547. getLoadedTexturesCache(): InternalTexture[];
  30548. /**
  30549. * Gets the object containing all engine capabilities
  30550. * @returns the EngineCapabilities object
  30551. */
  30552. getCaps(): EngineCapabilities;
  30553. /**
  30554. * Gets the current depth function
  30555. * @returns a number defining the depth function
  30556. */
  30557. getDepthFunction(): Nullable<number>;
  30558. /**
  30559. * Sets the current depth function
  30560. * @param depthFunc defines the function to use
  30561. */
  30562. setDepthFunction(depthFunc: number): void;
  30563. /**
  30564. * Sets the current depth function to GREATER
  30565. */
  30566. setDepthFunctionToGreater(): void;
  30567. /**
  30568. * Sets the current depth function to GEQUAL
  30569. */
  30570. setDepthFunctionToGreaterOrEqual(): void;
  30571. /**
  30572. * Sets the current depth function to LESS
  30573. */
  30574. setDepthFunctionToLess(): void;
  30575. private _cachedStencilBuffer;
  30576. private _cachedStencilFunction;
  30577. private _cachedStencilMask;
  30578. private _cachedStencilOperationPass;
  30579. private _cachedStencilOperationFail;
  30580. private _cachedStencilOperationDepthFail;
  30581. private _cachedStencilReference;
  30582. /**
  30583. * Caches the the state of the stencil buffer
  30584. */
  30585. cacheStencilState(): void;
  30586. /**
  30587. * Restores the state of the stencil buffer
  30588. */
  30589. restoreStencilState(): void;
  30590. /**
  30591. * Sets the current depth function to LEQUAL
  30592. */
  30593. setDepthFunctionToLessOrEqual(): void;
  30594. /**
  30595. * Gets a boolean indicating if stencil buffer is enabled
  30596. * @returns the current stencil buffer state
  30597. */
  30598. getStencilBuffer(): boolean;
  30599. /**
  30600. * Enable or disable the stencil buffer
  30601. * @param enable defines if the stencil buffer must be enabled or disabled
  30602. */
  30603. setStencilBuffer(enable: boolean): void;
  30604. /**
  30605. * Gets the current stencil mask
  30606. * @returns a number defining the new stencil mask to use
  30607. */
  30608. getStencilMask(): number;
  30609. /**
  30610. * Sets the current stencil mask
  30611. * @param mask defines the new stencil mask to use
  30612. */
  30613. setStencilMask(mask: number): void;
  30614. /**
  30615. * Gets the current stencil function
  30616. * @returns a number defining the stencil function to use
  30617. */
  30618. getStencilFunction(): number;
  30619. /**
  30620. * Gets the current stencil reference value
  30621. * @returns a number defining the stencil reference value to use
  30622. */
  30623. getStencilFunctionReference(): number;
  30624. /**
  30625. * Gets the current stencil mask
  30626. * @returns a number defining the stencil mask to use
  30627. */
  30628. getStencilFunctionMask(): number;
  30629. /**
  30630. * Sets the current stencil function
  30631. * @param stencilFunc defines the new stencil function to use
  30632. */
  30633. setStencilFunction(stencilFunc: number): void;
  30634. /**
  30635. * Sets the current stencil reference
  30636. * @param reference defines the new stencil reference to use
  30637. */
  30638. setStencilFunctionReference(reference: number): void;
  30639. /**
  30640. * Sets the current stencil mask
  30641. * @param mask defines the new stencil mask to use
  30642. */
  30643. setStencilFunctionMask(mask: number): void;
  30644. /**
  30645. * Gets the current stencil operation when stencil fails
  30646. * @returns a number defining stencil operation to use when stencil fails
  30647. */
  30648. getStencilOperationFail(): number;
  30649. /**
  30650. * Gets the current stencil operation when depth fails
  30651. * @returns a number defining stencil operation to use when depth fails
  30652. */
  30653. getStencilOperationDepthFail(): number;
  30654. /**
  30655. * Gets the current stencil operation when stencil passes
  30656. * @returns a number defining stencil operation to use when stencil passes
  30657. */
  30658. getStencilOperationPass(): number;
  30659. /**
  30660. * Sets the stencil operation to use when stencil fails
  30661. * @param operation defines the stencil operation to use when stencil fails
  30662. */
  30663. setStencilOperationFail(operation: number): void;
  30664. /**
  30665. * Sets the stencil operation to use when depth fails
  30666. * @param operation defines the stencil operation to use when depth fails
  30667. */
  30668. setStencilOperationDepthFail(operation: number): void;
  30669. /**
  30670. * Sets the stencil operation to use when stencil passes
  30671. * @param operation defines the stencil operation to use when stencil passes
  30672. */
  30673. setStencilOperationPass(operation: number): void;
  30674. /**
  30675. * Sets a boolean indicating if the dithering state is enabled or disabled
  30676. * @param value defines the dithering state
  30677. */
  30678. setDitheringState(value: boolean): void;
  30679. /**
  30680. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30681. * @param value defines the rasterizer state
  30682. */
  30683. setRasterizerState(value: boolean): void;
  30684. /**
  30685. * stop executing a render loop function and remove it from the execution array
  30686. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30687. */
  30688. stopRenderLoop(renderFunction?: () => void): void;
  30689. /** @hidden */
  30690. _renderLoop(): void;
  30691. /**
  30692. * Can be used to override the current requestAnimationFrame requester.
  30693. * @hidden
  30694. */
  30695. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30696. /**
  30697. * Register and execute a render loop. The engine can have more than one render function
  30698. * @param renderFunction defines the function to continuously execute
  30699. */
  30700. runRenderLoop(renderFunction: () => void): void;
  30701. /**
  30702. * Toggle full screen mode
  30703. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30704. */
  30705. switchFullscreen(requestPointerLock: boolean): void;
  30706. /**
  30707. * Enters full screen mode
  30708. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30709. */
  30710. enterFullscreen(requestPointerLock: boolean): void;
  30711. /**
  30712. * Exits full screen mode
  30713. */
  30714. exitFullscreen(): void;
  30715. /**
  30716. * Enters Pointerlock mode
  30717. */
  30718. enterPointerlock(): void;
  30719. /**
  30720. * Exits Pointerlock mode
  30721. */
  30722. exitPointerlock(): void;
  30723. /**
  30724. * Clear the current render buffer or the current render target (if any is set up)
  30725. * @param color defines the color to use
  30726. * @param backBuffer defines if the back buffer must be cleared
  30727. * @param depth defines if the depth buffer must be cleared
  30728. * @param stencil defines if the stencil buffer must be cleared
  30729. */
  30730. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30731. /**
  30732. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30733. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30734. * @param y defines the y-coordinate of the corner of the clear rectangle
  30735. * @param width defines the width of the clear rectangle
  30736. * @param height defines the height of the clear rectangle
  30737. * @param clearColor defines the clear color
  30738. */
  30739. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30740. /**
  30741. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30742. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30743. * @param y defines the y-coordinate of the corner of the clear rectangle
  30744. * @param width defines the width of the clear rectangle
  30745. * @param height defines the height of the clear rectangle
  30746. */
  30747. enableScissor(x: number, y: number, width: number, height: number): void;
  30748. /**
  30749. * Disable previously set scissor test rectangle
  30750. */
  30751. disableScissor(): void;
  30752. private _viewportCached;
  30753. /** @hidden */
  30754. _viewport(x: number, y: number, width: number, height: number): void;
  30755. /**
  30756. * Set the WebGL's viewport
  30757. * @param viewport defines the viewport element to be used
  30758. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30759. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30760. */
  30761. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30762. /**
  30763. * Directly set the WebGL Viewport
  30764. * @param x defines the x coordinate of the viewport (in screen space)
  30765. * @param y defines the y coordinate of the viewport (in screen space)
  30766. * @param width defines the width of the viewport (in screen space)
  30767. * @param height defines the height of the viewport (in screen space)
  30768. * @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
  30769. */
  30770. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30771. /**
  30772. * Begin a new frame
  30773. */
  30774. beginFrame(): void;
  30775. /**
  30776. * Enf the current frame
  30777. */
  30778. endFrame(): void;
  30779. /**
  30780. * Resize the view according to the canvas' size
  30781. */
  30782. resize(): void;
  30783. /**
  30784. * Force a specific size of the canvas
  30785. * @param width defines the new canvas' width
  30786. * @param height defines the new canvas' height
  30787. */
  30788. setSize(width: number, height: number): void;
  30789. /**
  30790. * Binds the frame buffer to the specified texture.
  30791. * @param texture The texture to render to or null for the default canvas
  30792. * @param faceIndex The face of the texture to render to in case of cube texture
  30793. * @param requiredWidth The width of the target to render to
  30794. * @param requiredHeight The height of the target to render to
  30795. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30796. * @param depthStencilTexture The depth stencil texture to use to render
  30797. * @param lodLevel defines le lod level to bind to the frame buffer
  30798. */
  30799. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30800. /** @hidden */
  30801. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30802. /**
  30803. * Unbind the current render target texture from the webGL context
  30804. * @param texture defines the render target texture to unbind
  30805. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30806. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30807. */
  30808. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30809. /**
  30810. * Force the mipmap generation for the given render target texture
  30811. * @param texture defines the render target texture to use
  30812. */
  30813. generateMipMapsForCubemap(texture: InternalTexture): void;
  30814. /**
  30815. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30816. */
  30817. flushFramebuffer(): void;
  30818. /**
  30819. * Unbind the current render target and bind the default framebuffer
  30820. */
  30821. restoreDefaultFramebuffer(): void;
  30822. /**
  30823. * Create an uniform buffer
  30824. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30825. * @param elements defines the content of the uniform buffer
  30826. * @returns the webGL uniform buffer
  30827. */
  30828. createUniformBuffer(elements: FloatArray): DataBuffer;
  30829. /**
  30830. * Create a dynamic uniform buffer
  30831. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30832. * @param elements defines the content of the uniform buffer
  30833. * @returns the webGL uniform buffer
  30834. */
  30835. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30836. /**
  30837. * Update an existing uniform buffer
  30838. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30839. * @param uniformBuffer defines the target uniform buffer
  30840. * @param elements defines the content to update
  30841. * @param offset defines the offset in the uniform buffer where update should start
  30842. * @param count defines the size of the data to update
  30843. */
  30844. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30845. private _resetVertexBufferBinding;
  30846. /**
  30847. * Creates a vertex buffer
  30848. * @param data the data for the vertex buffer
  30849. * @returns the new WebGL static buffer
  30850. */
  30851. createVertexBuffer(data: DataArray): DataBuffer;
  30852. /**
  30853. * Creates a dynamic vertex buffer
  30854. * @param data the data for the dynamic vertex buffer
  30855. * @returns the new WebGL dynamic buffer
  30856. */
  30857. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30858. /**
  30859. * Update a dynamic index buffer
  30860. * @param indexBuffer defines the target index buffer
  30861. * @param indices defines the data to update
  30862. * @param offset defines the offset in the target index buffer where update should start
  30863. */
  30864. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30865. /**
  30866. * Updates a dynamic vertex buffer.
  30867. * @param vertexBuffer the vertex buffer to update
  30868. * @param data the data used to update the vertex buffer
  30869. * @param byteOffset the byte offset of the data
  30870. * @param byteLength the byte length of the data
  30871. */
  30872. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30873. private _resetIndexBufferBinding;
  30874. /**
  30875. * Creates a new index buffer
  30876. * @param indices defines the content of the index buffer
  30877. * @param updatable defines if the index buffer must be updatable
  30878. * @returns a new webGL buffer
  30879. */
  30880. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30881. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30882. /**
  30883. * Bind a webGL buffer to the webGL context
  30884. * @param buffer defines the buffer to bind
  30885. */
  30886. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30887. /**
  30888. * Bind an uniform buffer to the current webGL context
  30889. * @param buffer defines the buffer to bind
  30890. */
  30891. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30892. /**
  30893. * Bind a buffer to the current webGL context at a given location
  30894. * @param buffer defines the buffer to bind
  30895. * @param location defines the index where to bind the buffer
  30896. */
  30897. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  30898. /**
  30899. * Bind a specific block at a given index in a specific shader program
  30900. * @param pipelineContext defines the pipeline context to use
  30901. * @param blockName defines the block name
  30902. * @param index defines the index where to bind the block
  30903. */
  30904. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30905. private bindIndexBuffer;
  30906. private bindBuffer;
  30907. /**
  30908. * update the bound buffer with the given data
  30909. * @param data defines the data to update
  30910. */
  30911. updateArrayBuffer(data: Float32Array): void;
  30912. private _vertexAttribPointer;
  30913. private _bindIndexBufferWithCache;
  30914. private _bindVertexBuffersAttributes;
  30915. /**
  30916. * Records a vertex array object
  30917. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30918. * @param vertexBuffers defines the list of vertex buffers to store
  30919. * @param indexBuffer defines the index buffer to store
  30920. * @param effect defines the effect to store
  30921. * @returns the new vertex array object
  30922. */
  30923. recordVertexArrayObject(vertexBuffers: {
  30924. [key: string]: VertexBuffer;
  30925. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30926. /**
  30927. * Bind a specific vertex array object
  30928. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30929. * @param vertexArrayObject defines the vertex array object to bind
  30930. * @param indexBuffer defines the index buffer to bind
  30931. */
  30932. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30933. /**
  30934. * Bind webGl buffers directly to the webGL context
  30935. * @param vertexBuffer defines the vertex buffer to bind
  30936. * @param indexBuffer defines the index buffer to bind
  30937. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30938. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30939. * @param effect defines the effect associated with the vertex buffer
  30940. */
  30941. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30942. private _unbindVertexArrayObject;
  30943. /**
  30944. * Bind a list of vertex buffers to the webGL context
  30945. * @param vertexBuffers defines the list of vertex buffers to bind
  30946. * @param indexBuffer defines the index buffer to bind
  30947. * @param effect defines the effect associated with the vertex buffers
  30948. */
  30949. bindBuffers(vertexBuffers: {
  30950. [key: string]: Nullable<VertexBuffer>;
  30951. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30952. /**
  30953. * Unbind all instance attributes
  30954. */
  30955. unbindInstanceAttributes(): void;
  30956. /**
  30957. * Release and free the memory of a vertex array object
  30958. * @param vao defines the vertex array object to delete
  30959. */
  30960. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30961. /** @hidden */
  30962. _releaseBuffer(buffer: DataBuffer): boolean;
  30963. protected _deleteBuffer(buffer: DataBuffer): void;
  30964. /**
  30965. * Creates a webGL buffer to use with instanciation
  30966. * @param capacity defines the size of the buffer
  30967. * @returns the webGL buffer
  30968. */
  30969. createInstancesBuffer(capacity: number): DataBuffer;
  30970. /**
  30971. * Delete a webGL buffer used with instanciation
  30972. * @param buffer defines the webGL buffer to delete
  30973. */
  30974. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30975. /**
  30976. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30977. * @param instancesBuffer defines the webGL buffer to update and bind
  30978. * @param data defines the data to store in the buffer
  30979. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30980. */
  30981. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30982. /**
  30983. * Apply all cached states (depth, culling, stencil and alpha)
  30984. */
  30985. applyStates(): void;
  30986. /**
  30987. * Send a draw order
  30988. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30989. * @param indexStart defines the starting index
  30990. * @param indexCount defines the number of index to draw
  30991. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30992. */
  30993. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30994. /**
  30995. * Draw a list of points
  30996. * @param verticesStart defines the index of first vertex to draw
  30997. * @param verticesCount defines the count of vertices to draw
  30998. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30999. */
  31000. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31001. /**
  31002. * Draw a list of unindexed primitives
  31003. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31004. * @param verticesStart defines the index of first vertex to draw
  31005. * @param verticesCount defines the count of vertices to draw
  31006. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31007. */
  31008. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31009. /**
  31010. * Draw a list of indexed primitives
  31011. * @param fillMode defines the primitive to use
  31012. * @param indexStart defines the starting index
  31013. * @param indexCount defines the number of index to draw
  31014. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31015. */
  31016. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31017. /**
  31018. * Draw a list of unindexed primitives
  31019. * @param fillMode defines the primitive to use
  31020. * @param verticesStart defines the index of first vertex to draw
  31021. * @param verticesCount defines the count of vertices to draw
  31022. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31023. */
  31024. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31025. private _drawMode;
  31026. /** @hidden */
  31027. _releaseEffect(effect: Effect): void;
  31028. /** @hidden */
  31029. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31030. /**
  31031. * Create a new effect (used to store vertex/fragment shaders)
  31032. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31033. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31034. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31035. * @param samplers defines an array of string used to represent textures
  31036. * @param defines defines the string containing the defines to use to compile the shaders
  31037. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31038. * @param onCompiled defines a function to call when the effect creation is successful
  31039. * @param onError defines a function to call when the effect creation has failed
  31040. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31041. * @returns the new Effect
  31042. */
  31043. 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;
  31044. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31045. private _compileShader;
  31046. private _compileRawShader;
  31047. /**
  31048. * Directly creates a webGL program
  31049. * @param pipelineContext defines the pipeline context to attach to
  31050. * @param vertexCode defines the vertex shader code to use
  31051. * @param fragmentCode defines the fragment shader code to use
  31052. * @param context defines the webGL context to use (if not set, the current one will be used)
  31053. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31054. * @returns the new webGL program
  31055. */
  31056. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31057. /**
  31058. * Creates a webGL program
  31059. * @param pipelineContext defines the pipeline context to attach to
  31060. * @param vertexCode defines the vertex shader code to use
  31061. * @param fragmentCode defines the fragment shader code to use
  31062. * @param defines defines the string containing the defines to use to compile the shaders
  31063. * @param context defines the webGL context to use (if not set, the current one will be used)
  31064. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31065. * @returns the new webGL program
  31066. */
  31067. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31068. /**
  31069. * Creates a new pipeline context
  31070. * @returns the new pipeline
  31071. */
  31072. createPipelineContext(): IPipelineContext;
  31073. private _createShaderProgram;
  31074. private _finalizePipelineContext;
  31075. /** @hidden */
  31076. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31077. /** @hidden */
  31078. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31079. /** @hidden */
  31080. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31081. /**
  31082. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31083. * @param pipelineContext defines the pipeline context to use
  31084. * @param uniformsNames defines the list of uniform names
  31085. * @returns an array of webGL uniform locations
  31086. */
  31087. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31088. /**
  31089. * Gets the lsit of active attributes for a given webGL program
  31090. * @param pipelineContext defines the pipeline context to use
  31091. * @param attributesNames defines the list of attribute names to get
  31092. * @returns an array of indices indicating the offset of each attribute
  31093. */
  31094. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31095. /**
  31096. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31097. * @param effect defines the effect to activate
  31098. */
  31099. enableEffect(effect: Nullable<Effect>): void;
  31100. /**
  31101. * Set the value of an uniform to an array of int32
  31102. * @param uniform defines the webGL uniform location where to store the value
  31103. * @param array defines the array of int32 to store
  31104. */
  31105. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31106. /**
  31107. * Set the value of an uniform to an array of int32 (stored as vec2)
  31108. * @param uniform defines the webGL uniform location where to store the value
  31109. * @param array defines the array of int32 to store
  31110. */
  31111. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31112. /**
  31113. * Set the value of an uniform to an array of int32 (stored as vec3)
  31114. * @param uniform defines the webGL uniform location where to store the value
  31115. * @param array defines the array of int32 to store
  31116. */
  31117. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31118. /**
  31119. * Set the value of an uniform to an array of int32 (stored as vec4)
  31120. * @param uniform defines the webGL uniform location where to store the value
  31121. * @param array defines the array of int32 to store
  31122. */
  31123. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31124. /**
  31125. * Set the value of an uniform to an array of float32
  31126. * @param uniform defines the webGL uniform location where to store the value
  31127. * @param array defines the array of float32 to store
  31128. */
  31129. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31130. /**
  31131. * Set the value of an uniform to an array of float32 (stored as vec2)
  31132. * @param uniform defines the webGL uniform location where to store the value
  31133. * @param array defines the array of float32 to store
  31134. */
  31135. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31136. /**
  31137. * Set the value of an uniform to an array of float32 (stored as vec3)
  31138. * @param uniform defines the webGL uniform location where to store the value
  31139. * @param array defines the array of float32 to store
  31140. */
  31141. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31142. /**
  31143. * Set the value of an uniform to an array of float32 (stored as vec4)
  31144. * @param uniform defines the webGL uniform location where to store the value
  31145. * @param array defines the array of float32 to store
  31146. */
  31147. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31148. /**
  31149. * Set the value of an uniform to an array of number
  31150. * @param uniform defines the webGL uniform location where to store the value
  31151. * @param array defines the array of number to store
  31152. */
  31153. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31154. /**
  31155. * Set the value of an uniform to an array of number (stored as vec2)
  31156. * @param uniform defines the webGL uniform location where to store the value
  31157. * @param array defines the array of number to store
  31158. */
  31159. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31160. /**
  31161. * Set the value of an uniform to an array of number (stored as vec3)
  31162. * @param uniform defines the webGL uniform location where to store the value
  31163. * @param array defines the array of number to store
  31164. */
  31165. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31166. /**
  31167. * Set the value of an uniform to an array of number (stored as vec4)
  31168. * @param uniform defines the webGL uniform location where to store the value
  31169. * @param array defines the array of number to store
  31170. */
  31171. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31172. /**
  31173. * Set the value of an uniform to an array of float32 (stored as matrices)
  31174. * @param uniform defines the webGL uniform location where to store the value
  31175. * @param matrices defines the array of float32 to store
  31176. */
  31177. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31178. /**
  31179. * Set the value of an uniform to a matrix (3x3)
  31180. * @param uniform defines the webGL uniform location where to store the value
  31181. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31182. */
  31183. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31184. /**
  31185. * Set the value of an uniform to a matrix (2x2)
  31186. * @param uniform defines the webGL uniform location where to store the value
  31187. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31188. */
  31189. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31190. /**
  31191. * Set the value of an uniform to a number (int)
  31192. * @param uniform defines the webGL uniform location where to store the value
  31193. * @param value defines the int number to store
  31194. */
  31195. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31196. /**
  31197. * Set the value of an uniform to a number (float)
  31198. * @param uniform defines the webGL uniform location where to store the value
  31199. * @param value defines the float number to store
  31200. */
  31201. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31202. /**
  31203. * Set the value of an uniform to a vec2
  31204. * @param uniform defines the webGL uniform location where to store the value
  31205. * @param x defines the 1st component of the value
  31206. * @param y defines the 2nd component of the value
  31207. */
  31208. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31209. /**
  31210. * Set the value of an uniform to a vec3
  31211. * @param uniform defines the webGL uniform location where to store the value
  31212. * @param x defines the 1st component of the value
  31213. * @param y defines the 2nd component of the value
  31214. * @param z defines the 3rd component of the value
  31215. */
  31216. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31217. /**
  31218. * Set the value of an uniform to a boolean
  31219. * @param uniform defines the webGL uniform location where to store the value
  31220. * @param bool defines the boolean to store
  31221. */
  31222. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31223. /**
  31224. * Set the value of an uniform to a vec4
  31225. * @param uniform defines the webGL uniform location where to store the value
  31226. * @param x defines the 1st component of the value
  31227. * @param y defines the 2nd component of the value
  31228. * @param z defines the 3rd component of the value
  31229. * @param w defines the 4th component of the value
  31230. */
  31231. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31232. /**
  31233. * Sets a Color4 on a uniform variable
  31234. * @param uniform defines the uniform location
  31235. * @param color4 defines the value to be set
  31236. */
  31237. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31238. /**
  31239. * Set various states to the webGL context
  31240. * @param culling defines backface culling state
  31241. * @param zOffset defines the value to apply to zOffset (0 by default)
  31242. * @param force defines if states must be applied even if cache is up to date
  31243. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31244. */
  31245. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31246. /**
  31247. * Set the z offset to apply to current rendering
  31248. * @param value defines the offset to apply
  31249. */
  31250. setZOffset(value: number): void;
  31251. /**
  31252. * Gets the current value of the zOffset
  31253. * @returns the current zOffset state
  31254. */
  31255. getZOffset(): number;
  31256. /**
  31257. * Enable or disable depth buffering
  31258. * @param enable defines the state to set
  31259. */
  31260. setDepthBuffer(enable: boolean): void;
  31261. /**
  31262. * Gets a boolean indicating if depth writing is enabled
  31263. * @returns the current depth writing state
  31264. */
  31265. getDepthWrite(): boolean;
  31266. /**
  31267. * Enable or disable depth writing
  31268. * @param enable defines the state to set
  31269. */
  31270. setDepthWrite(enable: boolean): void;
  31271. /**
  31272. * Enable or disable color writing
  31273. * @param enable defines the state to set
  31274. */
  31275. setColorWrite(enable: boolean): void;
  31276. /**
  31277. * Gets a boolean indicating if color writing is enabled
  31278. * @returns the current color writing state
  31279. */
  31280. getColorWrite(): boolean;
  31281. /**
  31282. * Sets alpha constants used by some alpha blending modes
  31283. * @param r defines the red component
  31284. * @param g defines the green component
  31285. * @param b defines the blue component
  31286. * @param a defines the alpha component
  31287. */
  31288. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31289. /**
  31290. * Sets the current alpha mode
  31291. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31292. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31293. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31294. */
  31295. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31296. /**
  31297. * Gets the current alpha mode
  31298. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31299. * @returns the current alpha mode
  31300. */
  31301. getAlphaMode(): number;
  31302. /**
  31303. * Clears the list of texture accessible through engine.
  31304. * This can help preventing texture load conflict due to name collision.
  31305. */
  31306. clearInternalTexturesCache(): void;
  31307. /**
  31308. * Force the entire cache to be cleared
  31309. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31310. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31311. */
  31312. wipeCaches(bruteForce?: boolean): void;
  31313. /**
  31314. * Set the compressed texture format to use, based on the formats you have, and the formats
  31315. * supported by the hardware / browser.
  31316. *
  31317. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31318. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31319. * to API arguments needed to compressed textures. This puts the burden on the container
  31320. * generator to house the arcane code for determining these for current & future formats.
  31321. *
  31322. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31323. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31324. *
  31325. * Note: The result of this call is not taken into account when a texture is base64.
  31326. *
  31327. * @param formatsAvailable defines the list of those format families you have created
  31328. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31329. *
  31330. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31331. * @returns The extension selected.
  31332. */
  31333. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31334. /** @hidden */
  31335. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31336. min: number;
  31337. mag: number;
  31338. };
  31339. /** @hidden */
  31340. _createTexture(): WebGLTexture;
  31341. /**
  31342. * Usually called from Texture.ts.
  31343. * Passed information to create a WebGLTexture
  31344. * @param urlArg defines a value which contains one of the following:
  31345. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31346. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31347. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31348. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31349. * @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)
  31350. * @param scene needed for loading to the correct scene
  31351. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31352. * @param onLoad optional callback to be called upon successful completion
  31353. * @param onError optional callback to be called upon failure
  31354. * @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
  31355. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31356. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31357. * @param forcedExtension defines the extension to use to pick the right loader
  31358. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31359. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31360. */
  31361. 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 | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  31362. /**
  31363. * @hidden
  31364. * Rescales a texture
  31365. * @param source input texutre
  31366. * @param destination destination texture
  31367. * @param scene scene to use to render the resize
  31368. * @param internalFormat format to use when resizing
  31369. * @param onComplete callback to be called when resize has completed
  31370. */
  31371. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  31372. private _unpackFlipYCached;
  31373. /**
  31374. * In case you are sharing the context with other applications, it might
  31375. * be interested to not cache the unpack flip y state to ensure a consistent
  31376. * value would be set.
  31377. */
  31378. enableUnpackFlipYCached: boolean;
  31379. /** @hidden */
  31380. _unpackFlipY(value: boolean): void;
  31381. /** @hidden */
  31382. _getUnpackAlignement(): number;
  31383. /**
  31384. * Creates a dynamic texture
  31385. * @param width defines the width of the texture
  31386. * @param height defines the height of the texture
  31387. * @param generateMipMaps defines if the engine should generate the mip levels
  31388. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31389. * @returns the dynamic texture inside an InternalTexture
  31390. */
  31391. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  31392. /**
  31393. * Update the sampling mode of a given texture
  31394. * @param samplingMode defines the required sampling mode
  31395. * @param texture defines the texture to update
  31396. */
  31397. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31398. /**
  31399. * Update the content of a dynamic texture
  31400. * @param texture defines the texture to update
  31401. * @param canvas defines the canvas containing the source
  31402. * @param invertY defines if data must be stored with Y axis inverted
  31403. * @param premulAlpha defines if alpha is stored as premultiplied
  31404. * @param format defines the format of the data
  31405. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31406. */
  31407. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  31408. /**
  31409. * Update a video texture
  31410. * @param texture defines the texture to update
  31411. * @param video defines the video element to use
  31412. * @param invertY defines if data must be stored with Y axis inverted
  31413. */
  31414. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31415. /**
  31416. * Updates a depth texture Comparison Mode and Function.
  31417. * If the comparison Function is equal to 0, the mode will be set to none.
  31418. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31419. * @param texture The texture to set the comparison function for
  31420. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31421. */
  31422. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  31423. /** @hidden */
  31424. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31425. width: number;
  31426. height: number;
  31427. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31428. /**
  31429. * Creates a depth stencil texture.
  31430. * This is only available in WebGL 2 or with the depth texture extension available.
  31431. * @param size The size of face edge in the texture.
  31432. * @param options The options defining the texture.
  31433. * @returns The texture
  31434. */
  31435. createDepthStencilTexture(size: number | {
  31436. width: number;
  31437. height: number;
  31438. }, options: DepthTextureCreationOptions): InternalTexture;
  31439. /**
  31440. * Creates a depth stencil texture.
  31441. * This is only available in WebGL 2 or with the depth texture extension available.
  31442. * @param size The size of face edge in the texture.
  31443. * @param options The options defining the texture.
  31444. * @returns The texture
  31445. */
  31446. private _createDepthStencilTexture;
  31447. /**
  31448. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31449. * @param renderTarget The render target to set the frame buffer for
  31450. */
  31451. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31452. /**
  31453. * Creates a new render target texture
  31454. * @param size defines the size of the texture
  31455. * @param options defines the options used to create the texture
  31456. * @returns a new render target texture stored in an InternalTexture
  31457. */
  31458. createRenderTargetTexture(size: number | {
  31459. width: number;
  31460. height: number;
  31461. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31462. /** @hidden */
  31463. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31464. /**
  31465. * Updates the sample count of a render target texture
  31466. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31467. * @param texture defines the texture to update
  31468. * @param samples defines the sample count to set
  31469. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31470. */
  31471. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31472. /** @hidden */
  31473. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31474. /** @hidden */
  31475. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31476. /** @hidden */
  31477. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31478. /** @hidden */
  31479. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31480. /**
  31481. * @hidden
  31482. */
  31483. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31484. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31485. private _prepareWebGLTexture;
  31486. /** @hidden */
  31487. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31488. /** @hidden */
  31489. _releaseFramebufferObjects(texture: InternalTexture): void;
  31490. /** @hidden */
  31491. _releaseTexture(texture: InternalTexture): void;
  31492. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31493. protected _setProgram(program: WebGLProgram): void;
  31494. protected _boundUniforms: {
  31495. [key: number]: WebGLUniformLocation;
  31496. };
  31497. /**
  31498. * Binds an effect to the webGL context
  31499. * @param effect defines the effect to bind
  31500. */
  31501. bindSamplers(effect: Effect): void;
  31502. private _activateCurrentTexture;
  31503. /** @hidden */
  31504. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31505. /** @hidden */
  31506. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31507. /**
  31508. * Sets a texture to the webGL context from a postprocess
  31509. * @param channel defines the channel to use
  31510. * @param postProcess defines the source postprocess
  31511. */
  31512. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31513. /**
  31514. * Binds the output of the passed in post process to the texture channel specified
  31515. * @param channel The channel the texture should be bound to
  31516. * @param postProcess The post process which's output should be bound
  31517. */
  31518. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31519. /**
  31520. * Unbind all textures from the webGL context
  31521. */
  31522. unbindAllTextures(): void;
  31523. /**
  31524. * Sets a texture to the according uniform.
  31525. * @param channel The texture channel
  31526. * @param uniform The uniform to set
  31527. * @param texture The texture to apply
  31528. */
  31529. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31530. /**
  31531. * Sets a depth stencil texture from a render target to the according uniform.
  31532. * @param channel The texture channel
  31533. * @param uniform The uniform to set
  31534. * @param texture The render target texture containing the depth stencil texture to apply
  31535. */
  31536. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31537. private _bindSamplerUniformToChannel;
  31538. private _getTextureWrapMode;
  31539. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31540. /**
  31541. * Sets an array of texture to the webGL context
  31542. * @param channel defines the channel where the texture array must be set
  31543. * @param uniform defines the associated uniform location
  31544. * @param textures defines the array of textures to bind
  31545. */
  31546. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31547. /** @hidden */
  31548. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31549. private _setTextureParameterFloat;
  31550. private _setTextureParameterInteger;
  31551. /**
  31552. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31553. * @param x defines the x coordinate of the rectangle where pixels must be read
  31554. * @param y defines the y coordinate of the rectangle where pixels must be read
  31555. * @param width defines the width of the rectangle where pixels must be read
  31556. * @param height defines the height of the rectangle where pixels must be read
  31557. * @returns a Uint8Array containing RGBA colors
  31558. */
  31559. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31560. /**
  31561. * Add an externaly attached data from its key.
  31562. * This method call will fail and return false, if such key already exists.
  31563. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  31564. * @param key the unique key that identifies the data
  31565. * @param data the data object to associate to the key for this Engine instance
  31566. * @return true if no such key were already present and the data was added successfully, false otherwise
  31567. */
  31568. addExternalData<T>(key: string, data: T): boolean;
  31569. /**
  31570. * Get an externaly attached data from its key
  31571. * @param key the unique key that identifies the data
  31572. * @return the associated data, if present (can be null), or undefined if not present
  31573. */
  31574. getExternalData<T>(key: string): T;
  31575. /**
  31576. * Get an externaly attached data from its key, create it using a factory if it's not already present
  31577. * @param key the unique key that identifies the data
  31578. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  31579. * @return the associated data, can be null if the factory returned null.
  31580. */
  31581. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  31582. /**
  31583. * Remove an externaly attached data from the Engine instance
  31584. * @param key the unique key that identifies the data
  31585. * @return true if the data was successfully removed, false if it doesn't exist
  31586. */
  31587. removeExternalData(key: string): boolean;
  31588. /**
  31589. * Unbind all vertex attributes from the webGL context
  31590. */
  31591. unbindAllAttributes(): void;
  31592. /**
  31593. * 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
  31594. */
  31595. releaseEffects(): void;
  31596. /**
  31597. * Dispose and release all associated resources
  31598. */
  31599. dispose(): void;
  31600. /**
  31601. * Display the loading screen
  31602. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31603. */
  31604. displayLoadingUI(): void;
  31605. /**
  31606. * Hide the loading screen
  31607. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31608. */
  31609. hideLoadingUI(): void;
  31610. /**
  31611. * Gets the current loading screen object
  31612. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31613. */
  31614. /**
  31615. * Sets the current loading screen object
  31616. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31617. */
  31618. loadingScreen: ILoadingScreen;
  31619. /**
  31620. * Sets the current loading screen text
  31621. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31622. */
  31623. loadingUIText: string;
  31624. /**
  31625. * Sets the current loading screen background color
  31626. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31627. */
  31628. loadingUIBackgroundColor: string;
  31629. /**
  31630. * Attach a new callback raised when context lost event is fired
  31631. * @param callback defines the callback to call
  31632. */
  31633. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31634. /**
  31635. * Attach a new callback raised when context restored event is fired
  31636. * @param callback defines the callback to call
  31637. */
  31638. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31639. /**
  31640. * Gets the source code of the vertex shader associated with a specific webGL program
  31641. * @param program defines the program to use
  31642. * @returns a string containing the source code of the vertex shader associated with the program
  31643. */
  31644. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31645. /**
  31646. * Gets the source code of the fragment shader associated with a specific webGL program
  31647. * @param program defines the program to use
  31648. * @returns a string containing the source code of the fragment shader associated with the program
  31649. */
  31650. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31651. /**
  31652. * Get the current error code of the webGL context
  31653. * @returns the error code
  31654. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31655. */
  31656. getError(): number;
  31657. /**
  31658. * Gets the current framerate
  31659. * @returns a number representing the framerate
  31660. */
  31661. getFps(): number;
  31662. /**
  31663. * Gets the time spent between current and previous frame
  31664. * @returns a number representing the delta time in ms
  31665. */
  31666. getDeltaTime(): number;
  31667. private _measureFps;
  31668. /** @hidden */
  31669. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31670. private _canRenderToFloatFramebuffer;
  31671. private _canRenderToHalfFloatFramebuffer;
  31672. private _canRenderToFramebuffer;
  31673. /** @hidden */
  31674. _getWebGLTextureType(type: number): number;
  31675. /** @hidden */
  31676. _getInternalFormat(format: number): number;
  31677. /** @hidden */
  31678. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31679. /** @hidden */
  31680. _getRGBAMultiSampleBufferFormat(type: number): number;
  31681. /** @hidden */
  31682. _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;
  31683. /** @hidden */
  31684. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31685. /**
  31686. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31687. * @returns true if the engine can be created
  31688. * @ignorenaming
  31689. */
  31690. static isSupported(): boolean;
  31691. /**
  31692. * Find the next highest power of two.
  31693. * @param x Number to start search from.
  31694. * @return Next highest power of two.
  31695. */
  31696. static CeilingPOT(x: number): number;
  31697. /**
  31698. * Find the next lowest power of two.
  31699. * @param x Number to start search from.
  31700. * @return Next lowest power of two.
  31701. */
  31702. static FloorPOT(x: number): number;
  31703. /**
  31704. * Find the nearest power of two.
  31705. * @param x Number to start search from.
  31706. * @return Next nearest power of two.
  31707. */
  31708. static NearestPOT(x: number): number;
  31709. /**
  31710. * Get the closest exponent of two
  31711. * @param value defines the value to approximate
  31712. * @param max defines the maximum value to return
  31713. * @param mode defines how to define the closest value
  31714. * @returns closest exponent of two of the given value
  31715. */
  31716. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31717. /**
  31718. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31719. * @param func - the function to be called
  31720. * @param requester - the object that will request the next frame. Falls back to window.
  31721. * @returns frame number
  31722. */
  31723. static QueueNewFrame(func: () => void, requester?: any): number;
  31724. /**
  31725. * Ask the browser to promote the current element to pointerlock mode
  31726. * @param element defines the DOM element to promote
  31727. */
  31728. static _RequestPointerlock(element: HTMLElement): void;
  31729. /**
  31730. * Asks the browser to exit pointerlock mode
  31731. */
  31732. static _ExitPointerlock(): void;
  31733. /**
  31734. * Ask the browser to promote the current element to fullscreen rendering mode
  31735. * @param element defines the DOM element to promote
  31736. */
  31737. static _RequestFullscreen(element: HTMLElement): void;
  31738. /**
  31739. * Asks the browser to exit fullscreen mode
  31740. */
  31741. static _ExitFullscreen(): void;
  31742. }
  31743. }
  31744. declare module BABYLON {
  31745. /**
  31746. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31747. * during the life time of the application.
  31748. */
  31749. export class EngineStore {
  31750. /** Gets the list of created engines */
  31751. static Instances: Engine[];
  31752. /** @hidden */
  31753. static _LastCreatedScene: Nullable<Scene>;
  31754. /**
  31755. * Gets the latest created engine
  31756. */
  31757. static readonly LastCreatedEngine: Nullable<Engine>;
  31758. /**
  31759. * Gets the latest created scene
  31760. */
  31761. static readonly LastCreatedScene: Nullable<Scene>;
  31762. /**
  31763. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31764. * @ignorenaming
  31765. */
  31766. static UseFallbackTexture: boolean;
  31767. /**
  31768. * Texture content used if a texture cannot loaded
  31769. * @ignorenaming
  31770. */
  31771. static FallbackTexture: string;
  31772. }
  31773. }
  31774. declare module BABYLON {
  31775. /**
  31776. * Helper class that provides a small promise polyfill
  31777. */
  31778. export class PromisePolyfill {
  31779. /**
  31780. * Static function used to check if the polyfill is required
  31781. * If this is the case then the function will inject the polyfill to window.Promise
  31782. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31783. */
  31784. static Apply(force?: boolean): void;
  31785. }
  31786. }
  31787. declare module BABYLON {
  31788. /**
  31789. * Interface for screenshot methods with describe argument called `size` as object with options
  31790. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31791. */
  31792. export interface IScreenshotSize {
  31793. /**
  31794. * number in pixels for canvas height
  31795. */
  31796. height?: number;
  31797. /**
  31798. * multiplier allowing render at a higher or lower resolution
  31799. * If value is defined then height and width will be ignored and taken from camera
  31800. */
  31801. precision?: number;
  31802. /**
  31803. * number in pixels for canvas width
  31804. */
  31805. width?: number;
  31806. }
  31807. }
  31808. declare module BABYLON {
  31809. interface IColor4Like {
  31810. r: float;
  31811. g: float;
  31812. b: float;
  31813. a: float;
  31814. }
  31815. /**
  31816. * Class containing a set of static utilities functions
  31817. */
  31818. export class Tools {
  31819. /**
  31820. * Gets or sets the base URL to use to load assets
  31821. */
  31822. static BaseUrl: string;
  31823. /**
  31824. * Enable/Disable Custom HTTP Request Headers globally.
  31825. * default = false
  31826. * @see CustomRequestHeaders
  31827. */
  31828. static UseCustomRequestHeaders: boolean;
  31829. /**
  31830. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31831. * i.e. when loading files, where the server/service expects an Authorization header
  31832. */
  31833. static CustomRequestHeaders: {
  31834. [key: string]: string;
  31835. };
  31836. /**
  31837. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31838. */
  31839. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31840. /**
  31841. * Default behaviour for cors in the application.
  31842. * It can be a string if the expected behavior is identical in the entire app.
  31843. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31844. */
  31845. static CorsBehavior: string | ((url: string | string[]) => string);
  31846. /**
  31847. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31848. * @ignorenaming
  31849. */
  31850. static UseFallbackTexture: boolean;
  31851. /**
  31852. * Use this object to register external classes like custom textures or material
  31853. * to allow the laoders to instantiate them
  31854. */
  31855. static RegisteredExternalClasses: {
  31856. [key: string]: Object;
  31857. };
  31858. /**
  31859. * Texture content used if a texture cannot loaded
  31860. * @ignorenaming
  31861. */
  31862. static fallbackTexture: string;
  31863. /**
  31864. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31865. * @param u defines the coordinate on X axis
  31866. * @param v defines the coordinate on Y axis
  31867. * @param width defines the width of the source data
  31868. * @param height defines the height of the source data
  31869. * @param pixels defines the source byte array
  31870. * @param color defines the output color
  31871. */
  31872. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31873. /**
  31874. * Interpolates between a and b via alpha
  31875. * @param a The lower value (returned when alpha = 0)
  31876. * @param b The upper value (returned when alpha = 1)
  31877. * @param alpha The interpolation-factor
  31878. * @return The mixed value
  31879. */
  31880. static Mix(a: number, b: number, alpha: number): number;
  31881. /**
  31882. * Tries to instantiate a new object from a given class name
  31883. * @param className defines the class name to instantiate
  31884. * @returns the new object or null if the system was not able to do the instantiation
  31885. */
  31886. static Instantiate(className: string): any;
  31887. /**
  31888. * Provides a slice function that will work even on IE
  31889. * @param data defines the array to slice
  31890. * @param start defines the start of the data (optional)
  31891. * @param end defines the end of the data (optional)
  31892. * @returns the new sliced array
  31893. */
  31894. static Slice<T>(data: T, start?: number, end?: number): T;
  31895. /**
  31896. * Polyfill for setImmediate
  31897. * @param action defines the action to execute after the current execution block
  31898. */
  31899. static SetImmediate(action: () => void): void;
  31900. /**
  31901. * Function indicating if a number is an exponent of 2
  31902. * @param value defines the value to test
  31903. * @returns true if the value is an exponent of 2
  31904. */
  31905. static IsExponentOfTwo(value: number): boolean;
  31906. private static _tmpFloatArray;
  31907. /**
  31908. * Returns the nearest 32-bit single precision float representation of a Number
  31909. * @param value A Number. If the parameter is of a different type, it will get converted
  31910. * to a number or to NaN if it cannot be converted
  31911. * @returns number
  31912. */
  31913. static FloatRound(value: number): number;
  31914. /**
  31915. * Extracts the filename from a path
  31916. * @param path defines the path to use
  31917. * @returns the filename
  31918. */
  31919. static GetFilename(path: string): string;
  31920. /**
  31921. * Extracts the "folder" part of a path (everything before the filename).
  31922. * @param uri The URI to extract the info from
  31923. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31924. * @returns The "folder" part of the path
  31925. */
  31926. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31927. /**
  31928. * Extracts text content from a DOM element hierarchy
  31929. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31930. */
  31931. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31932. /**
  31933. * Convert an angle in radians to degrees
  31934. * @param angle defines the angle to convert
  31935. * @returns the angle in degrees
  31936. */
  31937. static ToDegrees(angle: number): number;
  31938. /**
  31939. * Convert an angle in degrees to radians
  31940. * @param angle defines the angle to convert
  31941. * @returns the angle in radians
  31942. */
  31943. static ToRadians(angle: number): number;
  31944. /**
  31945. * Encode a buffer to a base64 string
  31946. * @param buffer defines the buffer to encode
  31947. * @returns the encoded string
  31948. */
  31949. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31950. /**
  31951. * Returns an array if obj is not an array
  31952. * @param obj defines the object to evaluate as an array
  31953. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31954. * @returns either obj directly if obj is an array or a new array containing obj
  31955. */
  31956. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31957. /**
  31958. * Gets the pointer prefix to use
  31959. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31960. */
  31961. static GetPointerPrefix(): string;
  31962. /**
  31963. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31964. * @param url define the url we are trying
  31965. * @param element define the dom element where to configure the cors policy
  31966. */
  31967. static SetCorsBehavior(url: string | string[], element: {
  31968. crossOrigin: string | null;
  31969. }): void;
  31970. /**
  31971. * Removes unwanted characters from an url
  31972. * @param url defines the url to clean
  31973. * @returns the cleaned url
  31974. */
  31975. static CleanUrl(url: string): string;
  31976. /**
  31977. * Gets or sets a function used to pre-process url before using them to load assets
  31978. */
  31979. static PreprocessUrl: (url: string) => string;
  31980. /**
  31981. * Loads an image as an HTMLImageElement.
  31982. * @param input url string, ArrayBuffer, or Blob to load
  31983. * @param onLoad callback called when the image successfully loads
  31984. * @param onError callback called when the image fails to load
  31985. * @param offlineProvider offline provider for caching
  31986. * @returns the HTMLImageElement of the loaded image
  31987. */
  31988. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31989. /**
  31990. * Loads a file
  31991. * @param url url string, ArrayBuffer, or Blob to load
  31992. * @param onSuccess callback called when the file successfully loads
  31993. * @param onProgress callback called while file is loading (if the server supports this mode)
  31994. * @param offlineProvider defines the offline provider for caching
  31995. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31996. * @param onError callback called when the file fails to load
  31997. * @returns a file request object
  31998. */
  31999. 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;
  32000. /**
  32001. * Loads a file from a url
  32002. * @param url the file url to load
  32003. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32004. */
  32005. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32006. /**
  32007. * Load a script (identified by an url). When the url returns, the
  32008. * content of this file is added into a new script element, attached to the DOM (body element)
  32009. * @param scriptUrl defines the url of the script to laod
  32010. * @param onSuccess defines the callback called when the script is loaded
  32011. * @param onError defines the callback to call if an error occurs
  32012. * @param scriptId defines the id of the script element
  32013. */
  32014. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32015. /**
  32016. * Load an asynchronous script (identified by an url). When the url returns, the
  32017. * content of this file is added into a new script element, attached to the DOM (body element)
  32018. * @param scriptUrl defines the url of the script to laod
  32019. * @param scriptId defines the id of the script element
  32020. * @returns a promise request object
  32021. */
  32022. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32023. /**
  32024. * Loads a file from a blob
  32025. * @param fileToLoad defines the blob to use
  32026. * @param callback defines the callback to call when data is loaded
  32027. * @param progressCallback defines the callback to call during loading process
  32028. * @returns a file request object
  32029. */
  32030. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32031. /**
  32032. * Loads a file
  32033. * @param fileToLoad defines the file to load
  32034. * @param callback defines the callback to call when data is loaded
  32035. * @param progressCallBack defines the callback to call during loading process
  32036. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32037. * @returns a file request object
  32038. */
  32039. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32040. /**
  32041. * Creates a data url from a given string content
  32042. * @param content defines the content to convert
  32043. * @returns the new data url link
  32044. */
  32045. static FileAsURL(content: string): string;
  32046. /**
  32047. * Format the given number to a specific decimal format
  32048. * @param value defines the number to format
  32049. * @param decimals defines the number of decimals to use
  32050. * @returns the formatted string
  32051. */
  32052. static Format(value: number, decimals?: number): string;
  32053. /**
  32054. * Tries to copy an object by duplicating every property
  32055. * @param source defines the source object
  32056. * @param destination defines the target object
  32057. * @param doNotCopyList defines a list of properties to avoid
  32058. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32059. */
  32060. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32061. /**
  32062. * Gets a boolean indicating if the given object has no own property
  32063. * @param obj defines the object to test
  32064. * @returns true if object has no own property
  32065. */
  32066. static IsEmpty(obj: any): boolean;
  32067. /**
  32068. * Function used to register events at window level
  32069. * @param windowElement defines the Window object to use
  32070. * @param events defines the events to register
  32071. */
  32072. static RegisterTopRootEvents(windowElement: Window, events: {
  32073. name: string;
  32074. handler: Nullable<(e: FocusEvent) => any>;
  32075. }[]): void;
  32076. /**
  32077. * Function used to unregister events from window level
  32078. * @param windowElement defines the Window object to use
  32079. * @param events defines the events to unregister
  32080. */
  32081. static UnregisterTopRootEvents(windowElement: Window, events: {
  32082. name: string;
  32083. handler: Nullable<(e: FocusEvent) => any>;
  32084. }[]): void;
  32085. /**
  32086. * @ignore
  32087. */
  32088. static _ScreenshotCanvas: HTMLCanvasElement;
  32089. /**
  32090. * Dumps the current bound framebuffer
  32091. * @param width defines the rendering width
  32092. * @param height defines the rendering height
  32093. * @param engine defines the hosting engine
  32094. * @param successCallback defines the callback triggered once the data are available
  32095. * @param mimeType defines the mime type of the result
  32096. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32097. */
  32098. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32099. /**
  32100. * Converts the canvas data to blob.
  32101. * This acts as a polyfill for browsers not supporting the to blob function.
  32102. * @param canvas Defines the canvas to extract the data from
  32103. * @param successCallback Defines the callback triggered once the data are available
  32104. * @param mimeType Defines the mime type of the result
  32105. */
  32106. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32107. /**
  32108. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32109. * @param successCallback defines the callback triggered once the data are available
  32110. * @param mimeType defines the mime type of the result
  32111. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32112. */
  32113. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32114. /**
  32115. * Downloads a blob in the browser
  32116. * @param blob defines the blob to download
  32117. * @param fileName defines the name of the downloaded file
  32118. */
  32119. static Download(blob: Blob, fileName: string): void;
  32120. /**
  32121. * Captures a screenshot of the current rendering
  32122. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32123. * @param engine defines the rendering engine
  32124. * @param camera defines the source camera
  32125. * @param size This parameter can be set to a single number or to an object with the
  32126. * following (optional) properties: precision, width, height. If a single number is passed,
  32127. * it will be used for both width and height. If an object is passed, the screenshot size
  32128. * will be derived from the parameters. The precision property is a multiplier allowing
  32129. * rendering at a higher or lower resolution
  32130. * @param successCallback defines the callback receives a single parameter which contains the
  32131. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32132. * src parameter of an <img> to display it
  32133. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32134. * Check your browser for supported MIME types
  32135. */
  32136. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32137. /**
  32138. * Captures a screenshot of the current rendering
  32139. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32140. * @param engine defines the rendering engine
  32141. * @param camera defines the source camera
  32142. * @param size This parameter can be set to a single number or to an object with the
  32143. * following (optional) properties: precision, width, height. If a single number is passed,
  32144. * it will be used for both width and height. If an object is passed, the screenshot size
  32145. * will be derived from the parameters. The precision property is a multiplier allowing
  32146. * rendering at a higher or lower resolution
  32147. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32148. * Check your browser for supported MIME types
  32149. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32150. * to the src parameter of an <img> to display it
  32151. */
  32152. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32153. /**
  32154. * Generates an image screenshot from the specified camera.
  32155. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32156. * @param engine The engine to use for rendering
  32157. * @param camera The camera to use for rendering
  32158. * @param size This parameter can be set to a single number or to an object with the
  32159. * following (optional) properties: precision, width, height. If a single number is passed,
  32160. * it will be used for both width and height. If an object is passed, the screenshot size
  32161. * will be derived from the parameters. The precision property is a multiplier allowing
  32162. * rendering at a higher or lower resolution
  32163. * @param successCallback The callback receives a single parameter which contains the
  32164. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32165. * src parameter of an <img> to display it
  32166. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32167. * Check your browser for supported MIME types
  32168. * @param samples Texture samples (default: 1)
  32169. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32170. * @param fileName A name for for the downloaded file.
  32171. */
  32172. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32173. /**
  32174. * Generates an image screenshot from the specified camera.
  32175. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32176. * @param engine The engine to use for rendering
  32177. * @param camera The camera to use for rendering
  32178. * @param size This parameter can be set to a single number or to an object with the
  32179. * following (optional) properties: precision, width, height. If a single number is passed,
  32180. * it will be used for both width and height. If an object is passed, the screenshot size
  32181. * will be derived from the parameters. The precision property is a multiplier allowing
  32182. * rendering at a higher or lower resolution
  32183. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32184. * Check your browser for supported MIME types
  32185. * @param samples Texture samples (default: 1)
  32186. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32187. * @param fileName A name for for the downloaded file.
  32188. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32189. * to the src parameter of an <img> to display it
  32190. */
  32191. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32192. /**
  32193. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32194. * Be aware Math.random() could cause collisions, but:
  32195. * "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"
  32196. * @returns a pseudo random id
  32197. */
  32198. static RandomId(): string;
  32199. /**
  32200. * Test if the given uri is a base64 string
  32201. * @param uri The uri to test
  32202. * @return True if the uri is a base64 string or false otherwise
  32203. */
  32204. static IsBase64(uri: string): boolean;
  32205. /**
  32206. * Decode the given base64 uri.
  32207. * @param uri The uri to decode
  32208. * @return The decoded base64 data.
  32209. */
  32210. static DecodeBase64(uri: string): ArrayBuffer;
  32211. /**
  32212. * Gets the absolute url.
  32213. * @param url the input url
  32214. * @return the absolute url
  32215. */
  32216. static GetAbsoluteUrl(url: string): string;
  32217. /**
  32218. * No log
  32219. */
  32220. static readonly NoneLogLevel: number;
  32221. /**
  32222. * Only message logs
  32223. */
  32224. static readonly MessageLogLevel: number;
  32225. /**
  32226. * Only warning logs
  32227. */
  32228. static readonly WarningLogLevel: number;
  32229. /**
  32230. * Only error logs
  32231. */
  32232. static readonly ErrorLogLevel: number;
  32233. /**
  32234. * All logs
  32235. */
  32236. static readonly AllLogLevel: number;
  32237. /**
  32238. * Gets a value indicating the number of loading errors
  32239. * @ignorenaming
  32240. */
  32241. static readonly errorsCount: number;
  32242. /**
  32243. * Callback called when a new log is added
  32244. */
  32245. static OnNewCacheEntry: (entry: string) => void;
  32246. /**
  32247. * Log a message to the console
  32248. * @param message defines the message to log
  32249. */
  32250. static Log(message: string): void;
  32251. /**
  32252. * Write a warning message to the console
  32253. * @param message defines the message to log
  32254. */
  32255. static Warn(message: string): void;
  32256. /**
  32257. * Write an error message to the console
  32258. * @param message defines the message to log
  32259. */
  32260. static Error(message: string): void;
  32261. /**
  32262. * Gets current log cache (list of logs)
  32263. */
  32264. static readonly LogCache: string;
  32265. /**
  32266. * Clears the log cache
  32267. */
  32268. static ClearLogCache(): void;
  32269. /**
  32270. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32271. */
  32272. static LogLevels: number;
  32273. /**
  32274. * Checks if the window object exists
  32275. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32276. */
  32277. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32278. /**
  32279. * No performance log
  32280. */
  32281. static readonly PerformanceNoneLogLevel: number;
  32282. /**
  32283. * Use user marks to log performance
  32284. */
  32285. static readonly PerformanceUserMarkLogLevel: number;
  32286. /**
  32287. * Log performance to the console
  32288. */
  32289. static readonly PerformanceConsoleLogLevel: number;
  32290. private static _performance;
  32291. /**
  32292. * Sets the current performance log level
  32293. */
  32294. static PerformanceLogLevel: number;
  32295. private static _StartPerformanceCounterDisabled;
  32296. private static _EndPerformanceCounterDisabled;
  32297. private static _StartUserMark;
  32298. private static _EndUserMark;
  32299. private static _StartPerformanceConsole;
  32300. private static _EndPerformanceConsole;
  32301. /**
  32302. * Starts a performance counter
  32303. */
  32304. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32305. /**
  32306. * Ends a specific performance coutner
  32307. */
  32308. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32309. /**
  32310. * Gets either window.performance.now() if supported or Date.now() else
  32311. */
  32312. static readonly Now: number;
  32313. /**
  32314. * This method will return the name of the class used to create the instance of the given object.
  32315. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32316. * @param object the object to get the class name from
  32317. * @param isType defines if the object is actually a type
  32318. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32319. */
  32320. static GetClassName(object: any, isType?: boolean): string;
  32321. /**
  32322. * Gets the first element of an array satisfying a given predicate
  32323. * @param array defines the array to browse
  32324. * @param predicate defines the predicate to use
  32325. * @returns null if not found or the element
  32326. */
  32327. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32328. /**
  32329. * This method will return the name of the full name of the class, including its owning module (if any).
  32330. * 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).
  32331. * @param object the object to get the class name from
  32332. * @param isType defines if the object is actually a type
  32333. * @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.
  32334. * @ignorenaming
  32335. */
  32336. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32337. /**
  32338. * Returns a promise that resolves after the given amount of time.
  32339. * @param delay Number of milliseconds to delay
  32340. * @returns Promise that resolves after the given amount of time
  32341. */
  32342. static DelayAsync(delay: number): Promise<void>;
  32343. }
  32344. /**
  32345. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32346. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32347. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32348. * @param name The name of the class, case should be preserved
  32349. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32350. */
  32351. export function className(name: string, module?: string): (target: Object) => void;
  32352. /**
  32353. * An implementation of a loop for asynchronous functions.
  32354. */
  32355. export class AsyncLoop {
  32356. /**
  32357. * Defines the number of iterations for the loop
  32358. */
  32359. iterations: number;
  32360. /**
  32361. * Defines the current index of the loop.
  32362. */
  32363. index: number;
  32364. private _done;
  32365. private _fn;
  32366. private _successCallback;
  32367. /**
  32368. * Constructor.
  32369. * @param iterations the number of iterations.
  32370. * @param func the function to run each iteration
  32371. * @param successCallback the callback that will be called upon succesful execution
  32372. * @param offset starting offset.
  32373. */
  32374. constructor(
  32375. /**
  32376. * Defines the number of iterations for the loop
  32377. */
  32378. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32379. /**
  32380. * Execute the next iteration. Must be called after the last iteration was finished.
  32381. */
  32382. executeNext(): void;
  32383. /**
  32384. * Break the loop and run the success callback.
  32385. */
  32386. breakLoop(): void;
  32387. /**
  32388. * Create and run an async loop.
  32389. * @param iterations the number of iterations.
  32390. * @param fn the function to run each iteration
  32391. * @param successCallback the callback that will be called upon succesful execution
  32392. * @param offset starting offset.
  32393. * @returns the created async loop object
  32394. */
  32395. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32396. /**
  32397. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32398. * @param iterations total number of iterations
  32399. * @param syncedIterations number of synchronous iterations in each async iteration.
  32400. * @param fn the function to call each iteration.
  32401. * @param callback a success call back that will be called when iterating stops.
  32402. * @param breakFunction a break condition (optional)
  32403. * @param timeout timeout settings for the setTimeout function. default - 0.
  32404. * @returns the created async loop object
  32405. */
  32406. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32407. }
  32408. }
  32409. declare module BABYLON {
  32410. /** @hidden */
  32411. export interface ICollisionCoordinator {
  32412. createCollider(): Collider;
  32413. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32414. init(scene: Scene): void;
  32415. }
  32416. /** @hidden */
  32417. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32418. private _scene;
  32419. private _scaledPosition;
  32420. private _scaledVelocity;
  32421. private _finalPosition;
  32422. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32423. createCollider(): Collider;
  32424. init(scene: Scene): void;
  32425. private _collideWithWorld;
  32426. }
  32427. }
  32428. declare module BABYLON {
  32429. /**
  32430. * Class used to manage all inputs for the scene.
  32431. */
  32432. export class InputManager {
  32433. /** The distance in pixel that you have to move to prevent some events */
  32434. static DragMovementThreshold: number;
  32435. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32436. static LongPressDelay: number;
  32437. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32438. static DoubleClickDelay: number;
  32439. /** If you need to check double click without raising a single click at first click, enable this flag */
  32440. static ExclusiveDoubleClickMode: boolean;
  32441. private _wheelEventName;
  32442. private _onPointerMove;
  32443. private _onPointerDown;
  32444. private _onPointerUp;
  32445. private _initClickEvent;
  32446. private _initActionManager;
  32447. private _delayedSimpleClick;
  32448. private _delayedSimpleClickTimeout;
  32449. private _previousDelayedSimpleClickTimeout;
  32450. private _meshPickProceed;
  32451. private _previousButtonPressed;
  32452. private _currentPickResult;
  32453. private _previousPickResult;
  32454. private _totalPointersPressed;
  32455. private _doubleClickOccured;
  32456. private _pointerOverMesh;
  32457. private _pickedDownMesh;
  32458. private _pickedUpMesh;
  32459. private _pointerX;
  32460. private _pointerY;
  32461. private _unTranslatedPointerX;
  32462. private _unTranslatedPointerY;
  32463. private _startingPointerPosition;
  32464. private _previousStartingPointerPosition;
  32465. private _startingPointerTime;
  32466. private _previousStartingPointerTime;
  32467. private _pointerCaptures;
  32468. private _onKeyDown;
  32469. private _onKeyUp;
  32470. private _onCanvasFocusObserver;
  32471. private _onCanvasBlurObserver;
  32472. private _scene;
  32473. /**
  32474. * Creates a new InputManager
  32475. * @param scene defines the hosting scene
  32476. */
  32477. constructor(scene: Scene);
  32478. /**
  32479. * Gets the mesh that is currently under the pointer
  32480. */
  32481. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32482. /**
  32483. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32484. */
  32485. readonly unTranslatedPointer: Vector2;
  32486. /**
  32487. * Gets or sets the current on-screen X position of the pointer
  32488. */
  32489. pointerX: number;
  32490. /**
  32491. * Gets or sets the current on-screen Y position of the pointer
  32492. */
  32493. pointerY: number;
  32494. private _updatePointerPosition;
  32495. private _processPointerMove;
  32496. private _setRayOnPointerInfo;
  32497. private _checkPrePointerObservable;
  32498. /**
  32499. * Use this method to simulate a pointer move on a mesh
  32500. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32501. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32502. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32503. */
  32504. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32505. /**
  32506. * Use this method to simulate a pointer down on a mesh
  32507. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32508. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32509. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32510. */
  32511. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32512. private _processPointerDown;
  32513. /** @hidden */
  32514. _isPointerSwiping(): boolean;
  32515. /**
  32516. * Use this method to simulate a pointer up on a mesh
  32517. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32518. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32519. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32520. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32521. */
  32522. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32523. private _processPointerUp;
  32524. /**
  32525. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32526. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32527. * @returns true if the pointer was captured
  32528. */
  32529. isPointerCaptured(pointerId?: number): boolean;
  32530. /**
  32531. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32532. * @param attachUp defines if you want to attach events to pointerup
  32533. * @param attachDown defines if you want to attach events to pointerdown
  32534. * @param attachMove defines if you want to attach events to pointermove
  32535. */
  32536. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32537. /**
  32538. * Detaches all event handlers
  32539. */
  32540. detachControl(): void;
  32541. /**
  32542. * Force the value of meshUnderPointer
  32543. * @param mesh defines the mesh to use
  32544. */
  32545. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32546. /**
  32547. * Gets the mesh under the pointer
  32548. * @returns a Mesh or null if no mesh is under the pointer
  32549. */
  32550. getPointerOverMesh(): Nullable<AbstractMesh>;
  32551. }
  32552. }
  32553. declare module BABYLON {
  32554. /**
  32555. * Helper class used to generate session unique ID
  32556. */
  32557. export class UniqueIdGenerator {
  32558. private static _UniqueIdCounter;
  32559. /**
  32560. * Gets an unique (relatively to the current scene) Id
  32561. */
  32562. static readonly UniqueId: number;
  32563. }
  32564. }
  32565. declare module BABYLON {
  32566. /**
  32567. * This class defines the direct association between an animation and a target
  32568. */
  32569. export class TargetedAnimation {
  32570. /**
  32571. * Animation to perform
  32572. */
  32573. animation: Animation;
  32574. /**
  32575. * Target to animate
  32576. */
  32577. target: any;
  32578. /**
  32579. * Serialize the object
  32580. * @returns the JSON object representing the current entity
  32581. */
  32582. serialize(): any;
  32583. }
  32584. /**
  32585. * Use this class to create coordinated animations on multiple targets
  32586. */
  32587. export class AnimationGroup implements IDisposable {
  32588. /** The name of the animation group */
  32589. name: string;
  32590. private _scene;
  32591. private _targetedAnimations;
  32592. private _animatables;
  32593. private _from;
  32594. private _to;
  32595. private _isStarted;
  32596. private _isPaused;
  32597. private _speedRatio;
  32598. private _loopAnimation;
  32599. /**
  32600. * Gets or sets the unique id of the node
  32601. */
  32602. uniqueId: number;
  32603. /**
  32604. * This observable will notify when one animation have ended
  32605. */
  32606. onAnimationEndObservable: Observable<TargetedAnimation>;
  32607. /**
  32608. * Observer raised when one animation loops
  32609. */
  32610. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32611. /**
  32612. * This observable will notify when all animations have ended.
  32613. */
  32614. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32615. /**
  32616. * This observable will notify when all animations have paused.
  32617. */
  32618. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32619. /**
  32620. * This observable will notify when all animations are playing.
  32621. */
  32622. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32623. /**
  32624. * Gets the first frame
  32625. */
  32626. readonly from: number;
  32627. /**
  32628. * Gets the last frame
  32629. */
  32630. readonly to: number;
  32631. /**
  32632. * Define if the animations are started
  32633. */
  32634. readonly isStarted: boolean;
  32635. /**
  32636. * Gets a value indicating that the current group is playing
  32637. */
  32638. readonly isPlaying: boolean;
  32639. /**
  32640. * Gets or sets the speed ratio to use for all animations
  32641. */
  32642. /**
  32643. * Gets or sets the speed ratio to use for all animations
  32644. */
  32645. speedRatio: number;
  32646. /**
  32647. * Gets or sets if all animations should loop or not
  32648. */
  32649. loopAnimation: boolean;
  32650. /**
  32651. * Gets the targeted animations for this animation group
  32652. */
  32653. readonly targetedAnimations: Array<TargetedAnimation>;
  32654. /**
  32655. * returning the list of animatables controlled by this animation group.
  32656. */
  32657. readonly animatables: Array<Animatable>;
  32658. /**
  32659. * Instantiates a new Animation Group.
  32660. * This helps managing several animations at once.
  32661. * @see http://doc.babylonjs.com/how_to/group
  32662. * @param name Defines the name of the group
  32663. * @param scene Defines the scene the group belongs to
  32664. */
  32665. constructor(
  32666. /** The name of the animation group */
  32667. name: string, scene?: Nullable<Scene>);
  32668. /**
  32669. * Add an animation (with its target) in the group
  32670. * @param animation defines the animation we want to add
  32671. * @param target defines the target of the animation
  32672. * @returns the TargetedAnimation object
  32673. */
  32674. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32675. /**
  32676. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32677. * It can add constant keys at begin or end
  32678. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32679. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32680. * @returns the animation group
  32681. */
  32682. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32683. /**
  32684. * Start all animations on given targets
  32685. * @param loop defines if animations must loop
  32686. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32687. * @param from defines the from key (optional)
  32688. * @param to defines the to key (optional)
  32689. * @returns the current animation group
  32690. */
  32691. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32692. /**
  32693. * Pause all animations
  32694. * @returns the animation group
  32695. */
  32696. pause(): AnimationGroup;
  32697. /**
  32698. * Play all animations to initial state
  32699. * This function will start() the animations if they were not started or will restart() them if they were paused
  32700. * @param loop defines if animations must loop
  32701. * @returns the animation group
  32702. */
  32703. play(loop?: boolean): AnimationGroup;
  32704. /**
  32705. * Reset all animations to initial state
  32706. * @returns the animation group
  32707. */
  32708. reset(): AnimationGroup;
  32709. /**
  32710. * Restart animations from key 0
  32711. * @returns the animation group
  32712. */
  32713. restart(): AnimationGroup;
  32714. /**
  32715. * Stop all animations
  32716. * @returns the animation group
  32717. */
  32718. stop(): AnimationGroup;
  32719. /**
  32720. * Set animation weight for all animatables
  32721. * @param weight defines the weight to use
  32722. * @return the animationGroup
  32723. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32724. */
  32725. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32726. /**
  32727. * Synchronize and normalize all animatables with a source animatable
  32728. * @param root defines the root animatable to synchronize with
  32729. * @return the animationGroup
  32730. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32731. */
  32732. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32733. /**
  32734. * Goes to a specific frame in this animation group
  32735. * @param frame the frame number to go to
  32736. * @return the animationGroup
  32737. */
  32738. goToFrame(frame: number): AnimationGroup;
  32739. /**
  32740. * Dispose all associated resources
  32741. */
  32742. dispose(): void;
  32743. private _checkAnimationGroupEnded;
  32744. /**
  32745. * Clone the current animation group and returns a copy
  32746. * @param newName defines the name of the new group
  32747. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32748. * @returns the new aniamtion group
  32749. */
  32750. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32751. /**
  32752. * Serializes the animationGroup to an object
  32753. * @returns Serialized object
  32754. */
  32755. serialize(): any;
  32756. /**
  32757. * Returns a new AnimationGroup object parsed from the source provided.
  32758. * @param parsedAnimationGroup defines the source
  32759. * @param scene defines the scene that will receive the animationGroup
  32760. * @returns a new AnimationGroup
  32761. */
  32762. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32763. /**
  32764. * Returns the string "AnimationGroup"
  32765. * @returns "AnimationGroup"
  32766. */
  32767. getClassName(): string;
  32768. /**
  32769. * Creates a detailled string about the object
  32770. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32771. * @returns a string representing the object
  32772. */
  32773. toString(fullDetails?: boolean): string;
  32774. }
  32775. }
  32776. declare module BABYLON {
  32777. /**
  32778. * Define an interface for all classes that will hold resources
  32779. */
  32780. export interface IDisposable {
  32781. /**
  32782. * Releases all held resources
  32783. */
  32784. dispose(): void;
  32785. }
  32786. /** Interface defining initialization parameters for Scene class */
  32787. export interface SceneOptions {
  32788. /**
  32789. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32790. * It will improve performance when the number of geometries becomes important.
  32791. */
  32792. useGeometryUniqueIdsMap?: boolean;
  32793. /**
  32794. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32795. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32796. */
  32797. useMaterialMeshMap?: boolean;
  32798. /**
  32799. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32800. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32801. */
  32802. useClonedMeshhMap?: boolean;
  32803. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32804. virtual?: boolean;
  32805. }
  32806. /**
  32807. * Represents a scene to be rendered by the engine.
  32808. * @see http://doc.babylonjs.com/features/scene
  32809. */
  32810. export class Scene extends AbstractScene implements IAnimatable {
  32811. /** The fog is deactivated */
  32812. static readonly FOGMODE_NONE: number;
  32813. /** The fog density is following an exponential function */
  32814. static readonly FOGMODE_EXP: number;
  32815. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32816. static readonly FOGMODE_EXP2: number;
  32817. /** The fog density is following a linear function. */
  32818. static readonly FOGMODE_LINEAR: number;
  32819. /**
  32820. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32821. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32822. */
  32823. static MinDeltaTime: number;
  32824. /**
  32825. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32826. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32827. */
  32828. static MaxDeltaTime: number;
  32829. /**
  32830. * Factory used to create the default material.
  32831. * @param name The name of the material to create
  32832. * @param scene The scene to create the material for
  32833. * @returns The default material
  32834. */
  32835. static DefaultMaterialFactory(scene: Scene): Material;
  32836. /**
  32837. * Factory used to create the a collision coordinator.
  32838. * @returns The collision coordinator
  32839. */
  32840. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32841. /** @hidden */
  32842. _inputManager: InputManager;
  32843. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32844. cameraToUseForPointers: Nullable<Camera>;
  32845. /** @hidden */
  32846. readonly _isScene: boolean;
  32847. /**
  32848. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32849. */
  32850. autoClear: boolean;
  32851. /**
  32852. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32853. */
  32854. autoClearDepthAndStencil: boolean;
  32855. /**
  32856. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32857. */
  32858. clearColor: Color4;
  32859. /**
  32860. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32861. */
  32862. ambientColor: Color3;
  32863. /**
  32864. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32865. * It should only be one of the following (if not the default embedded one):
  32866. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32867. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32868. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32869. * The material properties need to be setup according to the type of texture in use.
  32870. */
  32871. environmentBRDFTexture: BaseTexture;
  32872. /** @hidden */
  32873. protected _environmentTexture: Nullable<BaseTexture>;
  32874. /**
  32875. * Texture used in all pbr material as the reflection texture.
  32876. * As in the majority of the scene they are the same (exception for multi room and so on),
  32877. * this is easier to reference from here than from all the materials.
  32878. */
  32879. /**
  32880. * Texture used in all pbr material as the reflection texture.
  32881. * As in the majority of the scene they are the same (exception for multi room and so on),
  32882. * this is easier to set here than in all the materials.
  32883. */
  32884. environmentTexture: Nullable<BaseTexture>;
  32885. /** @hidden */
  32886. protected _environmentIntensity: number;
  32887. /**
  32888. * Intensity of the environment in all pbr material.
  32889. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32890. * As in the majority of the scene they are the same (exception for multi room and so on),
  32891. * this is easier to reference from here than from all the materials.
  32892. */
  32893. /**
  32894. * Intensity of the environment in all pbr material.
  32895. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32896. * As in the majority of the scene they are the same (exception for multi room and so on),
  32897. * this is easier to set here than in all the materials.
  32898. */
  32899. environmentIntensity: number;
  32900. /** @hidden */
  32901. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32902. /**
  32903. * Default image processing configuration used either in the rendering
  32904. * Forward main pass or through the imageProcessingPostProcess if present.
  32905. * As in the majority of the scene they are the same (exception for multi camera),
  32906. * this is easier to reference from here than from all the materials and post process.
  32907. *
  32908. * No setter as we it is a shared configuration, you can set the values instead.
  32909. */
  32910. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32911. private _forceWireframe;
  32912. /**
  32913. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32914. */
  32915. forceWireframe: boolean;
  32916. private _forcePointsCloud;
  32917. /**
  32918. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32919. */
  32920. forcePointsCloud: boolean;
  32921. /**
  32922. * Gets or sets the active clipplane 1
  32923. */
  32924. clipPlane: Nullable<Plane>;
  32925. /**
  32926. * Gets or sets the active clipplane 2
  32927. */
  32928. clipPlane2: Nullable<Plane>;
  32929. /**
  32930. * Gets or sets the active clipplane 3
  32931. */
  32932. clipPlane3: Nullable<Plane>;
  32933. /**
  32934. * Gets or sets the active clipplane 4
  32935. */
  32936. clipPlane4: Nullable<Plane>;
  32937. /**
  32938. * Gets or sets a boolean indicating if animations are enabled
  32939. */
  32940. animationsEnabled: boolean;
  32941. private _animationPropertiesOverride;
  32942. /**
  32943. * Gets or sets the animation properties override
  32944. */
  32945. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32946. /**
  32947. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32948. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32949. */
  32950. useConstantAnimationDeltaTime: boolean;
  32951. /**
  32952. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32953. * Please note that it requires to run a ray cast through the scene on every frame
  32954. */
  32955. constantlyUpdateMeshUnderPointer: boolean;
  32956. /**
  32957. * Defines the HTML cursor to use when hovering over interactive elements
  32958. */
  32959. hoverCursor: string;
  32960. /**
  32961. * Defines the HTML default cursor to use (empty by default)
  32962. */
  32963. defaultCursor: string;
  32964. /**
  32965. * This is used to call preventDefault() on pointer down
  32966. * in order to block unwanted artifacts like system double clicks
  32967. */
  32968. preventDefaultOnPointerDown: boolean;
  32969. /**
  32970. * This is used to call preventDefault() on pointer up
  32971. * in order to block unwanted artifacts like system double clicks
  32972. */
  32973. preventDefaultOnPointerUp: boolean;
  32974. /**
  32975. * Gets or sets user defined metadata
  32976. */
  32977. metadata: any;
  32978. /**
  32979. * For internal use only. Please do not use.
  32980. */
  32981. reservedDataStore: any;
  32982. /**
  32983. * Gets the name of the plugin used to load this scene (null by default)
  32984. */
  32985. loadingPluginName: string;
  32986. /**
  32987. * Use this array to add regular expressions used to disable offline support for specific urls
  32988. */
  32989. disableOfflineSupportExceptionRules: RegExp[];
  32990. /**
  32991. * An event triggered when the scene is disposed.
  32992. */
  32993. onDisposeObservable: Observable<Scene>;
  32994. private _onDisposeObserver;
  32995. /** Sets a function to be executed when this scene is disposed. */
  32996. onDispose: () => void;
  32997. /**
  32998. * An event triggered before rendering the scene (right after animations and physics)
  32999. */
  33000. onBeforeRenderObservable: Observable<Scene>;
  33001. private _onBeforeRenderObserver;
  33002. /** Sets a function to be executed before rendering this scene */
  33003. beforeRender: Nullable<() => void>;
  33004. /**
  33005. * An event triggered after rendering the scene
  33006. */
  33007. onAfterRenderObservable: Observable<Scene>;
  33008. /**
  33009. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33010. */
  33011. onAfterRenderCameraObservable: Observable<Camera>;
  33012. private _onAfterRenderObserver;
  33013. /** Sets a function to be executed after rendering this scene */
  33014. afterRender: Nullable<() => void>;
  33015. /**
  33016. * An event triggered before animating the scene
  33017. */
  33018. onBeforeAnimationsObservable: Observable<Scene>;
  33019. /**
  33020. * An event triggered after animations processing
  33021. */
  33022. onAfterAnimationsObservable: Observable<Scene>;
  33023. /**
  33024. * An event triggered before draw calls are ready to be sent
  33025. */
  33026. onBeforeDrawPhaseObservable: Observable<Scene>;
  33027. /**
  33028. * An event triggered after draw calls have been sent
  33029. */
  33030. onAfterDrawPhaseObservable: Observable<Scene>;
  33031. /**
  33032. * An event triggered when the scene is ready
  33033. */
  33034. onReadyObservable: Observable<Scene>;
  33035. /**
  33036. * An event triggered before rendering a camera
  33037. */
  33038. onBeforeCameraRenderObservable: Observable<Camera>;
  33039. private _onBeforeCameraRenderObserver;
  33040. /** Sets a function to be executed before rendering a camera*/
  33041. beforeCameraRender: () => void;
  33042. /**
  33043. * An event triggered after rendering a camera
  33044. */
  33045. onAfterCameraRenderObservable: Observable<Camera>;
  33046. private _onAfterCameraRenderObserver;
  33047. /** Sets a function to be executed after rendering a camera*/
  33048. afterCameraRender: () => void;
  33049. /**
  33050. * An event triggered when active meshes evaluation is about to start
  33051. */
  33052. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33053. /**
  33054. * An event triggered when active meshes evaluation is done
  33055. */
  33056. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33057. /**
  33058. * An event triggered when particles rendering is about to start
  33059. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33060. */
  33061. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33062. /**
  33063. * An event triggered when particles rendering is done
  33064. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33065. */
  33066. onAfterParticlesRenderingObservable: Observable<Scene>;
  33067. /**
  33068. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33069. */
  33070. onDataLoadedObservable: Observable<Scene>;
  33071. /**
  33072. * An event triggered when a camera is created
  33073. */
  33074. onNewCameraAddedObservable: Observable<Camera>;
  33075. /**
  33076. * An event triggered when a camera is removed
  33077. */
  33078. onCameraRemovedObservable: Observable<Camera>;
  33079. /**
  33080. * An event triggered when a light is created
  33081. */
  33082. onNewLightAddedObservable: Observable<Light>;
  33083. /**
  33084. * An event triggered when a light is removed
  33085. */
  33086. onLightRemovedObservable: Observable<Light>;
  33087. /**
  33088. * An event triggered when a geometry is created
  33089. */
  33090. onNewGeometryAddedObservable: Observable<Geometry>;
  33091. /**
  33092. * An event triggered when a geometry is removed
  33093. */
  33094. onGeometryRemovedObservable: Observable<Geometry>;
  33095. /**
  33096. * An event triggered when a transform node is created
  33097. */
  33098. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33099. /**
  33100. * An event triggered when a transform node is removed
  33101. */
  33102. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33103. /**
  33104. * An event triggered when a mesh is created
  33105. */
  33106. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33107. /**
  33108. * An event triggered when a mesh is removed
  33109. */
  33110. onMeshRemovedObservable: Observable<AbstractMesh>;
  33111. /**
  33112. * An event triggered when a skeleton is created
  33113. */
  33114. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33115. /**
  33116. * An event triggered when a skeleton is removed
  33117. */
  33118. onSkeletonRemovedObservable: Observable<Skeleton>;
  33119. /**
  33120. * An event triggered when a material is created
  33121. */
  33122. onNewMaterialAddedObservable: Observable<Material>;
  33123. /**
  33124. * An event triggered when a material is removed
  33125. */
  33126. onMaterialRemovedObservable: Observable<Material>;
  33127. /**
  33128. * An event triggered when a texture is created
  33129. */
  33130. onNewTextureAddedObservable: Observable<BaseTexture>;
  33131. /**
  33132. * An event triggered when a texture is removed
  33133. */
  33134. onTextureRemovedObservable: Observable<BaseTexture>;
  33135. /**
  33136. * An event triggered when render targets are about to be rendered
  33137. * Can happen multiple times per frame.
  33138. */
  33139. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33140. /**
  33141. * An event triggered when render targets were rendered.
  33142. * Can happen multiple times per frame.
  33143. */
  33144. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33145. /**
  33146. * An event triggered before calculating deterministic simulation step
  33147. */
  33148. onBeforeStepObservable: Observable<Scene>;
  33149. /**
  33150. * An event triggered after calculating deterministic simulation step
  33151. */
  33152. onAfterStepObservable: Observable<Scene>;
  33153. /**
  33154. * An event triggered when the activeCamera property is updated
  33155. */
  33156. onActiveCameraChanged: Observable<Scene>;
  33157. /**
  33158. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33159. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33160. * 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)
  33161. */
  33162. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33163. /**
  33164. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33165. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33166. * 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)
  33167. */
  33168. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33169. /**
  33170. * This Observable will when a mesh has been imported into the scene.
  33171. */
  33172. onMeshImportedObservable: Observable<AbstractMesh>;
  33173. /**
  33174. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33175. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33176. */
  33177. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33178. /** @hidden */
  33179. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33180. /**
  33181. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33182. */
  33183. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33184. /**
  33185. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33186. */
  33187. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33188. /**
  33189. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33190. */
  33191. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33192. /** Callback called when a pointer move is detected */
  33193. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33194. /** Callback called when a pointer down is detected */
  33195. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33196. /** Callback called when a pointer up is detected */
  33197. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33198. /** Callback called when a pointer pick is detected */
  33199. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33200. /**
  33201. * 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).
  33202. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33203. */
  33204. onPrePointerObservable: Observable<PointerInfoPre>;
  33205. /**
  33206. * Observable event triggered each time an input event is received from the rendering canvas
  33207. */
  33208. onPointerObservable: Observable<PointerInfo>;
  33209. /**
  33210. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33211. */
  33212. readonly unTranslatedPointer: Vector2;
  33213. /**
  33214. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33215. */
  33216. static DragMovementThreshold: number;
  33217. /**
  33218. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33219. */
  33220. static LongPressDelay: number;
  33221. /**
  33222. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33223. */
  33224. static DoubleClickDelay: number;
  33225. /** If you need to check double click without raising a single click at first click, enable this flag */
  33226. static ExclusiveDoubleClickMode: boolean;
  33227. /** @hidden */
  33228. _mirroredCameraPosition: Nullable<Vector3>;
  33229. /**
  33230. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33231. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33232. */
  33233. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33234. /**
  33235. * Observable event triggered each time an keyboard event is received from the hosting window
  33236. */
  33237. onKeyboardObservable: Observable<KeyboardInfo>;
  33238. private _useRightHandedSystem;
  33239. /**
  33240. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33241. */
  33242. useRightHandedSystem: boolean;
  33243. private _timeAccumulator;
  33244. private _currentStepId;
  33245. private _currentInternalStep;
  33246. /**
  33247. * Sets the step Id used by deterministic lock step
  33248. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33249. * @param newStepId defines the step Id
  33250. */
  33251. setStepId(newStepId: number): void;
  33252. /**
  33253. * Gets the step Id used by deterministic lock step
  33254. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33255. * @returns the step Id
  33256. */
  33257. getStepId(): number;
  33258. /**
  33259. * Gets the internal step used by deterministic lock step
  33260. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33261. * @returns the internal step
  33262. */
  33263. getInternalStep(): number;
  33264. private _fogEnabled;
  33265. /**
  33266. * Gets or sets a boolean indicating if fog is enabled on this scene
  33267. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33268. * (Default is true)
  33269. */
  33270. fogEnabled: boolean;
  33271. private _fogMode;
  33272. /**
  33273. * Gets or sets the fog mode to use
  33274. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33275. * | mode | value |
  33276. * | --- | --- |
  33277. * | FOGMODE_NONE | 0 |
  33278. * | FOGMODE_EXP | 1 |
  33279. * | FOGMODE_EXP2 | 2 |
  33280. * | FOGMODE_LINEAR | 3 |
  33281. */
  33282. fogMode: number;
  33283. /**
  33284. * Gets or sets the fog color to use
  33285. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33286. * (Default is Color3(0.2, 0.2, 0.3))
  33287. */
  33288. fogColor: Color3;
  33289. /**
  33290. * Gets or sets the fog density to use
  33291. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33292. * (Default is 0.1)
  33293. */
  33294. fogDensity: number;
  33295. /**
  33296. * Gets or sets the fog start distance to use
  33297. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33298. * (Default is 0)
  33299. */
  33300. fogStart: number;
  33301. /**
  33302. * Gets or sets the fog end distance to use
  33303. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33304. * (Default is 1000)
  33305. */
  33306. fogEnd: number;
  33307. private _shadowsEnabled;
  33308. /**
  33309. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33310. */
  33311. shadowsEnabled: boolean;
  33312. private _lightsEnabled;
  33313. /**
  33314. * Gets or sets a boolean indicating if lights are enabled on this scene
  33315. */
  33316. lightsEnabled: boolean;
  33317. /** All of the active cameras added to this scene. */
  33318. activeCameras: Camera[];
  33319. /** @hidden */
  33320. _activeCamera: Nullable<Camera>;
  33321. /** Gets or sets the current active camera */
  33322. activeCamera: Nullable<Camera>;
  33323. private _defaultMaterial;
  33324. /** The default material used on meshes when no material is affected */
  33325. /** The default material used on meshes when no material is affected */
  33326. defaultMaterial: Material;
  33327. private _texturesEnabled;
  33328. /**
  33329. * Gets or sets a boolean indicating if textures are enabled on this scene
  33330. */
  33331. texturesEnabled: boolean;
  33332. /**
  33333. * Gets or sets a boolean indicating if particles are enabled on this scene
  33334. */
  33335. particlesEnabled: boolean;
  33336. /**
  33337. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33338. */
  33339. spritesEnabled: boolean;
  33340. private _skeletonsEnabled;
  33341. /**
  33342. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33343. */
  33344. skeletonsEnabled: boolean;
  33345. /**
  33346. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33347. */
  33348. lensFlaresEnabled: boolean;
  33349. /**
  33350. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33351. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33352. */
  33353. collisionsEnabled: boolean;
  33354. private _collisionCoordinator;
  33355. /** @hidden */
  33356. readonly collisionCoordinator: ICollisionCoordinator;
  33357. /**
  33358. * Defines the gravity applied to this scene (used only for collisions)
  33359. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33360. */
  33361. gravity: Vector3;
  33362. /**
  33363. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33364. */
  33365. postProcessesEnabled: boolean;
  33366. /**
  33367. * The list of postprocesses added to the scene
  33368. */
  33369. postProcesses: PostProcess[];
  33370. /**
  33371. * Gets the current postprocess manager
  33372. */
  33373. postProcessManager: PostProcessManager;
  33374. /**
  33375. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33376. */
  33377. renderTargetsEnabled: boolean;
  33378. /**
  33379. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33380. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33381. */
  33382. dumpNextRenderTargets: boolean;
  33383. /**
  33384. * The list of user defined render targets added to the scene
  33385. */
  33386. customRenderTargets: RenderTargetTexture[];
  33387. /**
  33388. * Defines if texture loading must be delayed
  33389. * If true, textures will only be loaded when they need to be rendered
  33390. */
  33391. useDelayedTextureLoading: boolean;
  33392. /**
  33393. * Gets the list of meshes imported to the scene through SceneLoader
  33394. */
  33395. importedMeshesFiles: String[];
  33396. /**
  33397. * Gets or sets a boolean indicating if probes are enabled on this scene
  33398. */
  33399. probesEnabled: boolean;
  33400. /**
  33401. * Gets or sets the current offline provider to use to store scene data
  33402. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33403. */
  33404. offlineProvider: IOfflineProvider;
  33405. /**
  33406. * Gets or sets the action manager associated with the scene
  33407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33408. */
  33409. actionManager: AbstractActionManager;
  33410. private _meshesForIntersections;
  33411. /**
  33412. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33413. */
  33414. proceduralTexturesEnabled: boolean;
  33415. private _engine;
  33416. private _totalVertices;
  33417. /** @hidden */
  33418. _activeIndices: PerfCounter;
  33419. /** @hidden */
  33420. _activeParticles: PerfCounter;
  33421. /** @hidden */
  33422. _activeBones: PerfCounter;
  33423. private _animationRatio;
  33424. /** @hidden */
  33425. _animationTimeLast: number;
  33426. /** @hidden */
  33427. _animationTime: number;
  33428. /**
  33429. * Gets or sets a general scale for animation speed
  33430. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33431. */
  33432. animationTimeScale: number;
  33433. /** @hidden */
  33434. _cachedMaterial: Nullable<Material>;
  33435. /** @hidden */
  33436. _cachedEffect: Nullable<Effect>;
  33437. /** @hidden */
  33438. _cachedVisibility: Nullable<number>;
  33439. private _renderId;
  33440. private _frameId;
  33441. private _executeWhenReadyTimeoutId;
  33442. private _intermediateRendering;
  33443. private _viewUpdateFlag;
  33444. private _projectionUpdateFlag;
  33445. /** @hidden */
  33446. _toBeDisposed: Nullable<IDisposable>[];
  33447. private _activeRequests;
  33448. /** @hidden */
  33449. _pendingData: any[];
  33450. private _isDisposed;
  33451. /**
  33452. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33453. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33454. */
  33455. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33456. private _activeMeshes;
  33457. private _processedMaterials;
  33458. private _renderTargets;
  33459. /** @hidden */
  33460. _activeParticleSystems: SmartArray<IParticleSystem>;
  33461. private _activeSkeletons;
  33462. private _softwareSkinnedMeshes;
  33463. private _renderingManager;
  33464. /** @hidden */
  33465. _activeAnimatables: Animatable[];
  33466. private _transformMatrix;
  33467. private _sceneUbo;
  33468. /** @hidden */
  33469. _viewMatrix: Matrix;
  33470. private _projectionMatrix;
  33471. /** @hidden */
  33472. _forcedViewPosition: Nullable<Vector3>;
  33473. /** @hidden */
  33474. _frustumPlanes: Plane[];
  33475. /**
  33476. * Gets the list of frustum planes (built from the active camera)
  33477. */
  33478. readonly frustumPlanes: Plane[];
  33479. /**
  33480. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33481. * This is useful if there are more lights that the maximum simulteanous authorized
  33482. */
  33483. requireLightSorting: boolean;
  33484. /** @hidden */
  33485. readonly useMaterialMeshMap: boolean;
  33486. /** @hidden */
  33487. readonly useClonedMeshhMap: boolean;
  33488. private _externalData;
  33489. private _uid;
  33490. /**
  33491. * @hidden
  33492. * Backing store of defined scene components.
  33493. */
  33494. _components: ISceneComponent[];
  33495. /**
  33496. * @hidden
  33497. * Backing store of defined scene components.
  33498. */
  33499. _serializableComponents: ISceneSerializableComponent[];
  33500. /**
  33501. * List of components to register on the next registration step.
  33502. */
  33503. private _transientComponents;
  33504. /**
  33505. * Registers the transient components if needed.
  33506. */
  33507. private _registerTransientComponents;
  33508. /**
  33509. * @hidden
  33510. * Add a component to the scene.
  33511. * Note that the ccomponent could be registered on th next frame if this is called after
  33512. * the register component stage.
  33513. * @param component Defines the component to add to the scene
  33514. */
  33515. _addComponent(component: ISceneComponent): void;
  33516. /**
  33517. * @hidden
  33518. * Gets a component from the scene.
  33519. * @param name defines the name of the component to retrieve
  33520. * @returns the component or null if not present
  33521. */
  33522. _getComponent(name: string): Nullable<ISceneComponent>;
  33523. /**
  33524. * @hidden
  33525. * Defines the actions happening before camera updates.
  33526. */
  33527. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33528. /**
  33529. * @hidden
  33530. * Defines the actions happening before clear the canvas.
  33531. */
  33532. _beforeClearStage: Stage<SimpleStageAction>;
  33533. /**
  33534. * @hidden
  33535. * Defines the actions when collecting render targets for the frame.
  33536. */
  33537. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33538. /**
  33539. * @hidden
  33540. * Defines the actions happening for one camera in the frame.
  33541. */
  33542. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33543. /**
  33544. * @hidden
  33545. * Defines the actions happening during the per mesh ready checks.
  33546. */
  33547. _isReadyForMeshStage: Stage<MeshStageAction>;
  33548. /**
  33549. * @hidden
  33550. * Defines the actions happening before evaluate active mesh checks.
  33551. */
  33552. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33553. /**
  33554. * @hidden
  33555. * Defines the actions happening during the evaluate sub mesh checks.
  33556. */
  33557. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33558. /**
  33559. * @hidden
  33560. * Defines the actions happening during the active mesh stage.
  33561. */
  33562. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33563. /**
  33564. * @hidden
  33565. * Defines the actions happening during the per camera render target step.
  33566. */
  33567. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33568. /**
  33569. * @hidden
  33570. * Defines the actions happening just before the active camera is drawing.
  33571. */
  33572. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33573. /**
  33574. * @hidden
  33575. * Defines the actions happening just before a render target is drawing.
  33576. */
  33577. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33578. /**
  33579. * @hidden
  33580. * Defines the actions happening just before a rendering group is drawing.
  33581. */
  33582. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33583. /**
  33584. * @hidden
  33585. * Defines the actions happening just before a mesh is drawing.
  33586. */
  33587. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33588. /**
  33589. * @hidden
  33590. * Defines the actions happening just after a mesh has been drawn.
  33591. */
  33592. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33593. /**
  33594. * @hidden
  33595. * Defines the actions happening just after a rendering group has been drawn.
  33596. */
  33597. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33598. /**
  33599. * @hidden
  33600. * Defines the actions happening just after the active camera has been drawn.
  33601. */
  33602. _afterCameraDrawStage: Stage<CameraStageAction>;
  33603. /**
  33604. * @hidden
  33605. * Defines the actions happening just after a render target has been drawn.
  33606. */
  33607. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33608. /**
  33609. * @hidden
  33610. * Defines the actions happening just after rendering all cameras and computing intersections.
  33611. */
  33612. _afterRenderStage: Stage<SimpleStageAction>;
  33613. /**
  33614. * @hidden
  33615. * Defines the actions happening when a pointer move event happens.
  33616. */
  33617. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33618. /**
  33619. * @hidden
  33620. * Defines the actions happening when a pointer down event happens.
  33621. */
  33622. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33623. /**
  33624. * @hidden
  33625. * Defines the actions happening when a pointer up event happens.
  33626. */
  33627. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33628. /**
  33629. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33630. */
  33631. private geometriesByUniqueId;
  33632. /**
  33633. * Creates a new Scene
  33634. * @param engine defines the engine to use to render this scene
  33635. * @param options defines the scene options
  33636. */
  33637. constructor(engine: Engine, options?: SceneOptions);
  33638. /**
  33639. * Gets a string idenfifying the name of the class
  33640. * @returns "Scene" string
  33641. */
  33642. getClassName(): string;
  33643. private _defaultMeshCandidates;
  33644. /**
  33645. * @hidden
  33646. */
  33647. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33648. private _defaultSubMeshCandidates;
  33649. /**
  33650. * @hidden
  33651. */
  33652. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33653. /**
  33654. * Sets the default candidate providers for the scene.
  33655. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33656. * and getCollidingSubMeshCandidates to their default function
  33657. */
  33658. setDefaultCandidateProviders(): void;
  33659. /**
  33660. * Gets the mesh that is currently under the pointer
  33661. */
  33662. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33663. /**
  33664. * Gets or sets the current on-screen X position of the pointer
  33665. */
  33666. pointerX: number;
  33667. /**
  33668. * Gets or sets the current on-screen Y position of the pointer
  33669. */
  33670. pointerY: number;
  33671. /**
  33672. * Gets the cached material (ie. the latest rendered one)
  33673. * @returns the cached material
  33674. */
  33675. getCachedMaterial(): Nullable<Material>;
  33676. /**
  33677. * Gets the cached effect (ie. the latest rendered one)
  33678. * @returns the cached effect
  33679. */
  33680. getCachedEffect(): Nullable<Effect>;
  33681. /**
  33682. * Gets the cached visibility state (ie. the latest rendered one)
  33683. * @returns the cached visibility state
  33684. */
  33685. getCachedVisibility(): Nullable<number>;
  33686. /**
  33687. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33688. * @param material defines the current material
  33689. * @param effect defines the current effect
  33690. * @param visibility defines the current visibility state
  33691. * @returns true if one parameter is not cached
  33692. */
  33693. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33694. /**
  33695. * Gets the engine associated with the scene
  33696. * @returns an Engine
  33697. */
  33698. getEngine(): Engine;
  33699. /**
  33700. * Gets the total number of vertices rendered per frame
  33701. * @returns the total number of vertices rendered per frame
  33702. */
  33703. getTotalVertices(): number;
  33704. /**
  33705. * Gets the performance counter for total vertices
  33706. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33707. */
  33708. readonly totalVerticesPerfCounter: PerfCounter;
  33709. /**
  33710. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33711. * @returns the total number of active indices rendered per frame
  33712. */
  33713. getActiveIndices(): number;
  33714. /**
  33715. * Gets the performance counter for active indices
  33716. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33717. */
  33718. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33719. /**
  33720. * Gets the total number of active particles rendered per frame
  33721. * @returns the total number of active particles rendered per frame
  33722. */
  33723. getActiveParticles(): number;
  33724. /**
  33725. * Gets the performance counter for active particles
  33726. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33727. */
  33728. readonly activeParticlesPerfCounter: PerfCounter;
  33729. /**
  33730. * Gets the total number of active bones rendered per frame
  33731. * @returns the total number of active bones rendered per frame
  33732. */
  33733. getActiveBones(): number;
  33734. /**
  33735. * Gets the performance counter for active bones
  33736. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33737. */
  33738. readonly activeBonesPerfCounter: PerfCounter;
  33739. /**
  33740. * Gets the array of active meshes
  33741. * @returns an array of AbstractMesh
  33742. */
  33743. getActiveMeshes(): SmartArray<AbstractMesh>;
  33744. /**
  33745. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33746. * @returns a number
  33747. */
  33748. getAnimationRatio(): number;
  33749. /**
  33750. * Gets an unique Id for the current render phase
  33751. * @returns a number
  33752. */
  33753. getRenderId(): number;
  33754. /**
  33755. * Gets an unique Id for the current frame
  33756. * @returns a number
  33757. */
  33758. getFrameId(): number;
  33759. /** Call this function if you want to manually increment the render Id*/
  33760. incrementRenderId(): void;
  33761. private _createUbo;
  33762. /**
  33763. * Use this method to simulate a pointer move on a mesh
  33764. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33765. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33766. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33767. * @returns the current scene
  33768. */
  33769. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33770. /**
  33771. * Use this method to simulate a pointer down on a mesh
  33772. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33773. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33774. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33775. * @returns the current scene
  33776. */
  33777. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33778. /**
  33779. * Use this method to simulate a pointer up on a mesh
  33780. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33781. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33782. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33783. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33784. * @returns the current scene
  33785. */
  33786. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33787. /**
  33788. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33789. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33790. * @returns true if the pointer was captured
  33791. */
  33792. isPointerCaptured(pointerId?: number): boolean;
  33793. /**
  33794. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33795. * @param attachUp defines if you want to attach events to pointerup
  33796. * @param attachDown defines if you want to attach events to pointerdown
  33797. * @param attachMove defines if you want to attach events to pointermove
  33798. */
  33799. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33800. /** Detaches all event handlers*/
  33801. detachControl(): void;
  33802. /**
  33803. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33804. * Delay loaded resources are not taking in account
  33805. * @return true if all required resources are ready
  33806. */
  33807. isReady(): boolean;
  33808. /** Resets all cached information relative to material (including effect and visibility) */
  33809. resetCachedMaterial(): void;
  33810. /**
  33811. * Registers a function to be called before every frame render
  33812. * @param func defines the function to register
  33813. */
  33814. registerBeforeRender(func: () => void): void;
  33815. /**
  33816. * Unregisters a function called before every frame render
  33817. * @param func defines the function to unregister
  33818. */
  33819. unregisterBeforeRender(func: () => void): void;
  33820. /**
  33821. * Registers a function to be called after every frame render
  33822. * @param func defines the function to register
  33823. */
  33824. registerAfterRender(func: () => void): void;
  33825. /**
  33826. * Unregisters a function called after every frame render
  33827. * @param func defines the function to unregister
  33828. */
  33829. unregisterAfterRender(func: () => void): void;
  33830. private _executeOnceBeforeRender;
  33831. /**
  33832. * The provided function will run before render once and will be disposed afterwards.
  33833. * A timeout delay can be provided so that the function will be executed in N ms.
  33834. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33835. * @param func The function to be executed.
  33836. * @param timeout optional delay in ms
  33837. */
  33838. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33839. /** @hidden */
  33840. _addPendingData(data: any): void;
  33841. /** @hidden */
  33842. _removePendingData(data: any): void;
  33843. /**
  33844. * Returns the number of items waiting to be loaded
  33845. * @returns the number of items waiting to be loaded
  33846. */
  33847. getWaitingItemsCount(): number;
  33848. /**
  33849. * Returns a boolean indicating if the scene is still loading data
  33850. */
  33851. readonly isLoading: boolean;
  33852. /**
  33853. * Registers a function to be executed when the scene is ready
  33854. * @param {Function} func - the function to be executed
  33855. */
  33856. executeWhenReady(func: () => void): void;
  33857. /**
  33858. * Returns a promise that resolves when the scene is ready
  33859. * @returns A promise that resolves when the scene is ready
  33860. */
  33861. whenReadyAsync(): Promise<void>;
  33862. /** @hidden */
  33863. _checkIsReady(): void;
  33864. /**
  33865. * Gets all animatable attached to the scene
  33866. */
  33867. readonly animatables: Animatable[];
  33868. /**
  33869. * Resets the last animation time frame.
  33870. * Useful to override when animations start running when loading a scene for the first time.
  33871. */
  33872. resetLastAnimationTimeFrame(): void;
  33873. /**
  33874. * Gets the current view matrix
  33875. * @returns a Matrix
  33876. */
  33877. getViewMatrix(): Matrix;
  33878. /**
  33879. * Gets the current projection matrix
  33880. * @returns a Matrix
  33881. */
  33882. getProjectionMatrix(): Matrix;
  33883. /**
  33884. * Gets the current transform matrix
  33885. * @returns a Matrix made of View * Projection
  33886. */
  33887. getTransformMatrix(): Matrix;
  33888. /**
  33889. * Sets the current transform matrix
  33890. * @param viewL defines the View matrix to use
  33891. * @param projectionL defines the Projection matrix to use
  33892. * @param viewR defines the right View matrix to use (if provided)
  33893. * @param projectionR defines the right Projection matrix to use (if provided)
  33894. */
  33895. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33896. /**
  33897. * Gets the uniform buffer used to store scene data
  33898. * @returns a UniformBuffer
  33899. */
  33900. getSceneUniformBuffer(): UniformBuffer;
  33901. /**
  33902. * Gets an unique (relatively to the current scene) Id
  33903. * @returns an unique number for the scene
  33904. */
  33905. getUniqueId(): number;
  33906. /**
  33907. * Add a mesh to the list of scene's meshes
  33908. * @param newMesh defines the mesh to add
  33909. * @param recursive if all child meshes should also be added to the scene
  33910. */
  33911. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33912. /**
  33913. * Remove a mesh for the list of scene's meshes
  33914. * @param toRemove defines the mesh to remove
  33915. * @param recursive if all child meshes should also be removed from the scene
  33916. * @returns the index where the mesh was in the mesh list
  33917. */
  33918. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33919. /**
  33920. * Add a transform node to the list of scene's transform nodes
  33921. * @param newTransformNode defines the transform node to add
  33922. */
  33923. addTransformNode(newTransformNode: TransformNode): void;
  33924. /**
  33925. * Remove a transform node for the list of scene's transform nodes
  33926. * @param toRemove defines the transform node to remove
  33927. * @returns the index where the transform node was in the transform node list
  33928. */
  33929. removeTransformNode(toRemove: TransformNode): number;
  33930. /**
  33931. * Remove a skeleton for the list of scene's skeletons
  33932. * @param toRemove defines the skeleton to remove
  33933. * @returns the index where the skeleton was in the skeleton list
  33934. */
  33935. removeSkeleton(toRemove: Skeleton): number;
  33936. /**
  33937. * Remove a morph target for the list of scene's morph targets
  33938. * @param toRemove defines the morph target to remove
  33939. * @returns the index where the morph target was in the morph target list
  33940. */
  33941. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33942. /**
  33943. * Remove a light for the list of scene's lights
  33944. * @param toRemove defines the light to remove
  33945. * @returns the index where the light was in the light list
  33946. */
  33947. removeLight(toRemove: Light): number;
  33948. /**
  33949. * Remove a camera for the list of scene's cameras
  33950. * @param toRemove defines the camera to remove
  33951. * @returns the index where the camera was in the camera list
  33952. */
  33953. removeCamera(toRemove: Camera): number;
  33954. /**
  33955. * Remove a particle system for the list of scene's particle systems
  33956. * @param toRemove defines the particle system to remove
  33957. * @returns the index where the particle system was in the particle system list
  33958. */
  33959. removeParticleSystem(toRemove: IParticleSystem): number;
  33960. /**
  33961. * Remove a animation for the list of scene's animations
  33962. * @param toRemove defines the animation to remove
  33963. * @returns the index where the animation was in the animation list
  33964. */
  33965. removeAnimation(toRemove: Animation): number;
  33966. /**
  33967. * Will stop the animation of the given target
  33968. * @param target - the target
  33969. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33970. * @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)
  33971. */
  33972. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33973. /**
  33974. * Removes the given animation group from this scene.
  33975. * @param toRemove The animation group to remove
  33976. * @returns The index of the removed animation group
  33977. */
  33978. removeAnimationGroup(toRemove: AnimationGroup): number;
  33979. /**
  33980. * Removes the given multi-material from this scene.
  33981. * @param toRemove The multi-material to remove
  33982. * @returns The index of the removed multi-material
  33983. */
  33984. removeMultiMaterial(toRemove: MultiMaterial): number;
  33985. /**
  33986. * Removes the given material from this scene.
  33987. * @param toRemove The material to remove
  33988. * @returns The index of the removed material
  33989. */
  33990. removeMaterial(toRemove: Material): number;
  33991. /**
  33992. * Removes the given action manager from this scene.
  33993. * @param toRemove The action manager to remove
  33994. * @returns The index of the removed action manager
  33995. */
  33996. removeActionManager(toRemove: AbstractActionManager): number;
  33997. /**
  33998. * Removes the given texture from this scene.
  33999. * @param toRemove The texture to remove
  34000. * @returns The index of the removed texture
  34001. */
  34002. removeTexture(toRemove: BaseTexture): number;
  34003. /**
  34004. * Adds the given light to this scene
  34005. * @param newLight The light to add
  34006. */
  34007. addLight(newLight: Light): void;
  34008. /**
  34009. * Sorts the list list based on light priorities
  34010. */
  34011. sortLightsByPriority(): void;
  34012. /**
  34013. * Adds the given camera to this scene
  34014. * @param newCamera The camera to add
  34015. */
  34016. addCamera(newCamera: Camera): void;
  34017. /**
  34018. * Adds the given skeleton to this scene
  34019. * @param newSkeleton The skeleton to add
  34020. */
  34021. addSkeleton(newSkeleton: Skeleton): void;
  34022. /**
  34023. * Adds the given particle system to this scene
  34024. * @param newParticleSystem The particle system to add
  34025. */
  34026. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34027. /**
  34028. * Adds the given animation to this scene
  34029. * @param newAnimation The animation to add
  34030. */
  34031. addAnimation(newAnimation: Animation): void;
  34032. /**
  34033. * Adds the given animation group to this scene.
  34034. * @param newAnimationGroup The animation group to add
  34035. */
  34036. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34037. /**
  34038. * Adds the given multi-material to this scene
  34039. * @param newMultiMaterial The multi-material to add
  34040. */
  34041. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34042. /**
  34043. * Adds the given material to this scene
  34044. * @param newMaterial The material to add
  34045. */
  34046. addMaterial(newMaterial: Material): void;
  34047. /**
  34048. * Adds the given morph target to this scene
  34049. * @param newMorphTargetManager The morph target to add
  34050. */
  34051. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34052. /**
  34053. * Adds the given geometry to this scene
  34054. * @param newGeometry The geometry to add
  34055. */
  34056. addGeometry(newGeometry: Geometry): void;
  34057. /**
  34058. * Adds the given action manager to this scene
  34059. * @param newActionManager The action manager to add
  34060. */
  34061. addActionManager(newActionManager: AbstractActionManager): void;
  34062. /**
  34063. * Adds the given texture to this scene.
  34064. * @param newTexture The texture to add
  34065. */
  34066. addTexture(newTexture: BaseTexture): void;
  34067. /**
  34068. * Switch active camera
  34069. * @param newCamera defines the new active camera
  34070. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34071. */
  34072. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34073. /**
  34074. * sets the active camera of the scene using its ID
  34075. * @param id defines the camera's ID
  34076. * @return the new active camera or null if none found.
  34077. */
  34078. setActiveCameraByID(id: string): Nullable<Camera>;
  34079. /**
  34080. * sets the active camera of the scene using its name
  34081. * @param name defines the camera's name
  34082. * @returns the new active camera or null if none found.
  34083. */
  34084. setActiveCameraByName(name: string): Nullable<Camera>;
  34085. /**
  34086. * get an animation group using its name
  34087. * @param name defines the material's name
  34088. * @return the animation group or null if none found.
  34089. */
  34090. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34091. /**
  34092. * Get a material using its unique id
  34093. * @param uniqueId defines the material's unique id
  34094. * @return the material or null if none found.
  34095. */
  34096. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34097. /**
  34098. * get a material using its id
  34099. * @param id defines the material's ID
  34100. * @return the material or null if none found.
  34101. */
  34102. getMaterialByID(id: string): Nullable<Material>;
  34103. /**
  34104. * Gets a the last added material using a given id
  34105. * @param id defines the material's ID
  34106. * @return the last material with the given id or null if none found.
  34107. */
  34108. getLastMaterialByID(id: string): Nullable<Material>;
  34109. /**
  34110. * Gets a material using its name
  34111. * @param name defines the material's name
  34112. * @return the material or null if none found.
  34113. */
  34114. getMaterialByName(name: string): Nullable<Material>;
  34115. /**
  34116. * Get a texture using its unique id
  34117. * @param uniqueId defines the texture's unique id
  34118. * @return the texture or null if none found.
  34119. */
  34120. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34121. /**
  34122. * Gets a camera using its id
  34123. * @param id defines the id to look for
  34124. * @returns the camera or null if not found
  34125. */
  34126. getCameraByID(id: string): Nullable<Camera>;
  34127. /**
  34128. * Gets a camera using its unique id
  34129. * @param uniqueId defines the unique id to look for
  34130. * @returns the camera or null if not found
  34131. */
  34132. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34133. /**
  34134. * Gets a camera using its name
  34135. * @param name defines the camera's name
  34136. * @return the camera or null if none found.
  34137. */
  34138. getCameraByName(name: string): Nullable<Camera>;
  34139. /**
  34140. * Gets a bone using its id
  34141. * @param id defines the bone's id
  34142. * @return the bone or null if not found
  34143. */
  34144. getBoneByID(id: string): Nullable<Bone>;
  34145. /**
  34146. * Gets a bone using its id
  34147. * @param name defines the bone's name
  34148. * @return the bone or null if not found
  34149. */
  34150. getBoneByName(name: string): Nullable<Bone>;
  34151. /**
  34152. * Gets a light node using its name
  34153. * @param name defines the the light's name
  34154. * @return the light or null if none found.
  34155. */
  34156. getLightByName(name: string): Nullable<Light>;
  34157. /**
  34158. * Gets a light node using its id
  34159. * @param id defines the light's id
  34160. * @return the light or null if none found.
  34161. */
  34162. getLightByID(id: string): Nullable<Light>;
  34163. /**
  34164. * Gets a light node using its scene-generated unique ID
  34165. * @param uniqueId defines the light's unique id
  34166. * @return the light or null if none found.
  34167. */
  34168. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34169. /**
  34170. * Gets a particle system by id
  34171. * @param id defines the particle system id
  34172. * @return the corresponding system or null if none found
  34173. */
  34174. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34175. /**
  34176. * Gets a geometry using its ID
  34177. * @param id defines the geometry's id
  34178. * @return the geometry or null if none found.
  34179. */
  34180. getGeometryByID(id: string): Nullable<Geometry>;
  34181. private _getGeometryByUniqueID;
  34182. /**
  34183. * Add a new geometry to this scene
  34184. * @param geometry defines the geometry to be added to the scene.
  34185. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34186. * @return a boolean defining if the geometry was added or not
  34187. */
  34188. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34189. /**
  34190. * Removes an existing geometry
  34191. * @param geometry defines the geometry to be removed from the scene
  34192. * @return a boolean defining if the geometry was removed or not
  34193. */
  34194. removeGeometry(geometry: Geometry): boolean;
  34195. /**
  34196. * Gets the list of geometries attached to the scene
  34197. * @returns an array of Geometry
  34198. */
  34199. getGeometries(): Geometry[];
  34200. /**
  34201. * Gets the first added mesh found of a given ID
  34202. * @param id defines the id to search for
  34203. * @return the mesh found or null if not found at all
  34204. */
  34205. getMeshByID(id: string): Nullable<AbstractMesh>;
  34206. /**
  34207. * Gets a list of meshes using their id
  34208. * @param id defines the id to search for
  34209. * @returns a list of meshes
  34210. */
  34211. getMeshesByID(id: string): Array<AbstractMesh>;
  34212. /**
  34213. * Gets the first added transform node found of a given ID
  34214. * @param id defines the id to search for
  34215. * @return the found transform node or null if not found at all.
  34216. */
  34217. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34218. /**
  34219. * Gets a transform node with its auto-generated unique id
  34220. * @param uniqueId efines the unique id to search for
  34221. * @return the found transform node or null if not found at all.
  34222. */
  34223. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34224. /**
  34225. * Gets a list of transform nodes using their id
  34226. * @param id defines the id to search for
  34227. * @returns a list of transform nodes
  34228. */
  34229. getTransformNodesByID(id: string): Array<TransformNode>;
  34230. /**
  34231. * Gets a mesh with its auto-generated unique id
  34232. * @param uniqueId defines the unique id to search for
  34233. * @return the found mesh or null if not found at all.
  34234. */
  34235. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34236. /**
  34237. * Gets a the last added mesh using a given id
  34238. * @param id defines the id to search for
  34239. * @return the found mesh or null if not found at all.
  34240. */
  34241. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34242. /**
  34243. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34244. * @param id defines the id to search for
  34245. * @return the found node or null if not found at all
  34246. */
  34247. getLastEntryByID(id: string): Nullable<Node>;
  34248. /**
  34249. * Gets a node (Mesh, Camera, Light) using a given id
  34250. * @param id defines the id to search for
  34251. * @return the found node or null if not found at all
  34252. */
  34253. getNodeByID(id: string): Nullable<Node>;
  34254. /**
  34255. * Gets a node (Mesh, Camera, Light) using a given name
  34256. * @param name defines the name to search for
  34257. * @return the found node or null if not found at all.
  34258. */
  34259. getNodeByName(name: string): Nullable<Node>;
  34260. /**
  34261. * Gets a mesh using a given name
  34262. * @param name defines the name to search for
  34263. * @return the found mesh or null if not found at all.
  34264. */
  34265. getMeshByName(name: string): Nullable<AbstractMesh>;
  34266. /**
  34267. * Gets a transform node using a given name
  34268. * @param name defines the name to search for
  34269. * @return the found transform node or null if not found at all.
  34270. */
  34271. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34272. /**
  34273. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34274. * @param id defines the id to search for
  34275. * @return the found skeleton or null if not found at all.
  34276. */
  34277. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34278. /**
  34279. * Gets a skeleton using a given auto generated unique id
  34280. * @param uniqueId defines the unique id to search for
  34281. * @return the found skeleton or null if not found at all.
  34282. */
  34283. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34284. /**
  34285. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34286. * @param id defines the id to search for
  34287. * @return the found skeleton or null if not found at all.
  34288. */
  34289. getSkeletonById(id: string): Nullable<Skeleton>;
  34290. /**
  34291. * Gets a skeleton using a given name
  34292. * @param name defines the name to search for
  34293. * @return the found skeleton or null if not found at all.
  34294. */
  34295. getSkeletonByName(name: string): Nullable<Skeleton>;
  34296. /**
  34297. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34298. * @param id defines the id to search for
  34299. * @return the found morph target manager or null if not found at all.
  34300. */
  34301. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34302. /**
  34303. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34304. * @param id defines the id to search for
  34305. * @return the found morph target or null if not found at all.
  34306. */
  34307. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34308. /**
  34309. * Gets a boolean indicating if the given mesh is active
  34310. * @param mesh defines the mesh to look for
  34311. * @returns true if the mesh is in the active list
  34312. */
  34313. isActiveMesh(mesh: AbstractMesh): boolean;
  34314. /**
  34315. * Return a unique id as a string which can serve as an identifier for the scene
  34316. */
  34317. readonly uid: string;
  34318. /**
  34319. * Add an externaly attached data from its key.
  34320. * This method call will fail and return false, if such key already exists.
  34321. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34322. * @param key the unique key that identifies the data
  34323. * @param data the data object to associate to the key for this Engine instance
  34324. * @return true if no such key were already present and the data was added successfully, false otherwise
  34325. */
  34326. addExternalData<T>(key: string, data: T): boolean;
  34327. /**
  34328. * Get an externaly attached data from its key
  34329. * @param key the unique key that identifies the data
  34330. * @return the associated data, if present (can be null), or undefined if not present
  34331. */
  34332. getExternalData<T>(key: string): Nullable<T>;
  34333. /**
  34334. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34335. * @param key the unique key that identifies the data
  34336. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34337. * @return the associated data, can be null if the factory returned null.
  34338. */
  34339. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34340. /**
  34341. * Remove an externaly attached data from the Engine instance
  34342. * @param key the unique key that identifies the data
  34343. * @return true if the data was successfully removed, false if it doesn't exist
  34344. */
  34345. removeExternalData(key: string): boolean;
  34346. private _evaluateSubMesh;
  34347. /**
  34348. * Clear the processed materials smart array preventing retention point in material dispose.
  34349. */
  34350. freeProcessedMaterials(): void;
  34351. private _preventFreeActiveMeshesAndRenderingGroups;
  34352. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34353. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34354. * when disposing several meshes in a row or a hierarchy of meshes.
  34355. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34356. */
  34357. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34358. /**
  34359. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34360. */
  34361. freeActiveMeshes(): void;
  34362. /**
  34363. * Clear the info related to rendering groups preventing retention points during dispose.
  34364. */
  34365. freeRenderingGroups(): void;
  34366. /** @hidden */
  34367. _isInIntermediateRendering(): boolean;
  34368. /**
  34369. * Lambda returning the list of potentially active meshes.
  34370. */
  34371. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34372. /**
  34373. * Lambda returning the list of potentially active sub meshes.
  34374. */
  34375. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34376. /**
  34377. * Lambda returning the list of potentially intersecting sub meshes.
  34378. */
  34379. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34380. /**
  34381. * Lambda returning the list of potentially colliding sub meshes.
  34382. */
  34383. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34384. private _activeMeshesFrozen;
  34385. /**
  34386. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34387. * @returns the current scene
  34388. */
  34389. freezeActiveMeshes(): Scene;
  34390. /**
  34391. * Use this function to restart evaluating active meshes on every frame
  34392. * @returns the current scene
  34393. */
  34394. unfreezeActiveMeshes(): Scene;
  34395. private _evaluateActiveMeshes;
  34396. private _activeMesh;
  34397. /**
  34398. * Update the transform matrix to update from the current active camera
  34399. * @param force defines a boolean used to force the update even if cache is up to date
  34400. */
  34401. updateTransformMatrix(force?: boolean): void;
  34402. private _bindFrameBuffer;
  34403. /** @hidden */
  34404. _allowPostProcessClearColor: boolean;
  34405. /** @hidden */
  34406. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34407. private _processSubCameras;
  34408. private _checkIntersections;
  34409. /** @hidden */
  34410. _advancePhysicsEngineStep(step: number): void;
  34411. /**
  34412. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34413. */
  34414. getDeterministicFrameTime: () => number;
  34415. /** @hidden */
  34416. _animate(): void;
  34417. /** Execute all animations (for a frame) */
  34418. animate(): void;
  34419. /**
  34420. * Render the scene
  34421. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34422. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34423. */
  34424. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34425. /**
  34426. * Freeze all materials
  34427. * A frozen material will not be updatable but should be faster to render
  34428. */
  34429. freezeMaterials(): void;
  34430. /**
  34431. * Unfreeze all materials
  34432. * A frozen material will not be updatable but should be faster to render
  34433. */
  34434. unfreezeMaterials(): void;
  34435. /**
  34436. * Releases all held ressources
  34437. */
  34438. dispose(): void;
  34439. /**
  34440. * Gets if the scene is already disposed
  34441. */
  34442. readonly isDisposed: boolean;
  34443. /**
  34444. * Call this function to reduce memory footprint of the scene.
  34445. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34446. */
  34447. clearCachedVertexData(): void;
  34448. /**
  34449. * This function will remove the local cached buffer data from texture.
  34450. * It will save memory but will prevent the texture from being rebuilt
  34451. */
  34452. cleanCachedTextureBuffer(): void;
  34453. /**
  34454. * Get the world extend vectors with an optional filter
  34455. *
  34456. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34457. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34458. */
  34459. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34460. min: Vector3;
  34461. max: Vector3;
  34462. };
  34463. /**
  34464. * Creates a ray that can be used to pick in the scene
  34465. * @param x defines the x coordinate of the origin (on-screen)
  34466. * @param y defines the y coordinate of the origin (on-screen)
  34467. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34468. * @param camera defines the camera to use for the picking
  34469. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34470. * @returns a Ray
  34471. */
  34472. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34473. /**
  34474. * Creates a ray that can be used to pick in the scene
  34475. * @param x defines the x coordinate of the origin (on-screen)
  34476. * @param y defines the y coordinate of the origin (on-screen)
  34477. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34478. * @param result defines the ray where to store the picking ray
  34479. * @param camera defines the camera to use for the picking
  34480. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34481. * @returns the current scene
  34482. */
  34483. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34484. /**
  34485. * Creates a ray that can be used to pick in the scene
  34486. * @param x defines the x coordinate of the origin (on-screen)
  34487. * @param y defines the y coordinate of the origin (on-screen)
  34488. * @param camera defines the camera to use for the picking
  34489. * @returns a Ray
  34490. */
  34491. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34492. /**
  34493. * Creates a ray that can be used to pick in the scene
  34494. * @param x defines the x coordinate of the origin (on-screen)
  34495. * @param y defines the y coordinate of the origin (on-screen)
  34496. * @param result defines the ray where to store the picking ray
  34497. * @param camera defines the camera to use for the picking
  34498. * @returns the current scene
  34499. */
  34500. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34501. /** Launch a ray to try to pick a mesh in the scene
  34502. * @param x position on screen
  34503. * @param y position on screen
  34504. * @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
  34505. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34506. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34507. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34508. * @returns a PickingInfo
  34509. */
  34510. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34511. /** Use the given ray to pick a mesh in the scene
  34512. * @param ray The ray to use to pick meshes
  34513. * @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
  34514. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34515. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34516. * @returns a PickingInfo
  34517. */
  34518. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34519. /**
  34520. * Launch a ray to try to pick a mesh in the scene
  34521. * @param x X position on screen
  34522. * @param y Y position on screen
  34523. * @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
  34524. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34525. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34526. * @returns an array of PickingInfo
  34527. */
  34528. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34529. /**
  34530. * Launch a ray to try to pick a mesh in the scene
  34531. * @param ray Ray to use
  34532. * @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
  34533. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34534. * @returns an array of PickingInfo
  34535. */
  34536. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34537. /**
  34538. * Force the value of meshUnderPointer
  34539. * @param mesh defines the mesh to use
  34540. */
  34541. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34542. /**
  34543. * Gets the mesh under the pointer
  34544. * @returns a Mesh or null if no mesh is under the pointer
  34545. */
  34546. getPointerOverMesh(): Nullable<AbstractMesh>;
  34547. /** @hidden */
  34548. _rebuildGeometries(): void;
  34549. /** @hidden */
  34550. _rebuildTextures(): void;
  34551. private _getByTags;
  34552. /**
  34553. * Get a list of meshes by tags
  34554. * @param tagsQuery defines the tags query to use
  34555. * @param forEach defines a predicate used to filter results
  34556. * @returns an array of Mesh
  34557. */
  34558. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34559. /**
  34560. * Get a list of cameras by tags
  34561. * @param tagsQuery defines the tags query to use
  34562. * @param forEach defines a predicate used to filter results
  34563. * @returns an array of Camera
  34564. */
  34565. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34566. /**
  34567. * Get a list of lights by tags
  34568. * @param tagsQuery defines the tags query to use
  34569. * @param forEach defines a predicate used to filter results
  34570. * @returns an array of Light
  34571. */
  34572. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34573. /**
  34574. * Get a list of materials by tags
  34575. * @param tagsQuery defines the tags query to use
  34576. * @param forEach defines a predicate used to filter results
  34577. * @returns an array of Material
  34578. */
  34579. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34580. /**
  34581. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34582. * This allowed control for front to back rendering or reversly depending of the special needs.
  34583. *
  34584. * @param renderingGroupId The rendering group id corresponding to its index
  34585. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34586. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34587. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34588. */
  34589. 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;
  34590. /**
  34591. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34592. *
  34593. * @param renderingGroupId The rendering group id corresponding to its index
  34594. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34595. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34596. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34597. */
  34598. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34599. /**
  34600. * Gets the current auto clear configuration for one rendering group of the rendering
  34601. * manager.
  34602. * @param index the rendering group index to get the information for
  34603. * @returns The auto clear setup for the requested rendering group
  34604. */
  34605. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34606. private _blockMaterialDirtyMechanism;
  34607. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34608. blockMaterialDirtyMechanism: boolean;
  34609. /**
  34610. * Will flag all materials as dirty to trigger new shader compilation
  34611. * @param flag defines the flag used to specify which material part must be marked as dirty
  34612. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34613. */
  34614. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34615. /** @hidden */
  34616. _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;
  34617. /** @hidden */
  34618. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34619. }
  34620. }
  34621. declare module BABYLON {
  34622. /**
  34623. * Set of assets to keep when moving a scene into an asset container.
  34624. */
  34625. export class KeepAssets extends AbstractScene {
  34626. }
  34627. /**
  34628. * Container with a set of assets that can be added or removed from a scene.
  34629. */
  34630. export class AssetContainer extends AbstractScene {
  34631. /**
  34632. * The scene the AssetContainer belongs to.
  34633. */
  34634. scene: Scene;
  34635. /**
  34636. * Instantiates an AssetContainer.
  34637. * @param scene The scene the AssetContainer belongs to.
  34638. */
  34639. constructor(scene: Scene);
  34640. /**
  34641. * Adds all the assets from the container to the scene.
  34642. */
  34643. addAllToScene(): void;
  34644. /**
  34645. * Removes all the assets in the container from the scene
  34646. */
  34647. removeAllFromScene(): void;
  34648. /**
  34649. * Disposes all the assets in the container
  34650. */
  34651. dispose(): void;
  34652. private _moveAssets;
  34653. /**
  34654. * Removes all the assets contained in the scene and adds them to the container.
  34655. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34656. */
  34657. moveAllFromScene(keepAssets?: KeepAssets): void;
  34658. /**
  34659. * 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.
  34660. * @returns the root mesh
  34661. */
  34662. createRootMesh(): Mesh;
  34663. }
  34664. }
  34665. declare module BABYLON {
  34666. /**
  34667. * Defines how the parser contract is defined.
  34668. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34669. */
  34670. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34671. /**
  34672. * Defines how the individual parser contract is defined.
  34673. * These parser can parse an individual asset
  34674. */
  34675. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34676. /**
  34677. * Base class of the scene acting as a container for the different elements composing a scene.
  34678. * This class is dynamically extended by the different components of the scene increasing
  34679. * flexibility and reducing coupling
  34680. */
  34681. export abstract class AbstractScene {
  34682. /**
  34683. * Stores the list of available parsers in the application.
  34684. */
  34685. private static _BabylonFileParsers;
  34686. /**
  34687. * Stores the list of available individual parsers in the application.
  34688. */
  34689. private static _IndividualBabylonFileParsers;
  34690. /**
  34691. * Adds a parser in the list of available ones
  34692. * @param name Defines the name of the parser
  34693. * @param parser Defines the parser to add
  34694. */
  34695. static AddParser(name: string, parser: BabylonFileParser): void;
  34696. /**
  34697. * Gets a general parser from the list of avaialble ones
  34698. * @param name Defines the name of the parser
  34699. * @returns the requested parser or null
  34700. */
  34701. static GetParser(name: string): Nullable<BabylonFileParser>;
  34702. /**
  34703. * Adds n individual parser in the list of available ones
  34704. * @param name Defines the name of the parser
  34705. * @param parser Defines the parser to add
  34706. */
  34707. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34708. /**
  34709. * Gets an individual parser from the list of avaialble ones
  34710. * @param name Defines the name of the parser
  34711. * @returns the requested parser or null
  34712. */
  34713. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34714. /**
  34715. * Parser json data and populate both a scene and its associated container object
  34716. * @param jsonData Defines the data to parse
  34717. * @param scene Defines the scene to parse the data for
  34718. * @param container Defines the container attached to the parsing sequence
  34719. * @param rootUrl Defines the root url of the data
  34720. */
  34721. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34722. /**
  34723. * Gets the list of root nodes (ie. nodes with no parent)
  34724. */
  34725. rootNodes: Node[];
  34726. /** All of the cameras added to this scene
  34727. * @see http://doc.babylonjs.com/babylon101/cameras
  34728. */
  34729. cameras: Camera[];
  34730. /**
  34731. * All of the lights added to this scene
  34732. * @see http://doc.babylonjs.com/babylon101/lights
  34733. */
  34734. lights: Light[];
  34735. /**
  34736. * All of the (abstract) meshes added to this scene
  34737. */
  34738. meshes: AbstractMesh[];
  34739. /**
  34740. * The list of skeletons added to the scene
  34741. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34742. */
  34743. skeletons: Skeleton[];
  34744. /**
  34745. * All of the particle systems added to this scene
  34746. * @see http://doc.babylonjs.com/babylon101/particles
  34747. */
  34748. particleSystems: IParticleSystem[];
  34749. /**
  34750. * Gets a list of Animations associated with the scene
  34751. */
  34752. animations: Animation[];
  34753. /**
  34754. * All of the animation groups added to this scene
  34755. * @see http://doc.babylonjs.com/how_to/group
  34756. */
  34757. animationGroups: AnimationGroup[];
  34758. /**
  34759. * All of the multi-materials added to this scene
  34760. * @see http://doc.babylonjs.com/how_to/multi_materials
  34761. */
  34762. multiMaterials: MultiMaterial[];
  34763. /**
  34764. * All of the materials added to this scene
  34765. * In the context of a Scene, it is not supposed to be modified manually.
  34766. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34767. * Note also that the order of the Material wihin the array is not significant and might change.
  34768. * @see http://doc.babylonjs.com/babylon101/materials
  34769. */
  34770. materials: Material[];
  34771. /**
  34772. * The list of morph target managers added to the scene
  34773. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34774. */
  34775. morphTargetManagers: MorphTargetManager[];
  34776. /**
  34777. * The list of geometries used in the scene.
  34778. */
  34779. geometries: Geometry[];
  34780. /**
  34781. * All of the tranform nodes added to this scene
  34782. * In the context of a Scene, it is not supposed to be modified manually.
  34783. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34784. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34785. * @see http://doc.babylonjs.com/how_to/transformnode
  34786. */
  34787. transformNodes: TransformNode[];
  34788. /**
  34789. * ActionManagers available on the scene.
  34790. */
  34791. actionManagers: AbstractActionManager[];
  34792. /**
  34793. * Textures to keep.
  34794. */
  34795. textures: BaseTexture[];
  34796. /**
  34797. * Environment texture for the scene
  34798. */
  34799. environmentTexture: Nullable<BaseTexture>;
  34800. }
  34801. }
  34802. declare module BABYLON {
  34803. /**
  34804. * Interface used to define options for Sound class
  34805. */
  34806. export interface ISoundOptions {
  34807. /**
  34808. * Does the sound autoplay once loaded.
  34809. */
  34810. autoplay?: boolean;
  34811. /**
  34812. * Does the sound loop after it finishes playing once.
  34813. */
  34814. loop?: boolean;
  34815. /**
  34816. * Sound's volume
  34817. */
  34818. volume?: number;
  34819. /**
  34820. * Is it a spatial sound?
  34821. */
  34822. spatialSound?: boolean;
  34823. /**
  34824. * Maximum distance to hear that sound
  34825. */
  34826. maxDistance?: number;
  34827. /**
  34828. * Uses user defined attenuation function
  34829. */
  34830. useCustomAttenuation?: boolean;
  34831. /**
  34832. * Define the roll off factor of spatial sounds.
  34833. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34834. */
  34835. rolloffFactor?: number;
  34836. /**
  34837. * Define the reference distance the sound should be heard perfectly.
  34838. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34839. */
  34840. refDistance?: number;
  34841. /**
  34842. * Define the distance attenuation model the sound will follow.
  34843. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34844. */
  34845. distanceModel?: string;
  34846. /**
  34847. * Defines the playback speed (1 by default)
  34848. */
  34849. playbackRate?: number;
  34850. /**
  34851. * Defines if the sound is from a streaming source
  34852. */
  34853. streaming?: boolean;
  34854. /**
  34855. * Defines an optional length (in seconds) inside the sound file
  34856. */
  34857. length?: number;
  34858. /**
  34859. * Defines an optional offset (in seconds) inside the sound file
  34860. */
  34861. offset?: number;
  34862. /**
  34863. * If true, URLs will not be required to state the audio file codec to use.
  34864. */
  34865. skipCodecCheck?: boolean;
  34866. }
  34867. /**
  34868. * Defines a sound that can be played in the application.
  34869. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34870. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34871. */
  34872. export class Sound {
  34873. /**
  34874. * The name of the sound in the scene.
  34875. */
  34876. name: string;
  34877. /**
  34878. * Does the sound autoplay once loaded.
  34879. */
  34880. autoplay: boolean;
  34881. /**
  34882. * Does the sound loop after it finishes playing once.
  34883. */
  34884. loop: boolean;
  34885. /**
  34886. * Does the sound use a custom attenuation curve to simulate the falloff
  34887. * happening when the source gets further away from the camera.
  34888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34889. */
  34890. useCustomAttenuation: boolean;
  34891. /**
  34892. * The sound track id this sound belongs to.
  34893. */
  34894. soundTrackId: number;
  34895. /**
  34896. * Is this sound currently played.
  34897. */
  34898. isPlaying: boolean;
  34899. /**
  34900. * Is this sound currently paused.
  34901. */
  34902. isPaused: boolean;
  34903. /**
  34904. * Does this sound enables spatial sound.
  34905. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34906. */
  34907. spatialSound: boolean;
  34908. /**
  34909. * Define the reference distance the sound should be heard perfectly.
  34910. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34911. */
  34912. refDistance: number;
  34913. /**
  34914. * Define the roll off factor of spatial sounds.
  34915. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34916. */
  34917. rolloffFactor: number;
  34918. /**
  34919. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34920. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34921. */
  34922. maxDistance: number;
  34923. /**
  34924. * Define the distance attenuation model the sound will follow.
  34925. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34926. */
  34927. distanceModel: string;
  34928. /**
  34929. * @hidden
  34930. * Back Compat
  34931. **/
  34932. onended: () => any;
  34933. /**
  34934. * Observable event when the current playing sound finishes.
  34935. */
  34936. onEndedObservable: Observable<Sound>;
  34937. private _panningModel;
  34938. private _playbackRate;
  34939. private _streaming;
  34940. private _startTime;
  34941. private _startOffset;
  34942. private _position;
  34943. /** @hidden */
  34944. _positionInEmitterSpace: boolean;
  34945. private _localDirection;
  34946. private _volume;
  34947. private _isReadyToPlay;
  34948. private _isDirectional;
  34949. private _readyToPlayCallback;
  34950. private _audioBuffer;
  34951. private _soundSource;
  34952. private _streamingSource;
  34953. private _soundPanner;
  34954. private _soundGain;
  34955. private _inputAudioNode;
  34956. private _outputAudioNode;
  34957. private _coneInnerAngle;
  34958. private _coneOuterAngle;
  34959. private _coneOuterGain;
  34960. private _scene;
  34961. private _connectedTransformNode;
  34962. private _customAttenuationFunction;
  34963. private _registerFunc;
  34964. private _isOutputConnected;
  34965. private _htmlAudioElement;
  34966. private _urlType;
  34967. private _length?;
  34968. private _offset?;
  34969. /** @hidden */
  34970. static _SceneComponentInitialization: (scene: Scene) => void;
  34971. /**
  34972. * Create a sound and attach it to a scene
  34973. * @param name Name of your sound
  34974. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34975. * @param scene defines the scene the sound belongs to
  34976. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34977. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34978. */
  34979. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34980. /**
  34981. * Release the sound and its associated resources
  34982. */
  34983. dispose(): void;
  34984. /**
  34985. * Gets if the sounds is ready to be played or not.
  34986. * @returns true if ready, otherwise false
  34987. */
  34988. isReady(): boolean;
  34989. private _soundLoaded;
  34990. /**
  34991. * Sets the data of the sound from an audiobuffer
  34992. * @param audioBuffer The audioBuffer containing the data
  34993. */
  34994. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34995. /**
  34996. * Updates the current sounds options such as maxdistance, loop...
  34997. * @param options A JSON object containing values named as the object properties
  34998. */
  34999. updateOptions(options: ISoundOptions): void;
  35000. private _createSpatialParameters;
  35001. private _updateSpatialParameters;
  35002. /**
  35003. * Switch the panning model to HRTF:
  35004. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35005. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35006. */
  35007. switchPanningModelToHRTF(): void;
  35008. /**
  35009. * Switch the panning model to Equal Power:
  35010. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35011. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35012. */
  35013. switchPanningModelToEqualPower(): void;
  35014. private _switchPanningModel;
  35015. /**
  35016. * Connect this sound to a sound track audio node like gain...
  35017. * @param soundTrackAudioNode the sound track audio node to connect to
  35018. */
  35019. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35020. /**
  35021. * Transform this sound into a directional source
  35022. * @param coneInnerAngle Size of the inner cone in degree
  35023. * @param coneOuterAngle Size of the outer cone in degree
  35024. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35025. */
  35026. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35027. /**
  35028. * Gets or sets the inner angle for the directional cone.
  35029. */
  35030. /**
  35031. * Gets or sets the inner angle for the directional cone.
  35032. */
  35033. directionalConeInnerAngle: number;
  35034. /**
  35035. * Gets or sets the outer angle for the directional cone.
  35036. */
  35037. /**
  35038. * Gets or sets the outer angle for the directional cone.
  35039. */
  35040. directionalConeOuterAngle: number;
  35041. /**
  35042. * Sets the position of the emitter if spatial sound is enabled
  35043. * @param newPosition Defines the new posisiton
  35044. */
  35045. setPosition(newPosition: Vector3): void;
  35046. /**
  35047. * Sets the local direction of the emitter if spatial sound is enabled
  35048. * @param newLocalDirection Defines the new local direction
  35049. */
  35050. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35051. private _updateDirection;
  35052. /** @hidden */
  35053. updateDistanceFromListener(): void;
  35054. /**
  35055. * Sets a new custom attenuation function for the sound.
  35056. * @param callback Defines the function used for the attenuation
  35057. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35058. */
  35059. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35060. /**
  35061. * Play the sound
  35062. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35063. * @param offset (optional) Start the sound at a specific time in seconds
  35064. * @param length (optional) Sound duration (in seconds)
  35065. */
  35066. play(time?: number, offset?: number, length?: number): void;
  35067. private _onended;
  35068. /**
  35069. * Stop the sound
  35070. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35071. */
  35072. stop(time?: number): void;
  35073. /**
  35074. * Put the sound in pause
  35075. */
  35076. pause(): void;
  35077. /**
  35078. * Sets a dedicated volume for this sounds
  35079. * @param newVolume Define the new volume of the sound
  35080. * @param time Define time for gradual change to new volume
  35081. */
  35082. setVolume(newVolume: number, time?: number): void;
  35083. /**
  35084. * Set the sound play back rate
  35085. * @param newPlaybackRate Define the playback rate the sound should be played at
  35086. */
  35087. setPlaybackRate(newPlaybackRate: number): void;
  35088. /**
  35089. * Gets the volume of the sound.
  35090. * @returns the volume of the sound
  35091. */
  35092. getVolume(): number;
  35093. /**
  35094. * Attach the sound to a dedicated mesh
  35095. * @param transformNode The transform node to connect the sound with
  35096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35097. */
  35098. attachToMesh(transformNode: TransformNode): void;
  35099. /**
  35100. * Detach the sound from the previously attached mesh
  35101. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35102. */
  35103. detachFromMesh(): void;
  35104. private _onRegisterAfterWorldMatrixUpdate;
  35105. /**
  35106. * Clone the current sound in the scene.
  35107. * @returns the new sound clone
  35108. */
  35109. clone(): Nullable<Sound>;
  35110. /**
  35111. * Gets the current underlying audio buffer containing the data
  35112. * @returns the audio buffer
  35113. */
  35114. getAudioBuffer(): Nullable<AudioBuffer>;
  35115. /**
  35116. * Serializes the Sound in a JSON representation
  35117. * @returns the JSON representation of the sound
  35118. */
  35119. serialize(): any;
  35120. /**
  35121. * Parse a JSON representation of a sound to innstantiate in a given scene
  35122. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35123. * @param scene Define the scene the new parsed sound should be created in
  35124. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35125. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35126. * @returns the newly parsed sound
  35127. */
  35128. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35129. }
  35130. }
  35131. declare module BABYLON {
  35132. /**
  35133. * This defines an action helpful to play a defined sound on a triggered action.
  35134. */
  35135. export class PlaySoundAction extends Action {
  35136. private _sound;
  35137. /**
  35138. * Instantiate the action
  35139. * @param triggerOptions defines the trigger options
  35140. * @param sound defines the sound to play
  35141. * @param condition defines the trigger related conditions
  35142. */
  35143. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35144. /** @hidden */
  35145. _prepare(): void;
  35146. /**
  35147. * Execute the action and play the sound.
  35148. */
  35149. execute(): void;
  35150. /**
  35151. * Serializes the actions and its related information.
  35152. * @param parent defines the object to serialize in
  35153. * @returns the serialized object
  35154. */
  35155. serialize(parent: any): any;
  35156. }
  35157. /**
  35158. * This defines an action helpful to stop a defined sound on a triggered action.
  35159. */
  35160. export class StopSoundAction extends Action {
  35161. private _sound;
  35162. /**
  35163. * Instantiate the action
  35164. * @param triggerOptions defines the trigger options
  35165. * @param sound defines the sound to stop
  35166. * @param condition defines the trigger related conditions
  35167. */
  35168. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35169. /** @hidden */
  35170. _prepare(): void;
  35171. /**
  35172. * Execute the action and stop the sound.
  35173. */
  35174. execute(): void;
  35175. /**
  35176. * Serializes the actions and its related information.
  35177. * @param parent defines the object to serialize in
  35178. * @returns the serialized object
  35179. */
  35180. serialize(parent: any): any;
  35181. }
  35182. }
  35183. declare module BABYLON {
  35184. /**
  35185. * This defines an action responsible to change the value of a property
  35186. * by interpolating between its current value and the newly set one once triggered.
  35187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35188. */
  35189. export class InterpolateValueAction extends Action {
  35190. /**
  35191. * Defines the path of the property where the value should be interpolated
  35192. */
  35193. propertyPath: string;
  35194. /**
  35195. * Defines the target value at the end of the interpolation.
  35196. */
  35197. value: any;
  35198. /**
  35199. * Defines the time it will take for the property to interpolate to the value.
  35200. */
  35201. duration: number;
  35202. /**
  35203. * Defines if the other scene animations should be stopped when the action has been triggered
  35204. */
  35205. stopOtherAnimations?: boolean;
  35206. /**
  35207. * Defines a callback raised once the interpolation animation has been done.
  35208. */
  35209. onInterpolationDone?: () => void;
  35210. /**
  35211. * Observable triggered once the interpolation animation has been done.
  35212. */
  35213. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35214. private _target;
  35215. private _effectiveTarget;
  35216. private _property;
  35217. /**
  35218. * Instantiate the action
  35219. * @param triggerOptions defines the trigger options
  35220. * @param target defines the object containing the value to interpolate
  35221. * @param propertyPath defines the path to the property in the target object
  35222. * @param value defines the target value at the end of the interpolation
  35223. * @param duration deines the time it will take for the property to interpolate to the value.
  35224. * @param condition defines the trigger related conditions
  35225. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35226. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35227. */
  35228. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35229. /** @hidden */
  35230. _prepare(): void;
  35231. /**
  35232. * Execute the action starts the value interpolation.
  35233. */
  35234. execute(): void;
  35235. /**
  35236. * Serializes the actions and its related information.
  35237. * @param parent defines the object to serialize in
  35238. * @returns the serialized object
  35239. */
  35240. serialize(parent: any): any;
  35241. }
  35242. }
  35243. declare module BABYLON {
  35244. /**
  35245. * Options allowed during the creation of a sound track.
  35246. */
  35247. export interface ISoundTrackOptions {
  35248. /**
  35249. * The volume the sound track should take during creation
  35250. */
  35251. volume?: number;
  35252. /**
  35253. * Define if the sound track is the main sound track of the scene
  35254. */
  35255. mainTrack?: boolean;
  35256. }
  35257. /**
  35258. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35259. * It will be also used in a future release to apply effects on a specific track.
  35260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35261. */
  35262. export class SoundTrack {
  35263. /**
  35264. * The unique identifier of the sound track in the scene.
  35265. */
  35266. id: number;
  35267. /**
  35268. * The list of sounds included in the sound track.
  35269. */
  35270. soundCollection: Array<Sound>;
  35271. private _outputAudioNode;
  35272. private _scene;
  35273. private _isMainTrack;
  35274. private _connectedAnalyser;
  35275. private _options;
  35276. private _isInitialized;
  35277. /**
  35278. * Creates a new sound track.
  35279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35280. * @param scene Define the scene the sound track belongs to
  35281. * @param options
  35282. */
  35283. constructor(scene: Scene, options?: ISoundTrackOptions);
  35284. private _initializeSoundTrackAudioGraph;
  35285. /**
  35286. * Release the sound track and its associated resources
  35287. */
  35288. dispose(): void;
  35289. /**
  35290. * Adds a sound to this sound track
  35291. * @param sound define the cound to add
  35292. * @ignoreNaming
  35293. */
  35294. AddSound(sound: Sound): void;
  35295. /**
  35296. * Removes a sound to this sound track
  35297. * @param sound define the cound to remove
  35298. * @ignoreNaming
  35299. */
  35300. RemoveSound(sound: Sound): void;
  35301. /**
  35302. * Set a global volume for the full sound track.
  35303. * @param newVolume Define the new volume of the sound track
  35304. */
  35305. setVolume(newVolume: number): void;
  35306. /**
  35307. * Switch the panning model to HRTF:
  35308. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35309. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35310. */
  35311. switchPanningModelToHRTF(): void;
  35312. /**
  35313. * Switch the panning model to Equal Power:
  35314. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35316. */
  35317. switchPanningModelToEqualPower(): void;
  35318. /**
  35319. * Connect the sound track to an audio analyser allowing some amazing
  35320. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35322. * @param analyser The analyser to connect to the engine
  35323. */
  35324. connectToAnalyser(analyser: Analyser): void;
  35325. }
  35326. }
  35327. declare module BABYLON {
  35328. interface AbstractScene {
  35329. /**
  35330. * The list of sounds used in the scene.
  35331. */
  35332. sounds: Nullable<Array<Sound>>;
  35333. }
  35334. interface Scene {
  35335. /**
  35336. * @hidden
  35337. * Backing field
  35338. */
  35339. _mainSoundTrack: SoundTrack;
  35340. /**
  35341. * The main sound track played by the scene.
  35342. * It cotains your primary collection of sounds.
  35343. */
  35344. mainSoundTrack: SoundTrack;
  35345. /**
  35346. * The list of sound tracks added to the scene
  35347. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35348. */
  35349. soundTracks: Nullable<Array<SoundTrack>>;
  35350. /**
  35351. * Gets a sound using a given name
  35352. * @param name defines the name to search for
  35353. * @return the found sound or null if not found at all.
  35354. */
  35355. getSoundByName(name: string): Nullable<Sound>;
  35356. /**
  35357. * Gets or sets if audio support is enabled
  35358. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35359. */
  35360. audioEnabled: boolean;
  35361. /**
  35362. * Gets or sets if audio will be output to headphones
  35363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35364. */
  35365. headphone: boolean;
  35366. /**
  35367. * Gets or sets custom audio listener position provider
  35368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35369. */
  35370. audioListenerPositionProvider: Nullable<() => Vector3>;
  35371. }
  35372. /**
  35373. * Defines the sound scene component responsible to manage any sounds
  35374. * in a given scene.
  35375. */
  35376. export class AudioSceneComponent implements ISceneSerializableComponent {
  35377. /**
  35378. * The component name helpfull to identify the component in the list of scene components.
  35379. */
  35380. readonly name: string;
  35381. /**
  35382. * The scene the component belongs to.
  35383. */
  35384. scene: Scene;
  35385. private _audioEnabled;
  35386. /**
  35387. * Gets whether audio is enabled or not.
  35388. * Please use related enable/disable method to switch state.
  35389. */
  35390. readonly audioEnabled: boolean;
  35391. private _headphone;
  35392. /**
  35393. * Gets whether audio is outputing to headphone or not.
  35394. * Please use the according Switch methods to change output.
  35395. */
  35396. readonly headphone: boolean;
  35397. private _audioListenerPositionProvider;
  35398. /**
  35399. * Gets the current audio listener position provider
  35400. */
  35401. /**
  35402. * Sets a custom listener position for all sounds in the scene
  35403. * By default, this is the position of the first active camera
  35404. */
  35405. audioListenerPositionProvider: Nullable<() => Vector3>;
  35406. /**
  35407. * Creates a new instance of the component for the given scene
  35408. * @param scene Defines the scene to register the component in
  35409. */
  35410. constructor(scene: Scene);
  35411. /**
  35412. * Registers the component in a given scene
  35413. */
  35414. register(): void;
  35415. /**
  35416. * Rebuilds the elements related to this component in case of
  35417. * context lost for instance.
  35418. */
  35419. rebuild(): void;
  35420. /**
  35421. * Serializes the component data to the specified json object
  35422. * @param serializationObject The object to serialize to
  35423. */
  35424. serialize(serializationObject: any): void;
  35425. /**
  35426. * Adds all the elements from the container to the scene
  35427. * @param container the container holding the elements
  35428. */
  35429. addFromContainer(container: AbstractScene): void;
  35430. /**
  35431. * Removes all the elements in the container from the scene
  35432. * @param container contains the elements to remove
  35433. * @param dispose if the removed element should be disposed (default: false)
  35434. */
  35435. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35436. /**
  35437. * Disposes the component and the associated ressources.
  35438. */
  35439. dispose(): void;
  35440. /**
  35441. * Disables audio in the associated scene.
  35442. */
  35443. disableAudio(): void;
  35444. /**
  35445. * Enables audio in the associated scene.
  35446. */
  35447. enableAudio(): void;
  35448. /**
  35449. * Switch audio to headphone output.
  35450. */
  35451. switchAudioModeForHeadphones(): void;
  35452. /**
  35453. * Switch audio to normal speakers.
  35454. */
  35455. switchAudioModeForNormalSpeakers(): void;
  35456. private _afterRender;
  35457. }
  35458. }
  35459. declare module BABYLON {
  35460. /**
  35461. * Wraps one or more Sound objects and selects one with random weight for playback.
  35462. */
  35463. export class WeightedSound {
  35464. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35465. loop: boolean;
  35466. private _coneInnerAngle;
  35467. private _coneOuterAngle;
  35468. private _volume;
  35469. /** A Sound is currently playing. */
  35470. isPlaying: boolean;
  35471. /** A Sound is currently paused. */
  35472. isPaused: boolean;
  35473. private _sounds;
  35474. private _weights;
  35475. private _currentIndex?;
  35476. /**
  35477. * Creates a new WeightedSound from the list of sounds given.
  35478. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35479. * @param sounds Array of Sounds that will be selected from.
  35480. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35481. */
  35482. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35483. /**
  35484. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35485. */
  35486. /**
  35487. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35488. */
  35489. directionalConeInnerAngle: number;
  35490. /**
  35491. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35492. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35493. */
  35494. /**
  35495. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35496. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35497. */
  35498. directionalConeOuterAngle: number;
  35499. /**
  35500. * Playback volume.
  35501. */
  35502. /**
  35503. * Playback volume.
  35504. */
  35505. volume: number;
  35506. private _onended;
  35507. /**
  35508. * Suspend playback
  35509. */
  35510. pause(): void;
  35511. /**
  35512. * Stop playback
  35513. */
  35514. stop(): void;
  35515. /**
  35516. * Start playback.
  35517. * @param startOffset Position the clip head at a specific time in seconds.
  35518. */
  35519. play(startOffset?: number): void;
  35520. }
  35521. }
  35522. declare module BABYLON {
  35523. /**
  35524. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35525. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35526. */
  35527. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35528. /**
  35529. * Gets the name of the behavior.
  35530. */
  35531. readonly name: string;
  35532. /**
  35533. * The easing function used by animations
  35534. */
  35535. static EasingFunction: BackEase;
  35536. /**
  35537. * The easing mode used by animations
  35538. */
  35539. static EasingMode: number;
  35540. /**
  35541. * The duration of the animation, in milliseconds
  35542. */
  35543. transitionDuration: number;
  35544. /**
  35545. * Length of the distance animated by the transition when lower radius is reached
  35546. */
  35547. lowerRadiusTransitionRange: number;
  35548. /**
  35549. * Length of the distance animated by the transition when upper radius is reached
  35550. */
  35551. upperRadiusTransitionRange: number;
  35552. private _autoTransitionRange;
  35553. /**
  35554. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35555. */
  35556. /**
  35557. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35558. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35559. */
  35560. autoTransitionRange: boolean;
  35561. private _attachedCamera;
  35562. private _onAfterCheckInputsObserver;
  35563. private _onMeshTargetChangedObserver;
  35564. /**
  35565. * Initializes the behavior.
  35566. */
  35567. init(): void;
  35568. /**
  35569. * Attaches the behavior to its arc rotate camera.
  35570. * @param camera Defines the camera to attach the behavior to
  35571. */
  35572. attach(camera: ArcRotateCamera): void;
  35573. /**
  35574. * Detaches the behavior from its current arc rotate camera.
  35575. */
  35576. detach(): void;
  35577. private _radiusIsAnimating;
  35578. private _radiusBounceTransition;
  35579. private _animatables;
  35580. private _cachedWheelPrecision;
  35581. /**
  35582. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35583. * @param radiusLimit The limit to check against.
  35584. * @return Bool to indicate if at limit.
  35585. */
  35586. private _isRadiusAtLimit;
  35587. /**
  35588. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35589. * @param radiusDelta The delta by which to animate to. Can be negative.
  35590. */
  35591. private _applyBoundRadiusAnimation;
  35592. /**
  35593. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35594. */
  35595. protected _clearAnimationLocks(): void;
  35596. /**
  35597. * Stops and removes all animations that have been applied to the camera
  35598. */
  35599. stopAllAnimations(): void;
  35600. }
  35601. }
  35602. declare module BABYLON {
  35603. /**
  35604. * 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.
  35605. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35606. */
  35607. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35608. /**
  35609. * Gets the name of the behavior.
  35610. */
  35611. readonly name: string;
  35612. private _mode;
  35613. private _radiusScale;
  35614. private _positionScale;
  35615. private _defaultElevation;
  35616. private _elevationReturnTime;
  35617. private _elevationReturnWaitTime;
  35618. private _zoomStopsAnimation;
  35619. private _framingTime;
  35620. /**
  35621. * The easing function used by animations
  35622. */
  35623. static EasingFunction: ExponentialEase;
  35624. /**
  35625. * The easing mode used by animations
  35626. */
  35627. static EasingMode: number;
  35628. /**
  35629. * Sets the current mode used by the behavior
  35630. */
  35631. /**
  35632. * Gets current mode used by the behavior.
  35633. */
  35634. mode: number;
  35635. /**
  35636. * Sets the scale applied to the radius (1 by default)
  35637. */
  35638. /**
  35639. * Gets the scale applied to the radius
  35640. */
  35641. radiusScale: number;
  35642. /**
  35643. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35644. */
  35645. /**
  35646. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35647. */
  35648. positionScale: number;
  35649. /**
  35650. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35651. * behaviour is triggered, in radians.
  35652. */
  35653. /**
  35654. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35655. * behaviour is triggered, in radians.
  35656. */
  35657. defaultElevation: number;
  35658. /**
  35659. * Sets the time (in milliseconds) taken to return to the default beta position.
  35660. * Negative value indicates camera should not return to default.
  35661. */
  35662. /**
  35663. * Gets the time (in milliseconds) taken to return to the default beta position.
  35664. * Negative value indicates camera should not return to default.
  35665. */
  35666. elevationReturnTime: number;
  35667. /**
  35668. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35669. */
  35670. /**
  35671. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35672. */
  35673. elevationReturnWaitTime: number;
  35674. /**
  35675. * Sets the flag that indicates if user zooming should stop animation.
  35676. */
  35677. /**
  35678. * Gets the flag that indicates if user zooming should stop animation.
  35679. */
  35680. zoomStopsAnimation: boolean;
  35681. /**
  35682. * Sets the transition time when framing the mesh, in milliseconds
  35683. */
  35684. /**
  35685. * Gets the transition time when framing the mesh, in milliseconds
  35686. */
  35687. framingTime: number;
  35688. /**
  35689. * Define if the behavior should automatically change the configured
  35690. * camera limits and sensibilities.
  35691. */
  35692. autoCorrectCameraLimitsAndSensibility: boolean;
  35693. private _onPrePointerObservableObserver;
  35694. private _onAfterCheckInputsObserver;
  35695. private _onMeshTargetChangedObserver;
  35696. private _attachedCamera;
  35697. private _isPointerDown;
  35698. private _lastInteractionTime;
  35699. /**
  35700. * Initializes the behavior.
  35701. */
  35702. init(): void;
  35703. /**
  35704. * Attaches the behavior to its arc rotate camera.
  35705. * @param camera Defines the camera to attach the behavior to
  35706. */
  35707. attach(camera: ArcRotateCamera): void;
  35708. /**
  35709. * Detaches the behavior from its current arc rotate camera.
  35710. */
  35711. detach(): void;
  35712. private _animatables;
  35713. private _betaIsAnimating;
  35714. private _betaTransition;
  35715. private _radiusTransition;
  35716. private _vectorTransition;
  35717. /**
  35718. * Targets the given mesh and updates zoom level accordingly.
  35719. * @param mesh The mesh to target.
  35720. * @param radius Optional. If a cached radius position already exists, overrides default.
  35721. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35722. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35723. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35724. */
  35725. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35726. /**
  35727. * Targets the given mesh with its children and updates zoom level accordingly.
  35728. * @param mesh The mesh to target.
  35729. * @param radius Optional. If a cached radius position already exists, overrides default.
  35730. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35731. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35732. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35733. */
  35734. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35735. /**
  35736. * Targets the given meshes with their children and updates zoom level accordingly.
  35737. * @param meshes The mesh to target.
  35738. * @param radius Optional. If a cached radius position already exists, overrides default.
  35739. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35740. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35741. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35742. */
  35743. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35744. /**
  35745. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35746. * @param minimumWorld Determines the smaller position of the bounding box extend
  35747. * @param maximumWorld Determines the bigger position of the bounding box extend
  35748. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35749. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35750. */
  35751. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35752. /**
  35753. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35754. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35755. * frustum width.
  35756. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35757. * to fully enclose the mesh in the viewing frustum.
  35758. */
  35759. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35760. /**
  35761. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35762. * is automatically returned to its default position (expected to be above ground plane).
  35763. */
  35764. private _maintainCameraAboveGround;
  35765. /**
  35766. * Returns the frustum slope based on the canvas ratio and camera FOV
  35767. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35768. */
  35769. private _getFrustumSlope;
  35770. /**
  35771. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35772. */
  35773. private _clearAnimationLocks;
  35774. /**
  35775. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35776. */
  35777. private _applyUserInteraction;
  35778. /**
  35779. * Stops and removes all animations that have been applied to the camera
  35780. */
  35781. stopAllAnimations(): void;
  35782. /**
  35783. * Gets a value indicating if the user is moving the camera
  35784. */
  35785. readonly isUserIsMoving: boolean;
  35786. /**
  35787. * The camera can move all the way towards the mesh.
  35788. */
  35789. static IgnoreBoundsSizeMode: number;
  35790. /**
  35791. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35792. */
  35793. static FitFrustumSidesMode: number;
  35794. }
  35795. }
  35796. declare module BABYLON {
  35797. /**
  35798. * Base class for Camera Pointer Inputs.
  35799. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35800. * for example usage.
  35801. */
  35802. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35803. /**
  35804. * Defines the camera the input is attached to.
  35805. */
  35806. abstract camera: Camera;
  35807. /**
  35808. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35809. */
  35810. protected _altKey: boolean;
  35811. protected _ctrlKey: boolean;
  35812. protected _metaKey: boolean;
  35813. protected _shiftKey: boolean;
  35814. /**
  35815. * Which mouse buttons were pressed at time of last mouse event.
  35816. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35817. */
  35818. protected _buttonsPressed: number;
  35819. /**
  35820. * Defines the buttons associated with the input to handle camera move.
  35821. */
  35822. buttons: number[];
  35823. /**
  35824. * Attach the input controls to a specific dom element to get the input from.
  35825. * @param element Defines the element the controls should be listened from
  35826. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35827. */
  35828. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35829. /**
  35830. * Detach the current controls from the specified dom element.
  35831. * @param element Defines the element to stop listening the inputs from
  35832. */
  35833. detachControl(element: Nullable<HTMLElement>): void;
  35834. /**
  35835. * Gets the class name of the current input.
  35836. * @returns the class name
  35837. */
  35838. getClassName(): string;
  35839. /**
  35840. * Get the friendly name associated with the input class.
  35841. * @returns the input friendly name
  35842. */
  35843. getSimpleName(): string;
  35844. /**
  35845. * Called on pointer POINTERDOUBLETAP event.
  35846. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35847. */
  35848. protected onDoubleTap(type: string): void;
  35849. /**
  35850. * Called on pointer POINTERMOVE event if only a single touch is active.
  35851. * Override this method to provide functionality.
  35852. */
  35853. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35854. /**
  35855. * Called on pointer POINTERMOVE event if multiple touches are active.
  35856. * Override this method to provide functionality.
  35857. */
  35858. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35859. /**
  35860. * Called on JS contextmenu event.
  35861. * Override this method to provide functionality.
  35862. */
  35863. protected onContextMenu(evt: PointerEvent): void;
  35864. /**
  35865. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35866. * press.
  35867. * Override this method to provide functionality.
  35868. */
  35869. protected onButtonDown(evt: PointerEvent): void;
  35870. /**
  35871. * Called each time a new POINTERUP event occurs. Ie, for each button
  35872. * release.
  35873. * Override this method to provide functionality.
  35874. */
  35875. protected onButtonUp(evt: PointerEvent): void;
  35876. /**
  35877. * Called when window becomes inactive.
  35878. * Override this method to provide functionality.
  35879. */
  35880. protected onLostFocus(): void;
  35881. private _pointerInput;
  35882. private _observer;
  35883. private _onLostFocus;
  35884. private pointA;
  35885. private pointB;
  35886. }
  35887. }
  35888. declare module BABYLON {
  35889. /**
  35890. * Manage the pointers inputs to control an arc rotate camera.
  35891. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35892. */
  35893. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35894. /**
  35895. * Defines the camera the input is attached to.
  35896. */
  35897. camera: ArcRotateCamera;
  35898. /**
  35899. * Gets the class name of the current input.
  35900. * @returns the class name
  35901. */
  35902. getClassName(): string;
  35903. /**
  35904. * Defines the buttons associated with the input to handle camera move.
  35905. */
  35906. buttons: number[];
  35907. /**
  35908. * Defines the pointer angular sensibility along the X axis or how fast is
  35909. * the camera rotating.
  35910. */
  35911. angularSensibilityX: number;
  35912. /**
  35913. * Defines the pointer angular sensibility along the Y axis or how fast is
  35914. * the camera rotating.
  35915. */
  35916. angularSensibilityY: number;
  35917. /**
  35918. * Defines the pointer pinch precision or how fast is the camera zooming.
  35919. */
  35920. pinchPrecision: number;
  35921. /**
  35922. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35923. * from 0.
  35924. * It defines the percentage of current camera.radius to use as delta when
  35925. * pinch zoom is used.
  35926. */
  35927. pinchDeltaPercentage: number;
  35928. /**
  35929. * Defines the pointer panning sensibility or how fast is the camera moving.
  35930. */
  35931. panningSensibility: number;
  35932. /**
  35933. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35934. */
  35935. multiTouchPanning: boolean;
  35936. /**
  35937. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35938. * zoom (pinch) through multitouch.
  35939. */
  35940. multiTouchPanAndZoom: boolean;
  35941. /**
  35942. * Revers pinch action direction.
  35943. */
  35944. pinchInwards: boolean;
  35945. private _isPanClick;
  35946. private _twoFingerActivityCount;
  35947. private _isPinching;
  35948. /**
  35949. * Called on pointer POINTERMOVE event if only a single touch is active.
  35950. */
  35951. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35952. /**
  35953. * Called on pointer POINTERDOUBLETAP event.
  35954. */
  35955. protected onDoubleTap(type: string): void;
  35956. /**
  35957. * Called on pointer POINTERMOVE event if multiple touches are active.
  35958. */
  35959. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35960. /**
  35961. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35962. * press.
  35963. */
  35964. protected onButtonDown(evt: PointerEvent): void;
  35965. /**
  35966. * Called each time a new POINTERUP event occurs. Ie, for each button
  35967. * release.
  35968. */
  35969. protected onButtonUp(evt: PointerEvent): void;
  35970. /**
  35971. * Called when window becomes inactive.
  35972. */
  35973. protected onLostFocus(): void;
  35974. }
  35975. }
  35976. declare module BABYLON {
  35977. /**
  35978. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35979. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35980. */
  35981. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35982. /**
  35983. * Defines the camera the input is attached to.
  35984. */
  35985. camera: ArcRotateCamera;
  35986. /**
  35987. * Defines the list of key codes associated with the up action (increase alpha)
  35988. */
  35989. keysUp: number[];
  35990. /**
  35991. * Defines the list of key codes associated with the down action (decrease alpha)
  35992. */
  35993. keysDown: number[];
  35994. /**
  35995. * Defines the list of key codes associated with the left action (increase beta)
  35996. */
  35997. keysLeft: number[];
  35998. /**
  35999. * Defines the list of key codes associated with the right action (decrease beta)
  36000. */
  36001. keysRight: number[];
  36002. /**
  36003. * Defines the list of key codes associated with the reset action.
  36004. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36005. */
  36006. keysReset: number[];
  36007. /**
  36008. * Defines the panning sensibility of the inputs.
  36009. * (How fast is the camera paning)
  36010. */
  36011. panningSensibility: number;
  36012. /**
  36013. * Defines the zooming sensibility of the inputs.
  36014. * (How fast is the camera zooming)
  36015. */
  36016. zoomingSensibility: number;
  36017. /**
  36018. * Defines wether maintaining the alt key down switch the movement mode from
  36019. * orientation to zoom.
  36020. */
  36021. useAltToZoom: boolean;
  36022. /**
  36023. * Rotation speed of the camera
  36024. */
  36025. angularSpeed: number;
  36026. private _keys;
  36027. private _ctrlPressed;
  36028. private _altPressed;
  36029. private _onCanvasBlurObserver;
  36030. private _onKeyboardObserver;
  36031. private _engine;
  36032. private _scene;
  36033. /**
  36034. * Attach the input controls to a specific dom element to get the input from.
  36035. * @param element Defines the element the controls should be listened from
  36036. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36037. */
  36038. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36039. /**
  36040. * Detach the current controls from the specified dom element.
  36041. * @param element Defines the element to stop listening the inputs from
  36042. */
  36043. detachControl(element: Nullable<HTMLElement>): void;
  36044. /**
  36045. * Update the current camera state depending on the inputs that have been used this frame.
  36046. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36047. */
  36048. checkInputs(): void;
  36049. /**
  36050. * Gets the class name of the current intput.
  36051. * @returns the class name
  36052. */
  36053. getClassName(): string;
  36054. /**
  36055. * Get the friendly name associated with the input class.
  36056. * @returns the input friendly name
  36057. */
  36058. getSimpleName(): string;
  36059. }
  36060. }
  36061. declare module BABYLON {
  36062. /**
  36063. * Manage the mouse wheel inputs to control an arc rotate camera.
  36064. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36065. */
  36066. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36067. /**
  36068. * Defines the camera the input is attached to.
  36069. */
  36070. camera: ArcRotateCamera;
  36071. /**
  36072. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36073. */
  36074. wheelPrecision: number;
  36075. /**
  36076. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36077. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36078. */
  36079. wheelDeltaPercentage: number;
  36080. private _wheel;
  36081. private _observer;
  36082. private computeDeltaFromMouseWheelLegacyEvent;
  36083. /**
  36084. * Attach the input controls to a specific dom element to get the input from.
  36085. * @param element Defines the element the controls should be listened from
  36086. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36087. */
  36088. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36089. /**
  36090. * Detach the current controls from the specified dom element.
  36091. * @param element Defines the element to stop listening the inputs from
  36092. */
  36093. detachControl(element: Nullable<HTMLElement>): void;
  36094. /**
  36095. * Gets the class name of the current intput.
  36096. * @returns the class name
  36097. */
  36098. getClassName(): string;
  36099. /**
  36100. * Get the friendly name associated with the input class.
  36101. * @returns the input friendly name
  36102. */
  36103. getSimpleName(): string;
  36104. }
  36105. }
  36106. declare module BABYLON {
  36107. /**
  36108. * Default Inputs manager for the ArcRotateCamera.
  36109. * It groups all the default supported inputs for ease of use.
  36110. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36111. */
  36112. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36113. /**
  36114. * Instantiates a new ArcRotateCameraInputsManager.
  36115. * @param camera Defines the camera the inputs belong to
  36116. */
  36117. constructor(camera: ArcRotateCamera);
  36118. /**
  36119. * Add mouse wheel input support to the input manager.
  36120. * @returns the current input manager
  36121. */
  36122. addMouseWheel(): ArcRotateCameraInputsManager;
  36123. /**
  36124. * Add pointers input support to the input manager.
  36125. * @returns the current input manager
  36126. */
  36127. addPointers(): ArcRotateCameraInputsManager;
  36128. /**
  36129. * Add keyboard input support to the input manager.
  36130. * @returns the current input manager
  36131. */
  36132. addKeyboard(): ArcRotateCameraInputsManager;
  36133. }
  36134. }
  36135. declare module BABYLON {
  36136. /**
  36137. * This represents an orbital type of camera.
  36138. *
  36139. * 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.
  36140. * 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.
  36141. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36142. */
  36143. export class ArcRotateCamera extends TargetCamera {
  36144. /**
  36145. * Defines the rotation angle of the camera along the longitudinal axis.
  36146. */
  36147. alpha: number;
  36148. /**
  36149. * Defines the rotation angle of the camera along the latitudinal axis.
  36150. */
  36151. beta: number;
  36152. /**
  36153. * Defines the radius of the camera from it s target point.
  36154. */
  36155. radius: number;
  36156. protected _target: Vector3;
  36157. protected _targetHost: Nullable<AbstractMesh>;
  36158. /**
  36159. * Defines the target point of the camera.
  36160. * The camera looks towards it form the radius distance.
  36161. */
  36162. target: Vector3;
  36163. /**
  36164. * Define the current local position of the camera in the scene
  36165. */
  36166. position: Vector3;
  36167. protected _upVector: Vector3;
  36168. protected _upToYMatrix: Matrix;
  36169. protected _YToUpMatrix: Matrix;
  36170. /**
  36171. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36172. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36173. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36174. */
  36175. upVector: Vector3;
  36176. /**
  36177. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36178. */
  36179. setMatUp(): void;
  36180. /**
  36181. * Current inertia value on the longitudinal axis.
  36182. * The bigger this number the longer it will take for the camera to stop.
  36183. */
  36184. inertialAlphaOffset: number;
  36185. /**
  36186. * Current inertia value on the latitudinal axis.
  36187. * The bigger this number the longer it will take for the camera to stop.
  36188. */
  36189. inertialBetaOffset: number;
  36190. /**
  36191. * Current inertia value on the radius axis.
  36192. * The bigger this number the longer it will take for the camera to stop.
  36193. */
  36194. inertialRadiusOffset: number;
  36195. /**
  36196. * Minimum allowed angle on the longitudinal axis.
  36197. * This can help limiting how the Camera is able to move in the scene.
  36198. */
  36199. lowerAlphaLimit: Nullable<number>;
  36200. /**
  36201. * Maximum allowed angle on the longitudinal axis.
  36202. * This can help limiting how the Camera is able to move in the scene.
  36203. */
  36204. upperAlphaLimit: Nullable<number>;
  36205. /**
  36206. * Minimum allowed angle on the latitudinal axis.
  36207. * This can help limiting how the Camera is able to move in the scene.
  36208. */
  36209. lowerBetaLimit: number;
  36210. /**
  36211. * Maximum allowed angle on the latitudinal axis.
  36212. * This can help limiting how the Camera is able to move in the scene.
  36213. */
  36214. upperBetaLimit: number;
  36215. /**
  36216. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36217. * This can help limiting how the Camera is able to move in the scene.
  36218. */
  36219. lowerRadiusLimit: Nullable<number>;
  36220. /**
  36221. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36222. * This can help limiting how the Camera is able to move in the scene.
  36223. */
  36224. upperRadiusLimit: Nullable<number>;
  36225. /**
  36226. * Defines the current inertia value used during panning of the camera along the X axis.
  36227. */
  36228. inertialPanningX: number;
  36229. /**
  36230. * Defines the current inertia value used during panning of the camera along the Y axis.
  36231. */
  36232. inertialPanningY: number;
  36233. /**
  36234. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36235. * Basically if your fingers moves away from more than this distance you will be considered
  36236. * in pinch mode.
  36237. */
  36238. pinchToPanMaxDistance: number;
  36239. /**
  36240. * Defines the maximum distance the camera can pan.
  36241. * This could help keeping the cammera always in your scene.
  36242. */
  36243. panningDistanceLimit: Nullable<number>;
  36244. /**
  36245. * Defines the target of the camera before paning.
  36246. */
  36247. panningOriginTarget: Vector3;
  36248. /**
  36249. * Defines the value of the inertia used during panning.
  36250. * 0 would mean stop inertia and one would mean no decelleration at all.
  36251. */
  36252. panningInertia: number;
  36253. /**
  36254. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36255. */
  36256. angularSensibilityX: number;
  36257. /**
  36258. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36259. */
  36260. angularSensibilityY: number;
  36261. /**
  36262. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36263. */
  36264. pinchPrecision: number;
  36265. /**
  36266. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36267. * It will be used instead of pinchDeltaPrecision if different from 0.
  36268. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36269. */
  36270. pinchDeltaPercentage: number;
  36271. /**
  36272. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36273. */
  36274. panningSensibility: number;
  36275. /**
  36276. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36277. */
  36278. keysUp: number[];
  36279. /**
  36280. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36281. */
  36282. keysDown: number[];
  36283. /**
  36284. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36285. */
  36286. keysLeft: number[];
  36287. /**
  36288. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36289. */
  36290. keysRight: number[];
  36291. /**
  36292. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36293. */
  36294. wheelPrecision: number;
  36295. /**
  36296. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36297. * It will be used instead of pinchDeltaPrecision if different from 0.
  36298. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36299. */
  36300. wheelDeltaPercentage: number;
  36301. /**
  36302. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36303. */
  36304. zoomOnFactor: number;
  36305. /**
  36306. * Defines a screen offset for the camera position.
  36307. */
  36308. targetScreenOffset: Vector2;
  36309. /**
  36310. * Allows the camera to be completely reversed.
  36311. * If false the camera can not arrive upside down.
  36312. */
  36313. allowUpsideDown: boolean;
  36314. /**
  36315. * Define if double tap/click is used to restore the previously saved state of the camera.
  36316. */
  36317. useInputToRestoreState: boolean;
  36318. /** @hidden */
  36319. _viewMatrix: Matrix;
  36320. /** @hidden */
  36321. _useCtrlForPanning: boolean;
  36322. /** @hidden */
  36323. _panningMouseButton: number;
  36324. /**
  36325. * Defines the input associated to the camera.
  36326. */
  36327. inputs: ArcRotateCameraInputsManager;
  36328. /** @hidden */
  36329. _reset: () => void;
  36330. /**
  36331. * Defines the allowed panning axis.
  36332. */
  36333. panningAxis: Vector3;
  36334. protected _localDirection: Vector3;
  36335. protected _transformedDirection: Vector3;
  36336. private _bouncingBehavior;
  36337. /**
  36338. * Gets the bouncing behavior of the camera if it has been enabled.
  36339. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36340. */
  36341. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36342. /**
  36343. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36344. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36345. */
  36346. useBouncingBehavior: boolean;
  36347. private _framingBehavior;
  36348. /**
  36349. * Gets the framing behavior of the camera if it has been enabled.
  36350. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36351. */
  36352. readonly framingBehavior: Nullable<FramingBehavior>;
  36353. /**
  36354. * Defines if the framing behavior of the camera is enabled on the camera.
  36355. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36356. */
  36357. useFramingBehavior: boolean;
  36358. private _autoRotationBehavior;
  36359. /**
  36360. * Gets the auto rotation behavior of the camera if it has been enabled.
  36361. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36362. */
  36363. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36364. /**
  36365. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36366. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36367. */
  36368. useAutoRotationBehavior: boolean;
  36369. /**
  36370. * Observable triggered when the mesh target has been changed on the camera.
  36371. */
  36372. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36373. /**
  36374. * Event raised when the camera is colliding with a mesh.
  36375. */
  36376. onCollide: (collidedMesh: AbstractMesh) => void;
  36377. /**
  36378. * Defines whether the camera should check collision with the objects oh the scene.
  36379. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36380. */
  36381. checkCollisions: boolean;
  36382. /**
  36383. * Defines the collision radius of the camera.
  36384. * This simulates a sphere around the camera.
  36385. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36386. */
  36387. collisionRadius: Vector3;
  36388. protected _collider: Collider;
  36389. protected _previousPosition: Vector3;
  36390. protected _collisionVelocity: Vector3;
  36391. protected _newPosition: Vector3;
  36392. protected _previousAlpha: number;
  36393. protected _previousBeta: number;
  36394. protected _previousRadius: number;
  36395. protected _collisionTriggered: boolean;
  36396. protected _targetBoundingCenter: Nullable<Vector3>;
  36397. private _computationVector;
  36398. /**
  36399. * Instantiates a new ArcRotateCamera in a given scene
  36400. * @param name Defines the name of the camera
  36401. * @param alpha Defines the camera rotation along the logitudinal axis
  36402. * @param beta Defines the camera rotation along the latitudinal axis
  36403. * @param radius Defines the camera distance from its target
  36404. * @param target Defines the camera target
  36405. * @param scene Defines the scene the camera belongs to
  36406. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36407. */
  36408. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36409. /** @hidden */
  36410. _initCache(): void;
  36411. /** @hidden */
  36412. _updateCache(ignoreParentClass?: boolean): void;
  36413. protected _getTargetPosition(): Vector3;
  36414. private _storedAlpha;
  36415. private _storedBeta;
  36416. private _storedRadius;
  36417. private _storedTarget;
  36418. private _storedTargetScreenOffset;
  36419. /**
  36420. * Stores the current state of the camera (alpha, beta, radius and target)
  36421. * @returns the camera itself
  36422. */
  36423. storeState(): Camera;
  36424. /**
  36425. * @hidden
  36426. * Restored camera state. You must call storeState() first
  36427. */
  36428. _restoreStateValues(): boolean;
  36429. /** @hidden */
  36430. _isSynchronizedViewMatrix(): boolean;
  36431. /**
  36432. * Attached controls to the current camera.
  36433. * @param element Defines the element the controls should be listened from
  36434. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36435. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36436. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36437. */
  36438. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36439. /**
  36440. * Detach the current controls from the camera.
  36441. * The camera will stop reacting to inputs.
  36442. * @param element Defines the element to stop listening the inputs from
  36443. */
  36444. detachControl(element: HTMLElement): void;
  36445. /** @hidden */
  36446. _checkInputs(): void;
  36447. protected _checkLimits(): void;
  36448. /**
  36449. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36450. */
  36451. rebuildAnglesAndRadius(): void;
  36452. /**
  36453. * Use a position to define the current camera related information like aplha, beta and radius
  36454. * @param position Defines the position to set the camera at
  36455. */
  36456. setPosition(position: Vector3): void;
  36457. /**
  36458. * Defines the target the camera should look at.
  36459. * This will automatically adapt alpha beta and radius to fit within the new target.
  36460. * @param target Defines the new target as a Vector or a mesh
  36461. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36462. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36463. */
  36464. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36465. /** @hidden */
  36466. _getViewMatrix(): Matrix;
  36467. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36468. /**
  36469. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36470. * @param meshes Defines the mesh to zoom on
  36471. * @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)
  36472. */
  36473. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36474. /**
  36475. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36476. * The target will be changed but the radius
  36477. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36478. * @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)
  36479. */
  36480. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36481. min: Vector3;
  36482. max: Vector3;
  36483. distance: number;
  36484. }, doNotUpdateMaxZ?: boolean): void;
  36485. /**
  36486. * @override
  36487. * Override Camera.createRigCamera
  36488. */
  36489. createRigCamera(name: string, cameraIndex: number): Camera;
  36490. /**
  36491. * @hidden
  36492. * @override
  36493. * Override Camera._updateRigCameras
  36494. */
  36495. _updateRigCameras(): void;
  36496. /**
  36497. * Destroy the camera and release the current resources hold by it.
  36498. */
  36499. dispose(): void;
  36500. /**
  36501. * Gets the current object class name.
  36502. * @return the class name
  36503. */
  36504. getClassName(): string;
  36505. }
  36506. }
  36507. declare module BABYLON {
  36508. /**
  36509. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36510. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36511. */
  36512. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36513. /**
  36514. * Gets the name of the behavior.
  36515. */
  36516. readonly name: string;
  36517. private _zoomStopsAnimation;
  36518. private _idleRotationSpeed;
  36519. private _idleRotationWaitTime;
  36520. private _idleRotationSpinupTime;
  36521. /**
  36522. * Sets the flag that indicates if user zooming should stop animation.
  36523. */
  36524. /**
  36525. * Gets the flag that indicates if user zooming should stop animation.
  36526. */
  36527. zoomStopsAnimation: boolean;
  36528. /**
  36529. * Sets the default speed at which the camera rotates around the model.
  36530. */
  36531. /**
  36532. * Gets the default speed at which the camera rotates around the model.
  36533. */
  36534. idleRotationSpeed: number;
  36535. /**
  36536. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36537. */
  36538. /**
  36539. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36540. */
  36541. idleRotationWaitTime: number;
  36542. /**
  36543. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36544. */
  36545. /**
  36546. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36547. */
  36548. idleRotationSpinupTime: number;
  36549. /**
  36550. * Gets a value indicating if the camera is currently rotating because of this behavior
  36551. */
  36552. readonly rotationInProgress: boolean;
  36553. private _onPrePointerObservableObserver;
  36554. private _onAfterCheckInputsObserver;
  36555. private _attachedCamera;
  36556. private _isPointerDown;
  36557. private _lastFrameTime;
  36558. private _lastInteractionTime;
  36559. private _cameraRotationSpeed;
  36560. /**
  36561. * Initializes the behavior.
  36562. */
  36563. init(): void;
  36564. /**
  36565. * Attaches the behavior to its arc rotate camera.
  36566. * @param camera Defines the camera to attach the behavior to
  36567. */
  36568. attach(camera: ArcRotateCamera): void;
  36569. /**
  36570. * Detaches the behavior from its current arc rotate camera.
  36571. */
  36572. detach(): void;
  36573. /**
  36574. * Returns true if user is scrolling.
  36575. * @return true if user is scrolling.
  36576. */
  36577. private _userIsZooming;
  36578. private _lastFrameRadius;
  36579. private _shouldAnimationStopForInteraction;
  36580. /**
  36581. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36582. */
  36583. private _applyUserInteraction;
  36584. private _userIsMoving;
  36585. }
  36586. }
  36587. declare module BABYLON {
  36588. /**
  36589. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36590. */
  36591. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36592. private ui;
  36593. /**
  36594. * The name of the behavior
  36595. */
  36596. name: string;
  36597. /**
  36598. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36599. */
  36600. distanceAwayFromFace: number;
  36601. /**
  36602. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36603. */
  36604. distanceAwayFromBottomOfFace: number;
  36605. private _faceVectors;
  36606. private _target;
  36607. private _scene;
  36608. private _onRenderObserver;
  36609. private _tmpMatrix;
  36610. private _tmpVector;
  36611. /**
  36612. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36613. * @param ui The transform node that should be attched to the mesh
  36614. */
  36615. constructor(ui: TransformNode);
  36616. /**
  36617. * Initializes the behavior
  36618. */
  36619. init(): void;
  36620. private _closestFace;
  36621. private _zeroVector;
  36622. private _lookAtTmpMatrix;
  36623. private _lookAtToRef;
  36624. /**
  36625. * Attaches the AttachToBoxBehavior to the passed in mesh
  36626. * @param target The mesh that the specified node will be attached to
  36627. */
  36628. attach(target: Mesh): void;
  36629. /**
  36630. * Detaches the behavior from the mesh
  36631. */
  36632. detach(): void;
  36633. }
  36634. }
  36635. declare module BABYLON {
  36636. /**
  36637. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36638. */
  36639. export class FadeInOutBehavior implements Behavior<Mesh> {
  36640. /**
  36641. * Time in milliseconds to delay before fading in (Default: 0)
  36642. */
  36643. delay: number;
  36644. /**
  36645. * Time in milliseconds for the mesh to fade in (Default: 300)
  36646. */
  36647. fadeInTime: number;
  36648. private _millisecondsPerFrame;
  36649. private _hovered;
  36650. private _hoverValue;
  36651. private _ownerNode;
  36652. /**
  36653. * Instatiates the FadeInOutBehavior
  36654. */
  36655. constructor();
  36656. /**
  36657. * The name of the behavior
  36658. */
  36659. readonly name: string;
  36660. /**
  36661. * Initializes the behavior
  36662. */
  36663. init(): void;
  36664. /**
  36665. * Attaches the fade behavior on the passed in mesh
  36666. * @param ownerNode The mesh that will be faded in/out once attached
  36667. */
  36668. attach(ownerNode: Mesh): void;
  36669. /**
  36670. * Detaches the behavior from the mesh
  36671. */
  36672. detach(): void;
  36673. /**
  36674. * Triggers the mesh to begin fading in or out
  36675. * @param value if the object should fade in or out (true to fade in)
  36676. */
  36677. fadeIn(value: boolean): void;
  36678. private _update;
  36679. private _setAllVisibility;
  36680. }
  36681. }
  36682. declare module BABYLON {
  36683. /**
  36684. * Class containing a set of static utilities functions for managing Pivots
  36685. * @hidden
  36686. */
  36687. export class PivotTools {
  36688. private static _PivotCached;
  36689. private static _OldPivotPoint;
  36690. private static _PivotTranslation;
  36691. private static _PivotTmpVector;
  36692. /** @hidden */
  36693. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36694. /** @hidden */
  36695. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36696. }
  36697. }
  36698. declare module BABYLON {
  36699. /**
  36700. * Class containing static functions to help procedurally build meshes
  36701. */
  36702. export class PlaneBuilder {
  36703. /**
  36704. * Creates a plane mesh
  36705. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36706. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36707. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36709. * * 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
  36710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36711. * @param name defines the name of the mesh
  36712. * @param options defines the options used to create the mesh
  36713. * @param scene defines the hosting scene
  36714. * @returns the plane mesh
  36715. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36716. */
  36717. static CreatePlane(name: string, options: {
  36718. size?: number;
  36719. width?: number;
  36720. height?: number;
  36721. sideOrientation?: number;
  36722. frontUVs?: Vector4;
  36723. backUVs?: Vector4;
  36724. updatable?: boolean;
  36725. sourcePlane?: Plane;
  36726. }, scene?: Nullable<Scene>): Mesh;
  36727. }
  36728. }
  36729. declare module BABYLON {
  36730. /**
  36731. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36732. */
  36733. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36734. private static _AnyMouseID;
  36735. /**
  36736. * Abstract mesh the behavior is set on
  36737. */
  36738. attachedNode: AbstractMesh;
  36739. private _dragPlane;
  36740. private _scene;
  36741. private _pointerObserver;
  36742. private _beforeRenderObserver;
  36743. private static _planeScene;
  36744. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36745. /**
  36746. * 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)
  36747. */
  36748. maxDragAngle: number;
  36749. /**
  36750. * @hidden
  36751. */
  36752. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36753. /**
  36754. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36755. */
  36756. currentDraggingPointerID: number;
  36757. /**
  36758. * The last position where the pointer hit the drag plane in world space
  36759. */
  36760. lastDragPosition: Vector3;
  36761. /**
  36762. * If the behavior is currently in a dragging state
  36763. */
  36764. dragging: boolean;
  36765. /**
  36766. * 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)
  36767. */
  36768. dragDeltaRatio: number;
  36769. /**
  36770. * If the drag plane orientation should be updated during the dragging (Default: true)
  36771. */
  36772. updateDragPlane: boolean;
  36773. private _debugMode;
  36774. private _moving;
  36775. /**
  36776. * Fires each time the attached mesh is dragged with the pointer
  36777. * * delta between last drag position and current drag position in world space
  36778. * * dragDistance along the drag axis
  36779. * * dragPlaneNormal normal of the current drag plane used during the drag
  36780. * * dragPlanePoint in world space where the drag intersects the drag plane
  36781. */
  36782. onDragObservable: Observable<{
  36783. delta: Vector3;
  36784. dragPlanePoint: Vector3;
  36785. dragPlaneNormal: Vector3;
  36786. dragDistance: number;
  36787. pointerId: number;
  36788. }>;
  36789. /**
  36790. * Fires each time a drag begins (eg. mouse down on mesh)
  36791. */
  36792. onDragStartObservable: Observable<{
  36793. dragPlanePoint: Vector3;
  36794. pointerId: number;
  36795. }>;
  36796. /**
  36797. * Fires each time a drag ends (eg. mouse release after drag)
  36798. */
  36799. onDragEndObservable: Observable<{
  36800. dragPlanePoint: Vector3;
  36801. pointerId: number;
  36802. }>;
  36803. /**
  36804. * If the attached mesh should be moved when dragged
  36805. */
  36806. moveAttached: boolean;
  36807. /**
  36808. * If the drag behavior will react to drag events (Default: true)
  36809. */
  36810. enabled: boolean;
  36811. /**
  36812. * If pointer events should start and release the drag (Default: true)
  36813. */
  36814. startAndReleaseDragOnPointerEvents: boolean;
  36815. /**
  36816. * If camera controls should be detached during the drag
  36817. */
  36818. detachCameraControls: boolean;
  36819. /**
  36820. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36821. */
  36822. useObjectOrienationForDragging: boolean;
  36823. private _options;
  36824. /**
  36825. * Creates a pointer drag behavior that can be attached to a mesh
  36826. * @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)
  36827. */
  36828. constructor(options?: {
  36829. dragAxis?: Vector3;
  36830. dragPlaneNormal?: Vector3;
  36831. });
  36832. /**
  36833. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36834. */
  36835. validateDrag: (targetPosition: Vector3) => boolean;
  36836. /**
  36837. * The name of the behavior
  36838. */
  36839. readonly name: string;
  36840. /**
  36841. * Initializes the behavior
  36842. */
  36843. init(): void;
  36844. private _tmpVector;
  36845. private _alternatePickedPoint;
  36846. private _worldDragAxis;
  36847. private _targetPosition;
  36848. private _attachedElement;
  36849. /**
  36850. * Attaches the drag behavior the passed in mesh
  36851. * @param ownerNode The mesh that will be dragged around once attached
  36852. * @param predicate Predicate to use for pick filtering
  36853. */
  36854. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  36855. /**
  36856. * Force relase the drag action by code.
  36857. */
  36858. releaseDrag(): void;
  36859. private _startDragRay;
  36860. private _lastPointerRay;
  36861. /**
  36862. * Simulates the start of a pointer drag event on the behavior
  36863. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36864. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36865. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36866. */
  36867. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36868. private _startDrag;
  36869. private _dragDelta;
  36870. private _moveDrag;
  36871. private _pickWithRayOnDragPlane;
  36872. private _pointA;
  36873. private _pointB;
  36874. private _pointC;
  36875. private _lineA;
  36876. private _lineB;
  36877. private _localAxis;
  36878. private _lookAt;
  36879. private _updateDragPlanePosition;
  36880. /**
  36881. * Detaches the behavior from the mesh
  36882. */
  36883. detach(): void;
  36884. }
  36885. }
  36886. declare module BABYLON {
  36887. /**
  36888. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36889. */
  36890. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36891. private _dragBehaviorA;
  36892. private _dragBehaviorB;
  36893. private _startDistance;
  36894. private _initialScale;
  36895. private _targetScale;
  36896. private _ownerNode;
  36897. private _sceneRenderObserver;
  36898. /**
  36899. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36900. */
  36901. constructor();
  36902. /**
  36903. * The name of the behavior
  36904. */
  36905. readonly name: string;
  36906. /**
  36907. * Initializes the behavior
  36908. */
  36909. init(): void;
  36910. private _getCurrentDistance;
  36911. /**
  36912. * Attaches the scale behavior the passed in mesh
  36913. * @param ownerNode The mesh that will be scaled around once attached
  36914. */
  36915. attach(ownerNode: Mesh): void;
  36916. /**
  36917. * Detaches the behavior from the mesh
  36918. */
  36919. detach(): void;
  36920. }
  36921. }
  36922. declare module BABYLON {
  36923. /**
  36924. * 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
  36925. */
  36926. export class SixDofDragBehavior implements Behavior<Mesh> {
  36927. private static _virtualScene;
  36928. private _ownerNode;
  36929. private _sceneRenderObserver;
  36930. private _scene;
  36931. private _targetPosition;
  36932. private _virtualOriginMesh;
  36933. private _virtualDragMesh;
  36934. private _pointerObserver;
  36935. private _moving;
  36936. private _startingOrientation;
  36937. /**
  36938. * 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)
  36939. */
  36940. private zDragFactor;
  36941. /**
  36942. * If the object should rotate to face the drag origin
  36943. */
  36944. rotateDraggedObject: boolean;
  36945. /**
  36946. * If the behavior is currently in a dragging state
  36947. */
  36948. dragging: boolean;
  36949. /**
  36950. * 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)
  36951. */
  36952. dragDeltaRatio: number;
  36953. /**
  36954. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36955. */
  36956. currentDraggingPointerID: number;
  36957. /**
  36958. * If camera controls should be detached during the drag
  36959. */
  36960. detachCameraControls: boolean;
  36961. /**
  36962. * Fires each time a drag starts
  36963. */
  36964. onDragStartObservable: Observable<{}>;
  36965. /**
  36966. * Fires each time a drag ends (eg. mouse release after drag)
  36967. */
  36968. onDragEndObservable: Observable<{}>;
  36969. /**
  36970. * 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
  36971. */
  36972. constructor();
  36973. /**
  36974. * The name of the behavior
  36975. */
  36976. readonly name: string;
  36977. /**
  36978. * Initializes the behavior
  36979. */
  36980. init(): void;
  36981. /**
  36982. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36983. */
  36984. private readonly _pointerCamera;
  36985. /**
  36986. * Attaches the scale behavior the passed in mesh
  36987. * @param ownerNode The mesh that will be scaled around once attached
  36988. */
  36989. attach(ownerNode: Mesh): void;
  36990. /**
  36991. * Detaches the behavior from the mesh
  36992. */
  36993. detach(): void;
  36994. }
  36995. }
  36996. declare module BABYLON {
  36997. /**
  36998. * Class used to apply inverse kinematics to bones
  36999. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37000. */
  37001. export class BoneIKController {
  37002. private static _tmpVecs;
  37003. private static _tmpQuat;
  37004. private static _tmpMats;
  37005. /**
  37006. * Gets or sets the target mesh
  37007. */
  37008. targetMesh: AbstractMesh;
  37009. /** Gets or sets the mesh used as pole */
  37010. poleTargetMesh: AbstractMesh;
  37011. /**
  37012. * Gets or sets the bone used as pole
  37013. */
  37014. poleTargetBone: Nullable<Bone>;
  37015. /**
  37016. * Gets or sets the target position
  37017. */
  37018. targetPosition: Vector3;
  37019. /**
  37020. * Gets or sets the pole target position
  37021. */
  37022. poleTargetPosition: Vector3;
  37023. /**
  37024. * Gets or sets the pole target local offset
  37025. */
  37026. poleTargetLocalOffset: Vector3;
  37027. /**
  37028. * Gets or sets the pole angle
  37029. */
  37030. poleAngle: number;
  37031. /**
  37032. * Gets or sets the mesh associated with the controller
  37033. */
  37034. mesh: AbstractMesh;
  37035. /**
  37036. * 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)
  37037. */
  37038. slerpAmount: number;
  37039. private _bone1Quat;
  37040. private _bone1Mat;
  37041. private _bone2Ang;
  37042. private _bone1;
  37043. private _bone2;
  37044. private _bone1Length;
  37045. private _bone2Length;
  37046. private _maxAngle;
  37047. private _maxReach;
  37048. private _rightHandedSystem;
  37049. private _bendAxis;
  37050. private _slerping;
  37051. private _adjustRoll;
  37052. /**
  37053. * Gets or sets maximum allowed angle
  37054. */
  37055. maxAngle: number;
  37056. /**
  37057. * Creates a new BoneIKController
  37058. * @param mesh defines the mesh to control
  37059. * @param bone defines the bone to control
  37060. * @param options defines options to set up the controller
  37061. */
  37062. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37063. targetMesh?: AbstractMesh;
  37064. poleTargetMesh?: AbstractMesh;
  37065. poleTargetBone?: Bone;
  37066. poleTargetLocalOffset?: Vector3;
  37067. poleAngle?: number;
  37068. bendAxis?: Vector3;
  37069. maxAngle?: number;
  37070. slerpAmount?: number;
  37071. });
  37072. private _setMaxAngle;
  37073. /**
  37074. * Force the controller to update the bones
  37075. */
  37076. update(): void;
  37077. }
  37078. }
  37079. declare module BABYLON {
  37080. /**
  37081. * Class used to make a bone look toward a point in space
  37082. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37083. */
  37084. export class BoneLookController {
  37085. private static _tmpVecs;
  37086. private static _tmpQuat;
  37087. private static _tmpMats;
  37088. /**
  37089. * The target Vector3 that the bone will look at
  37090. */
  37091. target: Vector3;
  37092. /**
  37093. * The mesh that the bone is attached to
  37094. */
  37095. mesh: AbstractMesh;
  37096. /**
  37097. * The bone that will be looking to the target
  37098. */
  37099. bone: Bone;
  37100. /**
  37101. * The up axis of the coordinate system that is used when the bone is rotated
  37102. */
  37103. upAxis: Vector3;
  37104. /**
  37105. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37106. */
  37107. upAxisSpace: Space;
  37108. /**
  37109. * Used to make an adjustment to the yaw of the bone
  37110. */
  37111. adjustYaw: number;
  37112. /**
  37113. * Used to make an adjustment to the pitch of the bone
  37114. */
  37115. adjustPitch: number;
  37116. /**
  37117. * Used to make an adjustment to the roll of the bone
  37118. */
  37119. adjustRoll: number;
  37120. /**
  37121. * 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)
  37122. */
  37123. slerpAmount: number;
  37124. private _minYaw;
  37125. private _maxYaw;
  37126. private _minPitch;
  37127. private _maxPitch;
  37128. private _minYawSin;
  37129. private _minYawCos;
  37130. private _maxYawSin;
  37131. private _maxYawCos;
  37132. private _midYawConstraint;
  37133. private _minPitchTan;
  37134. private _maxPitchTan;
  37135. private _boneQuat;
  37136. private _slerping;
  37137. private _transformYawPitch;
  37138. private _transformYawPitchInv;
  37139. private _firstFrameSkipped;
  37140. private _yawRange;
  37141. private _fowardAxis;
  37142. /**
  37143. * Gets or sets the minimum yaw angle that the bone can look to
  37144. */
  37145. minYaw: number;
  37146. /**
  37147. * Gets or sets the maximum yaw angle that the bone can look to
  37148. */
  37149. maxYaw: number;
  37150. /**
  37151. * Gets or sets the minimum pitch angle that the bone can look to
  37152. */
  37153. minPitch: number;
  37154. /**
  37155. * Gets or sets the maximum pitch angle that the bone can look to
  37156. */
  37157. maxPitch: number;
  37158. /**
  37159. * Create a BoneLookController
  37160. * @param mesh the mesh that the bone belongs to
  37161. * @param bone the bone that will be looking to the target
  37162. * @param target the target Vector3 to look at
  37163. * @param options optional settings:
  37164. * * maxYaw: the maximum angle the bone will yaw to
  37165. * * minYaw: the minimum angle the bone will yaw to
  37166. * * maxPitch: the maximum angle the bone will pitch to
  37167. * * minPitch: the minimum angle the bone will yaw to
  37168. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37169. * * upAxis: the up axis of the coordinate system
  37170. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37171. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37172. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37173. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37174. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37175. * * adjustRoll: used to make an adjustment to the roll of the bone
  37176. **/
  37177. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37178. maxYaw?: number;
  37179. minYaw?: number;
  37180. maxPitch?: number;
  37181. minPitch?: number;
  37182. slerpAmount?: number;
  37183. upAxis?: Vector3;
  37184. upAxisSpace?: Space;
  37185. yawAxis?: Vector3;
  37186. pitchAxis?: Vector3;
  37187. adjustYaw?: number;
  37188. adjustPitch?: number;
  37189. adjustRoll?: number;
  37190. });
  37191. /**
  37192. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37193. */
  37194. update(): void;
  37195. private _getAngleDiff;
  37196. private _getAngleBetween;
  37197. private _isAngleBetween;
  37198. }
  37199. }
  37200. declare module BABYLON {
  37201. /**
  37202. * Manage the gamepad inputs to control an arc rotate camera.
  37203. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37204. */
  37205. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37206. /**
  37207. * Defines the camera the input is attached to.
  37208. */
  37209. camera: ArcRotateCamera;
  37210. /**
  37211. * Defines the gamepad the input is gathering event from.
  37212. */
  37213. gamepad: Nullable<Gamepad>;
  37214. /**
  37215. * Defines the gamepad rotation sensiblity.
  37216. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37217. */
  37218. gamepadRotationSensibility: number;
  37219. /**
  37220. * Defines the gamepad move sensiblity.
  37221. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37222. */
  37223. gamepadMoveSensibility: number;
  37224. private _onGamepadConnectedObserver;
  37225. private _onGamepadDisconnectedObserver;
  37226. /**
  37227. * Attach the input controls to a specific dom element to get the input from.
  37228. * @param element Defines the element the controls should be listened from
  37229. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37230. */
  37231. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37232. /**
  37233. * Detach the current controls from the specified dom element.
  37234. * @param element Defines the element to stop listening the inputs from
  37235. */
  37236. detachControl(element: Nullable<HTMLElement>): void;
  37237. /**
  37238. * Update the current camera state depending on the inputs that have been used this frame.
  37239. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37240. */
  37241. checkInputs(): void;
  37242. /**
  37243. * Gets the class name of the current intput.
  37244. * @returns the class name
  37245. */
  37246. getClassName(): string;
  37247. /**
  37248. * Get the friendly name associated with the input class.
  37249. * @returns the input friendly name
  37250. */
  37251. getSimpleName(): string;
  37252. }
  37253. }
  37254. declare module BABYLON {
  37255. interface ArcRotateCameraInputsManager {
  37256. /**
  37257. * Add orientation input support to the input manager.
  37258. * @returns the current input manager
  37259. */
  37260. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37261. }
  37262. /**
  37263. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37264. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37265. */
  37266. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37267. /**
  37268. * Defines the camera the input is attached to.
  37269. */
  37270. camera: ArcRotateCamera;
  37271. /**
  37272. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37273. */
  37274. alphaCorrection: number;
  37275. /**
  37276. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37277. */
  37278. gammaCorrection: number;
  37279. private _alpha;
  37280. private _gamma;
  37281. private _dirty;
  37282. private _deviceOrientationHandler;
  37283. /**
  37284. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37285. */
  37286. constructor();
  37287. /**
  37288. * Attach the input controls to a specific dom element to get the input from.
  37289. * @param element Defines the element the controls should be listened from
  37290. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37291. */
  37292. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37293. /** @hidden */
  37294. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37295. /**
  37296. * Update the current camera state depending on the inputs that have been used this frame.
  37297. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37298. */
  37299. checkInputs(): void;
  37300. /**
  37301. * Detach the current controls from the specified dom element.
  37302. * @param element Defines the element to stop listening the inputs from
  37303. */
  37304. detachControl(element: Nullable<HTMLElement>): void;
  37305. /**
  37306. * Gets the class name of the current intput.
  37307. * @returns the class name
  37308. */
  37309. getClassName(): string;
  37310. /**
  37311. * Get the friendly name associated with the input class.
  37312. * @returns the input friendly name
  37313. */
  37314. getSimpleName(): string;
  37315. }
  37316. }
  37317. declare module BABYLON {
  37318. /**
  37319. * Listen to mouse events to control the camera.
  37320. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37321. */
  37322. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37323. /**
  37324. * Defines the camera the input is attached to.
  37325. */
  37326. camera: FlyCamera;
  37327. /**
  37328. * Defines if touch is enabled. (Default is true.)
  37329. */
  37330. touchEnabled: boolean;
  37331. /**
  37332. * Defines the buttons associated with the input to handle camera rotation.
  37333. */
  37334. buttons: number[];
  37335. /**
  37336. * Assign buttons for Yaw control.
  37337. */
  37338. buttonsYaw: number[];
  37339. /**
  37340. * Assign buttons for Pitch control.
  37341. */
  37342. buttonsPitch: number[];
  37343. /**
  37344. * Assign buttons for Roll control.
  37345. */
  37346. buttonsRoll: number[];
  37347. /**
  37348. * Detect if any button is being pressed while mouse is moved.
  37349. * -1 = Mouse locked.
  37350. * 0 = Left button.
  37351. * 1 = Middle Button.
  37352. * 2 = Right Button.
  37353. */
  37354. activeButton: number;
  37355. /**
  37356. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37357. * Higher values reduce its sensitivity.
  37358. */
  37359. angularSensibility: number;
  37360. private _mousemoveCallback;
  37361. private _observer;
  37362. private _rollObserver;
  37363. private previousPosition;
  37364. private noPreventDefault;
  37365. private element;
  37366. /**
  37367. * Listen to mouse events to control the camera.
  37368. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37369. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37370. */
  37371. constructor(touchEnabled?: boolean);
  37372. /**
  37373. * Attach the mouse control to the HTML DOM element.
  37374. * @param element Defines the element that listens to the input events.
  37375. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37376. */
  37377. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37378. /**
  37379. * Detach the current controls from the specified dom element.
  37380. * @param element Defines the element to stop listening the inputs from
  37381. */
  37382. detachControl(element: Nullable<HTMLElement>): void;
  37383. /**
  37384. * Gets the class name of the current input.
  37385. * @returns the class name.
  37386. */
  37387. getClassName(): string;
  37388. /**
  37389. * Get the friendly name associated with the input class.
  37390. * @returns the input's friendly name.
  37391. */
  37392. getSimpleName(): string;
  37393. private _pointerInput;
  37394. private _onMouseMove;
  37395. /**
  37396. * Rotate camera by mouse offset.
  37397. */
  37398. private rotateCamera;
  37399. }
  37400. }
  37401. declare module BABYLON {
  37402. /**
  37403. * Default Inputs manager for the FlyCamera.
  37404. * It groups all the default supported inputs for ease of use.
  37405. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37406. */
  37407. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37408. /**
  37409. * Instantiates a new FlyCameraInputsManager.
  37410. * @param camera Defines the camera the inputs belong to.
  37411. */
  37412. constructor(camera: FlyCamera);
  37413. /**
  37414. * Add keyboard input support to the input manager.
  37415. * @returns the new FlyCameraKeyboardMoveInput().
  37416. */
  37417. addKeyboard(): FlyCameraInputsManager;
  37418. /**
  37419. * Add mouse input support to the input manager.
  37420. * @param touchEnabled Enable touch screen support.
  37421. * @returns the new FlyCameraMouseInput().
  37422. */
  37423. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37424. }
  37425. }
  37426. declare module BABYLON {
  37427. /**
  37428. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37429. * such as in a 3D Space Shooter or a Flight Simulator.
  37430. */
  37431. export class FlyCamera extends TargetCamera {
  37432. /**
  37433. * Define the collision ellipsoid of the camera.
  37434. * This is helpful for simulating a camera body, like a player's body.
  37435. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37436. */
  37437. ellipsoid: Vector3;
  37438. /**
  37439. * Define an offset for the position of the ellipsoid around the camera.
  37440. * This can be helpful if the camera is attached away from the player's body center,
  37441. * such as at its head.
  37442. */
  37443. ellipsoidOffset: Vector3;
  37444. /**
  37445. * Enable or disable collisions of the camera with the rest of the scene objects.
  37446. */
  37447. checkCollisions: boolean;
  37448. /**
  37449. * Enable or disable gravity on the camera.
  37450. */
  37451. applyGravity: boolean;
  37452. /**
  37453. * Define the current direction the camera is moving to.
  37454. */
  37455. cameraDirection: Vector3;
  37456. /**
  37457. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37458. * This overrides and empties cameraRotation.
  37459. */
  37460. rotationQuaternion: Quaternion;
  37461. /**
  37462. * Track Roll to maintain the wanted Rolling when looking around.
  37463. */
  37464. _trackRoll: number;
  37465. /**
  37466. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37467. */
  37468. rollCorrect: number;
  37469. /**
  37470. * Mimic a banked turn, Rolling the camera when Yawing.
  37471. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37472. */
  37473. bankedTurn: boolean;
  37474. /**
  37475. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37476. */
  37477. bankedTurnLimit: number;
  37478. /**
  37479. * Value of 0 disables the banked Roll.
  37480. * Value of 1 is equal to the Yaw angle in radians.
  37481. */
  37482. bankedTurnMultiplier: number;
  37483. /**
  37484. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37485. */
  37486. inputs: FlyCameraInputsManager;
  37487. /**
  37488. * Gets the input sensibility for mouse input.
  37489. * Higher values reduce sensitivity.
  37490. */
  37491. /**
  37492. * Sets the input sensibility for a mouse input.
  37493. * Higher values reduce sensitivity.
  37494. */
  37495. angularSensibility: number;
  37496. /**
  37497. * Get the keys for camera movement forward.
  37498. */
  37499. /**
  37500. * Set the keys for camera movement forward.
  37501. */
  37502. keysForward: number[];
  37503. /**
  37504. * Get the keys for camera movement backward.
  37505. */
  37506. keysBackward: number[];
  37507. /**
  37508. * Get the keys for camera movement up.
  37509. */
  37510. /**
  37511. * Set the keys for camera movement up.
  37512. */
  37513. keysUp: number[];
  37514. /**
  37515. * Get the keys for camera movement down.
  37516. */
  37517. /**
  37518. * Set the keys for camera movement down.
  37519. */
  37520. keysDown: number[];
  37521. /**
  37522. * Get the keys for camera movement left.
  37523. */
  37524. /**
  37525. * Set the keys for camera movement left.
  37526. */
  37527. keysLeft: number[];
  37528. /**
  37529. * Set the keys for camera movement right.
  37530. */
  37531. /**
  37532. * Set the keys for camera movement right.
  37533. */
  37534. keysRight: number[];
  37535. /**
  37536. * Event raised when the camera collides with a mesh in the scene.
  37537. */
  37538. onCollide: (collidedMesh: AbstractMesh) => void;
  37539. private _collider;
  37540. private _needMoveForGravity;
  37541. private _oldPosition;
  37542. private _diffPosition;
  37543. private _newPosition;
  37544. /** @hidden */
  37545. _localDirection: Vector3;
  37546. /** @hidden */
  37547. _transformedDirection: Vector3;
  37548. /**
  37549. * Instantiates a FlyCamera.
  37550. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37551. * such as in a 3D Space Shooter or a Flight Simulator.
  37552. * @param name Define the name of the camera in the scene.
  37553. * @param position Define the starting position of the camera in the scene.
  37554. * @param scene Define the scene the camera belongs to.
  37555. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37556. */
  37557. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37558. /**
  37559. * Attach a control to the HTML DOM element.
  37560. * @param element Defines the element that listens to the input events.
  37561. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37562. */
  37563. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37564. /**
  37565. * Detach a control from the HTML DOM element.
  37566. * The camera will stop reacting to that input.
  37567. * @param element Defines the element that listens to the input events.
  37568. */
  37569. detachControl(element: HTMLElement): void;
  37570. private _collisionMask;
  37571. /**
  37572. * Get the mask that the camera ignores in collision events.
  37573. */
  37574. /**
  37575. * Set the mask that the camera ignores in collision events.
  37576. */
  37577. collisionMask: number;
  37578. /** @hidden */
  37579. _collideWithWorld(displacement: Vector3): void;
  37580. /** @hidden */
  37581. private _onCollisionPositionChange;
  37582. /** @hidden */
  37583. _checkInputs(): void;
  37584. /** @hidden */
  37585. _decideIfNeedsToMove(): boolean;
  37586. /** @hidden */
  37587. _updatePosition(): void;
  37588. /**
  37589. * Restore the Roll to its target value at the rate specified.
  37590. * @param rate - Higher means slower restoring.
  37591. * @hidden
  37592. */
  37593. restoreRoll(rate: number): void;
  37594. /**
  37595. * Destroy the camera and release the current resources held by it.
  37596. */
  37597. dispose(): void;
  37598. /**
  37599. * Get the current object class name.
  37600. * @returns the class name.
  37601. */
  37602. getClassName(): string;
  37603. }
  37604. }
  37605. declare module BABYLON {
  37606. /**
  37607. * Listen to keyboard events to control the camera.
  37608. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37609. */
  37610. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37611. /**
  37612. * Defines the camera the input is attached to.
  37613. */
  37614. camera: FlyCamera;
  37615. /**
  37616. * The list of keyboard keys used to control the forward move of the camera.
  37617. */
  37618. keysForward: number[];
  37619. /**
  37620. * The list of keyboard keys used to control the backward move of the camera.
  37621. */
  37622. keysBackward: number[];
  37623. /**
  37624. * The list of keyboard keys used to control the forward move of the camera.
  37625. */
  37626. keysUp: number[];
  37627. /**
  37628. * The list of keyboard keys used to control the backward move of the camera.
  37629. */
  37630. keysDown: number[];
  37631. /**
  37632. * The list of keyboard keys used to control the right strafe move of the camera.
  37633. */
  37634. keysRight: number[];
  37635. /**
  37636. * The list of keyboard keys used to control the left strafe move of the camera.
  37637. */
  37638. keysLeft: number[];
  37639. private _keys;
  37640. private _onCanvasBlurObserver;
  37641. private _onKeyboardObserver;
  37642. private _engine;
  37643. private _scene;
  37644. /**
  37645. * Attach the input controls to a specific dom element to get the input from.
  37646. * @param element Defines the element the controls should be listened from
  37647. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37648. */
  37649. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37650. /**
  37651. * Detach the current controls from the specified dom element.
  37652. * @param element Defines the element to stop listening the inputs from
  37653. */
  37654. detachControl(element: Nullable<HTMLElement>): void;
  37655. /**
  37656. * Gets the class name of the current intput.
  37657. * @returns the class name
  37658. */
  37659. getClassName(): string;
  37660. /** @hidden */
  37661. _onLostFocus(e: FocusEvent): void;
  37662. /**
  37663. * Get the friendly name associated with the input class.
  37664. * @returns the input friendly name
  37665. */
  37666. getSimpleName(): string;
  37667. /**
  37668. * Update the current camera state depending on the inputs that have been used this frame.
  37669. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37670. */
  37671. checkInputs(): void;
  37672. }
  37673. }
  37674. declare module BABYLON {
  37675. /**
  37676. * Manage the mouse wheel inputs to control a follow camera.
  37677. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37678. */
  37679. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37680. /**
  37681. * Defines the camera the input is attached to.
  37682. */
  37683. camera: FollowCamera;
  37684. /**
  37685. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37686. */
  37687. axisControlRadius: boolean;
  37688. /**
  37689. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37690. */
  37691. axisControlHeight: boolean;
  37692. /**
  37693. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37694. */
  37695. axisControlRotation: boolean;
  37696. /**
  37697. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37698. * relation to mouseWheel events.
  37699. */
  37700. wheelPrecision: number;
  37701. /**
  37702. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37703. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37704. */
  37705. wheelDeltaPercentage: number;
  37706. private _wheel;
  37707. private _observer;
  37708. /**
  37709. * Attach the input controls to a specific dom element to get the input from.
  37710. * @param element Defines the element the controls should be listened from
  37711. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37712. */
  37713. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37714. /**
  37715. * Detach the current controls from the specified dom element.
  37716. * @param element Defines the element to stop listening the inputs from
  37717. */
  37718. detachControl(element: Nullable<HTMLElement>): void;
  37719. /**
  37720. * Gets the class name of the current intput.
  37721. * @returns the class name
  37722. */
  37723. getClassName(): string;
  37724. /**
  37725. * Get the friendly name associated with the input class.
  37726. * @returns the input friendly name
  37727. */
  37728. getSimpleName(): string;
  37729. }
  37730. }
  37731. declare module BABYLON {
  37732. /**
  37733. * Manage the pointers inputs to control an follow camera.
  37734. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37735. */
  37736. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37737. /**
  37738. * Defines the camera the input is attached to.
  37739. */
  37740. camera: FollowCamera;
  37741. /**
  37742. * Gets the class name of the current input.
  37743. * @returns the class name
  37744. */
  37745. getClassName(): string;
  37746. /**
  37747. * Defines the pointer angular sensibility along the X axis or how fast is
  37748. * the camera rotating.
  37749. * A negative number will reverse the axis direction.
  37750. */
  37751. angularSensibilityX: number;
  37752. /**
  37753. * Defines the pointer angular sensibility along the Y axis or how fast is
  37754. * the camera rotating.
  37755. * A negative number will reverse the axis direction.
  37756. */
  37757. angularSensibilityY: number;
  37758. /**
  37759. * Defines the pointer pinch precision or how fast is the camera zooming.
  37760. * A negative number will reverse the axis direction.
  37761. */
  37762. pinchPrecision: number;
  37763. /**
  37764. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37765. * from 0.
  37766. * It defines the percentage of current camera.radius to use as delta when
  37767. * pinch zoom is used.
  37768. */
  37769. pinchDeltaPercentage: number;
  37770. /**
  37771. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37772. */
  37773. axisXControlRadius: boolean;
  37774. /**
  37775. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37776. */
  37777. axisXControlHeight: boolean;
  37778. /**
  37779. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37780. */
  37781. axisXControlRotation: boolean;
  37782. /**
  37783. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37784. */
  37785. axisYControlRadius: boolean;
  37786. /**
  37787. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37788. */
  37789. axisYControlHeight: boolean;
  37790. /**
  37791. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37792. */
  37793. axisYControlRotation: boolean;
  37794. /**
  37795. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37796. */
  37797. axisPinchControlRadius: boolean;
  37798. /**
  37799. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37800. */
  37801. axisPinchControlHeight: boolean;
  37802. /**
  37803. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37804. */
  37805. axisPinchControlRotation: boolean;
  37806. /**
  37807. * Log error messages if basic misconfiguration has occurred.
  37808. */
  37809. warningEnable: boolean;
  37810. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37811. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37812. private _warningCounter;
  37813. private _warning;
  37814. }
  37815. }
  37816. declare module BABYLON {
  37817. /**
  37818. * Default Inputs manager for the FollowCamera.
  37819. * It groups all the default supported inputs for ease of use.
  37820. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37821. */
  37822. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37823. /**
  37824. * Instantiates a new FollowCameraInputsManager.
  37825. * @param camera Defines the camera the inputs belong to
  37826. */
  37827. constructor(camera: FollowCamera);
  37828. /**
  37829. * Add keyboard input support to the input manager.
  37830. * @returns the current input manager
  37831. */
  37832. addKeyboard(): FollowCameraInputsManager;
  37833. /**
  37834. * Add mouse wheel input support to the input manager.
  37835. * @returns the current input manager
  37836. */
  37837. addMouseWheel(): FollowCameraInputsManager;
  37838. /**
  37839. * Add pointers input support to the input manager.
  37840. * @returns the current input manager
  37841. */
  37842. addPointers(): FollowCameraInputsManager;
  37843. /**
  37844. * Add orientation input support to the input manager.
  37845. * @returns the current input manager
  37846. */
  37847. addVRDeviceOrientation(): FollowCameraInputsManager;
  37848. }
  37849. }
  37850. declare module BABYLON {
  37851. /**
  37852. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37853. * an arc rotate version arcFollowCamera are available.
  37854. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37855. */
  37856. export class FollowCamera extends TargetCamera {
  37857. /**
  37858. * Distance the follow camera should follow an object at
  37859. */
  37860. radius: number;
  37861. /**
  37862. * Minimum allowed distance of the camera to the axis of rotation
  37863. * (The camera can not get closer).
  37864. * This can help limiting how the Camera is able to move in the scene.
  37865. */
  37866. lowerRadiusLimit: Nullable<number>;
  37867. /**
  37868. * Maximum allowed distance of the camera to the axis of rotation
  37869. * (The camera can not get further).
  37870. * This can help limiting how the Camera is able to move in the scene.
  37871. */
  37872. upperRadiusLimit: Nullable<number>;
  37873. /**
  37874. * Define a rotation offset between the camera and the object it follows
  37875. */
  37876. rotationOffset: number;
  37877. /**
  37878. * Minimum allowed angle to camera position relative to target object.
  37879. * This can help limiting how the Camera is able to move in the scene.
  37880. */
  37881. lowerRotationOffsetLimit: Nullable<number>;
  37882. /**
  37883. * Maximum allowed angle to camera position relative to target object.
  37884. * This can help limiting how the Camera is able to move in the scene.
  37885. */
  37886. upperRotationOffsetLimit: Nullable<number>;
  37887. /**
  37888. * Define a height offset between the camera and the object it follows.
  37889. * It can help following an object from the top (like a car chaing a plane)
  37890. */
  37891. heightOffset: number;
  37892. /**
  37893. * Minimum allowed height of camera position relative to target object.
  37894. * This can help limiting how the Camera is able to move in the scene.
  37895. */
  37896. lowerHeightOffsetLimit: Nullable<number>;
  37897. /**
  37898. * Maximum allowed height of camera position relative to target object.
  37899. * This can help limiting how the Camera is able to move in the scene.
  37900. */
  37901. upperHeightOffsetLimit: Nullable<number>;
  37902. /**
  37903. * Define how fast the camera can accelerate to follow it s target.
  37904. */
  37905. cameraAcceleration: number;
  37906. /**
  37907. * Define the speed limit of the camera following an object.
  37908. */
  37909. maxCameraSpeed: number;
  37910. /**
  37911. * Define the target of the camera.
  37912. */
  37913. lockedTarget: Nullable<AbstractMesh>;
  37914. /**
  37915. * Defines the input associated with the camera.
  37916. */
  37917. inputs: FollowCameraInputsManager;
  37918. /**
  37919. * Instantiates the follow camera.
  37920. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37921. * @param name Define the name of the camera in the scene
  37922. * @param position Define the position of the camera
  37923. * @param scene Define the scene the camera belong to
  37924. * @param lockedTarget Define the target of the camera
  37925. */
  37926. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37927. private _follow;
  37928. /**
  37929. * Attached controls to the current camera.
  37930. * @param element Defines the element the controls should be listened from
  37931. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37932. */
  37933. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37934. /**
  37935. * Detach the current controls from the camera.
  37936. * The camera will stop reacting to inputs.
  37937. * @param element Defines the element to stop listening the inputs from
  37938. */
  37939. detachControl(element: HTMLElement): void;
  37940. /** @hidden */
  37941. _checkInputs(): void;
  37942. private _checkLimits;
  37943. /**
  37944. * Gets the camera class name.
  37945. * @returns the class name
  37946. */
  37947. getClassName(): string;
  37948. }
  37949. /**
  37950. * Arc Rotate version of the follow camera.
  37951. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37952. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37953. */
  37954. export class ArcFollowCamera extends TargetCamera {
  37955. /** The longitudinal angle of the camera */
  37956. alpha: number;
  37957. /** The latitudinal angle of the camera */
  37958. beta: number;
  37959. /** The radius of the camera from its target */
  37960. radius: number;
  37961. /** Define the camera target (the messh it should follow) */
  37962. target: Nullable<AbstractMesh>;
  37963. private _cartesianCoordinates;
  37964. /**
  37965. * Instantiates a new ArcFollowCamera
  37966. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37967. * @param name Define the name of the camera
  37968. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37969. * @param beta Define the rotation angle of the camera around the elevation axis
  37970. * @param radius Define the radius of the camera from its target point
  37971. * @param target Define the target of the camera
  37972. * @param scene Define the scene the camera belongs to
  37973. */
  37974. constructor(name: string,
  37975. /** The longitudinal angle of the camera */
  37976. alpha: number,
  37977. /** The latitudinal angle of the camera */
  37978. beta: number,
  37979. /** The radius of the camera from its target */
  37980. radius: number,
  37981. /** Define the camera target (the messh it should follow) */
  37982. target: Nullable<AbstractMesh>, scene: Scene);
  37983. private _follow;
  37984. /** @hidden */
  37985. _checkInputs(): void;
  37986. /**
  37987. * Returns the class name of the object.
  37988. * It is mostly used internally for serialization purposes.
  37989. */
  37990. getClassName(): string;
  37991. }
  37992. }
  37993. declare module BABYLON {
  37994. /**
  37995. * Manage the keyboard inputs to control the movement of a follow camera.
  37996. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37997. */
  37998. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37999. /**
  38000. * Defines the camera the input is attached to.
  38001. */
  38002. camera: FollowCamera;
  38003. /**
  38004. * Defines the list of key codes associated with the up action (increase heightOffset)
  38005. */
  38006. keysHeightOffsetIncr: number[];
  38007. /**
  38008. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38009. */
  38010. keysHeightOffsetDecr: number[];
  38011. /**
  38012. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38013. */
  38014. keysHeightOffsetModifierAlt: boolean;
  38015. /**
  38016. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38017. */
  38018. keysHeightOffsetModifierCtrl: boolean;
  38019. /**
  38020. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38021. */
  38022. keysHeightOffsetModifierShift: boolean;
  38023. /**
  38024. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38025. */
  38026. keysRotationOffsetIncr: number[];
  38027. /**
  38028. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38029. */
  38030. keysRotationOffsetDecr: number[];
  38031. /**
  38032. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38033. */
  38034. keysRotationOffsetModifierAlt: boolean;
  38035. /**
  38036. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38037. */
  38038. keysRotationOffsetModifierCtrl: boolean;
  38039. /**
  38040. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38041. */
  38042. keysRotationOffsetModifierShift: boolean;
  38043. /**
  38044. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38045. */
  38046. keysRadiusIncr: number[];
  38047. /**
  38048. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38049. */
  38050. keysRadiusDecr: number[];
  38051. /**
  38052. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38053. */
  38054. keysRadiusModifierAlt: boolean;
  38055. /**
  38056. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38057. */
  38058. keysRadiusModifierCtrl: boolean;
  38059. /**
  38060. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38061. */
  38062. keysRadiusModifierShift: boolean;
  38063. /**
  38064. * Defines the rate of change of heightOffset.
  38065. */
  38066. heightSensibility: number;
  38067. /**
  38068. * Defines the rate of change of rotationOffset.
  38069. */
  38070. rotationSensibility: number;
  38071. /**
  38072. * Defines the rate of change of radius.
  38073. */
  38074. radiusSensibility: number;
  38075. private _keys;
  38076. private _ctrlPressed;
  38077. private _altPressed;
  38078. private _shiftPressed;
  38079. private _onCanvasBlurObserver;
  38080. private _onKeyboardObserver;
  38081. private _engine;
  38082. private _scene;
  38083. /**
  38084. * Attach the input controls to a specific dom element to get the input from.
  38085. * @param element Defines the element the controls should be listened from
  38086. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38087. */
  38088. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38089. /**
  38090. * Detach the current controls from the specified dom element.
  38091. * @param element Defines the element to stop listening the inputs from
  38092. */
  38093. detachControl(element: Nullable<HTMLElement>): void;
  38094. /**
  38095. * Update the current camera state depending on the inputs that have been used this frame.
  38096. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38097. */
  38098. checkInputs(): void;
  38099. /**
  38100. * Gets the class name of the current input.
  38101. * @returns the class name
  38102. */
  38103. getClassName(): string;
  38104. /**
  38105. * Get the friendly name associated with the input class.
  38106. * @returns the input friendly name
  38107. */
  38108. getSimpleName(): string;
  38109. /**
  38110. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38111. * allow modification of the heightOffset value.
  38112. */
  38113. private _modifierHeightOffset;
  38114. /**
  38115. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38116. * allow modification of the rotationOffset value.
  38117. */
  38118. private _modifierRotationOffset;
  38119. /**
  38120. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38121. * allow modification of the radius value.
  38122. */
  38123. private _modifierRadius;
  38124. }
  38125. }
  38126. declare module BABYLON {
  38127. interface FreeCameraInputsManager {
  38128. /**
  38129. * @hidden
  38130. */
  38131. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38132. /**
  38133. * Add orientation input support to the input manager.
  38134. * @returns the current input manager
  38135. */
  38136. addDeviceOrientation(): FreeCameraInputsManager;
  38137. }
  38138. /**
  38139. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38140. * Screen rotation is taken into account.
  38141. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38142. */
  38143. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38144. private _camera;
  38145. private _screenOrientationAngle;
  38146. private _constantTranform;
  38147. private _screenQuaternion;
  38148. private _alpha;
  38149. private _beta;
  38150. private _gamma;
  38151. /**
  38152. * Can be used to detect if a device orientation sensor is availible on a device
  38153. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38154. * @returns a promise that will resolve on orientation change
  38155. */
  38156. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38157. /**
  38158. * @hidden
  38159. */
  38160. _onDeviceOrientationChangedObservable: Observable<void>;
  38161. /**
  38162. * Instantiates a new input
  38163. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38164. */
  38165. constructor();
  38166. /**
  38167. * Define the camera controlled by the input.
  38168. */
  38169. camera: FreeCamera;
  38170. /**
  38171. * Attach the input controls to a specific dom element to get the input from.
  38172. * @param element Defines the element the controls should be listened from
  38173. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38174. */
  38175. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38176. private _orientationChanged;
  38177. private _deviceOrientation;
  38178. /**
  38179. * Detach the current controls from the specified dom element.
  38180. * @param element Defines the element to stop listening the inputs from
  38181. */
  38182. detachControl(element: Nullable<HTMLElement>): void;
  38183. /**
  38184. * Update the current camera state depending on the inputs that have been used this frame.
  38185. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38186. */
  38187. checkInputs(): void;
  38188. /**
  38189. * Gets the class name of the current intput.
  38190. * @returns the class name
  38191. */
  38192. getClassName(): string;
  38193. /**
  38194. * Get the friendly name associated with the input class.
  38195. * @returns the input friendly name
  38196. */
  38197. getSimpleName(): string;
  38198. }
  38199. }
  38200. declare module BABYLON {
  38201. /**
  38202. * Manage the gamepad inputs to control a free camera.
  38203. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38204. */
  38205. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38206. /**
  38207. * Define the camera the input is attached to.
  38208. */
  38209. camera: FreeCamera;
  38210. /**
  38211. * Define the Gamepad controlling the input
  38212. */
  38213. gamepad: Nullable<Gamepad>;
  38214. /**
  38215. * Defines the gamepad rotation sensiblity.
  38216. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38217. */
  38218. gamepadAngularSensibility: number;
  38219. /**
  38220. * Defines the gamepad move sensiblity.
  38221. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38222. */
  38223. gamepadMoveSensibility: number;
  38224. private _onGamepadConnectedObserver;
  38225. private _onGamepadDisconnectedObserver;
  38226. private _cameraTransform;
  38227. private _deltaTransform;
  38228. private _vector3;
  38229. private _vector2;
  38230. /**
  38231. * Attach the input controls to a specific dom element to get the input from.
  38232. * @param element Defines the element the controls should be listened from
  38233. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38234. */
  38235. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38236. /**
  38237. * Detach the current controls from the specified dom element.
  38238. * @param element Defines the element to stop listening the inputs from
  38239. */
  38240. detachControl(element: Nullable<HTMLElement>): void;
  38241. /**
  38242. * Update the current camera state depending on the inputs that have been used this frame.
  38243. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38244. */
  38245. checkInputs(): void;
  38246. /**
  38247. * Gets the class name of the current intput.
  38248. * @returns the class name
  38249. */
  38250. getClassName(): string;
  38251. /**
  38252. * Get the friendly name associated with the input class.
  38253. * @returns the input friendly name
  38254. */
  38255. getSimpleName(): string;
  38256. }
  38257. }
  38258. declare module BABYLON {
  38259. /**
  38260. * Defines the potential axis of a Joystick
  38261. */
  38262. export enum JoystickAxis {
  38263. /** X axis */
  38264. X = 0,
  38265. /** Y axis */
  38266. Y = 1,
  38267. /** Z axis */
  38268. Z = 2
  38269. }
  38270. /**
  38271. * Class used to define virtual joystick (used in touch mode)
  38272. */
  38273. export class VirtualJoystick {
  38274. /**
  38275. * Gets or sets a boolean indicating that left and right values must be inverted
  38276. */
  38277. reverseLeftRight: boolean;
  38278. /**
  38279. * Gets or sets a boolean indicating that up and down values must be inverted
  38280. */
  38281. reverseUpDown: boolean;
  38282. /**
  38283. * Gets the offset value for the position (ie. the change of the position value)
  38284. */
  38285. deltaPosition: Vector3;
  38286. /**
  38287. * Gets a boolean indicating if the virtual joystick was pressed
  38288. */
  38289. pressed: boolean;
  38290. /**
  38291. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38292. */
  38293. static Canvas: Nullable<HTMLCanvasElement>;
  38294. private static _globalJoystickIndex;
  38295. private static vjCanvasContext;
  38296. private static vjCanvasWidth;
  38297. private static vjCanvasHeight;
  38298. private static halfWidth;
  38299. private _action;
  38300. private _axisTargetedByLeftAndRight;
  38301. private _axisTargetedByUpAndDown;
  38302. private _joystickSensibility;
  38303. private _inversedSensibility;
  38304. private _joystickPointerID;
  38305. private _joystickColor;
  38306. private _joystickPointerPos;
  38307. private _joystickPreviousPointerPos;
  38308. private _joystickPointerStartPos;
  38309. private _deltaJoystickVector;
  38310. private _leftJoystick;
  38311. private _touches;
  38312. private _onPointerDownHandlerRef;
  38313. private _onPointerMoveHandlerRef;
  38314. private _onPointerUpHandlerRef;
  38315. private _onResize;
  38316. /**
  38317. * Creates a new virtual joystick
  38318. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38319. */
  38320. constructor(leftJoystick?: boolean);
  38321. /**
  38322. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38323. * @param newJoystickSensibility defines the new sensibility
  38324. */
  38325. setJoystickSensibility(newJoystickSensibility: number): void;
  38326. private _onPointerDown;
  38327. private _onPointerMove;
  38328. private _onPointerUp;
  38329. /**
  38330. * Change the color of the virtual joystick
  38331. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38332. */
  38333. setJoystickColor(newColor: string): void;
  38334. /**
  38335. * Defines a callback to call when the joystick is touched
  38336. * @param action defines the callback
  38337. */
  38338. setActionOnTouch(action: () => any): void;
  38339. /**
  38340. * Defines which axis you'd like to control for left & right
  38341. * @param axis defines the axis to use
  38342. */
  38343. setAxisForLeftRight(axis: JoystickAxis): void;
  38344. /**
  38345. * Defines which axis you'd like to control for up & down
  38346. * @param axis defines the axis to use
  38347. */
  38348. setAxisForUpDown(axis: JoystickAxis): void;
  38349. private _drawVirtualJoystick;
  38350. /**
  38351. * Release internal HTML canvas
  38352. */
  38353. releaseCanvas(): void;
  38354. }
  38355. }
  38356. declare module BABYLON {
  38357. interface FreeCameraInputsManager {
  38358. /**
  38359. * Add virtual joystick input support to the input manager.
  38360. * @returns the current input manager
  38361. */
  38362. addVirtualJoystick(): FreeCameraInputsManager;
  38363. }
  38364. /**
  38365. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38366. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38367. */
  38368. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38369. /**
  38370. * Defines the camera the input is attached to.
  38371. */
  38372. camera: FreeCamera;
  38373. private _leftjoystick;
  38374. private _rightjoystick;
  38375. /**
  38376. * Gets the left stick of the virtual joystick.
  38377. * @returns The virtual Joystick
  38378. */
  38379. getLeftJoystick(): VirtualJoystick;
  38380. /**
  38381. * Gets the right stick of the virtual joystick.
  38382. * @returns The virtual Joystick
  38383. */
  38384. getRightJoystick(): VirtualJoystick;
  38385. /**
  38386. * Update the current camera state depending on the inputs that have been used this frame.
  38387. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38388. */
  38389. checkInputs(): void;
  38390. /**
  38391. * Attach the input controls to a specific dom element to get the input from.
  38392. * @param element Defines the element the controls should be listened from
  38393. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38394. */
  38395. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38396. /**
  38397. * Detach the current controls from the specified dom element.
  38398. * @param element Defines the element to stop listening the inputs from
  38399. */
  38400. detachControl(element: Nullable<HTMLElement>): void;
  38401. /**
  38402. * Gets the class name of the current intput.
  38403. * @returns the class name
  38404. */
  38405. getClassName(): string;
  38406. /**
  38407. * Get the friendly name associated with the input class.
  38408. * @returns the input friendly name
  38409. */
  38410. getSimpleName(): string;
  38411. }
  38412. }
  38413. declare module BABYLON {
  38414. /**
  38415. * This represents a FPS type of camera controlled by touch.
  38416. * This is like a universal camera minus the Gamepad controls.
  38417. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38418. */
  38419. export class TouchCamera extends FreeCamera {
  38420. /**
  38421. * Defines the touch sensibility for rotation.
  38422. * The higher the faster.
  38423. */
  38424. touchAngularSensibility: number;
  38425. /**
  38426. * Defines the touch sensibility for move.
  38427. * The higher the faster.
  38428. */
  38429. touchMoveSensibility: number;
  38430. /**
  38431. * Instantiates a new touch camera.
  38432. * This represents a FPS type of camera controlled by touch.
  38433. * This is like a universal camera minus the Gamepad controls.
  38434. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38435. * @param name Define the name of the camera in the scene
  38436. * @param position Define the start position of the camera in the scene
  38437. * @param scene Define the scene the camera belongs to
  38438. */
  38439. constructor(name: string, position: Vector3, scene: Scene);
  38440. /**
  38441. * Gets the current object class name.
  38442. * @return the class name
  38443. */
  38444. getClassName(): string;
  38445. /** @hidden */
  38446. _setupInputs(): void;
  38447. }
  38448. }
  38449. declare module BABYLON {
  38450. /**
  38451. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38452. * being tilted forward or back and left or right.
  38453. */
  38454. export class DeviceOrientationCamera extends FreeCamera {
  38455. private _initialQuaternion;
  38456. private _quaternionCache;
  38457. private _tmpDragQuaternion;
  38458. private _disablePointerInputWhenUsingDeviceOrientation;
  38459. /**
  38460. * Creates a new device orientation camera
  38461. * @param name The name of the camera
  38462. * @param position The start position camera
  38463. * @param scene The scene the camera belongs to
  38464. */
  38465. constructor(name: string, position: Vector3, scene: Scene);
  38466. /**
  38467. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38468. */
  38469. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38470. private _dragFactor;
  38471. /**
  38472. * Enabled turning on the y axis when the orientation sensor is active
  38473. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38474. */
  38475. enableHorizontalDragging(dragFactor?: number): void;
  38476. /**
  38477. * Gets the current instance class name ("DeviceOrientationCamera").
  38478. * This helps avoiding instanceof at run time.
  38479. * @returns the class name
  38480. */
  38481. getClassName(): string;
  38482. /**
  38483. * @hidden
  38484. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38485. */
  38486. _checkInputs(): void;
  38487. /**
  38488. * Reset the camera to its default orientation on the specified axis only.
  38489. * @param axis The axis to reset
  38490. */
  38491. resetToCurrentRotation(axis?: Axis): void;
  38492. }
  38493. }
  38494. declare module BABYLON {
  38495. /**
  38496. * Defines supported buttons for XBox360 compatible gamepads
  38497. */
  38498. export enum Xbox360Button {
  38499. /** A */
  38500. A = 0,
  38501. /** B */
  38502. B = 1,
  38503. /** X */
  38504. X = 2,
  38505. /** Y */
  38506. Y = 3,
  38507. /** Start */
  38508. Start = 4,
  38509. /** Back */
  38510. Back = 5,
  38511. /** Left button */
  38512. LB = 6,
  38513. /** Right button */
  38514. RB = 7,
  38515. /** Left stick */
  38516. LeftStick = 8,
  38517. /** Right stick */
  38518. RightStick = 9
  38519. }
  38520. /** Defines values for XBox360 DPad */
  38521. export enum Xbox360Dpad {
  38522. /** Up */
  38523. Up = 0,
  38524. /** Down */
  38525. Down = 1,
  38526. /** Left */
  38527. Left = 2,
  38528. /** Right */
  38529. Right = 3
  38530. }
  38531. /**
  38532. * Defines a XBox360 gamepad
  38533. */
  38534. export class Xbox360Pad extends Gamepad {
  38535. private _leftTrigger;
  38536. private _rightTrigger;
  38537. private _onlefttriggerchanged;
  38538. private _onrighttriggerchanged;
  38539. private _onbuttondown;
  38540. private _onbuttonup;
  38541. private _ondpaddown;
  38542. private _ondpadup;
  38543. /** Observable raised when a button is pressed */
  38544. onButtonDownObservable: Observable<Xbox360Button>;
  38545. /** Observable raised when a button is released */
  38546. onButtonUpObservable: Observable<Xbox360Button>;
  38547. /** Observable raised when a pad is pressed */
  38548. onPadDownObservable: Observable<Xbox360Dpad>;
  38549. /** Observable raised when a pad is released */
  38550. onPadUpObservable: Observable<Xbox360Dpad>;
  38551. private _buttonA;
  38552. private _buttonB;
  38553. private _buttonX;
  38554. private _buttonY;
  38555. private _buttonBack;
  38556. private _buttonStart;
  38557. private _buttonLB;
  38558. private _buttonRB;
  38559. private _buttonLeftStick;
  38560. private _buttonRightStick;
  38561. private _dPadUp;
  38562. private _dPadDown;
  38563. private _dPadLeft;
  38564. private _dPadRight;
  38565. private _isXboxOnePad;
  38566. /**
  38567. * Creates a new XBox360 gamepad object
  38568. * @param id defines the id of this gamepad
  38569. * @param index defines its index
  38570. * @param gamepad defines the internal HTML gamepad object
  38571. * @param xboxOne defines if it is a XBox One gamepad
  38572. */
  38573. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38574. /**
  38575. * Defines the callback to call when left trigger is pressed
  38576. * @param callback defines the callback to use
  38577. */
  38578. onlefttriggerchanged(callback: (value: number) => void): void;
  38579. /**
  38580. * Defines the callback to call when right trigger is pressed
  38581. * @param callback defines the callback to use
  38582. */
  38583. onrighttriggerchanged(callback: (value: number) => void): void;
  38584. /**
  38585. * Gets the left trigger value
  38586. */
  38587. /**
  38588. * Sets the left trigger value
  38589. */
  38590. leftTrigger: number;
  38591. /**
  38592. * Gets the right trigger value
  38593. */
  38594. /**
  38595. * Sets the right trigger value
  38596. */
  38597. rightTrigger: number;
  38598. /**
  38599. * Defines the callback to call when a button is pressed
  38600. * @param callback defines the callback to use
  38601. */
  38602. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38603. /**
  38604. * Defines the callback to call when a button is released
  38605. * @param callback defines the callback to use
  38606. */
  38607. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38608. /**
  38609. * Defines the callback to call when a pad is pressed
  38610. * @param callback defines the callback to use
  38611. */
  38612. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38613. /**
  38614. * Defines the callback to call when a pad is released
  38615. * @param callback defines the callback to use
  38616. */
  38617. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38618. private _setButtonValue;
  38619. private _setDPadValue;
  38620. /**
  38621. * Gets the value of the `A` button
  38622. */
  38623. /**
  38624. * Sets the value of the `A` button
  38625. */
  38626. buttonA: number;
  38627. /**
  38628. * Gets the value of the `B` button
  38629. */
  38630. /**
  38631. * Sets the value of the `B` button
  38632. */
  38633. buttonB: number;
  38634. /**
  38635. * Gets the value of the `X` button
  38636. */
  38637. /**
  38638. * Sets the value of the `X` button
  38639. */
  38640. buttonX: number;
  38641. /**
  38642. * Gets the value of the `Y` button
  38643. */
  38644. /**
  38645. * Sets the value of the `Y` button
  38646. */
  38647. buttonY: number;
  38648. /**
  38649. * Gets the value of the `Start` button
  38650. */
  38651. /**
  38652. * Sets the value of the `Start` button
  38653. */
  38654. buttonStart: number;
  38655. /**
  38656. * Gets the value of the `Back` button
  38657. */
  38658. /**
  38659. * Sets the value of the `Back` button
  38660. */
  38661. buttonBack: number;
  38662. /**
  38663. * Gets the value of the `Left` button
  38664. */
  38665. /**
  38666. * Sets the value of the `Left` button
  38667. */
  38668. buttonLB: number;
  38669. /**
  38670. * Gets the value of the `Right` button
  38671. */
  38672. /**
  38673. * Sets the value of the `Right` button
  38674. */
  38675. buttonRB: number;
  38676. /**
  38677. * Gets the value of the Left joystick
  38678. */
  38679. /**
  38680. * Sets the value of the Left joystick
  38681. */
  38682. buttonLeftStick: number;
  38683. /**
  38684. * Gets the value of the Right joystick
  38685. */
  38686. /**
  38687. * Sets the value of the Right joystick
  38688. */
  38689. buttonRightStick: number;
  38690. /**
  38691. * Gets the value of D-pad up
  38692. */
  38693. /**
  38694. * Sets the value of D-pad up
  38695. */
  38696. dPadUp: number;
  38697. /**
  38698. * Gets the value of D-pad down
  38699. */
  38700. /**
  38701. * Sets the value of D-pad down
  38702. */
  38703. dPadDown: number;
  38704. /**
  38705. * Gets the value of D-pad left
  38706. */
  38707. /**
  38708. * Sets the value of D-pad left
  38709. */
  38710. dPadLeft: number;
  38711. /**
  38712. * Gets the value of D-pad right
  38713. */
  38714. /**
  38715. * Sets the value of D-pad right
  38716. */
  38717. dPadRight: number;
  38718. /**
  38719. * Force the gamepad to synchronize with device values
  38720. */
  38721. update(): void;
  38722. /**
  38723. * Disposes the gamepad
  38724. */
  38725. dispose(): void;
  38726. }
  38727. }
  38728. declare module BABYLON {
  38729. /**
  38730. * Defines supported buttons for DualShock compatible gamepads
  38731. */
  38732. export enum DualShockButton {
  38733. /** Cross */
  38734. Cross = 0,
  38735. /** Circle */
  38736. Circle = 1,
  38737. /** Square */
  38738. Square = 2,
  38739. /** Triangle */
  38740. Triangle = 3,
  38741. /** Options */
  38742. Options = 4,
  38743. /** Share */
  38744. Share = 5,
  38745. /** L1 */
  38746. L1 = 6,
  38747. /** R1 */
  38748. R1 = 7,
  38749. /** Left stick */
  38750. LeftStick = 8,
  38751. /** Right stick */
  38752. RightStick = 9
  38753. }
  38754. /** Defines values for DualShock DPad */
  38755. export enum DualShockDpad {
  38756. /** Up */
  38757. Up = 0,
  38758. /** Down */
  38759. Down = 1,
  38760. /** Left */
  38761. Left = 2,
  38762. /** Right */
  38763. Right = 3
  38764. }
  38765. /**
  38766. * Defines a DualShock gamepad
  38767. */
  38768. export class DualShockPad extends Gamepad {
  38769. private _leftTrigger;
  38770. private _rightTrigger;
  38771. private _onlefttriggerchanged;
  38772. private _onrighttriggerchanged;
  38773. private _onbuttondown;
  38774. private _onbuttonup;
  38775. private _ondpaddown;
  38776. private _ondpadup;
  38777. /** Observable raised when a button is pressed */
  38778. onButtonDownObservable: Observable<DualShockButton>;
  38779. /** Observable raised when a button is released */
  38780. onButtonUpObservable: Observable<DualShockButton>;
  38781. /** Observable raised when a pad is pressed */
  38782. onPadDownObservable: Observable<DualShockDpad>;
  38783. /** Observable raised when a pad is released */
  38784. onPadUpObservable: Observable<DualShockDpad>;
  38785. private _buttonCross;
  38786. private _buttonCircle;
  38787. private _buttonSquare;
  38788. private _buttonTriangle;
  38789. private _buttonShare;
  38790. private _buttonOptions;
  38791. private _buttonL1;
  38792. private _buttonR1;
  38793. private _buttonLeftStick;
  38794. private _buttonRightStick;
  38795. private _dPadUp;
  38796. private _dPadDown;
  38797. private _dPadLeft;
  38798. private _dPadRight;
  38799. /**
  38800. * Creates a new DualShock gamepad object
  38801. * @param id defines the id of this gamepad
  38802. * @param index defines its index
  38803. * @param gamepad defines the internal HTML gamepad object
  38804. */
  38805. constructor(id: string, index: number, gamepad: any);
  38806. /**
  38807. * Defines the callback to call when left trigger is pressed
  38808. * @param callback defines the callback to use
  38809. */
  38810. onlefttriggerchanged(callback: (value: number) => void): void;
  38811. /**
  38812. * Defines the callback to call when right trigger is pressed
  38813. * @param callback defines the callback to use
  38814. */
  38815. onrighttriggerchanged(callback: (value: number) => void): void;
  38816. /**
  38817. * Gets the left trigger value
  38818. */
  38819. /**
  38820. * Sets the left trigger value
  38821. */
  38822. leftTrigger: number;
  38823. /**
  38824. * Gets the right trigger value
  38825. */
  38826. /**
  38827. * Sets the right trigger value
  38828. */
  38829. rightTrigger: number;
  38830. /**
  38831. * Defines the callback to call when a button is pressed
  38832. * @param callback defines the callback to use
  38833. */
  38834. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38835. /**
  38836. * Defines the callback to call when a button is released
  38837. * @param callback defines the callback to use
  38838. */
  38839. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38840. /**
  38841. * Defines the callback to call when a pad is pressed
  38842. * @param callback defines the callback to use
  38843. */
  38844. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38845. /**
  38846. * Defines the callback to call when a pad is released
  38847. * @param callback defines the callback to use
  38848. */
  38849. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38850. private _setButtonValue;
  38851. private _setDPadValue;
  38852. /**
  38853. * Gets the value of the `Cross` button
  38854. */
  38855. /**
  38856. * Sets the value of the `Cross` button
  38857. */
  38858. buttonCross: number;
  38859. /**
  38860. * Gets the value of the `Circle` button
  38861. */
  38862. /**
  38863. * Sets the value of the `Circle` button
  38864. */
  38865. buttonCircle: number;
  38866. /**
  38867. * Gets the value of the `Square` button
  38868. */
  38869. /**
  38870. * Sets the value of the `Square` button
  38871. */
  38872. buttonSquare: number;
  38873. /**
  38874. * Gets the value of the `Triangle` button
  38875. */
  38876. /**
  38877. * Sets the value of the `Triangle` button
  38878. */
  38879. buttonTriangle: number;
  38880. /**
  38881. * Gets the value of the `Options` button
  38882. */
  38883. /**
  38884. * Sets the value of the `Options` button
  38885. */
  38886. buttonOptions: number;
  38887. /**
  38888. * Gets the value of the `Share` button
  38889. */
  38890. /**
  38891. * Sets the value of the `Share` button
  38892. */
  38893. buttonShare: number;
  38894. /**
  38895. * Gets the value of the `L1` button
  38896. */
  38897. /**
  38898. * Sets the value of the `L1` button
  38899. */
  38900. buttonL1: number;
  38901. /**
  38902. * Gets the value of the `R1` button
  38903. */
  38904. /**
  38905. * Sets the value of the `R1` button
  38906. */
  38907. buttonR1: number;
  38908. /**
  38909. * Gets the value of the Left joystick
  38910. */
  38911. /**
  38912. * Sets the value of the Left joystick
  38913. */
  38914. buttonLeftStick: number;
  38915. /**
  38916. * Gets the value of the Right joystick
  38917. */
  38918. /**
  38919. * Sets the value of the Right joystick
  38920. */
  38921. buttonRightStick: number;
  38922. /**
  38923. * Gets the value of D-pad up
  38924. */
  38925. /**
  38926. * Sets the value of D-pad up
  38927. */
  38928. dPadUp: number;
  38929. /**
  38930. * Gets the value of D-pad down
  38931. */
  38932. /**
  38933. * Sets the value of D-pad down
  38934. */
  38935. dPadDown: number;
  38936. /**
  38937. * Gets the value of D-pad left
  38938. */
  38939. /**
  38940. * Sets the value of D-pad left
  38941. */
  38942. dPadLeft: number;
  38943. /**
  38944. * Gets the value of D-pad right
  38945. */
  38946. /**
  38947. * Sets the value of D-pad right
  38948. */
  38949. dPadRight: number;
  38950. /**
  38951. * Force the gamepad to synchronize with device values
  38952. */
  38953. update(): void;
  38954. /**
  38955. * Disposes the gamepad
  38956. */
  38957. dispose(): void;
  38958. }
  38959. }
  38960. declare module BABYLON {
  38961. /**
  38962. * Manager for handling gamepads
  38963. */
  38964. export class GamepadManager {
  38965. private _scene?;
  38966. private _babylonGamepads;
  38967. private _oneGamepadConnected;
  38968. /** @hidden */
  38969. _isMonitoring: boolean;
  38970. private _gamepadEventSupported;
  38971. private _gamepadSupport;
  38972. /**
  38973. * observable to be triggered when the gamepad controller has been connected
  38974. */
  38975. onGamepadConnectedObservable: Observable<Gamepad>;
  38976. /**
  38977. * observable to be triggered when the gamepad controller has been disconnected
  38978. */
  38979. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38980. private _onGamepadConnectedEvent;
  38981. private _onGamepadDisconnectedEvent;
  38982. /**
  38983. * Initializes the gamepad manager
  38984. * @param _scene BabylonJS scene
  38985. */
  38986. constructor(_scene?: Scene | undefined);
  38987. /**
  38988. * The gamepads in the game pad manager
  38989. */
  38990. readonly gamepads: Gamepad[];
  38991. /**
  38992. * Get the gamepad controllers based on type
  38993. * @param type The type of gamepad controller
  38994. * @returns Nullable gamepad
  38995. */
  38996. getGamepadByType(type?: number): Nullable<Gamepad>;
  38997. /**
  38998. * Disposes the gamepad manager
  38999. */
  39000. dispose(): void;
  39001. private _addNewGamepad;
  39002. private _startMonitoringGamepads;
  39003. private _stopMonitoringGamepads;
  39004. /** @hidden */
  39005. _checkGamepadsStatus(): void;
  39006. private _updateGamepadObjects;
  39007. }
  39008. }
  39009. declare module BABYLON {
  39010. interface Scene {
  39011. /** @hidden */
  39012. _gamepadManager: Nullable<GamepadManager>;
  39013. /**
  39014. * Gets the gamepad manager associated with the scene
  39015. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39016. */
  39017. gamepadManager: GamepadManager;
  39018. }
  39019. /**
  39020. * Interface representing a free camera inputs manager
  39021. */
  39022. interface FreeCameraInputsManager {
  39023. /**
  39024. * Adds gamepad input support to the FreeCameraInputsManager.
  39025. * @returns the FreeCameraInputsManager
  39026. */
  39027. addGamepad(): FreeCameraInputsManager;
  39028. }
  39029. /**
  39030. * Interface representing an arc rotate camera inputs manager
  39031. */
  39032. interface ArcRotateCameraInputsManager {
  39033. /**
  39034. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39035. * @returns the camera inputs manager
  39036. */
  39037. addGamepad(): ArcRotateCameraInputsManager;
  39038. }
  39039. /**
  39040. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39041. */
  39042. export class GamepadSystemSceneComponent implements ISceneComponent {
  39043. /**
  39044. * The component name helpfull to identify the component in the list of scene components.
  39045. */
  39046. readonly name: string;
  39047. /**
  39048. * The scene the component belongs to.
  39049. */
  39050. scene: Scene;
  39051. /**
  39052. * Creates a new instance of the component for the given scene
  39053. * @param scene Defines the scene to register the component in
  39054. */
  39055. constructor(scene: Scene);
  39056. /**
  39057. * Registers the component in a given scene
  39058. */
  39059. register(): void;
  39060. /**
  39061. * Rebuilds the elements related to this component in case of
  39062. * context lost for instance.
  39063. */
  39064. rebuild(): void;
  39065. /**
  39066. * Disposes the component and the associated ressources
  39067. */
  39068. dispose(): void;
  39069. private _beforeCameraUpdate;
  39070. }
  39071. }
  39072. declare module BABYLON {
  39073. /**
  39074. * 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,
  39075. * which still works and will still be found in many Playgrounds.
  39076. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39077. */
  39078. export class UniversalCamera extends TouchCamera {
  39079. /**
  39080. * Defines the gamepad rotation sensiblity.
  39081. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39082. */
  39083. gamepadAngularSensibility: number;
  39084. /**
  39085. * Defines the gamepad move sensiblity.
  39086. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39087. */
  39088. gamepadMoveSensibility: number;
  39089. /**
  39090. * 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,
  39091. * which still works and will still be found in many Playgrounds.
  39092. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39093. * @param name Define the name of the camera in the scene
  39094. * @param position Define the start position of the camera in the scene
  39095. * @param scene Define the scene the camera belongs to
  39096. */
  39097. constructor(name: string, position: Vector3, scene: Scene);
  39098. /**
  39099. * Gets the current object class name.
  39100. * @return the class name
  39101. */
  39102. getClassName(): string;
  39103. }
  39104. }
  39105. declare module BABYLON {
  39106. /**
  39107. * This represents a FPS type of camera. This is only here for back compat purpose.
  39108. * Please use the UniversalCamera instead as both are identical.
  39109. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39110. */
  39111. export class GamepadCamera extends UniversalCamera {
  39112. /**
  39113. * Instantiates a new Gamepad Camera
  39114. * This represents a FPS type of camera. This is only here for back compat purpose.
  39115. * Please use the UniversalCamera instead as both are identical.
  39116. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39117. * @param name Define the name of the camera in the scene
  39118. * @param position Define the start position of the camera in the scene
  39119. * @param scene Define the scene the camera belongs to
  39120. */
  39121. constructor(name: string, position: Vector3, scene: Scene);
  39122. /**
  39123. * Gets the current object class name.
  39124. * @return the class name
  39125. */
  39126. getClassName(): string;
  39127. }
  39128. }
  39129. declare module BABYLON {
  39130. /** @hidden */
  39131. export var passPixelShader: {
  39132. name: string;
  39133. shader: string;
  39134. };
  39135. }
  39136. declare module BABYLON {
  39137. /** @hidden */
  39138. export var passCubePixelShader: {
  39139. name: string;
  39140. shader: string;
  39141. };
  39142. }
  39143. declare module BABYLON {
  39144. /**
  39145. * PassPostProcess which produces an output the same as it's input
  39146. */
  39147. export class PassPostProcess extends PostProcess {
  39148. /**
  39149. * Creates the PassPostProcess
  39150. * @param name The name of the effect.
  39151. * @param options The required width/height ratio to downsize to before computing the render pass.
  39152. * @param camera The camera to apply the render pass to.
  39153. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39154. * @param engine The engine which the post process will be applied. (default: current engine)
  39155. * @param reusable If the post process can be reused on the same frame. (default: false)
  39156. * @param textureType The type of texture to be used when performing the post processing.
  39157. * @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)
  39158. */
  39159. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39160. }
  39161. /**
  39162. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39163. */
  39164. export class PassCubePostProcess extends PostProcess {
  39165. private _face;
  39166. /**
  39167. * Gets or sets the cube face to display.
  39168. * * 0 is +X
  39169. * * 1 is -X
  39170. * * 2 is +Y
  39171. * * 3 is -Y
  39172. * * 4 is +Z
  39173. * * 5 is -Z
  39174. */
  39175. face: number;
  39176. /**
  39177. * Creates the PassCubePostProcess
  39178. * @param name The name of the effect.
  39179. * @param options The required width/height ratio to downsize to before computing the render pass.
  39180. * @param camera The camera to apply the render pass to.
  39181. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39182. * @param engine The engine which the post process will be applied. (default: current engine)
  39183. * @param reusable If the post process can be reused on the same frame. (default: false)
  39184. * @param textureType The type of texture to be used when performing the post processing.
  39185. * @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)
  39186. */
  39187. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39188. }
  39189. }
  39190. declare module BABYLON {
  39191. /** @hidden */
  39192. export var anaglyphPixelShader: {
  39193. name: string;
  39194. shader: string;
  39195. };
  39196. }
  39197. declare module BABYLON {
  39198. /**
  39199. * Postprocess used to generate anaglyphic rendering
  39200. */
  39201. export class AnaglyphPostProcess extends PostProcess {
  39202. private _passedProcess;
  39203. /**
  39204. * Creates a new AnaglyphPostProcess
  39205. * @param name defines postprocess name
  39206. * @param options defines creation options or target ratio scale
  39207. * @param rigCameras defines cameras using this postprocess
  39208. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39209. * @param engine defines hosting engine
  39210. * @param reusable defines if the postprocess will be reused multiple times per frame
  39211. */
  39212. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39213. }
  39214. }
  39215. declare module BABYLON {
  39216. /**
  39217. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39218. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39219. */
  39220. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39221. /**
  39222. * Creates a new AnaglyphArcRotateCamera
  39223. * @param name defines camera name
  39224. * @param alpha defines alpha angle (in radians)
  39225. * @param beta defines beta angle (in radians)
  39226. * @param radius defines radius
  39227. * @param target defines camera target
  39228. * @param interaxialDistance defines distance between each color axis
  39229. * @param scene defines the hosting scene
  39230. */
  39231. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39232. /**
  39233. * Gets camera class name
  39234. * @returns AnaglyphArcRotateCamera
  39235. */
  39236. getClassName(): string;
  39237. }
  39238. }
  39239. declare module BABYLON {
  39240. /**
  39241. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39242. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39243. */
  39244. export class AnaglyphFreeCamera extends FreeCamera {
  39245. /**
  39246. * Creates a new AnaglyphFreeCamera
  39247. * @param name defines camera name
  39248. * @param position defines initial position
  39249. * @param interaxialDistance defines distance between each color axis
  39250. * @param scene defines the hosting scene
  39251. */
  39252. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39253. /**
  39254. * Gets camera class name
  39255. * @returns AnaglyphFreeCamera
  39256. */
  39257. getClassName(): string;
  39258. }
  39259. }
  39260. declare module BABYLON {
  39261. /**
  39262. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39263. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39264. */
  39265. export class AnaglyphGamepadCamera extends GamepadCamera {
  39266. /**
  39267. * Creates a new AnaglyphGamepadCamera
  39268. * @param name defines camera name
  39269. * @param position defines initial position
  39270. * @param interaxialDistance defines distance between each color axis
  39271. * @param scene defines the hosting scene
  39272. */
  39273. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39274. /**
  39275. * Gets camera class name
  39276. * @returns AnaglyphGamepadCamera
  39277. */
  39278. getClassName(): string;
  39279. }
  39280. }
  39281. declare module BABYLON {
  39282. /**
  39283. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39284. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39285. */
  39286. export class AnaglyphUniversalCamera extends UniversalCamera {
  39287. /**
  39288. * Creates a new AnaglyphUniversalCamera
  39289. * @param name defines camera name
  39290. * @param position defines initial position
  39291. * @param interaxialDistance defines distance between each color axis
  39292. * @param scene defines the hosting scene
  39293. */
  39294. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39295. /**
  39296. * Gets camera class name
  39297. * @returns AnaglyphUniversalCamera
  39298. */
  39299. getClassName(): string;
  39300. }
  39301. }
  39302. declare module BABYLON {
  39303. /** @hidden */
  39304. export var stereoscopicInterlacePixelShader: {
  39305. name: string;
  39306. shader: string;
  39307. };
  39308. }
  39309. declare module BABYLON {
  39310. /**
  39311. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39312. */
  39313. export class StereoscopicInterlacePostProcess extends PostProcess {
  39314. private _stepSize;
  39315. private _passedProcess;
  39316. /**
  39317. * Initializes a StereoscopicInterlacePostProcess
  39318. * @param name The name of the effect.
  39319. * @param rigCameras The rig cameras to be appled to the post process
  39320. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39321. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39322. * @param engine The engine which the post process will be applied. (default: current engine)
  39323. * @param reusable If the post process can be reused on the same frame. (default: false)
  39324. */
  39325. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39326. }
  39327. }
  39328. declare module BABYLON {
  39329. /**
  39330. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39331. * @see http://doc.babylonjs.com/features/cameras
  39332. */
  39333. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39334. /**
  39335. * Creates a new StereoscopicArcRotateCamera
  39336. * @param name defines camera name
  39337. * @param alpha defines alpha angle (in radians)
  39338. * @param beta defines beta angle (in radians)
  39339. * @param radius defines radius
  39340. * @param target defines camera target
  39341. * @param interaxialDistance defines distance between each color axis
  39342. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39343. * @param scene defines the hosting scene
  39344. */
  39345. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39346. /**
  39347. * Gets camera class name
  39348. * @returns StereoscopicArcRotateCamera
  39349. */
  39350. getClassName(): string;
  39351. }
  39352. }
  39353. declare module BABYLON {
  39354. /**
  39355. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39356. * @see http://doc.babylonjs.com/features/cameras
  39357. */
  39358. export class StereoscopicFreeCamera extends FreeCamera {
  39359. /**
  39360. * Creates a new StereoscopicFreeCamera
  39361. * @param name defines camera name
  39362. * @param position defines initial position
  39363. * @param interaxialDistance defines distance between each color axis
  39364. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39365. * @param scene defines the hosting scene
  39366. */
  39367. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39368. /**
  39369. * Gets camera class name
  39370. * @returns StereoscopicFreeCamera
  39371. */
  39372. getClassName(): string;
  39373. }
  39374. }
  39375. declare module BABYLON {
  39376. /**
  39377. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39378. * @see http://doc.babylonjs.com/features/cameras
  39379. */
  39380. export class StereoscopicGamepadCamera extends GamepadCamera {
  39381. /**
  39382. * Creates a new StereoscopicGamepadCamera
  39383. * @param name defines camera name
  39384. * @param position defines initial position
  39385. * @param interaxialDistance defines distance between each color axis
  39386. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39387. * @param scene defines the hosting scene
  39388. */
  39389. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39390. /**
  39391. * Gets camera class name
  39392. * @returns StereoscopicGamepadCamera
  39393. */
  39394. getClassName(): string;
  39395. }
  39396. }
  39397. declare module BABYLON {
  39398. /**
  39399. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39400. * @see http://doc.babylonjs.com/features/cameras
  39401. */
  39402. export class StereoscopicUniversalCamera extends UniversalCamera {
  39403. /**
  39404. * Creates a new StereoscopicUniversalCamera
  39405. * @param name defines camera name
  39406. * @param position defines initial position
  39407. * @param interaxialDistance defines distance between each color axis
  39408. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39409. * @param scene defines the hosting scene
  39410. */
  39411. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39412. /**
  39413. * Gets camera class name
  39414. * @returns StereoscopicUniversalCamera
  39415. */
  39416. getClassName(): string;
  39417. }
  39418. }
  39419. declare module BABYLON {
  39420. /**
  39421. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39422. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39423. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39424. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39425. */
  39426. export class VirtualJoysticksCamera extends FreeCamera {
  39427. /**
  39428. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39429. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39430. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39431. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39432. * @param name Define the name of the camera in the scene
  39433. * @param position Define the start position of the camera in the scene
  39434. * @param scene Define the scene the camera belongs to
  39435. */
  39436. constructor(name: string, position: Vector3, scene: Scene);
  39437. /**
  39438. * Gets the current object class name.
  39439. * @return the class name
  39440. */
  39441. getClassName(): string;
  39442. }
  39443. }
  39444. declare module BABYLON {
  39445. /**
  39446. * This represents all the required metrics to create a VR camera.
  39447. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39448. */
  39449. export class VRCameraMetrics {
  39450. /**
  39451. * Define the horizontal resolution off the screen.
  39452. */
  39453. hResolution: number;
  39454. /**
  39455. * Define the vertical resolution off the screen.
  39456. */
  39457. vResolution: number;
  39458. /**
  39459. * Define the horizontal screen size.
  39460. */
  39461. hScreenSize: number;
  39462. /**
  39463. * Define the vertical screen size.
  39464. */
  39465. vScreenSize: number;
  39466. /**
  39467. * Define the vertical screen center position.
  39468. */
  39469. vScreenCenter: number;
  39470. /**
  39471. * Define the distance of the eyes to the screen.
  39472. */
  39473. eyeToScreenDistance: number;
  39474. /**
  39475. * Define the distance between both lenses
  39476. */
  39477. lensSeparationDistance: number;
  39478. /**
  39479. * Define the distance between both viewer's eyes.
  39480. */
  39481. interpupillaryDistance: number;
  39482. /**
  39483. * Define the distortion factor of the VR postprocess.
  39484. * Please, touch with care.
  39485. */
  39486. distortionK: number[];
  39487. /**
  39488. * Define the chromatic aberration correction factors for the VR post process.
  39489. */
  39490. chromaAbCorrection: number[];
  39491. /**
  39492. * Define the scale factor of the post process.
  39493. * The smaller the better but the slower.
  39494. */
  39495. postProcessScaleFactor: number;
  39496. /**
  39497. * Define an offset for the lens center.
  39498. */
  39499. lensCenterOffset: number;
  39500. /**
  39501. * Define if the current vr camera should compensate the distortion of the lense or not.
  39502. */
  39503. compensateDistortion: boolean;
  39504. /**
  39505. * Defines if multiview should be enabled when rendering (Default: false)
  39506. */
  39507. multiviewEnabled: boolean;
  39508. /**
  39509. * Gets the rendering aspect ratio based on the provided resolutions.
  39510. */
  39511. readonly aspectRatio: number;
  39512. /**
  39513. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39514. */
  39515. readonly aspectRatioFov: number;
  39516. /**
  39517. * @hidden
  39518. */
  39519. readonly leftHMatrix: Matrix;
  39520. /**
  39521. * @hidden
  39522. */
  39523. readonly rightHMatrix: Matrix;
  39524. /**
  39525. * @hidden
  39526. */
  39527. readonly leftPreViewMatrix: Matrix;
  39528. /**
  39529. * @hidden
  39530. */
  39531. readonly rightPreViewMatrix: Matrix;
  39532. /**
  39533. * Get the default VRMetrics based on the most generic setup.
  39534. * @returns the default vr metrics
  39535. */
  39536. static GetDefault(): VRCameraMetrics;
  39537. }
  39538. }
  39539. declare module BABYLON {
  39540. /** @hidden */
  39541. export var vrDistortionCorrectionPixelShader: {
  39542. name: string;
  39543. shader: string;
  39544. };
  39545. }
  39546. declare module BABYLON {
  39547. /**
  39548. * VRDistortionCorrectionPostProcess used for mobile VR
  39549. */
  39550. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39551. private _isRightEye;
  39552. private _distortionFactors;
  39553. private _postProcessScaleFactor;
  39554. private _lensCenterOffset;
  39555. private _scaleIn;
  39556. private _scaleFactor;
  39557. private _lensCenter;
  39558. /**
  39559. * Initializes the VRDistortionCorrectionPostProcess
  39560. * @param name The name of the effect.
  39561. * @param camera The camera to apply the render pass to.
  39562. * @param isRightEye If this is for the right eye distortion
  39563. * @param vrMetrics All the required metrics for the VR camera
  39564. */
  39565. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39566. }
  39567. }
  39568. declare module BABYLON {
  39569. /**
  39570. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39571. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39572. */
  39573. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39574. /**
  39575. * Creates a new VRDeviceOrientationArcRotateCamera
  39576. * @param name defines camera name
  39577. * @param alpha defines the camera rotation along the logitudinal axis
  39578. * @param beta defines the camera rotation along the latitudinal axis
  39579. * @param radius defines the camera distance from its target
  39580. * @param target defines the camera target
  39581. * @param scene defines the scene the camera belongs to
  39582. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39583. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39584. */
  39585. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39586. /**
  39587. * Gets camera class name
  39588. * @returns VRDeviceOrientationArcRotateCamera
  39589. */
  39590. getClassName(): string;
  39591. }
  39592. }
  39593. declare module BABYLON {
  39594. /**
  39595. * Camera used to simulate VR rendering (based on FreeCamera)
  39596. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39597. */
  39598. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39599. /**
  39600. * Creates a new VRDeviceOrientationFreeCamera
  39601. * @param name defines camera name
  39602. * @param position defines the start position of the camera
  39603. * @param scene defines the scene the camera belongs to
  39604. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39605. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39606. */
  39607. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39608. /**
  39609. * Gets camera class name
  39610. * @returns VRDeviceOrientationFreeCamera
  39611. */
  39612. getClassName(): string;
  39613. }
  39614. }
  39615. declare module BABYLON {
  39616. /**
  39617. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39618. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39619. */
  39620. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39621. /**
  39622. * Creates a new VRDeviceOrientationGamepadCamera
  39623. * @param name defines camera name
  39624. * @param position defines the start position of the camera
  39625. * @param scene defines the scene the camera belongs to
  39626. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39627. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39628. */
  39629. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39630. /**
  39631. * Gets camera class name
  39632. * @returns VRDeviceOrientationGamepadCamera
  39633. */
  39634. getClassName(): string;
  39635. }
  39636. }
  39637. declare module BABYLON {
  39638. /**
  39639. * Base class of materials working in push mode in babylon JS
  39640. * @hidden
  39641. */
  39642. export class PushMaterial extends Material {
  39643. protected _activeEffect: Effect;
  39644. protected _normalMatrix: Matrix;
  39645. /**
  39646. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39647. * This means that the material can keep using a previous shader while a new one is being compiled.
  39648. * This is mostly used when shader parallel compilation is supported (true by default)
  39649. */
  39650. allowShaderHotSwapping: boolean;
  39651. constructor(name: string, scene: Scene);
  39652. getEffect(): Effect;
  39653. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39654. /**
  39655. * Binds the given world matrix to the active effect
  39656. *
  39657. * @param world the matrix to bind
  39658. */
  39659. bindOnlyWorldMatrix(world: Matrix): void;
  39660. /**
  39661. * Binds the given normal matrix to the active effect
  39662. *
  39663. * @param normalMatrix the matrix to bind
  39664. */
  39665. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39666. bind(world: Matrix, mesh?: Mesh): void;
  39667. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39668. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39669. }
  39670. }
  39671. declare module BABYLON {
  39672. /**
  39673. * This groups all the flags used to control the materials channel.
  39674. */
  39675. export class MaterialFlags {
  39676. private static _DiffuseTextureEnabled;
  39677. /**
  39678. * Are diffuse textures enabled in the application.
  39679. */
  39680. static DiffuseTextureEnabled: boolean;
  39681. private static _AmbientTextureEnabled;
  39682. /**
  39683. * Are ambient textures enabled in the application.
  39684. */
  39685. static AmbientTextureEnabled: boolean;
  39686. private static _OpacityTextureEnabled;
  39687. /**
  39688. * Are opacity textures enabled in the application.
  39689. */
  39690. static OpacityTextureEnabled: boolean;
  39691. private static _ReflectionTextureEnabled;
  39692. /**
  39693. * Are reflection textures enabled in the application.
  39694. */
  39695. static ReflectionTextureEnabled: boolean;
  39696. private static _EmissiveTextureEnabled;
  39697. /**
  39698. * Are emissive textures enabled in the application.
  39699. */
  39700. static EmissiveTextureEnabled: boolean;
  39701. private static _SpecularTextureEnabled;
  39702. /**
  39703. * Are specular textures enabled in the application.
  39704. */
  39705. static SpecularTextureEnabled: boolean;
  39706. private static _BumpTextureEnabled;
  39707. /**
  39708. * Are bump textures enabled in the application.
  39709. */
  39710. static BumpTextureEnabled: boolean;
  39711. private static _LightmapTextureEnabled;
  39712. /**
  39713. * Are lightmap textures enabled in the application.
  39714. */
  39715. static LightmapTextureEnabled: boolean;
  39716. private static _RefractionTextureEnabled;
  39717. /**
  39718. * Are refraction textures enabled in the application.
  39719. */
  39720. static RefractionTextureEnabled: boolean;
  39721. private static _ColorGradingTextureEnabled;
  39722. /**
  39723. * Are color grading textures enabled in the application.
  39724. */
  39725. static ColorGradingTextureEnabled: boolean;
  39726. private static _FresnelEnabled;
  39727. /**
  39728. * Are fresnels enabled in the application.
  39729. */
  39730. static FresnelEnabled: boolean;
  39731. private static _ClearCoatTextureEnabled;
  39732. /**
  39733. * Are clear coat textures enabled in the application.
  39734. */
  39735. static ClearCoatTextureEnabled: boolean;
  39736. private static _ClearCoatBumpTextureEnabled;
  39737. /**
  39738. * Are clear coat bump textures enabled in the application.
  39739. */
  39740. static ClearCoatBumpTextureEnabled: boolean;
  39741. private static _ClearCoatTintTextureEnabled;
  39742. /**
  39743. * Are clear coat tint textures enabled in the application.
  39744. */
  39745. static ClearCoatTintTextureEnabled: boolean;
  39746. private static _SheenTextureEnabled;
  39747. /**
  39748. * Are sheen textures enabled in the application.
  39749. */
  39750. static SheenTextureEnabled: boolean;
  39751. private static _AnisotropicTextureEnabled;
  39752. /**
  39753. * Are anisotropic textures enabled in the application.
  39754. */
  39755. static AnisotropicTextureEnabled: boolean;
  39756. private static _ThicknessTextureEnabled;
  39757. /**
  39758. * Are thickness textures enabled in the application.
  39759. */
  39760. static ThicknessTextureEnabled: boolean;
  39761. }
  39762. }
  39763. declare module BABYLON {
  39764. /** @hidden */
  39765. export var defaultFragmentDeclaration: {
  39766. name: string;
  39767. shader: string;
  39768. };
  39769. }
  39770. declare module BABYLON {
  39771. /** @hidden */
  39772. export var defaultUboDeclaration: {
  39773. name: string;
  39774. shader: string;
  39775. };
  39776. }
  39777. declare module BABYLON {
  39778. /** @hidden */
  39779. export var lightFragmentDeclaration: {
  39780. name: string;
  39781. shader: string;
  39782. };
  39783. }
  39784. declare module BABYLON {
  39785. /** @hidden */
  39786. export var lightUboDeclaration: {
  39787. name: string;
  39788. shader: string;
  39789. };
  39790. }
  39791. declare module BABYLON {
  39792. /** @hidden */
  39793. export var lightsFragmentFunctions: {
  39794. name: string;
  39795. shader: string;
  39796. };
  39797. }
  39798. declare module BABYLON {
  39799. /** @hidden */
  39800. export var shadowsFragmentFunctions: {
  39801. name: string;
  39802. shader: string;
  39803. };
  39804. }
  39805. declare module BABYLON {
  39806. /** @hidden */
  39807. export var fresnelFunction: {
  39808. name: string;
  39809. shader: string;
  39810. };
  39811. }
  39812. declare module BABYLON {
  39813. /** @hidden */
  39814. export var reflectionFunction: {
  39815. name: string;
  39816. shader: string;
  39817. };
  39818. }
  39819. declare module BABYLON {
  39820. /** @hidden */
  39821. export var bumpFragmentFunctions: {
  39822. name: string;
  39823. shader: string;
  39824. };
  39825. }
  39826. declare module BABYLON {
  39827. /** @hidden */
  39828. export var logDepthDeclaration: {
  39829. name: string;
  39830. shader: string;
  39831. };
  39832. }
  39833. declare module BABYLON {
  39834. /** @hidden */
  39835. export var bumpFragment: {
  39836. name: string;
  39837. shader: string;
  39838. };
  39839. }
  39840. declare module BABYLON {
  39841. /** @hidden */
  39842. export var depthPrePass: {
  39843. name: string;
  39844. shader: string;
  39845. };
  39846. }
  39847. declare module BABYLON {
  39848. /** @hidden */
  39849. export var lightFragment: {
  39850. name: string;
  39851. shader: string;
  39852. };
  39853. }
  39854. declare module BABYLON {
  39855. /** @hidden */
  39856. export var logDepthFragment: {
  39857. name: string;
  39858. shader: string;
  39859. };
  39860. }
  39861. declare module BABYLON {
  39862. /** @hidden */
  39863. export var defaultPixelShader: {
  39864. name: string;
  39865. shader: string;
  39866. };
  39867. }
  39868. declare module BABYLON {
  39869. /** @hidden */
  39870. export var defaultVertexDeclaration: {
  39871. name: string;
  39872. shader: string;
  39873. };
  39874. }
  39875. declare module BABYLON {
  39876. /** @hidden */
  39877. export var bumpVertexDeclaration: {
  39878. name: string;
  39879. shader: string;
  39880. };
  39881. }
  39882. declare module BABYLON {
  39883. /** @hidden */
  39884. export var bumpVertex: {
  39885. name: string;
  39886. shader: string;
  39887. };
  39888. }
  39889. declare module BABYLON {
  39890. /** @hidden */
  39891. export var fogVertex: {
  39892. name: string;
  39893. shader: string;
  39894. };
  39895. }
  39896. declare module BABYLON {
  39897. /** @hidden */
  39898. export var shadowsVertex: {
  39899. name: string;
  39900. shader: string;
  39901. };
  39902. }
  39903. declare module BABYLON {
  39904. /** @hidden */
  39905. export var pointCloudVertex: {
  39906. name: string;
  39907. shader: string;
  39908. };
  39909. }
  39910. declare module BABYLON {
  39911. /** @hidden */
  39912. export var logDepthVertex: {
  39913. name: string;
  39914. shader: string;
  39915. };
  39916. }
  39917. declare module BABYLON {
  39918. /** @hidden */
  39919. export var defaultVertexShader: {
  39920. name: string;
  39921. shader: string;
  39922. };
  39923. }
  39924. declare module BABYLON {
  39925. /** @hidden */
  39926. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39927. MAINUV1: boolean;
  39928. MAINUV2: boolean;
  39929. DIFFUSE: boolean;
  39930. DIFFUSEDIRECTUV: number;
  39931. AMBIENT: boolean;
  39932. AMBIENTDIRECTUV: number;
  39933. OPACITY: boolean;
  39934. OPACITYDIRECTUV: number;
  39935. OPACITYRGB: boolean;
  39936. REFLECTION: boolean;
  39937. EMISSIVE: boolean;
  39938. EMISSIVEDIRECTUV: number;
  39939. SPECULAR: boolean;
  39940. SPECULARDIRECTUV: number;
  39941. BUMP: boolean;
  39942. BUMPDIRECTUV: number;
  39943. PARALLAX: boolean;
  39944. PARALLAXOCCLUSION: boolean;
  39945. SPECULAROVERALPHA: boolean;
  39946. CLIPPLANE: boolean;
  39947. CLIPPLANE2: boolean;
  39948. CLIPPLANE3: boolean;
  39949. CLIPPLANE4: boolean;
  39950. ALPHATEST: boolean;
  39951. DEPTHPREPASS: boolean;
  39952. ALPHAFROMDIFFUSE: boolean;
  39953. POINTSIZE: boolean;
  39954. FOG: boolean;
  39955. SPECULARTERM: boolean;
  39956. DIFFUSEFRESNEL: boolean;
  39957. OPACITYFRESNEL: boolean;
  39958. REFLECTIONFRESNEL: boolean;
  39959. REFRACTIONFRESNEL: boolean;
  39960. EMISSIVEFRESNEL: boolean;
  39961. FRESNEL: boolean;
  39962. NORMAL: boolean;
  39963. UV1: boolean;
  39964. UV2: boolean;
  39965. VERTEXCOLOR: boolean;
  39966. VERTEXALPHA: boolean;
  39967. NUM_BONE_INFLUENCERS: number;
  39968. BonesPerMesh: number;
  39969. BONETEXTURE: boolean;
  39970. INSTANCES: boolean;
  39971. GLOSSINESS: boolean;
  39972. ROUGHNESS: boolean;
  39973. EMISSIVEASILLUMINATION: boolean;
  39974. LINKEMISSIVEWITHDIFFUSE: boolean;
  39975. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39976. LIGHTMAP: boolean;
  39977. LIGHTMAPDIRECTUV: number;
  39978. OBJECTSPACE_NORMALMAP: boolean;
  39979. USELIGHTMAPASSHADOWMAP: boolean;
  39980. REFLECTIONMAP_3D: boolean;
  39981. REFLECTIONMAP_SPHERICAL: boolean;
  39982. REFLECTIONMAP_PLANAR: boolean;
  39983. REFLECTIONMAP_CUBIC: boolean;
  39984. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39985. REFLECTIONMAP_PROJECTION: boolean;
  39986. REFLECTIONMAP_SKYBOX: boolean;
  39987. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39988. REFLECTIONMAP_EXPLICIT: boolean;
  39989. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39990. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39991. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39992. INVERTCUBICMAP: boolean;
  39993. LOGARITHMICDEPTH: boolean;
  39994. REFRACTION: boolean;
  39995. REFRACTIONMAP_3D: boolean;
  39996. REFLECTIONOVERALPHA: boolean;
  39997. TWOSIDEDLIGHTING: boolean;
  39998. SHADOWFLOAT: boolean;
  39999. MORPHTARGETS: boolean;
  40000. MORPHTARGETS_NORMAL: boolean;
  40001. MORPHTARGETS_TANGENT: boolean;
  40002. MORPHTARGETS_UV: boolean;
  40003. NUM_MORPH_INFLUENCERS: number;
  40004. NONUNIFORMSCALING: boolean;
  40005. PREMULTIPLYALPHA: boolean;
  40006. IMAGEPROCESSING: boolean;
  40007. VIGNETTE: boolean;
  40008. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40009. VIGNETTEBLENDMODEOPAQUE: boolean;
  40010. TONEMAPPING: boolean;
  40011. TONEMAPPING_ACES: boolean;
  40012. CONTRAST: boolean;
  40013. COLORCURVES: boolean;
  40014. COLORGRADING: boolean;
  40015. COLORGRADING3D: boolean;
  40016. SAMPLER3DGREENDEPTH: boolean;
  40017. SAMPLER3DBGRMAP: boolean;
  40018. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40019. MULTIVIEW: boolean;
  40020. /**
  40021. * If the reflection texture on this material is in linear color space
  40022. * @hidden
  40023. */
  40024. IS_REFLECTION_LINEAR: boolean;
  40025. /**
  40026. * If the refraction texture on this material is in linear color space
  40027. * @hidden
  40028. */
  40029. IS_REFRACTION_LINEAR: boolean;
  40030. EXPOSURE: boolean;
  40031. constructor();
  40032. setReflectionMode(modeToEnable: string): void;
  40033. }
  40034. /**
  40035. * This is the default material used in Babylon. It is the best trade off between quality
  40036. * and performances.
  40037. * @see http://doc.babylonjs.com/babylon101/materials
  40038. */
  40039. export class StandardMaterial extends PushMaterial {
  40040. private _diffuseTexture;
  40041. /**
  40042. * The basic texture of the material as viewed under a light.
  40043. */
  40044. diffuseTexture: Nullable<BaseTexture>;
  40045. private _ambientTexture;
  40046. /**
  40047. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40048. */
  40049. ambientTexture: Nullable<BaseTexture>;
  40050. private _opacityTexture;
  40051. /**
  40052. * Define the transparency of the material from a texture.
  40053. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40054. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40055. */
  40056. opacityTexture: Nullable<BaseTexture>;
  40057. private _reflectionTexture;
  40058. /**
  40059. * Define the texture used to display the reflection.
  40060. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40061. */
  40062. reflectionTexture: Nullable<BaseTexture>;
  40063. private _emissiveTexture;
  40064. /**
  40065. * Define texture of the material as if self lit.
  40066. * This will be mixed in the final result even in the absence of light.
  40067. */
  40068. emissiveTexture: Nullable<BaseTexture>;
  40069. private _specularTexture;
  40070. /**
  40071. * Define how the color and intensity of the highlight given by the light in the material.
  40072. */
  40073. specularTexture: Nullable<BaseTexture>;
  40074. private _bumpTexture;
  40075. /**
  40076. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40077. * 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.
  40078. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40079. */
  40080. bumpTexture: Nullable<BaseTexture>;
  40081. private _lightmapTexture;
  40082. /**
  40083. * Complex lighting can be computationally expensive to compute at runtime.
  40084. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40085. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40086. */
  40087. lightmapTexture: Nullable<BaseTexture>;
  40088. private _refractionTexture;
  40089. /**
  40090. * Define the texture used to display the refraction.
  40091. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40092. */
  40093. refractionTexture: Nullable<BaseTexture>;
  40094. /**
  40095. * The color of the material lit by the environmental background lighting.
  40096. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40097. */
  40098. ambientColor: Color3;
  40099. /**
  40100. * The basic color of the material as viewed under a light.
  40101. */
  40102. diffuseColor: Color3;
  40103. /**
  40104. * Define how the color and intensity of the highlight given by the light in the material.
  40105. */
  40106. specularColor: Color3;
  40107. /**
  40108. * Define the color of the material as if self lit.
  40109. * This will be mixed in the final result even in the absence of light.
  40110. */
  40111. emissiveColor: Color3;
  40112. /**
  40113. * Defines how sharp are the highlights in the material.
  40114. * The bigger the value the sharper giving a more glossy feeling to the result.
  40115. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40116. */
  40117. specularPower: number;
  40118. private _useAlphaFromDiffuseTexture;
  40119. /**
  40120. * Does the transparency come from the diffuse texture alpha channel.
  40121. */
  40122. useAlphaFromDiffuseTexture: boolean;
  40123. private _useEmissiveAsIllumination;
  40124. /**
  40125. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40126. */
  40127. useEmissiveAsIllumination: boolean;
  40128. private _linkEmissiveWithDiffuse;
  40129. /**
  40130. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40131. * the emissive level when the final color is close to one.
  40132. */
  40133. linkEmissiveWithDiffuse: boolean;
  40134. private _useSpecularOverAlpha;
  40135. /**
  40136. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40137. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40138. */
  40139. useSpecularOverAlpha: boolean;
  40140. private _useReflectionOverAlpha;
  40141. /**
  40142. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40143. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40144. */
  40145. useReflectionOverAlpha: boolean;
  40146. private _disableLighting;
  40147. /**
  40148. * Does lights from the scene impacts this material.
  40149. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40150. */
  40151. disableLighting: boolean;
  40152. private _useObjectSpaceNormalMap;
  40153. /**
  40154. * Allows using an object space normal map (instead of tangent space).
  40155. */
  40156. useObjectSpaceNormalMap: boolean;
  40157. private _useParallax;
  40158. /**
  40159. * Is parallax enabled or not.
  40160. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40161. */
  40162. useParallax: boolean;
  40163. private _useParallaxOcclusion;
  40164. /**
  40165. * Is parallax occlusion enabled or not.
  40166. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40167. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40168. */
  40169. useParallaxOcclusion: boolean;
  40170. /**
  40171. * 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.
  40172. */
  40173. parallaxScaleBias: number;
  40174. private _roughness;
  40175. /**
  40176. * Helps to define how blurry the reflections should appears in the material.
  40177. */
  40178. roughness: number;
  40179. /**
  40180. * In case of refraction, define the value of the index of refraction.
  40181. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40182. */
  40183. indexOfRefraction: number;
  40184. /**
  40185. * Invert the refraction texture alongside the y axis.
  40186. * It can be useful with procedural textures or probe for instance.
  40187. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40188. */
  40189. invertRefractionY: boolean;
  40190. /**
  40191. * Defines the alpha limits in alpha test mode.
  40192. */
  40193. alphaCutOff: number;
  40194. private _useLightmapAsShadowmap;
  40195. /**
  40196. * In case of light mapping, define whether the map contains light or shadow informations.
  40197. */
  40198. useLightmapAsShadowmap: boolean;
  40199. private _diffuseFresnelParameters;
  40200. /**
  40201. * Define the diffuse fresnel parameters of the material.
  40202. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40203. */
  40204. diffuseFresnelParameters: FresnelParameters;
  40205. private _opacityFresnelParameters;
  40206. /**
  40207. * Define the opacity fresnel parameters of the material.
  40208. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40209. */
  40210. opacityFresnelParameters: FresnelParameters;
  40211. private _reflectionFresnelParameters;
  40212. /**
  40213. * Define the reflection fresnel parameters of the material.
  40214. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40215. */
  40216. reflectionFresnelParameters: FresnelParameters;
  40217. private _refractionFresnelParameters;
  40218. /**
  40219. * Define the refraction fresnel parameters of the material.
  40220. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40221. */
  40222. refractionFresnelParameters: FresnelParameters;
  40223. private _emissiveFresnelParameters;
  40224. /**
  40225. * Define the emissive fresnel parameters of the material.
  40226. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40227. */
  40228. emissiveFresnelParameters: FresnelParameters;
  40229. private _useReflectionFresnelFromSpecular;
  40230. /**
  40231. * If true automatically deducts the fresnels values from the material specularity.
  40232. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40233. */
  40234. useReflectionFresnelFromSpecular: boolean;
  40235. private _useGlossinessFromSpecularMapAlpha;
  40236. /**
  40237. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40238. */
  40239. useGlossinessFromSpecularMapAlpha: boolean;
  40240. private _maxSimultaneousLights;
  40241. /**
  40242. * Defines the maximum number of lights that can be used in the material
  40243. */
  40244. maxSimultaneousLights: number;
  40245. private _invertNormalMapX;
  40246. /**
  40247. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40248. */
  40249. invertNormalMapX: boolean;
  40250. private _invertNormalMapY;
  40251. /**
  40252. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40253. */
  40254. invertNormalMapY: boolean;
  40255. private _twoSidedLighting;
  40256. /**
  40257. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40258. */
  40259. twoSidedLighting: boolean;
  40260. /**
  40261. * Default configuration related to image processing available in the standard Material.
  40262. */
  40263. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40264. /**
  40265. * Gets the image processing configuration used either in this material.
  40266. */
  40267. /**
  40268. * Sets the Default image processing configuration used either in the this material.
  40269. *
  40270. * If sets to null, the scene one is in use.
  40271. */
  40272. imageProcessingConfiguration: ImageProcessingConfiguration;
  40273. /**
  40274. * Keep track of the image processing observer to allow dispose and replace.
  40275. */
  40276. private _imageProcessingObserver;
  40277. /**
  40278. * Attaches a new image processing configuration to the Standard Material.
  40279. * @param configuration
  40280. */
  40281. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40282. /**
  40283. * Gets wether the color curves effect is enabled.
  40284. */
  40285. /**
  40286. * Sets wether the color curves effect is enabled.
  40287. */
  40288. cameraColorCurvesEnabled: boolean;
  40289. /**
  40290. * Gets wether the color grading effect is enabled.
  40291. */
  40292. /**
  40293. * Gets wether the color grading effect is enabled.
  40294. */
  40295. cameraColorGradingEnabled: boolean;
  40296. /**
  40297. * Gets wether tonemapping is enabled or not.
  40298. */
  40299. /**
  40300. * Sets wether tonemapping is enabled or not
  40301. */
  40302. cameraToneMappingEnabled: boolean;
  40303. /**
  40304. * The camera exposure used on this material.
  40305. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40306. * This corresponds to a photographic exposure.
  40307. */
  40308. /**
  40309. * The camera exposure used on this material.
  40310. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40311. * This corresponds to a photographic exposure.
  40312. */
  40313. cameraExposure: number;
  40314. /**
  40315. * Gets The camera contrast used on this material.
  40316. */
  40317. /**
  40318. * Sets The camera contrast used on this material.
  40319. */
  40320. cameraContrast: number;
  40321. /**
  40322. * Gets the Color Grading 2D Lookup Texture.
  40323. */
  40324. /**
  40325. * Sets the Color Grading 2D Lookup Texture.
  40326. */
  40327. cameraColorGradingTexture: Nullable<BaseTexture>;
  40328. /**
  40329. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40330. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40331. * 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;
  40332. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40333. */
  40334. /**
  40335. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40336. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40337. * 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;
  40338. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40339. */
  40340. cameraColorCurves: Nullable<ColorCurves>;
  40341. /**
  40342. * Custom callback helping to override the default shader used in the material.
  40343. */
  40344. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40345. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40346. protected _worldViewProjectionMatrix: Matrix;
  40347. protected _globalAmbientColor: Color3;
  40348. protected _useLogarithmicDepth: boolean;
  40349. protected _rebuildInParallel: boolean;
  40350. /**
  40351. * Instantiates a new standard material.
  40352. * This is the default material used in Babylon. It is the best trade off between quality
  40353. * and performances.
  40354. * @see http://doc.babylonjs.com/babylon101/materials
  40355. * @param name Define the name of the material in the scene
  40356. * @param scene Define the scene the material belong to
  40357. */
  40358. constructor(name: string, scene: Scene);
  40359. /**
  40360. * Gets a boolean indicating that current material needs to register RTT
  40361. */
  40362. readonly hasRenderTargetTextures: boolean;
  40363. /**
  40364. * Gets the current class name of the material e.g. "StandardMaterial"
  40365. * Mainly use in serialization.
  40366. * @returns the class name
  40367. */
  40368. getClassName(): string;
  40369. /**
  40370. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40371. * You can try switching to logarithmic depth.
  40372. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40373. */
  40374. useLogarithmicDepth: boolean;
  40375. /**
  40376. * Specifies if the material will require alpha blending
  40377. * @returns a boolean specifying if alpha blending is needed
  40378. */
  40379. needAlphaBlending(): boolean;
  40380. /**
  40381. * Specifies if this material should be rendered in alpha test mode
  40382. * @returns a boolean specifying if an alpha test is needed.
  40383. */
  40384. needAlphaTesting(): boolean;
  40385. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40386. /**
  40387. * Get the texture used for alpha test purpose.
  40388. * @returns the diffuse texture in case of the standard material.
  40389. */
  40390. getAlphaTestTexture(): Nullable<BaseTexture>;
  40391. /**
  40392. * Get if the submesh is ready to be used and all its information available.
  40393. * Child classes can use it to update shaders
  40394. * @param mesh defines the mesh to check
  40395. * @param subMesh defines which submesh to check
  40396. * @param useInstances specifies that instances should be used
  40397. * @returns a boolean indicating that the submesh is ready or not
  40398. */
  40399. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40400. /**
  40401. * Builds the material UBO layouts.
  40402. * Used internally during the effect preparation.
  40403. */
  40404. buildUniformLayout(): void;
  40405. /**
  40406. * Unbinds the material from the mesh
  40407. */
  40408. unbind(): void;
  40409. /**
  40410. * Binds the submesh to this material by preparing the effect and shader to draw
  40411. * @param world defines the world transformation matrix
  40412. * @param mesh defines the mesh containing the submesh
  40413. * @param subMesh defines the submesh to bind the material to
  40414. */
  40415. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40416. /**
  40417. * Get the list of animatables in the material.
  40418. * @returns the list of animatables object used in the material
  40419. */
  40420. getAnimatables(): IAnimatable[];
  40421. /**
  40422. * Gets the active textures from the material
  40423. * @returns an array of textures
  40424. */
  40425. getActiveTextures(): BaseTexture[];
  40426. /**
  40427. * Specifies if the material uses a texture
  40428. * @param texture defines the texture to check against the material
  40429. * @returns a boolean specifying if the material uses the texture
  40430. */
  40431. hasTexture(texture: BaseTexture): boolean;
  40432. /**
  40433. * Disposes the material
  40434. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40435. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40436. */
  40437. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40438. /**
  40439. * Makes a duplicate of the material, and gives it a new name
  40440. * @param name defines the new name for the duplicated material
  40441. * @returns the cloned material
  40442. */
  40443. clone(name: string): StandardMaterial;
  40444. /**
  40445. * Serializes this material in a JSON representation
  40446. * @returns the serialized material object
  40447. */
  40448. serialize(): any;
  40449. /**
  40450. * Creates a standard material from parsed material data
  40451. * @param source defines the JSON representation of the material
  40452. * @param scene defines the hosting scene
  40453. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40454. * @returns a new standard material
  40455. */
  40456. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40457. /**
  40458. * Are diffuse textures enabled in the application.
  40459. */
  40460. static DiffuseTextureEnabled: boolean;
  40461. /**
  40462. * Are ambient textures enabled in the application.
  40463. */
  40464. static AmbientTextureEnabled: boolean;
  40465. /**
  40466. * Are opacity textures enabled in the application.
  40467. */
  40468. static OpacityTextureEnabled: boolean;
  40469. /**
  40470. * Are reflection textures enabled in the application.
  40471. */
  40472. static ReflectionTextureEnabled: boolean;
  40473. /**
  40474. * Are emissive textures enabled in the application.
  40475. */
  40476. static EmissiveTextureEnabled: boolean;
  40477. /**
  40478. * Are specular textures enabled in the application.
  40479. */
  40480. static SpecularTextureEnabled: boolean;
  40481. /**
  40482. * Are bump textures enabled in the application.
  40483. */
  40484. static BumpTextureEnabled: boolean;
  40485. /**
  40486. * Are lightmap textures enabled in the application.
  40487. */
  40488. static LightmapTextureEnabled: boolean;
  40489. /**
  40490. * Are refraction textures enabled in the application.
  40491. */
  40492. static RefractionTextureEnabled: boolean;
  40493. /**
  40494. * Are color grading textures enabled in the application.
  40495. */
  40496. static ColorGradingTextureEnabled: boolean;
  40497. /**
  40498. * Are fresnels enabled in the application.
  40499. */
  40500. static FresnelEnabled: boolean;
  40501. }
  40502. }
  40503. declare module BABYLON {
  40504. /** @hidden */
  40505. export var imageProcessingPixelShader: {
  40506. name: string;
  40507. shader: string;
  40508. };
  40509. }
  40510. declare module BABYLON {
  40511. /**
  40512. * ImageProcessingPostProcess
  40513. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40514. */
  40515. export class ImageProcessingPostProcess extends PostProcess {
  40516. /**
  40517. * Default configuration related to image processing available in the PBR Material.
  40518. */
  40519. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40520. /**
  40521. * Gets the image processing configuration used either in this material.
  40522. */
  40523. /**
  40524. * Sets the Default image processing configuration used either in the this material.
  40525. *
  40526. * If sets to null, the scene one is in use.
  40527. */
  40528. imageProcessingConfiguration: ImageProcessingConfiguration;
  40529. /**
  40530. * Keep track of the image processing observer to allow dispose and replace.
  40531. */
  40532. private _imageProcessingObserver;
  40533. /**
  40534. * Attaches a new image processing configuration to the PBR Material.
  40535. * @param configuration
  40536. */
  40537. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40538. /**
  40539. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40540. */
  40541. /**
  40542. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40543. */
  40544. colorCurves: Nullable<ColorCurves>;
  40545. /**
  40546. * Gets wether the color curves effect is enabled.
  40547. */
  40548. /**
  40549. * Sets wether the color curves effect is enabled.
  40550. */
  40551. colorCurvesEnabled: boolean;
  40552. /**
  40553. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40554. */
  40555. /**
  40556. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40557. */
  40558. colorGradingTexture: Nullable<BaseTexture>;
  40559. /**
  40560. * Gets wether the color grading effect is enabled.
  40561. */
  40562. /**
  40563. * Gets wether the color grading effect is enabled.
  40564. */
  40565. colorGradingEnabled: boolean;
  40566. /**
  40567. * Gets exposure used in the effect.
  40568. */
  40569. /**
  40570. * Sets exposure used in the effect.
  40571. */
  40572. exposure: number;
  40573. /**
  40574. * Gets wether tonemapping is enabled or not.
  40575. */
  40576. /**
  40577. * Sets wether tonemapping is enabled or not
  40578. */
  40579. toneMappingEnabled: boolean;
  40580. /**
  40581. * Gets the type of tone mapping effect.
  40582. */
  40583. /**
  40584. * Sets the type of tone mapping effect.
  40585. */
  40586. toneMappingType: number;
  40587. /**
  40588. * Gets contrast used in the effect.
  40589. */
  40590. /**
  40591. * Sets contrast used in the effect.
  40592. */
  40593. contrast: number;
  40594. /**
  40595. * Gets Vignette stretch size.
  40596. */
  40597. /**
  40598. * Sets Vignette stretch size.
  40599. */
  40600. vignetteStretch: number;
  40601. /**
  40602. * Gets Vignette centre X Offset.
  40603. */
  40604. /**
  40605. * Sets Vignette centre X Offset.
  40606. */
  40607. vignetteCentreX: number;
  40608. /**
  40609. * Gets Vignette centre Y Offset.
  40610. */
  40611. /**
  40612. * Sets Vignette centre Y Offset.
  40613. */
  40614. vignetteCentreY: number;
  40615. /**
  40616. * Gets Vignette weight or intensity of the vignette effect.
  40617. */
  40618. /**
  40619. * Sets Vignette weight or intensity of the vignette effect.
  40620. */
  40621. vignetteWeight: number;
  40622. /**
  40623. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40624. * if vignetteEnabled is set to true.
  40625. */
  40626. /**
  40627. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40628. * if vignetteEnabled is set to true.
  40629. */
  40630. vignetteColor: Color4;
  40631. /**
  40632. * Gets Camera field of view used by the Vignette effect.
  40633. */
  40634. /**
  40635. * Sets Camera field of view used by the Vignette effect.
  40636. */
  40637. vignetteCameraFov: number;
  40638. /**
  40639. * Gets the vignette blend mode allowing different kind of effect.
  40640. */
  40641. /**
  40642. * Sets the vignette blend mode allowing different kind of effect.
  40643. */
  40644. vignetteBlendMode: number;
  40645. /**
  40646. * Gets wether the vignette effect is enabled.
  40647. */
  40648. /**
  40649. * Sets wether the vignette effect is enabled.
  40650. */
  40651. vignetteEnabled: boolean;
  40652. private _fromLinearSpace;
  40653. /**
  40654. * Gets wether the input of the processing is in Gamma or Linear Space.
  40655. */
  40656. /**
  40657. * Sets wether the input of the processing is in Gamma or Linear Space.
  40658. */
  40659. fromLinearSpace: boolean;
  40660. /**
  40661. * Defines cache preventing GC.
  40662. */
  40663. private _defines;
  40664. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40665. /**
  40666. * "ImageProcessingPostProcess"
  40667. * @returns "ImageProcessingPostProcess"
  40668. */
  40669. getClassName(): string;
  40670. protected _updateParameters(): void;
  40671. dispose(camera?: Camera): void;
  40672. }
  40673. }
  40674. declare module BABYLON {
  40675. /**
  40676. * Class containing static functions to help procedurally build meshes
  40677. */
  40678. export class GroundBuilder {
  40679. /**
  40680. * Creates a ground mesh
  40681. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40682. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40684. * @param name defines the name of the mesh
  40685. * @param options defines the options used to create the mesh
  40686. * @param scene defines the hosting scene
  40687. * @returns the ground mesh
  40688. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40689. */
  40690. static CreateGround(name: string, options: {
  40691. width?: number;
  40692. height?: number;
  40693. subdivisions?: number;
  40694. subdivisionsX?: number;
  40695. subdivisionsY?: number;
  40696. updatable?: boolean;
  40697. }, scene: any): Mesh;
  40698. /**
  40699. * Creates a tiled ground mesh
  40700. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40701. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40702. * * 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
  40703. * * 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
  40704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40705. * @param name defines the name of the mesh
  40706. * @param options defines the options used to create the mesh
  40707. * @param scene defines the hosting scene
  40708. * @returns the tiled ground mesh
  40709. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40710. */
  40711. static CreateTiledGround(name: string, options: {
  40712. xmin: number;
  40713. zmin: number;
  40714. xmax: number;
  40715. zmax: number;
  40716. subdivisions?: {
  40717. w: number;
  40718. h: number;
  40719. };
  40720. precision?: {
  40721. w: number;
  40722. h: number;
  40723. };
  40724. updatable?: boolean;
  40725. }, scene?: Nullable<Scene>): Mesh;
  40726. /**
  40727. * Creates a ground mesh from a height map
  40728. * * The parameter `url` sets the URL of the height map image resource.
  40729. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40730. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40731. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40732. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40733. * * 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.
  40734. * * 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).
  40735. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40737. * @param name defines the name of the mesh
  40738. * @param url defines the url to the height map
  40739. * @param options defines the options used to create the mesh
  40740. * @param scene defines the hosting scene
  40741. * @returns the ground mesh
  40742. * @see https://doc.babylonjs.com/babylon101/height_map
  40743. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40744. */
  40745. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40746. width?: number;
  40747. height?: number;
  40748. subdivisions?: number;
  40749. minHeight?: number;
  40750. maxHeight?: number;
  40751. colorFilter?: Color3;
  40752. alphaFilter?: number;
  40753. updatable?: boolean;
  40754. onReady?: (mesh: GroundMesh) => void;
  40755. }, scene?: Nullable<Scene>): GroundMesh;
  40756. }
  40757. }
  40758. declare module BABYLON {
  40759. /**
  40760. * Class containing static functions to help procedurally build meshes
  40761. */
  40762. export class TorusBuilder {
  40763. /**
  40764. * Creates a torus mesh
  40765. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40766. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40767. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40768. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40769. * * 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
  40770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40771. * @param name defines the name of the mesh
  40772. * @param options defines the options used to create the mesh
  40773. * @param scene defines the hosting scene
  40774. * @returns the torus mesh
  40775. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40776. */
  40777. static CreateTorus(name: string, options: {
  40778. diameter?: number;
  40779. thickness?: number;
  40780. tessellation?: number;
  40781. updatable?: boolean;
  40782. sideOrientation?: number;
  40783. frontUVs?: Vector4;
  40784. backUVs?: Vector4;
  40785. }, scene: any): Mesh;
  40786. }
  40787. }
  40788. declare module BABYLON {
  40789. /**
  40790. * Class containing static functions to help procedurally build meshes
  40791. */
  40792. export class CylinderBuilder {
  40793. /**
  40794. * Creates a cylinder or a cone mesh
  40795. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40796. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40797. * * 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.
  40798. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40799. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40800. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40801. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40802. * * 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).
  40803. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40804. * * 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).
  40805. * * 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
  40806. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40807. * * 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
  40808. * * 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.
  40809. * * If `enclose` is false, a ring surface is one element.
  40810. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40811. * * 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
  40812. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40813. * * 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
  40814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40815. * @param name defines the name of the mesh
  40816. * @param options defines the options used to create the mesh
  40817. * @param scene defines the hosting scene
  40818. * @returns the cylinder mesh
  40819. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40820. */
  40821. static CreateCylinder(name: string, options: {
  40822. height?: number;
  40823. diameterTop?: number;
  40824. diameterBottom?: number;
  40825. diameter?: number;
  40826. tessellation?: number;
  40827. subdivisions?: number;
  40828. arc?: number;
  40829. faceColors?: Color4[];
  40830. faceUV?: Vector4[];
  40831. updatable?: boolean;
  40832. hasRings?: boolean;
  40833. enclose?: boolean;
  40834. cap?: number;
  40835. sideOrientation?: number;
  40836. frontUVs?: Vector4;
  40837. backUVs?: Vector4;
  40838. }, scene: any): Mesh;
  40839. }
  40840. }
  40841. declare module BABYLON {
  40842. /**
  40843. * Options to modify the vr teleportation behavior.
  40844. */
  40845. export interface VRTeleportationOptions {
  40846. /**
  40847. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40848. */
  40849. floorMeshName?: string;
  40850. /**
  40851. * A list of meshes to be used as the teleportation floor. (default: empty)
  40852. */
  40853. floorMeshes?: Mesh[];
  40854. }
  40855. /**
  40856. * Options to modify the vr experience helper's behavior.
  40857. */
  40858. export interface VRExperienceHelperOptions extends WebVROptions {
  40859. /**
  40860. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40861. */
  40862. createDeviceOrientationCamera?: boolean;
  40863. /**
  40864. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40865. */
  40866. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40867. /**
  40868. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40869. */
  40870. laserToggle?: boolean;
  40871. /**
  40872. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40873. */
  40874. floorMeshes?: Mesh[];
  40875. /**
  40876. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40877. */
  40878. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40879. }
  40880. /**
  40881. * Event containing information after VR has been entered
  40882. */
  40883. export class OnAfterEnteringVRObservableEvent {
  40884. /**
  40885. * If entering vr was successful
  40886. */
  40887. success: boolean;
  40888. }
  40889. /**
  40890. * Helps to quickly add VR support to an existing scene.
  40891. * See http://doc.babylonjs.com/how_to/webvr_helper
  40892. */
  40893. export class VRExperienceHelper {
  40894. /** Options to modify the vr experience helper's behavior. */
  40895. webVROptions: VRExperienceHelperOptions;
  40896. private _scene;
  40897. private _position;
  40898. private _btnVR;
  40899. private _btnVRDisplayed;
  40900. private _webVRsupported;
  40901. private _webVRready;
  40902. private _webVRrequesting;
  40903. private _webVRpresenting;
  40904. private _hasEnteredVR;
  40905. private _fullscreenVRpresenting;
  40906. private _canvas;
  40907. private _webVRCamera;
  40908. private _vrDeviceOrientationCamera;
  40909. private _deviceOrientationCamera;
  40910. private _existingCamera;
  40911. private _onKeyDown;
  40912. private _onVrDisplayPresentChange;
  40913. private _onVRDisplayChanged;
  40914. private _onVRRequestPresentStart;
  40915. private _onVRRequestPresentComplete;
  40916. /**
  40917. * 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)
  40918. */
  40919. enableGazeEvenWhenNoPointerLock: boolean;
  40920. /**
  40921. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40922. */
  40923. exitVROnDoubleTap: boolean;
  40924. /**
  40925. * Observable raised right before entering VR.
  40926. */
  40927. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40928. /**
  40929. * Observable raised when entering VR has completed.
  40930. */
  40931. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40932. /**
  40933. * Observable raised when exiting VR.
  40934. */
  40935. onExitingVRObservable: Observable<VRExperienceHelper>;
  40936. /**
  40937. * Observable raised when controller mesh is loaded.
  40938. */
  40939. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40940. /** Return this.onEnteringVRObservable
  40941. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40942. */
  40943. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40944. /** Return this.onExitingVRObservable
  40945. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40946. */
  40947. readonly onExitingVR: Observable<VRExperienceHelper>;
  40948. /** Return this.onControllerMeshLoadedObservable
  40949. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40950. */
  40951. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40952. private _rayLength;
  40953. private _useCustomVRButton;
  40954. private _teleportationRequested;
  40955. private _teleportActive;
  40956. private _floorMeshName;
  40957. private _floorMeshesCollection;
  40958. private _rotationAllowed;
  40959. private _teleportBackwardsVector;
  40960. private _teleportationTarget;
  40961. private _isDefaultTeleportationTarget;
  40962. private _postProcessMove;
  40963. private _teleportationFillColor;
  40964. private _teleportationBorderColor;
  40965. private _rotationAngle;
  40966. private _haloCenter;
  40967. private _cameraGazer;
  40968. private _padSensibilityUp;
  40969. private _padSensibilityDown;
  40970. private _leftController;
  40971. private _rightController;
  40972. /**
  40973. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40974. */
  40975. onNewMeshSelected: Observable<AbstractMesh>;
  40976. /**
  40977. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  40978. * This observable will provide the mesh and the controller used to select the mesh
  40979. */
  40980. onMeshSelectedWithController: Observable<{
  40981. mesh: AbstractMesh;
  40982. controller: WebVRController;
  40983. }>;
  40984. /**
  40985. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40986. */
  40987. onNewMeshPicked: Observable<PickingInfo>;
  40988. private _circleEase;
  40989. /**
  40990. * Observable raised before camera teleportation
  40991. */
  40992. onBeforeCameraTeleport: Observable<Vector3>;
  40993. /**
  40994. * Observable raised after camera teleportation
  40995. */
  40996. onAfterCameraTeleport: Observable<Vector3>;
  40997. /**
  40998. * Observable raised when current selected mesh gets unselected
  40999. */
  41000. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41001. private _raySelectionPredicate;
  41002. /**
  41003. * To be optionaly changed by user to define custom ray selection
  41004. */
  41005. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41006. /**
  41007. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41008. */
  41009. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41010. /**
  41011. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41012. */
  41013. teleportationEnabled: boolean;
  41014. private _defaultHeight;
  41015. private _teleportationInitialized;
  41016. private _interactionsEnabled;
  41017. private _interactionsRequested;
  41018. private _displayGaze;
  41019. private _displayLaserPointer;
  41020. /**
  41021. * The mesh used to display where the user is going to teleport.
  41022. */
  41023. /**
  41024. * Sets the mesh to be used to display where the user is going to teleport.
  41025. */
  41026. teleportationTarget: Mesh;
  41027. /**
  41028. * 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
  41029. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41030. * See http://doc.babylonjs.com/resources/baking_transformations
  41031. */
  41032. gazeTrackerMesh: Mesh;
  41033. /**
  41034. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41035. */
  41036. updateGazeTrackerScale: boolean;
  41037. /**
  41038. * If the gaze trackers color should be updated when selecting meshes
  41039. */
  41040. updateGazeTrackerColor: boolean;
  41041. /**
  41042. * If the controller laser color should be updated when selecting meshes
  41043. */
  41044. updateControllerLaserColor: boolean;
  41045. /**
  41046. * The gaze tracking mesh corresponding to the left controller
  41047. */
  41048. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41049. /**
  41050. * The gaze tracking mesh corresponding to the right controller
  41051. */
  41052. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41053. /**
  41054. * If the ray of the gaze should be displayed.
  41055. */
  41056. /**
  41057. * Sets if the ray of the gaze should be displayed.
  41058. */
  41059. displayGaze: boolean;
  41060. /**
  41061. * If the ray of the LaserPointer should be displayed.
  41062. */
  41063. /**
  41064. * Sets if the ray of the LaserPointer should be displayed.
  41065. */
  41066. displayLaserPointer: boolean;
  41067. /**
  41068. * The deviceOrientationCamera used as the camera when not in VR.
  41069. */
  41070. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41071. /**
  41072. * Based on the current WebVR support, returns the current VR camera used.
  41073. */
  41074. readonly currentVRCamera: Nullable<Camera>;
  41075. /**
  41076. * The webVRCamera which is used when in VR.
  41077. */
  41078. readonly webVRCamera: WebVRFreeCamera;
  41079. /**
  41080. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41081. */
  41082. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41083. /**
  41084. * The html button that is used to trigger entering into VR.
  41085. */
  41086. readonly vrButton: Nullable<HTMLButtonElement>;
  41087. private readonly _teleportationRequestInitiated;
  41088. /**
  41089. * Defines wether or not Pointer lock should be requested when switching to
  41090. * full screen.
  41091. */
  41092. requestPointerLockOnFullScreen: boolean;
  41093. /**
  41094. * Instantiates a VRExperienceHelper.
  41095. * Helps to quickly add VR support to an existing scene.
  41096. * @param scene The scene the VRExperienceHelper belongs to.
  41097. * @param webVROptions Options to modify the vr experience helper's behavior.
  41098. */
  41099. constructor(scene: Scene,
  41100. /** Options to modify the vr experience helper's behavior. */
  41101. webVROptions?: VRExperienceHelperOptions);
  41102. private _onDefaultMeshLoaded;
  41103. private _onResize;
  41104. private _onFullscreenChange;
  41105. /**
  41106. * Gets a value indicating if we are currently in VR mode.
  41107. */
  41108. readonly isInVRMode: boolean;
  41109. private onVrDisplayPresentChange;
  41110. private onVRDisplayChanged;
  41111. private moveButtonToBottomRight;
  41112. private displayVRButton;
  41113. private updateButtonVisibility;
  41114. private _cachedAngularSensibility;
  41115. /**
  41116. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41117. * Otherwise, will use the fullscreen API.
  41118. */
  41119. enterVR(): void;
  41120. /**
  41121. * Attempt to exit VR, or fullscreen.
  41122. */
  41123. exitVR(): void;
  41124. /**
  41125. * The position of the vr experience helper.
  41126. */
  41127. /**
  41128. * Sets the position of the vr experience helper.
  41129. */
  41130. position: Vector3;
  41131. /**
  41132. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41133. */
  41134. enableInteractions(): void;
  41135. private readonly _noControllerIsActive;
  41136. private beforeRender;
  41137. private _isTeleportationFloor;
  41138. /**
  41139. * Adds a floor mesh to be used for teleportation.
  41140. * @param floorMesh the mesh to be used for teleportation.
  41141. */
  41142. addFloorMesh(floorMesh: Mesh): void;
  41143. /**
  41144. * Removes a floor mesh from being used for teleportation.
  41145. * @param floorMesh the mesh to be removed.
  41146. */
  41147. removeFloorMesh(floorMesh: Mesh): void;
  41148. /**
  41149. * Enables interactions and teleportation using the VR controllers and gaze.
  41150. * @param vrTeleportationOptions options to modify teleportation behavior.
  41151. */
  41152. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41153. private _onNewGamepadConnected;
  41154. private _tryEnableInteractionOnController;
  41155. private _onNewGamepadDisconnected;
  41156. private _enableInteractionOnController;
  41157. private _checkTeleportWithRay;
  41158. private _checkRotate;
  41159. private _checkTeleportBackwards;
  41160. private _enableTeleportationOnController;
  41161. private _createTeleportationCircles;
  41162. private _displayTeleportationTarget;
  41163. private _hideTeleportationTarget;
  41164. private _rotateCamera;
  41165. private _moveTeleportationSelectorTo;
  41166. private _workingVector;
  41167. private _workingQuaternion;
  41168. private _workingMatrix;
  41169. /**
  41170. * Teleports the users feet to the desired location
  41171. * @param location The location where the user's feet should be placed
  41172. */
  41173. teleportCamera(location: Vector3): void;
  41174. private _convertNormalToDirectionOfRay;
  41175. private _castRayAndSelectObject;
  41176. private _notifySelectedMeshUnselected;
  41177. /**
  41178. * Sets the color of the laser ray from the vr controllers.
  41179. * @param color new color for the ray.
  41180. */
  41181. changeLaserColor(color: Color3): void;
  41182. /**
  41183. * Sets the color of the ray from the vr headsets gaze.
  41184. * @param color new color for the ray.
  41185. */
  41186. changeGazeColor(color: Color3): void;
  41187. /**
  41188. * Exits VR and disposes of the vr experience helper
  41189. */
  41190. dispose(): void;
  41191. /**
  41192. * Gets the name of the VRExperienceHelper class
  41193. * @returns "VRExperienceHelper"
  41194. */
  41195. getClassName(): string;
  41196. }
  41197. }
  41198. declare module BABYLON {
  41199. /**
  41200. * Manages an XRSession to work with Babylon's engine
  41201. * @see https://doc.babylonjs.com/how_to/webxr
  41202. */
  41203. export class WebXRSessionManager implements IDisposable {
  41204. private scene;
  41205. /**
  41206. * Fires every time a new xrFrame arrives which can be used to update the camera
  41207. */
  41208. onXRFrameObservable: Observable<any>;
  41209. /**
  41210. * Fires when the xr session is ended either by the device or manually done
  41211. */
  41212. onXRSessionEnded: Observable<any>;
  41213. /**
  41214. * Underlying xr session
  41215. */
  41216. session: XRSession;
  41217. /**
  41218. * Type of reference space used when creating the session
  41219. */
  41220. referenceSpace: XRReferenceSpace;
  41221. /** @hidden */
  41222. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41223. /**
  41224. * Current XR frame
  41225. */
  41226. currentFrame: Nullable<XRFrame>;
  41227. private _xrNavigator;
  41228. private baseLayer;
  41229. /**
  41230. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41231. * @param scene The scene which the session should be created for
  41232. */
  41233. constructor(scene: Scene);
  41234. /**
  41235. * Initializes the manager
  41236. * After initialization enterXR can be called to start an XR session
  41237. * @returns Promise which resolves after it is initialized
  41238. */
  41239. initializeAsync(): Promise<void>;
  41240. /**
  41241. * Initializes an xr session
  41242. * @param xrSessionMode mode to initialize
  41243. * @returns a promise which will resolve once the session has been initialized
  41244. */
  41245. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41246. /**
  41247. * Sets the reference space on the xr session
  41248. * @param referenceSpace space to set
  41249. * @returns a promise that will resolve once the reference space has been set
  41250. */
  41251. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41252. /**
  41253. * Updates the render state of the session
  41254. * @param state state to set
  41255. * @returns a promise that resolves once the render state has been updated
  41256. */
  41257. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41258. /**
  41259. * Starts rendering to the xr layer
  41260. * @returns a promise that will resolve once rendering has started
  41261. */
  41262. startRenderingToXRAsync(): Promise<void>;
  41263. /**
  41264. * Stops the xrSession and restores the renderloop
  41265. * @returns Promise which resolves after it exits XR
  41266. */
  41267. exitXRAsync(): Promise<unknown>;
  41268. /**
  41269. * Checks if a session would be supported for the creation options specified
  41270. * @param sessionMode session mode to check if supported eg. immersive-vr
  41271. * @returns true if supported
  41272. */
  41273. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41274. /**
  41275. * @hidden
  41276. * Converts the render layer of xrSession to a render target
  41277. * @param session session to create render target for
  41278. * @param scene scene the new render target should be created for
  41279. */
  41280. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41281. /**
  41282. * Disposes of the session manager
  41283. */
  41284. dispose(): void;
  41285. }
  41286. }
  41287. declare module BABYLON {
  41288. /**
  41289. * WebXR Camera which holds the views for the xrSession
  41290. * @see https://doc.babylonjs.com/how_to/webxr
  41291. */
  41292. export class WebXRCamera extends FreeCamera {
  41293. private static _TmpMatrix;
  41294. /**
  41295. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41296. * @param name the name of the camera
  41297. * @param scene the scene to add the camera to
  41298. */
  41299. constructor(name: string, scene: Scene);
  41300. private _updateNumberOfRigCameras;
  41301. /** @hidden */
  41302. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41303. /**
  41304. * Updates the cameras position from the current pose information of the XR session
  41305. * @param xrSessionManager the session containing pose information
  41306. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41307. */
  41308. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41309. }
  41310. }
  41311. declare module BABYLON {
  41312. /**
  41313. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41314. */
  41315. export class WebXRManagedOutputCanvas implements IDisposable {
  41316. private helper;
  41317. private _canvas;
  41318. /**
  41319. * xrpresent context of the canvas which can be used to display/mirror xr content
  41320. */
  41321. canvasContext: WebGLRenderingContext;
  41322. /**
  41323. * xr layer for the canvas
  41324. */
  41325. xrLayer: Nullable<XRWebGLLayer>;
  41326. /**
  41327. * Initializes the xr layer for the session
  41328. * @param xrSession xr session
  41329. * @returns a promise that will resolve once the XR Layer has been created
  41330. */
  41331. initializeXRLayerAsync(xrSession: any): any;
  41332. /**
  41333. * Initializes the canvas to be added/removed upon entering/exiting xr
  41334. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41335. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41336. */
  41337. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41338. /**
  41339. * Disposes of the object
  41340. */
  41341. dispose(): void;
  41342. private _setManagedOutputCanvas;
  41343. private _addCanvas;
  41344. private _removeCanvas;
  41345. }
  41346. }
  41347. declare module BABYLON {
  41348. /**
  41349. * States of the webXR experience
  41350. */
  41351. export enum WebXRState {
  41352. /**
  41353. * Transitioning to being in XR mode
  41354. */
  41355. ENTERING_XR = 0,
  41356. /**
  41357. * Transitioning to non XR mode
  41358. */
  41359. EXITING_XR = 1,
  41360. /**
  41361. * In XR mode and presenting
  41362. */
  41363. IN_XR = 2,
  41364. /**
  41365. * Not entered XR mode
  41366. */
  41367. NOT_IN_XR = 3
  41368. }
  41369. /**
  41370. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41371. * @see https://doc.babylonjs.com/how_to/webxr
  41372. */
  41373. export class WebXRExperienceHelper implements IDisposable {
  41374. private scene;
  41375. /**
  41376. * 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
  41377. */
  41378. container: AbstractMesh;
  41379. /**
  41380. * Camera used to render xr content
  41381. */
  41382. camera: WebXRCamera;
  41383. /**
  41384. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41385. */
  41386. state: WebXRState;
  41387. private _setState;
  41388. private static _TmpVector;
  41389. /**
  41390. * Fires when the state of the experience helper has changed
  41391. */
  41392. onStateChangedObservable: Observable<WebXRState>;
  41393. /** Session manager used to keep track of xr session */
  41394. sessionManager: WebXRSessionManager;
  41395. private _nonVRCamera;
  41396. private _originalSceneAutoClear;
  41397. private _supported;
  41398. /**
  41399. * Creates the experience helper
  41400. * @param scene the scene to attach the experience helper to
  41401. * @returns a promise for the experience helper
  41402. */
  41403. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41404. /**
  41405. * Creates a WebXRExperienceHelper
  41406. * @param scene The scene the helper should be created in
  41407. */
  41408. private constructor();
  41409. /**
  41410. * Exits XR mode and returns the scene to its original state
  41411. * @returns promise that resolves after xr mode has exited
  41412. */
  41413. exitXRAsync(): Promise<unknown>;
  41414. /**
  41415. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41416. * @param sessionCreationOptions options for the XR session
  41417. * @param referenceSpaceType frame of reference of the XR session
  41418. * @param outputCanvas the output canvas that will be used to enter XR mode
  41419. * @returns promise that resolves after xr mode has entered
  41420. */
  41421. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41422. /**
  41423. * Updates the global position of the camera by moving the camera's container
  41424. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41425. * @param position The desired global position of the camera
  41426. */
  41427. setPositionOfCameraUsingContainer(position: Vector3): void;
  41428. /**
  41429. * Rotates the xr camera by rotating the camera's container around the camera's position
  41430. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41431. * @param rotation the desired quaternion rotation to apply to the camera
  41432. */
  41433. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41434. /**
  41435. * Disposes of the experience helper
  41436. */
  41437. dispose(): void;
  41438. }
  41439. }
  41440. declare module BABYLON {
  41441. /**
  41442. * Button which can be used to enter a different mode of XR
  41443. */
  41444. export class WebXREnterExitUIButton {
  41445. /** button element */
  41446. element: HTMLElement;
  41447. /** XR initialization options for the button */
  41448. sessionMode: XRSessionMode;
  41449. /** Reference space type */
  41450. referenceSpaceType: XRReferenceSpaceType;
  41451. /**
  41452. * Creates a WebXREnterExitUIButton
  41453. * @param element button element
  41454. * @param sessionMode XR initialization session mode
  41455. * @param referenceSpaceType the type of reference space to be used
  41456. */
  41457. constructor(
  41458. /** button element */
  41459. element: HTMLElement,
  41460. /** XR initialization options for the button */
  41461. sessionMode: XRSessionMode,
  41462. /** Reference space type */
  41463. referenceSpaceType: XRReferenceSpaceType);
  41464. /**
  41465. * Overwritable function which can be used to update the button's visuals when the state changes
  41466. * @param activeButton the current active button in the UI
  41467. */
  41468. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41469. }
  41470. /**
  41471. * Options to create the webXR UI
  41472. */
  41473. export class WebXREnterExitUIOptions {
  41474. /**
  41475. * Context to enter xr with
  41476. */
  41477. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41478. /**
  41479. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41480. */
  41481. customButtons?: Array<WebXREnterExitUIButton>;
  41482. }
  41483. /**
  41484. * UI to allow the user to enter/exit XR mode
  41485. */
  41486. export class WebXREnterExitUI implements IDisposable {
  41487. private scene;
  41488. private _overlay;
  41489. private _buttons;
  41490. private _activeButton;
  41491. /**
  41492. * Fired every time the active button is changed.
  41493. *
  41494. * When xr is entered via a button that launches xr that button will be the callback parameter
  41495. *
  41496. * When exiting xr the callback parameter will be null)
  41497. */
  41498. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41499. /**
  41500. * Creates UI to allow the user to enter/exit XR mode
  41501. * @param scene the scene to add the ui to
  41502. * @param helper the xr experience helper to enter/exit xr with
  41503. * @param options options to configure the UI
  41504. * @returns the created ui
  41505. */
  41506. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41507. private constructor();
  41508. private _updateButtons;
  41509. /**
  41510. * Disposes of the object
  41511. */
  41512. dispose(): void;
  41513. }
  41514. }
  41515. declare module BABYLON {
  41516. /**
  41517. * Represents an XR input
  41518. */
  41519. export class WebXRController {
  41520. private scene;
  41521. /** The underlying input source for the controller */
  41522. inputSource: XRInputSource;
  41523. private parentContainer;
  41524. /**
  41525. * 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
  41526. */
  41527. grip?: AbstractMesh;
  41528. /**
  41529. * Pointer which can be used to select objects or attach a visible laser to
  41530. */
  41531. pointer: AbstractMesh;
  41532. /**
  41533. * Event that fires when the controller is removed/disposed
  41534. */
  41535. onDisposeObservable: Observable<{}>;
  41536. private _tmpMatrix;
  41537. private _tmpQuaternion;
  41538. private _tmpVector;
  41539. /**
  41540. * Creates the controller
  41541. * @see https://doc.babylonjs.com/how_to/webxr
  41542. * @param scene the scene which the controller should be associated to
  41543. * @param inputSource the underlying input source for the controller
  41544. * @param parentContainer parent that the controller meshes should be children of
  41545. */
  41546. constructor(scene: Scene,
  41547. /** The underlying input source for the controller */
  41548. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41549. /**
  41550. * Updates the controller pose based on the given XRFrame
  41551. * @param xrFrame xr frame to update the pose with
  41552. * @param referenceSpace reference space to use
  41553. */
  41554. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41555. /**
  41556. * Gets a world space ray coming from the controller
  41557. * @param result the resulting ray
  41558. */
  41559. getWorldPointerRayToRef(result: Ray): void;
  41560. /**
  41561. * Disposes of the object
  41562. */
  41563. dispose(): void;
  41564. }
  41565. }
  41566. declare module BABYLON {
  41567. /**
  41568. * XR input used to track XR inputs such as controllers/rays
  41569. */
  41570. export class WebXRInput implements IDisposable {
  41571. /**
  41572. * Base experience the input listens to
  41573. */
  41574. baseExperience: WebXRExperienceHelper;
  41575. /**
  41576. * XR controllers being tracked
  41577. */
  41578. controllers: Array<WebXRController>;
  41579. private _frameObserver;
  41580. private _stateObserver;
  41581. /**
  41582. * Event when a controller has been connected/added
  41583. */
  41584. onControllerAddedObservable: Observable<WebXRController>;
  41585. /**
  41586. * Event when a controller has been removed/disconnected
  41587. */
  41588. onControllerRemovedObservable: Observable<WebXRController>;
  41589. /**
  41590. * Initializes the WebXRInput
  41591. * @param baseExperience experience helper which the input should be created for
  41592. */
  41593. constructor(
  41594. /**
  41595. * Base experience the input listens to
  41596. */
  41597. baseExperience: WebXRExperienceHelper);
  41598. private _onInputSourcesChange;
  41599. private _addAndRemoveControllers;
  41600. /**
  41601. * Disposes of the object
  41602. */
  41603. dispose(): void;
  41604. }
  41605. }
  41606. declare module BABYLON {
  41607. /**
  41608. * Enables teleportation
  41609. */
  41610. export class WebXRControllerTeleportation {
  41611. private _teleportationFillColor;
  41612. private _teleportationBorderColor;
  41613. private _tmpRay;
  41614. private _tmpVector;
  41615. /**
  41616. * Creates a WebXRControllerTeleportation
  41617. * @param input input manager to add teleportation to
  41618. * @param floorMeshes floormeshes which can be teleported to
  41619. */
  41620. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41621. }
  41622. }
  41623. declare module BABYLON {
  41624. /**
  41625. * Handles pointer input automatically for the pointer of XR controllers
  41626. */
  41627. export class WebXRControllerPointerSelection {
  41628. private static _idCounter;
  41629. private _tmpRay;
  41630. /**
  41631. * Creates a WebXRControllerPointerSelection
  41632. * @param input input manager to setup pointer selection
  41633. */
  41634. constructor(input: WebXRInput);
  41635. private _convertNormalToDirectionOfRay;
  41636. private _updatePointerDistance;
  41637. }
  41638. }
  41639. declare module BABYLON {
  41640. /**
  41641. * Class used to represent data loading progression
  41642. */
  41643. export class SceneLoaderProgressEvent {
  41644. /** defines if data length to load can be evaluated */
  41645. readonly lengthComputable: boolean;
  41646. /** defines the loaded data length */
  41647. readonly loaded: number;
  41648. /** defines the data length to load */
  41649. readonly total: number;
  41650. /**
  41651. * Create a new progress event
  41652. * @param lengthComputable defines if data length to load can be evaluated
  41653. * @param loaded defines the loaded data length
  41654. * @param total defines the data length to load
  41655. */
  41656. constructor(
  41657. /** defines if data length to load can be evaluated */
  41658. lengthComputable: boolean,
  41659. /** defines the loaded data length */
  41660. loaded: number,
  41661. /** defines the data length to load */
  41662. total: number);
  41663. /**
  41664. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41665. * @param event defines the source event
  41666. * @returns a new SceneLoaderProgressEvent
  41667. */
  41668. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41669. }
  41670. /**
  41671. * Interface used by SceneLoader plugins to define supported file extensions
  41672. */
  41673. export interface ISceneLoaderPluginExtensions {
  41674. /**
  41675. * Defines the list of supported extensions
  41676. */
  41677. [extension: string]: {
  41678. isBinary: boolean;
  41679. };
  41680. }
  41681. /**
  41682. * Interface used by SceneLoader plugin factory
  41683. */
  41684. export interface ISceneLoaderPluginFactory {
  41685. /**
  41686. * Defines the name of the factory
  41687. */
  41688. name: string;
  41689. /**
  41690. * Function called to create a new plugin
  41691. * @return the new plugin
  41692. */
  41693. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41694. /**
  41695. * Boolean indicating if the plugin can direct load specific data
  41696. */
  41697. canDirectLoad?: (data: string) => boolean;
  41698. }
  41699. /**
  41700. * Interface used to define a SceneLoader plugin
  41701. */
  41702. export interface ISceneLoaderPlugin {
  41703. /**
  41704. * The friendly name of this plugin.
  41705. */
  41706. name: string;
  41707. /**
  41708. * The file extensions supported by this plugin.
  41709. */
  41710. extensions: string | ISceneLoaderPluginExtensions;
  41711. /**
  41712. * Import meshes into a scene.
  41713. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41714. * @param scene The scene to import into
  41715. * @param data The data to import
  41716. * @param rootUrl The root url for scene and resources
  41717. * @param meshes The meshes array to import into
  41718. * @param particleSystems The particle systems array to import into
  41719. * @param skeletons The skeletons array to import into
  41720. * @param onError The callback when import fails
  41721. * @returns True if successful or false otherwise
  41722. */
  41723. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41724. /**
  41725. * Load into a scene.
  41726. * @param scene The scene to load into
  41727. * @param data The data to import
  41728. * @param rootUrl The root url for scene and resources
  41729. * @param onError The callback when import fails
  41730. * @returns true if successful or false otherwise
  41731. */
  41732. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41733. /**
  41734. * The callback that returns true if the data can be directly loaded.
  41735. */
  41736. canDirectLoad?: (data: string) => boolean;
  41737. /**
  41738. * The callback that allows custom handling of the root url based on the response url.
  41739. */
  41740. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41741. /**
  41742. * Load into an asset container.
  41743. * @param scene The scene to load into
  41744. * @param data The data to import
  41745. * @param rootUrl The root url for scene and resources
  41746. * @param onError The callback when import fails
  41747. * @returns The loaded asset container
  41748. */
  41749. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41750. }
  41751. /**
  41752. * Interface used to define an async SceneLoader plugin
  41753. */
  41754. export interface ISceneLoaderPluginAsync {
  41755. /**
  41756. * The friendly name of this plugin.
  41757. */
  41758. name: string;
  41759. /**
  41760. * The file extensions supported by this plugin.
  41761. */
  41762. extensions: string | ISceneLoaderPluginExtensions;
  41763. /**
  41764. * Import meshes into a scene.
  41765. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41766. * @param scene The scene to import into
  41767. * @param data The data to import
  41768. * @param rootUrl The root url for scene and resources
  41769. * @param onProgress The callback when the load progresses
  41770. * @param fileName Defines the name of the file to load
  41771. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41772. */
  41773. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41774. meshes: AbstractMesh[];
  41775. particleSystems: IParticleSystem[];
  41776. skeletons: Skeleton[];
  41777. animationGroups: AnimationGroup[];
  41778. }>;
  41779. /**
  41780. * Load into a scene.
  41781. * @param scene The scene to load into
  41782. * @param data The data to import
  41783. * @param rootUrl The root url for scene and resources
  41784. * @param onProgress The callback when the load progresses
  41785. * @param fileName Defines the name of the file to load
  41786. * @returns Nothing
  41787. */
  41788. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41789. /**
  41790. * The callback that returns true if the data can be directly loaded.
  41791. */
  41792. canDirectLoad?: (data: string) => boolean;
  41793. /**
  41794. * The callback that allows custom handling of the root url based on the response url.
  41795. */
  41796. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41797. /**
  41798. * Load into an asset container.
  41799. * @param scene The scene to load into
  41800. * @param data The data to import
  41801. * @param rootUrl The root url for scene and resources
  41802. * @param onProgress The callback when the load progresses
  41803. * @param fileName Defines the name of the file to load
  41804. * @returns The loaded asset container
  41805. */
  41806. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41807. }
  41808. /**
  41809. * Class used to load scene from various file formats using registered plugins
  41810. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41811. */
  41812. export class SceneLoader {
  41813. /**
  41814. * No logging while loading
  41815. */
  41816. static readonly NO_LOGGING: number;
  41817. /**
  41818. * Minimal logging while loading
  41819. */
  41820. static readonly MINIMAL_LOGGING: number;
  41821. /**
  41822. * Summary logging while loading
  41823. */
  41824. static readonly SUMMARY_LOGGING: number;
  41825. /**
  41826. * Detailled logging while loading
  41827. */
  41828. static readonly DETAILED_LOGGING: number;
  41829. /**
  41830. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41831. */
  41832. static ForceFullSceneLoadingForIncremental: boolean;
  41833. /**
  41834. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41835. */
  41836. static ShowLoadingScreen: boolean;
  41837. /**
  41838. * Defines the current logging level (while loading the scene)
  41839. * @ignorenaming
  41840. */
  41841. static loggingLevel: number;
  41842. /**
  41843. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41844. */
  41845. static CleanBoneMatrixWeights: boolean;
  41846. /**
  41847. * Event raised when a plugin is used to load a scene
  41848. */
  41849. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41850. private static _registeredPlugins;
  41851. private static _getDefaultPlugin;
  41852. private static _getPluginForExtension;
  41853. private static _getPluginForDirectLoad;
  41854. private static _getPluginForFilename;
  41855. private static _getDirectLoad;
  41856. private static _loadData;
  41857. private static _getFileInfo;
  41858. /**
  41859. * Gets a plugin that can load the given extension
  41860. * @param extension defines the extension to load
  41861. * @returns a plugin or null if none works
  41862. */
  41863. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41864. /**
  41865. * Gets a boolean indicating that the given extension can be loaded
  41866. * @param extension defines the extension to load
  41867. * @returns true if the extension is supported
  41868. */
  41869. static IsPluginForExtensionAvailable(extension: string): boolean;
  41870. /**
  41871. * Adds a new plugin to the list of registered plugins
  41872. * @param plugin defines the plugin to add
  41873. */
  41874. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41875. /**
  41876. * Import meshes into a scene
  41877. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41878. * @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)
  41879. * @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)
  41880. * @param scene the instance of BABYLON.Scene to append to
  41881. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41882. * @param onProgress a callback with a progress event for each file being loaded
  41883. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41884. * @param pluginExtension the extension used to determine the plugin
  41885. * @returns The loaded plugin
  41886. */
  41887. 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>;
  41888. /**
  41889. * Import meshes into a scene
  41890. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41891. * @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)
  41892. * @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)
  41893. * @param scene the instance of BABYLON.Scene to append to
  41894. * @param onProgress a callback with a progress event for each file being loaded
  41895. * @param pluginExtension the extension used to determine the plugin
  41896. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41897. */
  41898. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41899. meshes: AbstractMesh[];
  41900. particleSystems: IParticleSystem[];
  41901. skeletons: Skeleton[];
  41902. animationGroups: AnimationGroup[];
  41903. }>;
  41904. /**
  41905. * Load a scene
  41906. * @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)
  41907. * @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)
  41908. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41909. * @param onSuccess a callback with the scene when import succeeds
  41910. * @param onProgress a callback with a progress event for each file being loaded
  41911. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41912. * @param pluginExtension the extension used to determine the plugin
  41913. * @returns The loaded plugin
  41914. */
  41915. 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>;
  41916. /**
  41917. * Load a scene
  41918. * @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)
  41919. * @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)
  41920. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41921. * @param onProgress a callback with a progress event for each file being loaded
  41922. * @param pluginExtension the extension used to determine the plugin
  41923. * @returns The loaded scene
  41924. */
  41925. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41926. /**
  41927. * Append a scene
  41928. * @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)
  41929. * @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)
  41930. * @param scene is the instance of BABYLON.Scene to append to
  41931. * @param onSuccess a callback with the scene when import succeeds
  41932. * @param onProgress a callback with a progress event for each file being loaded
  41933. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41934. * @param pluginExtension the extension used to determine the plugin
  41935. * @returns The loaded plugin
  41936. */
  41937. 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>;
  41938. /**
  41939. * Append a scene
  41940. * @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)
  41941. * @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)
  41942. * @param scene is the instance of BABYLON.Scene to append to
  41943. * @param onProgress a callback with a progress event for each file being loaded
  41944. * @param pluginExtension the extension used to determine the plugin
  41945. * @returns The given scene
  41946. */
  41947. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41948. /**
  41949. * Load a scene into an asset container
  41950. * @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)
  41951. * @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)
  41952. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41953. * @param onSuccess a callback with the scene when import succeeds
  41954. * @param onProgress a callback with a progress event for each file being loaded
  41955. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41956. * @param pluginExtension the extension used to determine the plugin
  41957. * @returns The loaded plugin
  41958. */
  41959. 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>;
  41960. /**
  41961. * Load a scene into an asset container
  41962. * @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)
  41963. * @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)
  41964. * @param scene is the instance of Scene to append to
  41965. * @param onProgress a callback with a progress event for each file being loaded
  41966. * @param pluginExtension the extension used to determine the plugin
  41967. * @returns The loaded asset container
  41968. */
  41969. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41970. }
  41971. }
  41972. declare module BABYLON {
  41973. /**
  41974. * Generic Controller
  41975. */
  41976. export class GenericController extends WebVRController {
  41977. /**
  41978. * Base Url for the controller model.
  41979. */
  41980. static readonly MODEL_BASE_URL: string;
  41981. /**
  41982. * File name for the controller model.
  41983. */
  41984. static readonly MODEL_FILENAME: string;
  41985. /**
  41986. * Creates a new GenericController from a gamepad
  41987. * @param vrGamepad the gamepad that the controller should be created from
  41988. */
  41989. constructor(vrGamepad: any);
  41990. /**
  41991. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41992. * @param scene scene in which to add meshes
  41993. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41994. */
  41995. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41996. /**
  41997. * Called once for each button that changed state since the last frame
  41998. * @param buttonIdx Which button index changed
  41999. * @param state New state of the button
  42000. * @param changes Which properties on the state changed since last frame
  42001. */
  42002. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42003. }
  42004. }
  42005. declare module BABYLON {
  42006. /**
  42007. * Defines the WindowsMotionController object that the state of the windows motion controller
  42008. */
  42009. export class WindowsMotionController extends WebVRController {
  42010. /**
  42011. * The base url used to load the left and right controller models
  42012. */
  42013. static MODEL_BASE_URL: string;
  42014. /**
  42015. * The name of the left controller model file
  42016. */
  42017. static MODEL_LEFT_FILENAME: string;
  42018. /**
  42019. * The name of the right controller model file
  42020. */
  42021. static MODEL_RIGHT_FILENAME: string;
  42022. /**
  42023. * The controller name prefix for this controller type
  42024. */
  42025. static readonly GAMEPAD_ID_PREFIX: string;
  42026. /**
  42027. * The controller id pattern for this controller type
  42028. */
  42029. private static readonly GAMEPAD_ID_PATTERN;
  42030. private _loadedMeshInfo;
  42031. private readonly _mapping;
  42032. /**
  42033. * Fired when the trackpad on this controller is clicked
  42034. */
  42035. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42036. /**
  42037. * Fired when the trackpad on this controller is modified
  42038. */
  42039. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42040. /**
  42041. * The current x and y values of this controller's trackpad
  42042. */
  42043. trackpad: StickValues;
  42044. /**
  42045. * Creates a new WindowsMotionController from a gamepad
  42046. * @param vrGamepad the gamepad that the controller should be created from
  42047. */
  42048. constructor(vrGamepad: any);
  42049. /**
  42050. * Fired when the trigger on this controller is modified
  42051. */
  42052. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42053. /**
  42054. * Fired when the menu button on this controller is modified
  42055. */
  42056. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42057. /**
  42058. * Fired when the grip button on this controller is modified
  42059. */
  42060. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42061. /**
  42062. * Fired when the thumbstick button on this controller is modified
  42063. */
  42064. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42065. /**
  42066. * Fired when the touchpad button on this controller is modified
  42067. */
  42068. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42069. /**
  42070. * Fired when the touchpad values on this controller are modified
  42071. */
  42072. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42073. private _updateTrackpad;
  42074. /**
  42075. * Called once per frame by the engine.
  42076. */
  42077. update(): void;
  42078. /**
  42079. * Called once for each button that changed state since the last frame
  42080. * @param buttonIdx Which button index changed
  42081. * @param state New state of the button
  42082. * @param changes Which properties on the state changed since last frame
  42083. */
  42084. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42085. /**
  42086. * Moves the buttons on the controller mesh based on their current state
  42087. * @param buttonName the name of the button to move
  42088. * @param buttonValue the value of the button which determines the buttons new position
  42089. */
  42090. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42091. /**
  42092. * Moves the axis on the controller mesh based on its current state
  42093. * @param axis the index of the axis
  42094. * @param axisValue the value of the axis which determines the meshes new position
  42095. * @hidden
  42096. */
  42097. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42098. /**
  42099. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42100. * @param scene scene in which to add meshes
  42101. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42102. */
  42103. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42104. /**
  42105. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42106. * can be transformed by button presses and axes values, based on this._mapping.
  42107. *
  42108. * @param scene scene in which the meshes exist
  42109. * @param meshes list of meshes that make up the controller model to process
  42110. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42111. */
  42112. private processModel;
  42113. private createMeshInfo;
  42114. /**
  42115. * Gets the ray of the controller in the direction the controller is pointing
  42116. * @param length the length the resulting ray should be
  42117. * @returns a ray in the direction the controller is pointing
  42118. */
  42119. getForwardRay(length?: number): Ray;
  42120. /**
  42121. * Disposes of the controller
  42122. */
  42123. dispose(): void;
  42124. }
  42125. }
  42126. declare module BABYLON {
  42127. /**
  42128. * Oculus Touch Controller
  42129. */
  42130. export class OculusTouchController extends WebVRController {
  42131. /**
  42132. * Base Url for the controller model.
  42133. */
  42134. static MODEL_BASE_URL: string;
  42135. /**
  42136. * File name for the left controller model.
  42137. */
  42138. static MODEL_LEFT_FILENAME: string;
  42139. /**
  42140. * File name for the right controller model.
  42141. */
  42142. static MODEL_RIGHT_FILENAME: string;
  42143. /**
  42144. * Base Url for the Quest controller model.
  42145. */
  42146. static QUEST_MODEL_BASE_URL: string;
  42147. /**
  42148. * @hidden
  42149. * If the controllers are running on a device that needs the updated Quest controller models
  42150. */
  42151. static _IsQuest: boolean;
  42152. /**
  42153. * Fired when the secondary trigger on this controller is modified
  42154. */
  42155. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42156. /**
  42157. * Fired when the thumb rest on this controller is modified
  42158. */
  42159. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42160. /**
  42161. * Creates a new OculusTouchController from a gamepad
  42162. * @param vrGamepad the gamepad that the controller should be created from
  42163. */
  42164. constructor(vrGamepad: any);
  42165. /**
  42166. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42167. * @param scene scene in which to add meshes
  42168. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42169. */
  42170. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42171. /**
  42172. * Fired when the A button on this controller is modified
  42173. */
  42174. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42175. /**
  42176. * Fired when the B button on this controller is modified
  42177. */
  42178. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42179. /**
  42180. * Fired when the X button on this controller is modified
  42181. */
  42182. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42183. /**
  42184. * Fired when the Y button on this controller is modified
  42185. */
  42186. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42187. /**
  42188. * Called once for each button that changed state since the last frame
  42189. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42190. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42191. * 2) secondary trigger (same)
  42192. * 3) A (right) X (left), touch, pressed = value
  42193. * 4) B / Y
  42194. * 5) thumb rest
  42195. * @param buttonIdx Which button index changed
  42196. * @param state New state of the button
  42197. * @param changes Which properties on the state changed since last frame
  42198. */
  42199. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42200. }
  42201. }
  42202. declare module BABYLON {
  42203. /**
  42204. * Vive Controller
  42205. */
  42206. export class ViveController extends WebVRController {
  42207. /**
  42208. * Base Url for the controller model.
  42209. */
  42210. static MODEL_BASE_URL: string;
  42211. /**
  42212. * File name for the controller model.
  42213. */
  42214. static MODEL_FILENAME: string;
  42215. /**
  42216. * Creates a new ViveController from a gamepad
  42217. * @param vrGamepad the gamepad that the controller should be created from
  42218. */
  42219. constructor(vrGamepad: any);
  42220. /**
  42221. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42222. * @param scene scene in which to add meshes
  42223. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42224. */
  42225. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42226. /**
  42227. * Fired when the left button on this controller is modified
  42228. */
  42229. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42230. /**
  42231. * Fired when the right button on this controller is modified
  42232. */
  42233. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42234. /**
  42235. * Fired when the menu button on this controller is modified
  42236. */
  42237. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42238. /**
  42239. * Called once for each button that changed state since the last frame
  42240. * Vive mapping:
  42241. * 0: touchpad
  42242. * 1: trigger
  42243. * 2: left AND right buttons
  42244. * 3: menu button
  42245. * @param buttonIdx Which button index changed
  42246. * @param state New state of the button
  42247. * @param changes Which properties on the state changed since last frame
  42248. */
  42249. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42250. }
  42251. }
  42252. declare module BABYLON {
  42253. /**
  42254. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42255. */
  42256. export class WebXRControllerModelLoader {
  42257. /**
  42258. * Creates the WebXRControllerModelLoader
  42259. * @param input xr input that creates the controllers
  42260. */
  42261. constructor(input: WebXRInput);
  42262. }
  42263. }
  42264. declare module BABYLON {
  42265. /**
  42266. * Contains an array of blocks representing the octree
  42267. */
  42268. export interface IOctreeContainer<T> {
  42269. /**
  42270. * Blocks within the octree
  42271. */
  42272. blocks: Array<OctreeBlock<T>>;
  42273. }
  42274. /**
  42275. * Class used to store a cell in an octree
  42276. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42277. */
  42278. export class OctreeBlock<T> {
  42279. /**
  42280. * Gets the content of the current block
  42281. */
  42282. entries: T[];
  42283. /**
  42284. * Gets the list of block children
  42285. */
  42286. blocks: Array<OctreeBlock<T>>;
  42287. private _depth;
  42288. private _maxDepth;
  42289. private _capacity;
  42290. private _minPoint;
  42291. private _maxPoint;
  42292. private _boundingVectors;
  42293. private _creationFunc;
  42294. /**
  42295. * Creates a new block
  42296. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42297. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42298. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42299. * @param depth defines the current depth of this block in the octree
  42300. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42301. * @param creationFunc defines a callback to call when an element is added to the block
  42302. */
  42303. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42304. /**
  42305. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42306. */
  42307. readonly capacity: number;
  42308. /**
  42309. * Gets the minimum vector (in world space) of the block's bounding box
  42310. */
  42311. readonly minPoint: Vector3;
  42312. /**
  42313. * Gets the maximum vector (in world space) of the block's bounding box
  42314. */
  42315. readonly maxPoint: Vector3;
  42316. /**
  42317. * Add a new element to this block
  42318. * @param entry defines the element to add
  42319. */
  42320. addEntry(entry: T): void;
  42321. /**
  42322. * Remove an element from this block
  42323. * @param entry defines the element to remove
  42324. */
  42325. removeEntry(entry: T): void;
  42326. /**
  42327. * Add an array of elements to this block
  42328. * @param entries defines the array of elements to add
  42329. */
  42330. addEntries(entries: T[]): void;
  42331. /**
  42332. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42333. * @param frustumPlanes defines the frustum planes to test
  42334. * @param selection defines the array to store current content if selection is positive
  42335. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42336. */
  42337. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42338. /**
  42339. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42340. * @param sphereCenter defines the bounding sphere center
  42341. * @param sphereRadius defines the bounding sphere radius
  42342. * @param selection defines the array to store current content if selection is positive
  42343. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42344. */
  42345. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42346. /**
  42347. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42348. * @param ray defines the ray to test with
  42349. * @param selection defines the array to store current content if selection is positive
  42350. */
  42351. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42352. /**
  42353. * Subdivide the content into child blocks (this block will then be empty)
  42354. */
  42355. createInnerBlocks(): void;
  42356. /**
  42357. * @hidden
  42358. */
  42359. 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;
  42360. }
  42361. }
  42362. declare module BABYLON {
  42363. /**
  42364. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42365. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42366. */
  42367. export class Octree<T> {
  42368. /** 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.) */
  42369. maxDepth: number;
  42370. /**
  42371. * Blocks within the octree containing objects
  42372. */
  42373. blocks: Array<OctreeBlock<T>>;
  42374. /**
  42375. * Content stored in the octree
  42376. */
  42377. dynamicContent: T[];
  42378. private _maxBlockCapacity;
  42379. private _selectionContent;
  42380. private _creationFunc;
  42381. /**
  42382. * Creates a octree
  42383. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42384. * @param creationFunc function to be used to instatiate the octree
  42385. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42386. * @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.)
  42387. */
  42388. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42389. /** 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.) */
  42390. maxDepth?: number);
  42391. /**
  42392. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42393. * @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);
  42394. * @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);
  42395. * @param entries meshes to be added to the octree blocks
  42396. */
  42397. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42398. /**
  42399. * Adds a mesh to the octree
  42400. * @param entry Mesh to add to the octree
  42401. */
  42402. addMesh(entry: T): void;
  42403. /**
  42404. * Remove an element from the octree
  42405. * @param entry defines the element to remove
  42406. */
  42407. removeMesh(entry: T): void;
  42408. /**
  42409. * Selects an array of meshes within the frustum
  42410. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42411. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42412. * @returns array of meshes within the frustum
  42413. */
  42414. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42415. /**
  42416. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42417. * @param sphereCenter defines the bounding sphere center
  42418. * @param sphereRadius defines the bounding sphere radius
  42419. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42420. * @returns an array of objects that intersect the sphere
  42421. */
  42422. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42423. /**
  42424. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42425. * @param ray defines the ray to test with
  42426. * @returns array of intersected objects
  42427. */
  42428. intersectsRay(ray: Ray): SmartArray<T>;
  42429. /**
  42430. * Adds a mesh into the octree block if it intersects the block
  42431. */
  42432. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42433. /**
  42434. * Adds a submesh into the octree block if it intersects the block
  42435. */
  42436. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42437. }
  42438. }
  42439. declare module BABYLON {
  42440. interface Scene {
  42441. /**
  42442. * @hidden
  42443. * Backing Filed
  42444. */
  42445. _selectionOctree: Octree<AbstractMesh>;
  42446. /**
  42447. * Gets the octree used to boost mesh selection (picking)
  42448. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42449. */
  42450. selectionOctree: Octree<AbstractMesh>;
  42451. /**
  42452. * Creates or updates the octree used to boost selection (picking)
  42453. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42454. * @param maxCapacity defines the maximum capacity per leaf
  42455. * @param maxDepth defines the maximum depth of the octree
  42456. * @returns an octree of AbstractMesh
  42457. */
  42458. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42459. }
  42460. interface AbstractMesh {
  42461. /**
  42462. * @hidden
  42463. * Backing Field
  42464. */
  42465. _submeshesOctree: Octree<SubMesh>;
  42466. /**
  42467. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42468. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42469. * @param maxCapacity defines the maximum size of each block (64 by default)
  42470. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42471. * @returns the new octree
  42472. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42473. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42474. */
  42475. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42476. }
  42477. /**
  42478. * Defines the octree scene component responsible to manage any octrees
  42479. * in a given scene.
  42480. */
  42481. export class OctreeSceneComponent {
  42482. /**
  42483. * The component name help to identify the component in the list of scene components.
  42484. */
  42485. readonly name: string;
  42486. /**
  42487. * The scene the component belongs to.
  42488. */
  42489. scene: Scene;
  42490. /**
  42491. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42492. */
  42493. readonly checksIsEnabled: boolean;
  42494. /**
  42495. * Creates a new instance of the component for the given scene
  42496. * @param scene Defines the scene to register the component in
  42497. */
  42498. constructor(scene: Scene);
  42499. /**
  42500. * Registers the component in a given scene
  42501. */
  42502. register(): void;
  42503. /**
  42504. * Return the list of active meshes
  42505. * @returns the list of active meshes
  42506. */
  42507. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42508. /**
  42509. * Return the list of active sub meshes
  42510. * @param mesh The mesh to get the candidates sub meshes from
  42511. * @returns the list of active sub meshes
  42512. */
  42513. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42514. private _tempRay;
  42515. /**
  42516. * Return the list of sub meshes intersecting with a given local ray
  42517. * @param mesh defines the mesh to find the submesh for
  42518. * @param localRay defines the ray in local space
  42519. * @returns the list of intersecting sub meshes
  42520. */
  42521. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42522. /**
  42523. * Return the list of sub meshes colliding with a collider
  42524. * @param mesh defines the mesh to find the submesh for
  42525. * @param collider defines the collider to evaluate the collision against
  42526. * @returns the list of colliding sub meshes
  42527. */
  42528. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42529. /**
  42530. * Rebuilds the elements related to this component in case of
  42531. * context lost for instance.
  42532. */
  42533. rebuild(): void;
  42534. /**
  42535. * Disposes the component and the associated ressources.
  42536. */
  42537. dispose(): void;
  42538. }
  42539. }
  42540. declare module BABYLON {
  42541. /**
  42542. * Renders a layer on top of an existing scene
  42543. */
  42544. export class UtilityLayerRenderer implements IDisposable {
  42545. /** the original scene that will be rendered on top of */
  42546. originalScene: Scene;
  42547. private _pointerCaptures;
  42548. private _lastPointerEvents;
  42549. private static _DefaultUtilityLayer;
  42550. private static _DefaultKeepDepthUtilityLayer;
  42551. private _sharedGizmoLight;
  42552. private _renderCamera;
  42553. /**
  42554. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42555. * @returns the camera that is used when rendering the utility layer
  42556. */
  42557. getRenderCamera(): Nullable<Camera>;
  42558. /**
  42559. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42560. * @param cam the camera that should be used when rendering the utility layer
  42561. */
  42562. setRenderCamera(cam: Nullable<Camera>): void;
  42563. /**
  42564. * @hidden
  42565. * Light which used by gizmos to get light shading
  42566. */
  42567. _getSharedGizmoLight(): HemisphericLight;
  42568. /**
  42569. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42570. */
  42571. pickUtilitySceneFirst: boolean;
  42572. /**
  42573. * 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)
  42574. */
  42575. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42576. /**
  42577. * 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)
  42578. */
  42579. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42580. /**
  42581. * The scene that is rendered on top of the original scene
  42582. */
  42583. utilityLayerScene: Scene;
  42584. /**
  42585. * If the utility layer should automatically be rendered on top of existing scene
  42586. */
  42587. shouldRender: boolean;
  42588. /**
  42589. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42590. */
  42591. onlyCheckPointerDownEvents: boolean;
  42592. /**
  42593. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42594. */
  42595. processAllEvents: boolean;
  42596. /**
  42597. * Observable raised when the pointer move from the utility layer scene to the main scene
  42598. */
  42599. onPointerOutObservable: Observable<number>;
  42600. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42601. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42602. private _afterRenderObserver;
  42603. private _sceneDisposeObserver;
  42604. private _originalPointerObserver;
  42605. /**
  42606. * Instantiates a UtilityLayerRenderer
  42607. * @param originalScene the original scene that will be rendered on top of
  42608. * @param handleEvents boolean indicating if the utility layer should handle events
  42609. */
  42610. constructor(
  42611. /** the original scene that will be rendered on top of */
  42612. originalScene: Scene, handleEvents?: boolean);
  42613. private _notifyObservers;
  42614. /**
  42615. * Renders the utility layers scene on top of the original scene
  42616. */
  42617. render(): void;
  42618. /**
  42619. * Disposes of the renderer
  42620. */
  42621. dispose(): void;
  42622. private _updateCamera;
  42623. }
  42624. }
  42625. declare module BABYLON {
  42626. /**
  42627. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42628. */
  42629. export class Gizmo implements IDisposable {
  42630. /** The utility layer the gizmo will be added to */
  42631. gizmoLayer: UtilityLayerRenderer;
  42632. /**
  42633. * The root mesh of the gizmo
  42634. */
  42635. _rootMesh: Mesh;
  42636. private _attachedMesh;
  42637. /**
  42638. * Ratio for the scale of the gizmo (Default: 1)
  42639. */
  42640. scaleRatio: number;
  42641. /**
  42642. * If a custom mesh has been set (Default: false)
  42643. */
  42644. protected _customMeshSet: boolean;
  42645. /**
  42646. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42647. * * When set, interactions will be enabled
  42648. */
  42649. attachedMesh: Nullable<AbstractMesh>;
  42650. /**
  42651. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42652. * @param mesh The mesh to replace the default mesh of the gizmo
  42653. */
  42654. setCustomMesh(mesh: Mesh): void;
  42655. /**
  42656. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42657. */
  42658. updateGizmoRotationToMatchAttachedMesh: boolean;
  42659. /**
  42660. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42661. */
  42662. updateGizmoPositionToMatchAttachedMesh: boolean;
  42663. /**
  42664. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42665. */
  42666. updateScale: boolean;
  42667. protected _interactionsEnabled: boolean;
  42668. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42669. private _beforeRenderObserver;
  42670. private _tempVector;
  42671. /**
  42672. * Creates a gizmo
  42673. * @param gizmoLayer The utility layer the gizmo will be added to
  42674. */
  42675. constructor(
  42676. /** The utility layer the gizmo will be added to */
  42677. gizmoLayer?: UtilityLayerRenderer);
  42678. /**
  42679. * Updates the gizmo to match the attached mesh's position/rotation
  42680. */
  42681. protected _update(): void;
  42682. /**
  42683. * Disposes of the gizmo
  42684. */
  42685. dispose(): void;
  42686. }
  42687. }
  42688. declare module BABYLON {
  42689. /**
  42690. * Single plane drag gizmo
  42691. */
  42692. export class PlaneDragGizmo extends Gizmo {
  42693. /**
  42694. * Drag behavior responsible for the gizmos dragging interactions
  42695. */
  42696. dragBehavior: PointerDragBehavior;
  42697. private _pointerObserver;
  42698. /**
  42699. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42700. */
  42701. snapDistance: number;
  42702. /**
  42703. * Event that fires each time the gizmo snaps to a new location.
  42704. * * snapDistance is the the change in distance
  42705. */
  42706. onSnapObservable: Observable<{
  42707. snapDistance: number;
  42708. }>;
  42709. private _plane;
  42710. private _coloredMaterial;
  42711. private _hoverMaterial;
  42712. private _isEnabled;
  42713. private _parent;
  42714. /** @hidden */
  42715. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42716. /** @hidden */
  42717. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42718. /**
  42719. * Creates a PlaneDragGizmo
  42720. * @param gizmoLayer The utility layer the gizmo will be added to
  42721. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42722. * @param color The color of the gizmo
  42723. */
  42724. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42725. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42726. /**
  42727. * If the gizmo is enabled
  42728. */
  42729. isEnabled: boolean;
  42730. /**
  42731. * Disposes of the gizmo
  42732. */
  42733. dispose(): void;
  42734. }
  42735. }
  42736. declare module BABYLON {
  42737. /**
  42738. * Gizmo that enables dragging a mesh along 3 axis
  42739. */
  42740. export class PositionGizmo extends Gizmo {
  42741. /**
  42742. * Internal gizmo used for interactions on the x axis
  42743. */
  42744. xGizmo: AxisDragGizmo;
  42745. /**
  42746. * Internal gizmo used for interactions on the y axis
  42747. */
  42748. yGizmo: AxisDragGizmo;
  42749. /**
  42750. * Internal gizmo used for interactions on the z axis
  42751. */
  42752. zGizmo: AxisDragGizmo;
  42753. /**
  42754. * Internal gizmo used for interactions on the yz plane
  42755. */
  42756. xPlaneGizmo: PlaneDragGizmo;
  42757. /**
  42758. * Internal gizmo used for interactions on the xz plane
  42759. */
  42760. yPlaneGizmo: PlaneDragGizmo;
  42761. /**
  42762. * Internal gizmo used for interactions on the xy plane
  42763. */
  42764. zPlaneGizmo: PlaneDragGizmo;
  42765. /**
  42766. * private variables
  42767. */
  42768. private _meshAttached;
  42769. private _updateGizmoRotationToMatchAttachedMesh;
  42770. private _snapDistance;
  42771. private _scaleRatio;
  42772. /** Fires an event when any of it's sub gizmos are dragged */
  42773. onDragStartObservable: Observable<unknown>;
  42774. /** Fires an event when any of it's sub gizmos are released from dragging */
  42775. onDragEndObservable: Observable<unknown>;
  42776. /**
  42777. * If set to true, planar drag is enabled
  42778. */
  42779. private _planarGizmoEnabled;
  42780. attachedMesh: Nullable<AbstractMesh>;
  42781. /**
  42782. * Creates a PositionGizmo
  42783. * @param gizmoLayer The utility layer the gizmo will be added to
  42784. */
  42785. constructor(gizmoLayer?: UtilityLayerRenderer);
  42786. /**
  42787. * If the planar drag gizmo is enabled
  42788. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42789. */
  42790. planarGizmoEnabled: boolean;
  42791. updateGizmoRotationToMatchAttachedMesh: boolean;
  42792. /**
  42793. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42794. */
  42795. snapDistance: number;
  42796. /**
  42797. * Ratio for the scale of the gizmo (Default: 1)
  42798. */
  42799. scaleRatio: number;
  42800. /**
  42801. * Disposes of the gizmo
  42802. */
  42803. dispose(): void;
  42804. /**
  42805. * CustomMeshes are not supported by this gizmo
  42806. * @param mesh The mesh to replace the default mesh of the gizmo
  42807. */
  42808. setCustomMesh(mesh: Mesh): void;
  42809. }
  42810. }
  42811. declare module BABYLON {
  42812. /**
  42813. * Single axis drag gizmo
  42814. */
  42815. export class AxisDragGizmo extends Gizmo {
  42816. /**
  42817. * Drag behavior responsible for the gizmos dragging interactions
  42818. */
  42819. dragBehavior: PointerDragBehavior;
  42820. private _pointerObserver;
  42821. /**
  42822. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42823. */
  42824. snapDistance: number;
  42825. /**
  42826. * Event that fires each time the gizmo snaps to a new location.
  42827. * * snapDistance is the the change in distance
  42828. */
  42829. onSnapObservable: Observable<{
  42830. snapDistance: number;
  42831. }>;
  42832. private _isEnabled;
  42833. private _parent;
  42834. private _arrow;
  42835. private _coloredMaterial;
  42836. private _hoverMaterial;
  42837. /** @hidden */
  42838. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42839. /** @hidden */
  42840. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42841. /**
  42842. * Creates an AxisDragGizmo
  42843. * @param gizmoLayer The utility layer the gizmo will be added to
  42844. * @param dragAxis The axis which the gizmo will be able to drag on
  42845. * @param color The color of the gizmo
  42846. */
  42847. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42848. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42849. /**
  42850. * If the gizmo is enabled
  42851. */
  42852. isEnabled: boolean;
  42853. /**
  42854. * Disposes of the gizmo
  42855. */
  42856. dispose(): void;
  42857. }
  42858. }
  42859. declare module BABYLON.Debug {
  42860. /**
  42861. * The Axes viewer will show 3 axes in a specific point in space
  42862. */
  42863. export class AxesViewer {
  42864. private _xAxis;
  42865. private _yAxis;
  42866. private _zAxis;
  42867. private _scaleLinesFactor;
  42868. private _instanced;
  42869. /**
  42870. * Gets the hosting scene
  42871. */
  42872. scene: Scene;
  42873. /**
  42874. * Gets or sets a number used to scale line length
  42875. */
  42876. scaleLines: number;
  42877. /** Gets the node hierarchy used to render x-axis */
  42878. readonly xAxis: TransformNode;
  42879. /** Gets the node hierarchy used to render y-axis */
  42880. readonly yAxis: TransformNode;
  42881. /** Gets the node hierarchy used to render z-axis */
  42882. readonly zAxis: TransformNode;
  42883. /**
  42884. * Creates a new AxesViewer
  42885. * @param scene defines the hosting scene
  42886. * @param scaleLines defines a number used to scale line length (1 by default)
  42887. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42888. * @param xAxis defines the node hierarchy used to render the x-axis
  42889. * @param yAxis defines the node hierarchy used to render the y-axis
  42890. * @param zAxis defines the node hierarchy used to render the z-axis
  42891. */
  42892. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42893. /**
  42894. * Force the viewer to update
  42895. * @param position defines the position of the viewer
  42896. * @param xaxis defines the x axis of the viewer
  42897. * @param yaxis defines the y axis of the viewer
  42898. * @param zaxis defines the z axis of the viewer
  42899. */
  42900. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42901. /**
  42902. * Creates an instance of this axes viewer.
  42903. * @returns a new axes viewer with instanced meshes
  42904. */
  42905. createInstance(): AxesViewer;
  42906. /** Releases resources */
  42907. dispose(): void;
  42908. private static _SetRenderingGroupId;
  42909. }
  42910. }
  42911. declare module BABYLON.Debug {
  42912. /**
  42913. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42914. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42915. */
  42916. export class BoneAxesViewer extends AxesViewer {
  42917. /**
  42918. * Gets or sets the target mesh where to display the axes viewer
  42919. */
  42920. mesh: Nullable<Mesh>;
  42921. /**
  42922. * Gets or sets the target bone where to display the axes viewer
  42923. */
  42924. bone: Nullable<Bone>;
  42925. /** Gets current position */
  42926. pos: Vector3;
  42927. /** Gets direction of X axis */
  42928. xaxis: Vector3;
  42929. /** Gets direction of Y axis */
  42930. yaxis: Vector3;
  42931. /** Gets direction of Z axis */
  42932. zaxis: Vector3;
  42933. /**
  42934. * Creates a new BoneAxesViewer
  42935. * @param scene defines the hosting scene
  42936. * @param bone defines the target bone
  42937. * @param mesh defines the target mesh
  42938. * @param scaleLines defines a scaling factor for line length (1 by default)
  42939. */
  42940. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42941. /**
  42942. * Force the viewer to update
  42943. */
  42944. update(): void;
  42945. /** Releases resources */
  42946. dispose(): void;
  42947. }
  42948. }
  42949. declare module BABYLON {
  42950. /**
  42951. * Interface used to define scene explorer extensibility option
  42952. */
  42953. export interface IExplorerExtensibilityOption {
  42954. /**
  42955. * Define the option label
  42956. */
  42957. label: string;
  42958. /**
  42959. * Defines the action to execute on click
  42960. */
  42961. action: (entity: any) => void;
  42962. }
  42963. /**
  42964. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42965. */
  42966. export interface IExplorerExtensibilityGroup {
  42967. /**
  42968. * Defines a predicate to test if a given type mut be extended
  42969. */
  42970. predicate: (entity: any) => boolean;
  42971. /**
  42972. * Gets the list of options added to a type
  42973. */
  42974. entries: IExplorerExtensibilityOption[];
  42975. }
  42976. /**
  42977. * Interface used to define the options to use to create the Inspector
  42978. */
  42979. export interface IInspectorOptions {
  42980. /**
  42981. * Display in overlay mode (default: false)
  42982. */
  42983. overlay?: boolean;
  42984. /**
  42985. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42986. */
  42987. globalRoot?: HTMLElement;
  42988. /**
  42989. * Display the Scene explorer
  42990. */
  42991. showExplorer?: boolean;
  42992. /**
  42993. * Display the property inspector
  42994. */
  42995. showInspector?: boolean;
  42996. /**
  42997. * Display in embed mode (both panes on the right)
  42998. */
  42999. embedMode?: boolean;
  43000. /**
  43001. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43002. */
  43003. handleResize?: boolean;
  43004. /**
  43005. * Allow the panes to popup (default: true)
  43006. */
  43007. enablePopup?: boolean;
  43008. /**
  43009. * Allow the panes to be closed by users (default: true)
  43010. */
  43011. enableClose?: boolean;
  43012. /**
  43013. * Optional list of extensibility entries
  43014. */
  43015. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43016. /**
  43017. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43018. */
  43019. inspectorURL?: string;
  43020. }
  43021. interface Scene {
  43022. /**
  43023. * @hidden
  43024. * Backing field
  43025. */
  43026. _debugLayer: DebugLayer;
  43027. /**
  43028. * Gets the debug layer (aka Inspector) associated with the scene
  43029. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43030. */
  43031. debugLayer: DebugLayer;
  43032. }
  43033. /**
  43034. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43035. * what is happening in your scene
  43036. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43037. */
  43038. export class DebugLayer {
  43039. /**
  43040. * Define the url to get the inspector script from.
  43041. * By default it uses the babylonjs CDN.
  43042. * @ignoreNaming
  43043. */
  43044. static InspectorURL: string;
  43045. private _scene;
  43046. private BJSINSPECTOR;
  43047. private _onPropertyChangedObservable?;
  43048. /**
  43049. * Observable triggered when a property is changed through the inspector.
  43050. */
  43051. readonly onPropertyChangedObservable: any;
  43052. /**
  43053. * Instantiates a new debug layer.
  43054. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43055. * what is happening in your scene
  43056. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43057. * @param scene Defines the scene to inspect
  43058. */
  43059. constructor(scene: Scene);
  43060. /** Creates the inspector window. */
  43061. private _createInspector;
  43062. /**
  43063. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43064. * @param entity defines the entity to select
  43065. * @param lineContainerTitle defines the specific block to highlight
  43066. */
  43067. select(entity: any, lineContainerTitle?: string): void;
  43068. /** Get the inspector from bundle or global */
  43069. private _getGlobalInspector;
  43070. /**
  43071. * Get if the inspector is visible or not.
  43072. * @returns true if visible otherwise, false
  43073. */
  43074. isVisible(): boolean;
  43075. /**
  43076. * Hide the inspector and close its window.
  43077. */
  43078. hide(): void;
  43079. /**
  43080. * Launch the debugLayer.
  43081. * @param config Define the configuration of the inspector
  43082. * @return a promise fulfilled when the debug layer is visible
  43083. */
  43084. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43085. }
  43086. }
  43087. declare module BABYLON {
  43088. /**
  43089. * Class containing static functions to help procedurally build meshes
  43090. */
  43091. export class BoxBuilder {
  43092. /**
  43093. * Creates a box mesh
  43094. * * The parameter `size` sets the size (float) of each box side (default 1)
  43095. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43096. * * 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)
  43097. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43099. * * 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
  43100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43101. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43102. * @param name defines the name of the mesh
  43103. * @param options defines the options used to create the mesh
  43104. * @param scene defines the hosting scene
  43105. * @returns the box mesh
  43106. */
  43107. static CreateBox(name: string, options: {
  43108. size?: number;
  43109. width?: number;
  43110. height?: number;
  43111. depth?: number;
  43112. faceUV?: Vector4[];
  43113. faceColors?: Color4[];
  43114. sideOrientation?: number;
  43115. frontUVs?: Vector4;
  43116. backUVs?: Vector4;
  43117. wrap?: boolean;
  43118. topBaseAt?: number;
  43119. bottomBaseAt?: number;
  43120. updatable?: boolean;
  43121. }, scene?: Nullable<Scene>): Mesh;
  43122. }
  43123. }
  43124. declare module BABYLON {
  43125. /**
  43126. * Class containing static functions to help procedurally build meshes
  43127. */
  43128. export class SphereBuilder {
  43129. /**
  43130. * Creates a sphere mesh
  43131. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43132. * * 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`)
  43133. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43134. * * 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
  43135. * * 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)
  43136. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43137. * * 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
  43138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43139. * @param name defines the name of the mesh
  43140. * @param options defines the options used to create the mesh
  43141. * @param scene defines the hosting scene
  43142. * @returns the sphere mesh
  43143. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43144. */
  43145. static CreateSphere(name: string, options: {
  43146. segments?: number;
  43147. diameter?: number;
  43148. diameterX?: number;
  43149. diameterY?: number;
  43150. diameterZ?: number;
  43151. arc?: number;
  43152. slice?: number;
  43153. sideOrientation?: number;
  43154. frontUVs?: Vector4;
  43155. backUVs?: Vector4;
  43156. updatable?: boolean;
  43157. }, scene?: Nullable<Scene>): Mesh;
  43158. }
  43159. }
  43160. declare module BABYLON.Debug {
  43161. /**
  43162. * Used to show the physics impostor around the specific mesh
  43163. */
  43164. export class PhysicsViewer {
  43165. /** @hidden */
  43166. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43167. /** @hidden */
  43168. protected _meshes: Array<Nullable<AbstractMesh>>;
  43169. /** @hidden */
  43170. protected _scene: Nullable<Scene>;
  43171. /** @hidden */
  43172. protected _numMeshes: number;
  43173. /** @hidden */
  43174. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43175. private _renderFunction;
  43176. private _utilityLayer;
  43177. private _debugBoxMesh;
  43178. private _debugSphereMesh;
  43179. private _debugCylinderMesh;
  43180. private _debugMaterial;
  43181. private _debugMeshMeshes;
  43182. /**
  43183. * Creates a new PhysicsViewer
  43184. * @param scene defines the hosting scene
  43185. */
  43186. constructor(scene: Scene);
  43187. /** @hidden */
  43188. protected _updateDebugMeshes(): void;
  43189. /**
  43190. * Renders a specified physic impostor
  43191. * @param impostor defines the impostor to render
  43192. * @param targetMesh defines the mesh represented by the impostor
  43193. * @returns the new debug mesh used to render the impostor
  43194. */
  43195. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43196. /**
  43197. * Hides a specified physic impostor
  43198. * @param impostor defines the impostor to hide
  43199. */
  43200. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43201. private _getDebugMaterial;
  43202. private _getDebugBoxMesh;
  43203. private _getDebugSphereMesh;
  43204. private _getDebugCylinderMesh;
  43205. private _getDebugMeshMesh;
  43206. private _getDebugMesh;
  43207. /** Releases all resources */
  43208. dispose(): void;
  43209. }
  43210. }
  43211. declare module BABYLON {
  43212. /**
  43213. * Class containing static functions to help procedurally build meshes
  43214. */
  43215. export class LinesBuilder {
  43216. /**
  43217. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43218. * * 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
  43219. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43220. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43221. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43222. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43223. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43224. * * 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
  43225. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43227. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43228. * @param name defines the name of the new line system
  43229. * @param options defines the options used to create the line system
  43230. * @param scene defines the hosting scene
  43231. * @returns a new line system mesh
  43232. */
  43233. static CreateLineSystem(name: string, options: {
  43234. lines: Vector3[][];
  43235. updatable?: boolean;
  43236. instance?: Nullable<LinesMesh>;
  43237. colors?: Nullable<Color4[][]>;
  43238. useVertexAlpha?: boolean;
  43239. }, scene: Nullable<Scene>): LinesMesh;
  43240. /**
  43241. * Creates a line mesh
  43242. * 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
  43243. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43244. * * The parameter `points` is an array successive Vector3
  43245. * * 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
  43246. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43247. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43248. * * When updating an instance, remember that only point positions can change, not the number of points
  43249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43250. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43251. * @param name defines the name of the new line system
  43252. * @param options defines the options used to create the line system
  43253. * @param scene defines the hosting scene
  43254. * @returns a new line mesh
  43255. */
  43256. static CreateLines(name: string, options: {
  43257. points: Vector3[];
  43258. updatable?: boolean;
  43259. instance?: Nullable<LinesMesh>;
  43260. colors?: Color4[];
  43261. useVertexAlpha?: boolean;
  43262. }, scene?: Nullable<Scene>): LinesMesh;
  43263. /**
  43264. * Creates a dashed line mesh
  43265. * * 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
  43266. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43267. * * The parameter `points` is an array successive Vector3
  43268. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43269. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43270. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43271. * * 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
  43272. * * When updating an instance, remember that only point positions can change, not the number of points
  43273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43274. * @param name defines the name of the mesh
  43275. * @param options defines the options used to create the mesh
  43276. * @param scene defines the hosting scene
  43277. * @returns the dashed line mesh
  43278. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43279. */
  43280. static CreateDashedLines(name: string, options: {
  43281. points: Vector3[];
  43282. dashSize?: number;
  43283. gapSize?: number;
  43284. dashNb?: number;
  43285. updatable?: boolean;
  43286. instance?: LinesMesh;
  43287. }, scene?: Nullable<Scene>): LinesMesh;
  43288. }
  43289. }
  43290. declare module BABYLON {
  43291. /**
  43292. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43293. * in order to better appreciate the issue one might have.
  43294. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43295. */
  43296. export class RayHelper {
  43297. /**
  43298. * Defines the ray we are currently tryin to visualize.
  43299. */
  43300. ray: Nullable<Ray>;
  43301. private _renderPoints;
  43302. private _renderLine;
  43303. private _renderFunction;
  43304. private _scene;
  43305. private _updateToMeshFunction;
  43306. private _attachedToMesh;
  43307. private _meshSpaceDirection;
  43308. private _meshSpaceOrigin;
  43309. /**
  43310. * Helper function to create a colored helper in a scene in one line.
  43311. * @param ray Defines the ray we are currently tryin to visualize
  43312. * @param scene Defines the scene the ray is used in
  43313. * @param color Defines the color we want to see the ray in
  43314. * @returns The newly created ray helper.
  43315. */
  43316. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43317. /**
  43318. * Instantiate a new ray helper.
  43319. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43320. * in order to better appreciate the issue one might have.
  43321. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43322. * @param ray Defines the ray we are currently tryin to visualize
  43323. */
  43324. constructor(ray: Ray);
  43325. /**
  43326. * Shows the ray we are willing to debug.
  43327. * @param scene Defines the scene the ray needs to be rendered in
  43328. * @param color Defines the color the ray needs to be rendered in
  43329. */
  43330. show(scene: Scene, color?: Color3): void;
  43331. /**
  43332. * Hides the ray we are debugging.
  43333. */
  43334. hide(): void;
  43335. private _render;
  43336. /**
  43337. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43338. * @param mesh Defines the mesh we want the helper attached to
  43339. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43340. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43341. * @param length Defines the length of the ray
  43342. */
  43343. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43344. /**
  43345. * Detach the ray helper from the mesh it has previously been attached to.
  43346. */
  43347. detachFromMesh(): void;
  43348. private _updateToMesh;
  43349. /**
  43350. * Dispose the helper and release its associated resources.
  43351. */
  43352. dispose(): void;
  43353. }
  43354. }
  43355. declare module BABYLON.Debug {
  43356. /**
  43357. * Class used to render a debug view of a given skeleton
  43358. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43359. */
  43360. export class SkeletonViewer {
  43361. /** defines the skeleton to render */
  43362. skeleton: Skeleton;
  43363. /** defines the mesh attached to the skeleton */
  43364. mesh: AbstractMesh;
  43365. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43366. autoUpdateBonesMatrices: boolean;
  43367. /** defines the rendering group id to use with the viewer */
  43368. renderingGroupId: number;
  43369. /** Gets or sets the color used to render the skeleton */
  43370. color: Color3;
  43371. private _scene;
  43372. private _debugLines;
  43373. private _debugMesh;
  43374. private _isEnabled;
  43375. private _renderFunction;
  43376. private _utilityLayer;
  43377. /**
  43378. * Returns the mesh used to render the bones
  43379. */
  43380. readonly debugMesh: Nullable<LinesMesh>;
  43381. /**
  43382. * Creates a new SkeletonViewer
  43383. * @param skeleton defines the skeleton to render
  43384. * @param mesh defines the mesh attached to the skeleton
  43385. * @param scene defines the hosting scene
  43386. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43387. * @param renderingGroupId defines the rendering group id to use with the viewer
  43388. */
  43389. constructor(
  43390. /** defines the skeleton to render */
  43391. skeleton: Skeleton,
  43392. /** defines the mesh attached to the skeleton */
  43393. mesh: AbstractMesh, scene: Scene,
  43394. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43395. autoUpdateBonesMatrices?: boolean,
  43396. /** defines the rendering group id to use with the viewer */
  43397. renderingGroupId?: number);
  43398. /** Gets or sets a boolean indicating if the viewer is enabled */
  43399. isEnabled: boolean;
  43400. private _getBonePosition;
  43401. private _getLinesForBonesWithLength;
  43402. private _getLinesForBonesNoLength;
  43403. /** Update the viewer to sync with current skeleton state */
  43404. update(): void;
  43405. /** Release associated resources */
  43406. dispose(): void;
  43407. }
  43408. }
  43409. declare module BABYLON {
  43410. /**
  43411. * Options to create the null engine
  43412. */
  43413. export class NullEngineOptions {
  43414. /**
  43415. * Render width (Default: 512)
  43416. */
  43417. renderWidth: number;
  43418. /**
  43419. * Render height (Default: 256)
  43420. */
  43421. renderHeight: number;
  43422. /**
  43423. * Texture size (Default: 512)
  43424. */
  43425. textureSize: number;
  43426. /**
  43427. * If delta time between frames should be constant
  43428. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43429. */
  43430. deterministicLockstep: boolean;
  43431. /**
  43432. * Maximum about of steps between frames (Default: 4)
  43433. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43434. */
  43435. lockstepMaxSteps: number;
  43436. }
  43437. /**
  43438. * The null engine class provides support for headless version of babylon.js.
  43439. * This can be used in server side scenario or for testing purposes
  43440. */
  43441. export class NullEngine extends Engine {
  43442. private _options;
  43443. /**
  43444. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43445. */
  43446. isDeterministicLockStep(): boolean;
  43447. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43448. getLockstepMaxSteps(): number;
  43449. /**
  43450. * Sets hardware scaling, used to save performance if needed
  43451. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43452. */
  43453. getHardwareScalingLevel(): number;
  43454. constructor(options?: NullEngineOptions);
  43455. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43456. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43457. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43458. getRenderWidth(useScreen?: boolean): number;
  43459. getRenderHeight(useScreen?: boolean): number;
  43460. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43461. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43462. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43463. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43464. bindSamplers(effect: Effect): void;
  43465. enableEffect(effect: Effect): void;
  43466. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43467. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43468. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43469. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43470. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43471. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43472. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43473. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43474. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43475. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43476. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43477. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43478. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43479. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43480. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43481. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43482. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43483. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43484. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43485. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43486. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43487. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43488. bindBuffers(vertexBuffers: {
  43489. [key: string]: VertexBuffer;
  43490. }, indexBuffer: DataBuffer, effect: Effect): void;
  43491. wipeCaches(bruteForce?: boolean): void;
  43492. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43493. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43494. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43495. /** @hidden */
  43496. _createTexture(): WebGLTexture;
  43497. /** @hidden */
  43498. _releaseTexture(texture: InternalTexture): void;
  43499. 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;
  43500. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43501. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43502. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43503. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43504. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43505. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43506. areAllEffectsReady(): boolean;
  43507. /**
  43508. * @hidden
  43509. * Get the current error code of the webGL context
  43510. * @returns the error code
  43511. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43512. */
  43513. getError(): number;
  43514. /** @hidden */
  43515. _getUnpackAlignement(): number;
  43516. /** @hidden */
  43517. _unpackFlipY(value: boolean): void;
  43518. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43519. /**
  43520. * Updates a dynamic vertex buffer.
  43521. * @param vertexBuffer the vertex buffer to update
  43522. * @param data the data used to update the vertex buffer
  43523. * @param byteOffset the byte offset of the data (optional)
  43524. * @param byteLength the byte length of the data (optional)
  43525. */
  43526. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43527. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43528. /** @hidden */
  43529. _bindTexture(channel: number, texture: InternalTexture): void;
  43530. protected _deleteBuffer(buffer: WebGLBuffer): void;
  43531. releaseEffects(): void;
  43532. displayLoadingUI(): void;
  43533. hideLoadingUI(): void;
  43534. /** @hidden */
  43535. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43536. /** @hidden */
  43537. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43538. /** @hidden */
  43539. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43540. /** @hidden */
  43541. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43542. }
  43543. }
  43544. declare module BABYLON {
  43545. /** @hidden */
  43546. export class _OcclusionDataStorage {
  43547. /** @hidden */
  43548. occlusionInternalRetryCounter: number;
  43549. /** @hidden */
  43550. isOcclusionQueryInProgress: boolean;
  43551. /** @hidden */
  43552. isOccluded: boolean;
  43553. /** @hidden */
  43554. occlusionRetryCount: number;
  43555. /** @hidden */
  43556. occlusionType: number;
  43557. /** @hidden */
  43558. occlusionQueryAlgorithmType: number;
  43559. }
  43560. interface Engine {
  43561. /**
  43562. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43563. * @return the new query
  43564. */
  43565. createQuery(): WebGLQuery;
  43566. /**
  43567. * Delete and release a webGL query
  43568. * @param query defines the query to delete
  43569. * @return the current engine
  43570. */
  43571. deleteQuery(query: WebGLQuery): Engine;
  43572. /**
  43573. * Check if a given query has resolved and got its value
  43574. * @param query defines the query to check
  43575. * @returns true if the query got its value
  43576. */
  43577. isQueryResultAvailable(query: WebGLQuery): boolean;
  43578. /**
  43579. * Gets the value of a given query
  43580. * @param query defines the query to check
  43581. * @returns the value of the query
  43582. */
  43583. getQueryResult(query: WebGLQuery): number;
  43584. /**
  43585. * Initiates an occlusion query
  43586. * @param algorithmType defines the algorithm to use
  43587. * @param query defines the query to use
  43588. * @returns the current engine
  43589. * @see http://doc.babylonjs.com/features/occlusionquery
  43590. */
  43591. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43592. /**
  43593. * Ends an occlusion query
  43594. * @see http://doc.babylonjs.com/features/occlusionquery
  43595. * @param algorithmType defines the algorithm to use
  43596. * @returns the current engine
  43597. */
  43598. endOcclusionQuery(algorithmType: number): Engine;
  43599. /**
  43600. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43601. * Please note that only one query can be issued at a time
  43602. * @returns a time token used to track the time span
  43603. */
  43604. startTimeQuery(): Nullable<_TimeToken>;
  43605. /**
  43606. * Ends a time query
  43607. * @param token defines the token used to measure the time span
  43608. * @returns the time spent (in ns)
  43609. */
  43610. endTimeQuery(token: _TimeToken): int;
  43611. /** @hidden */
  43612. _currentNonTimestampToken: Nullable<_TimeToken>;
  43613. /** @hidden */
  43614. _createTimeQuery(): WebGLQuery;
  43615. /** @hidden */
  43616. _deleteTimeQuery(query: WebGLQuery): void;
  43617. /** @hidden */
  43618. _getGlAlgorithmType(algorithmType: number): number;
  43619. /** @hidden */
  43620. _getTimeQueryResult(query: WebGLQuery): any;
  43621. /** @hidden */
  43622. _getTimeQueryAvailability(query: WebGLQuery): any;
  43623. }
  43624. interface AbstractMesh {
  43625. /**
  43626. * Backing filed
  43627. * @hidden
  43628. */
  43629. __occlusionDataStorage: _OcclusionDataStorage;
  43630. /**
  43631. * Access property
  43632. * @hidden
  43633. */
  43634. _occlusionDataStorage: _OcclusionDataStorage;
  43635. /**
  43636. * 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.
  43637. * The default value is -1 which means don't break the query and wait till the result
  43638. * @see http://doc.babylonjs.com/features/occlusionquery
  43639. */
  43640. occlusionRetryCount: number;
  43641. /**
  43642. * 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:
  43643. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43644. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43645. * * 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.
  43646. * @see http://doc.babylonjs.com/features/occlusionquery
  43647. */
  43648. occlusionType: number;
  43649. /**
  43650. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43651. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43652. * * 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.
  43653. * @see http://doc.babylonjs.com/features/occlusionquery
  43654. */
  43655. occlusionQueryAlgorithmType: number;
  43656. /**
  43657. * 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
  43658. * @see http://doc.babylonjs.com/features/occlusionquery
  43659. */
  43660. isOccluded: boolean;
  43661. /**
  43662. * Flag to check the progress status of the query
  43663. * @see http://doc.babylonjs.com/features/occlusionquery
  43664. */
  43665. isOcclusionQueryInProgress: boolean;
  43666. }
  43667. }
  43668. declare module BABYLON {
  43669. /** @hidden */
  43670. export var _forceTransformFeedbackToBundle: boolean;
  43671. interface Engine {
  43672. /**
  43673. * Creates a webGL transform feedback object
  43674. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43675. * @returns the webGL transform feedback object
  43676. */
  43677. createTransformFeedback(): WebGLTransformFeedback;
  43678. /**
  43679. * Delete a webGL transform feedback object
  43680. * @param value defines the webGL transform feedback object to delete
  43681. */
  43682. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43683. /**
  43684. * Bind a webGL transform feedback object to the webgl context
  43685. * @param value defines the webGL transform feedback object to bind
  43686. */
  43687. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43688. /**
  43689. * Begins a transform feedback operation
  43690. * @param usePoints defines if points or triangles must be used
  43691. */
  43692. beginTransformFeedback(usePoints: boolean): void;
  43693. /**
  43694. * Ends a transform feedback operation
  43695. */
  43696. endTransformFeedback(): void;
  43697. /**
  43698. * Specify the varyings to use with transform feedback
  43699. * @param program defines the associated webGL program
  43700. * @param value defines the list of strings representing the varying names
  43701. */
  43702. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43703. /**
  43704. * Bind a webGL buffer for a transform feedback operation
  43705. * @param value defines the webGL buffer to bind
  43706. */
  43707. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43708. }
  43709. }
  43710. declare module BABYLON {
  43711. /**
  43712. * Creation options of the multi render target texture.
  43713. */
  43714. export interface IMultiRenderTargetOptions {
  43715. /**
  43716. * Define if the texture needs to create mip maps after render.
  43717. */
  43718. generateMipMaps?: boolean;
  43719. /**
  43720. * Define the types of all the draw buffers we want to create
  43721. */
  43722. types?: number[];
  43723. /**
  43724. * Define the sampling modes of all the draw buffers we want to create
  43725. */
  43726. samplingModes?: number[];
  43727. /**
  43728. * Define if a depth buffer is required
  43729. */
  43730. generateDepthBuffer?: boolean;
  43731. /**
  43732. * Define if a stencil buffer is required
  43733. */
  43734. generateStencilBuffer?: boolean;
  43735. /**
  43736. * Define if a depth texture is required instead of a depth buffer
  43737. */
  43738. generateDepthTexture?: boolean;
  43739. /**
  43740. * Define the number of desired draw buffers
  43741. */
  43742. textureCount?: number;
  43743. /**
  43744. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43745. */
  43746. doNotChangeAspectRatio?: boolean;
  43747. /**
  43748. * Define the default type of the buffers we are creating
  43749. */
  43750. defaultType?: number;
  43751. }
  43752. /**
  43753. * A multi render target, like a render target provides the ability to render to a texture.
  43754. * Unlike the render target, it can render to several draw buffers in one draw.
  43755. * This is specially interesting in deferred rendering or for any effects requiring more than
  43756. * just one color from a single pass.
  43757. */
  43758. export class MultiRenderTarget extends RenderTargetTexture {
  43759. private _internalTextures;
  43760. private _textures;
  43761. private _multiRenderTargetOptions;
  43762. /**
  43763. * Get if draw buffers are currently supported by the used hardware and browser.
  43764. */
  43765. readonly isSupported: boolean;
  43766. /**
  43767. * Get the list of textures generated by the multi render target.
  43768. */
  43769. readonly textures: Texture[];
  43770. /**
  43771. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43772. */
  43773. readonly depthTexture: Texture;
  43774. /**
  43775. * Set the wrapping mode on U of all the textures we are rendering to.
  43776. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43777. */
  43778. wrapU: number;
  43779. /**
  43780. * Set the wrapping mode on V of all the textures we are rendering to.
  43781. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43782. */
  43783. wrapV: number;
  43784. /**
  43785. * Instantiate a new multi render target texture.
  43786. * A multi render target, like a render target provides the ability to render to a texture.
  43787. * Unlike the render target, it can render to several draw buffers in one draw.
  43788. * This is specially interesting in deferred rendering or for any effects requiring more than
  43789. * just one color from a single pass.
  43790. * @param name Define the name of the texture
  43791. * @param size Define the size of the buffers to render to
  43792. * @param count Define the number of target we are rendering into
  43793. * @param scene Define the scene the texture belongs to
  43794. * @param options Define the options used to create the multi render target
  43795. */
  43796. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43797. /** @hidden */
  43798. _rebuild(): void;
  43799. private _createInternalTextures;
  43800. private _createTextures;
  43801. /**
  43802. * Define the number of samples used if MSAA is enabled.
  43803. */
  43804. samples: number;
  43805. /**
  43806. * Resize all the textures in the multi render target.
  43807. * Be carrefull as it will recreate all the data in the new texture.
  43808. * @param size Define the new size
  43809. */
  43810. resize(size: any): void;
  43811. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43812. /**
  43813. * Dispose the render targets and their associated resources
  43814. */
  43815. dispose(): void;
  43816. /**
  43817. * Release all the underlying texture used as draw buffers.
  43818. */
  43819. releaseInternalTextures(): void;
  43820. }
  43821. }
  43822. declare module BABYLON {
  43823. interface Engine {
  43824. /**
  43825. * Unbind a list of render target textures from the webGL context
  43826. * This is used only when drawBuffer extension or webGL2 are active
  43827. * @param textures defines the render target textures to unbind
  43828. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43829. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43830. */
  43831. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43832. /**
  43833. * Create a multi render target texture
  43834. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43835. * @param size defines the size of the texture
  43836. * @param options defines the creation options
  43837. * @returns the cube texture as an InternalTexture
  43838. */
  43839. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43840. /**
  43841. * Update the sample count for a given multiple render target texture
  43842. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43843. * @param textures defines the textures to update
  43844. * @param samples defines the sample count to set
  43845. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43846. */
  43847. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43848. }
  43849. }
  43850. declare module BABYLON {
  43851. /** @hidden */
  43852. export var rgbdEncodePixelShader: {
  43853. name: string;
  43854. shader: string;
  43855. };
  43856. }
  43857. declare module BABYLON {
  43858. /** @hidden */
  43859. export var rgbdDecodePixelShader: {
  43860. name: string;
  43861. shader: string;
  43862. };
  43863. }
  43864. declare module BABYLON {
  43865. /**
  43866. * Raw texture data and descriptor sufficient for WebGL texture upload
  43867. */
  43868. export interface EnvironmentTextureInfo {
  43869. /**
  43870. * Version of the environment map
  43871. */
  43872. version: number;
  43873. /**
  43874. * Width of image
  43875. */
  43876. width: number;
  43877. /**
  43878. * Irradiance information stored in the file.
  43879. */
  43880. irradiance: any;
  43881. /**
  43882. * Specular information stored in the file.
  43883. */
  43884. specular: any;
  43885. }
  43886. /**
  43887. * Defines One Image in the file. It requires only the position in the file
  43888. * as well as the length.
  43889. */
  43890. interface BufferImageData {
  43891. /**
  43892. * Length of the image data.
  43893. */
  43894. length: number;
  43895. /**
  43896. * Position of the data from the null terminator delimiting the end of the JSON.
  43897. */
  43898. position: number;
  43899. }
  43900. /**
  43901. * Defines the specular data enclosed in the file.
  43902. * This corresponds to the version 1 of the data.
  43903. */
  43904. export interface EnvironmentTextureSpecularInfoV1 {
  43905. /**
  43906. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  43907. */
  43908. specularDataPosition?: number;
  43909. /**
  43910. * This contains all the images data needed to reconstruct the cubemap.
  43911. */
  43912. mipmaps: Array<BufferImageData>;
  43913. /**
  43914. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  43915. */
  43916. lodGenerationScale: number;
  43917. }
  43918. /**
  43919. * Sets of helpers addressing the serialization and deserialization of environment texture
  43920. * stored in a BabylonJS env file.
  43921. * Those files are usually stored as .env files.
  43922. */
  43923. export class EnvironmentTextureTools {
  43924. /**
  43925. * Magic number identifying the env file.
  43926. */
  43927. private static _MagicBytes;
  43928. /**
  43929. * Gets the environment info from an env file.
  43930. * @param data The array buffer containing the .env bytes.
  43931. * @returns the environment file info (the json header) if successfully parsed.
  43932. */
  43933. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  43934. /**
  43935. * Creates an environment texture from a loaded cube texture.
  43936. * @param texture defines the cube texture to convert in env file
  43937. * @return a promise containing the environment data if succesfull.
  43938. */
  43939. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  43940. /**
  43941. * Creates a JSON representation of the spherical data.
  43942. * @param texture defines the texture containing the polynomials
  43943. * @return the JSON representation of the spherical info
  43944. */
  43945. private static _CreateEnvTextureIrradiance;
  43946. /**
  43947. * Creates the ArrayBufferViews used for initializing environment texture image data.
  43948. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  43949. * @param info parameters that determine what views will be created for accessing the underlying buffer
  43950. * @return the views described by info providing access to the underlying buffer
  43951. */
  43952. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  43953. /**
  43954. * Uploads the texture info contained in the env file to the GPU.
  43955. * @param texture defines the internal texture to upload to
  43956. * @param arrayBuffer defines the buffer cotaining the data to load
  43957. * @param info defines the texture info retrieved through the GetEnvInfo method
  43958. * @returns a promise
  43959. */
  43960. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  43961. /**
  43962. * Uploads the levels of image data to the GPU.
  43963. * @param texture defines the internal texture to upload to
  43964. * @param imageData defines the array buffer views of image data [mipmap][face]
  43965. * @returns a promise
  43966. */
  43967. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  43968. /**
  43969. * Uploads spherical polynomials information to the texture.
  43970. * @param texture defines the texture we are trying to upload the information to
  43971. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  43972. */
  43973. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  43974. /** @hidden */
  43975. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  43976. }
  43977. }
  43978. declare module BABYLON {
  43979. /**
  43980. * Contains position and normal vectors for a vertex
  43981. */
  43982. export class PositionNormalVertex {
  43983. /** the position of the vertex (defaut: 0,0,0) */
  43984. position: Vector3;
  43985. /** the normal of the vertex (defaut: 0,1,0) */
  43986. normal: Vector3;
  43987. /**
  43988. * Creates a PositionNormalVertex
  43989. * @param position the position of the vertex (defaut: 0,0,0)
  43990. * @param normal the normal of the vertex (defaut: 0,1,0)
  43991. */
  43992. constructor(
  43993. /** the position of the vertex (defaut: 0,0,0) */
  43994. position?: Vector3,
  43995. /** the normal of the vertex (defaut: 0,1,0) */
  43996. normal?: Vector3);
  43997. /**
  43998. * Clones the PositionNormalVertex
  43999. * @returns the cloned PositionNormalVertex
  44000. */
  44001. clone(): PositionNormalVertex;
  44002. }
  44003. /**
  44004. * Contains position, normal and uv vectors for a vertex
  44005. */
  44006. export class PositionNormalTextureVertex {
  44007. /** the position of the vertex (defaut: 0,0,0) */
  44008. position: Vector3;
  44009. /** the normal of the vertex (defaut: 0,1,0) */
  44010. normal: Vector3;
  44011. /** the uv of the vertex (default: 0,0) */
  44012. uv: Vector2;
  44013. /**
  44014. * Creates a PositionNormalTextureVertex
  44015. * @param position the position of the vertex (defaut: 0,0,0)
  44016. * @param normal the normal of the vertex (defaut: 0,1,0)
  44017. * @param uv the uv of the vertex (default: 0,0)
  44018. */
  44019. constructor(
  44020. /** the position of the vertex (defaut: 0,0,0) */
  44021. position?: Vector3,
  44022. /** the normal of the vertex (defaut: 0,1,0) */
  44023. normal?: Vector3,
  44024. /** the uv of the vertex (default: 0,0) */
  44025. uv?: Vector2);
  44026. /**
  44027. * Clones the PositionNormalTextureVertex
  44028. * @returns the cloned PositionNormalTextureVertex
  44029. */
  44030. clone(): PositionNormalTextureVertex;
  44031. }
  44032. }
  44033. declare module BABYLON {
  44034. /** @hidden */
  44035. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44036. private _genericAttributeLocation;
  44037. private _varyingLocationCount;
  44038. private _varyingLocationMap;
  44039. private _replacements;
  44040. private _textureCount;
  44041. private _uniforms;
  44042. lineProcessor(line: string): string;
  44043. attributeProcessor(attribute: string): string;
  44044. varyingProcessor(varying: string, isFragment: boolean): string;
  44045. uniformProcessor(uniform: string): string;
  44046. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44047. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44048. }
  44049. }
  44050. declare module BABYLON {
  44051. /**
  44052. * Container for accessors for natively-stored mesh data buffers.
  44053. */
  44054. class NativeDataBuffer extends DataBuffer {
  44055. /**
  44056. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44057. */
  44058. nativeIndexBuffer?: any;
  44059. /**
  44060. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44061. */
  44062. nativeVertexBuffer?: any;
  44063. }
  44064. /** @hidden */
  44065. export class NativeEngine extends Engine {
  44066. private readonly _native;
  44067. getHardwareScalingLevel(): number;
  44068. constructor();
  44069. /**
  44070. * Can be used to override the current requestAnimationFrame requester.
  44071. * @hidden
  44072. */
  44073. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  44074. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44075. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44076. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44077. recordVertexArrayObject(vertexBuffers: {
  44078. [key: string]: VertexBuffer;
  44079. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44080. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44081. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44082. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44083. /**
  44084. * Draw a list of indexed primitives
  44085. * @param fillMode defines the primitive to use
  44086. * @param indexStart defines the starting index
  44087. * @param indexCount defines the number of index to draw
  44088. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44089. */
  44090. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44091. /**
  44092. * Draw a list of unindexed primitives
  44093. * @param fillMode defines the primitive to use
  44094. * @param verticesStart defines the index of first vertex to draw
  44095. * @param verticesCount defines the count of vertices to draw
  44096. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44097. */
  44098. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44099. createPipelineContext(): IPipelineContext;
  44100. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44101. /** @hidden */
  44102. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44103. /** @hidden */
  44104. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44105. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44106. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44107. protected _setProgram(program: WebGLProgram): void;
  44108. _releaseEffect(effect: Effect): void;
  44109. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44110. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44111. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44112. bindSamplers(effect: Effect): void;
  44113. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44114. getRenderWidth(useScreen?: boolean): number;
  44115. getRenderHeight(useScreen?: boolean): number;
  44116. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44117. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44118. /**
  44119. * Set the z offset to apply to current rendering
  44120. * @param value defines the offset to apply
  44121. */
  44122. setZOffset(value: number): void;
  44123. /**
  44124. * Gets the current value of the zOffset
  44125. * @returns the current zOffset state
  44126. */
  44127. getZOffset(): number;
  44128. /**
  44129. * Enable or disable depth buffering
  44130. * @param enable defines the state to set
  44131. */
  44132. setDepthBuffer(enable: boolean): void;
  44133. /**
  44134. * Gets a boolean indicating if depth writing is enabled
  44135. * @returns the current depth writing state
  44136. */
  44137. getDepthWrite(): boolean;
  44138. /**
  44139. * Enable or disable depth writing
  44140. * @param enable defines the state to set
  44141. */
  44142. setDepthWrite(enable: boolean): void;
  44143. /**
  44144. * Enable or disable color writing
  44145. * @param enable defines the state to set
  44146. */
  44147. setColorWrite(enable: boolean): void;
  44148. /**
  44149. * Gets a boolean indicating if color writing is enabled
  44150. * @returns the current color writing state
  44151. */
  44152. getColorWrite(): boolean;
  44153. /**
  44154. * Sets alpha constants used by some alpha blending modes
  44155. * @param r defines the red component
  44156. * @param g defines the green component
  44157. * @param b defines the blue component
  44158. * @param a defines the alpha component
  44159. */
  44160. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44161. /**
  44162. * Sets the current alpha mode
  44163. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  44164. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44165. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44166. */
  44167. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44168. /**
  44169. * Gets the current alpha mode
  44170. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44171. * @returns the current alpha mode
  44172. */
  44173. getAlphaMode(): number;
  44174. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44175. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44176. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44177. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44178. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44179. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44180. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44181. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44182. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44183. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44184. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44185. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44186. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44187. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44188. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44189. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44190. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44191. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44192. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44193. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44194. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44195. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44196. wipeCaches(bruteForce?: boolean): void;
  44197. _createTexture(): WebGLTexture;
  44198. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44199. /**
  44200. * Usually called from BABYLON.Texture.ts.
  44201. * Passed information to create a WebGLTexture
  44202. * @param urlArg defines a value which contains one of the following:
  44203. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44204. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44205. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44206. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44207. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44208. * @param scene needed for loading to the correct scene
  44209. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44210. * @param onLoad optional callback to be called upon successful completion
  44211. * @param onError optional callback to be called upon failure
  44212. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44213. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44214. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44215. * @param forcedExtension defines the extension to use to pick the right loader
  44216. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44217. */
  44218. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  44219. /**
  44220. * Creates a cube texture
  44221. * @param rootUrl defines the url where the files to load is located
  44222. * @param scene defines the current scene
  44223. * @param files defines the list of files to load (1 per face)
  44224. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44225. * @param onLoad defines an optional callback raised when the texture is loaded
  44226. * @param onError defines an optional callback raised if there is an issue to load the texture
  44227. * @param format defines the format of the data
  44228. * @param forcedExtension defines the extension to use to pick the right loader
  44229. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44230. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44231. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44232. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44233. * @returns the cube texture as an InternalTexture
  44234. */
  44235. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  44236. private _getSamplingFilter;
  44237. private static _GetNativeTextureFormat;
  44238. createRenderTargetTexture(size: number | {
  44239. width: number;
  44240. height: number;
  44241. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44242. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44243. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44244. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44245. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44246. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44247. /**
  44248. * Updates a dynamic vertex buffer.
  44249. * @param vertexBuffer the vertex buffer to update
  44250. * @param data the data used to update the vertex buffer
  44251. * @param byteOffset the byte offset of the data (optional)
  44252. * @param byteLength the byte length of the data (optional)
  44253. */
  44254. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44255. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44256. private _updateAnisotropicLevel;
  44257. private _getAddressMode;
  44258. /** @hidden */
  44259. _bindTexture(channel: number, texture: InternalTexture): void;
  44260. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44261. releaseEffects(): void;
  44262. /** @hidden */
  44263. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44264. /** @hidden */
  44265. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44266. /** @hidden */
  44267. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44268. /** @hidden */
  44269. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44270. }
  44271. }
  44272. declare module BABYLON {
  44273. /**
  44274. * Gather the list of clipboard event types as constants.
  44275. */
  44276. export class ClipboardEventTypes {
  44277. /**
  44278. * The clipboard event is fired when a copy command is active (pressed).
  44279. */
  44280. static readonly COPY: number;
  44281. /**
  44282. * The clipboard event is fired when a cut command is active (pressed).
  44283. */
  44284. static readonly CUT: number;
  44285. /**
  44286. * The clipboard event is fired when a paste command is active (pressed).
  44287. */
  44288. static readonly PASTE: number;
  44289. }
  44290. /**
  44291. * This class is used to store clipboard related info for the onClipboardObservable event.
  44292. */
  44293. export class ClipboardInfo {
  44294. /**
  44295. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44296. */
  44297. type: number;
  44298. /**
  44299. * Defines the related dom event
  44300. */
  44301. event: ClipboardEvent;
  44302. /**
  44303. *Creates an instance of ClipboardInfo.
  44304. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44305. * @param event Defines the related dom event
  44306. */
  44307. constructor(
  44308. /**
  44309. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44310. */
  44311. type: number,
  44312. /**
  44313. * Defines the related dom event
  44314. */
  44315. event: ClipboardEvent);
  44316. /**
  44317. * Get the clipboard event's type from the keycode.
  44318. * @param keyCode Defines the keyCode for the current keyboard event.
  44319. * @return {number}
  44320. */
  44321. static GetTypeFromCharacter(keyCode: number): number;
  44322. }
  44323. }
  44324. declare module BABYLON {
  44325. /**
  44326. * Google Daydream controller
  44327. */
  44328. export class DaydreamController extends WebVRController {
  44329. /**
  44330. * Base Url for the controller model.
  44331. */
  44332. static MODEL_BASE_URL: string;
  44333. /**
  44334. * File name for the controller model.
  44335. */
  44336. static MODEL_FILENAME: string;
  44337. /**
  44338. * Gamepad Id prefix used to identify Daydream Controller.
  44339. */
  44340. static readonly GAMEPAD_ID_PREFIX: string;
  44341. /**
  44342. * Creates a new DaydreamController from a gamepad
  44343. * @param vrGamepad the gamepad that the controller should be created from
  44344. */
  44345. constructor(vrGamepad: any);
  44346. /**
  44347. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44348. * @param scene scene in which to add meshes
  44349. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44350. */
  44351. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44352. /**
  44353. * Called once for each button that changed state since the last frame
  44354. * @param buttonIdx Which button index changed
  44355. * @param state New state of the button
  44356. * @param changes Which properties on the state changed since last frame
  44357. */
  44358. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44359. }
  44360. }
  44361. declare module BABYLON {
  44362. /**
  44363. * Gear VR Controller
  44364. */
  44365. export class GearVRController extends WebVRController {
  44366. /**
  44367. * Base Url for the controller model.
  44368. */
  44369. static MODEL_BASE_URL: string;
  44370. /**
  44371. * File name for the controller model.
  44372. */
  44373. static MODEL_FILENAME: string;
  44374. /**
  44375. * Gamepad Id prefix used to identify this controller.
  44376. */
  44377. static readonly GAMEPAD_ID_PREFIX: string;
  44378. private readonly _buttonIndexToObservableNameMap;
  44379. /**
  44380. * Creates a new GearVRController from a gamepad
  44381. * @param vrGamepad the gamepad that the controller should be created from
  44382. */
  44383. constructor(vrGamepad: any);
  44384. /**
  44385. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44386. * @param scene scene in which to add meshes
  44387. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44388. */
  44389. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44390. /**
  44391. * Called once for each button that changed state since the last frame
  44392. * @param buttonIdx Which button index changed
  44393. * @param state New state of the button
  44394. * @param changes Which properties on the state changed since last frame
  44395. */
  44396. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44397. }
  44398. }
  44399. declare module BABYLON {
  44400. /**
  44401. * Class containing static functions to help procedurally build meshes
  44402. */
  44403. export class PolyhedronBuilder {
  44404. /**
  44405. * Creates a polyhedron mesh
  44406. * * 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
  44407. * * The parameter `size` (positive float, default 1) sets the polygon size
  44408. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44409. * * 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`
  44410. * * 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
  44411. * * 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)`)
  44412. * * 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
  44413. * * 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
  44414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44415. * * 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
  44416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44417. * @param name defines the name of the mesh
  44418. * @param options defines the options used to create the mesh
  44419. * @param scene defines the hosting scene
  44420. * @returns the polyhedron mesh
  44421. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44422. */
  44423. static CreatePolyhedron(name: string, options: {
  44424. type?: number;
  44425. size?: number;
  44426. sizeX?: number;
  44427. sizeY?: number;
  44428. sizeZ?: number;
  44429. custom?: any;
  44430. faceUV?: Vector4[];
  44431. faceColors?: Color4[];
  44432. flat?: boolean;
  44433. updatable?: boolean;
  44434. sideOrientation?: number;
  44435. frontUVs?: Vector4;
  44436. backUVs?: Vector4;
  44437. }, scene?: Nullable<Scene>): Mesh;
  44438. }
  44439. }
  44440. declare module BABYLON {
  44441. /**
  44442. * Gizmo that enables scaling a mesh along 3 axis
  44443. */
  44444. export class ScaleGizmo extends Gizmo {
  44445. /**
  44446. * Internal gizmo used for interactions on the x axis
  44447. */
  44448. xGizmo: AxisScaleGizmo;
  44449. /**
  44450. * Internal gizmo used for interactions on the y axis
  44451. */
  44452. yGizmo: AxisScaleGizmo;
  44453. /**
  44454. * Internal gizmo used for interactions on the z axis
  44455. */
  44456. zGizmo: AxisScaleGizmo;
  44457. /**
  44458. * Internal gizmo used to scale all axis equally
  44459. */
  44460. uniformScaleGizmo: AxisScaleGizmo;
  44461. private _meshAttached;
  44462. private _updateGizmoRotationToMatchAttachedMesh;
  44463. private _snapDistance;
  44464. private _scaleRatio;
  44465. private _uniformScalingMesh;
  44466. private _octahedron;
  44467. /** Fires an event when any of it's sub gizmos are dragged */
  44468. onDragStartObservable: Observable<unknown>;
  44469. /** Fires an event when any of it's sub gizmos are released from dragging */
  44470. onDragEndObservable: Observable<unknown>;
  44471. attachedMesh: Nullable<AbstractMesh>;
  44472. /**
  44473. * Creates a ScaleGizmo
  44474. * @param gizmoLayer The utility layer the gizmo will be added to
  44475. */
  44476. constructor(gizmoLayer?: UtilityLayerRenderer);
  44477. updateGizmoRotationToMatchAttachedMesh: boolean;
  44478. /**
  44479. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44480. */
  44481. snapDistance: number;
  44482. /**
  44483. * Ratio for the scale of the gizmo (Default: 1)
  44484. */
  44485. scaleRatio: number;
  44486. /**
  44487. * Disposes of the gizmo
  44488. */
  44489. dispose(): void;
  44490. }
  44491. }
  44492. declare module BABYLON {
  44493. /**
  44494. * Single axis scale gizmo
  44495. */
  44496. export class AxisScaleGizmo extends Gizmo {
  44497. /**
  44498. * Drag behavior responsible for the gizmos dragging interactions
  44499. */
  44500. dragBehavior: PointerDragBehavior;
  44501. private _pointerObserver;
  44502. /**
  44503. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44504. */
  44505. snapDistance: number;
  44506. /**
  44507. * Event that fires each time the gizmo snaps to a new location.
  44508. * * snapDistance is the the change in distance
  44509. */
  44510. onSnapObservable: Observable<{
  44511. snapDistance: number;
  44512. }>;
  44513. /**
  44514. * If the scaling operation should be done on all axis (default: false)
  44515. */
  44516. uniformScaling: boolean;
  44517. private _isEnabled;
  44518. private _parent;
  44519. private _arrow;
  44520. private _coloredMaterial;
  44521. private _hoverMaterial;
  44522. /**
  44523. * Creates an AxisScaleGizmo
  44524. * @param gizmoLayer The utility layer the gizmo will be added to
  44525. * @param dragAxis The axis which the gizmo will be able to scale on
  44526. * @param color The color of the gizmo
  44527. */
  44528. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44529. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44530. /**
  44531. * If the gizmo is enabled
  44532. */
  44533. isEnabled: boolean;
  44534. /**
  44535. * Disposes of the gizmo
  44536. */
  44537. dispose(): void;
  44538. /**
  44539. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44540. * @param mesh The mesh to replace the default mesh of the gizmo
  44541. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44542. */
  44543. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44544. }
  44545. }
  44546. declare module BABYLON {
  44547. /**
  44548. * Bounding box gizmo
  44549. */
  44550. export class BoundingBoxGizmo extends Gizmo {
  44551. private _lineBoundingBox;
  44552. private _rotateSpheresParent;
  44553. private _scaleBoxesParent;
  44554. private _boundingDimensions;
  44555. private _renderObserver;
  44556. private _pointerObserver;
  44557. private _scaleDragSpeed;
  44558. private _tmpQuaternion;
  44559. private _tmpVector;
  44560. private _tmpRotationMatrix;
  44561. /**
  44562. * 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)
  44563. */
  44564. ignoreChildren: boolean;
  44565. /**
  44566. * 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)
  44567. */
  44568. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44569. /**
  44570. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44571. */
  44572. rotationSphereSize: number;
  44573. /**
  44574. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44575. */
  44576. scaleBoxSize: number;
  44577. /**
  44578. * 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)
  44579. */
  44580. fixedDragMeshScreenSize: boolean;
  44581. /**
  44582. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44583. */
  44584. fixedDragMeshScreenSizeDistanceFactor: number;
  44585. /**
  44586. * Fired when a rotation sphere or scale box is dragged
  44587. */
  44588. onDragStartObservable: Observable<{}>;
  44589. /**
  44590. * Fired when a scale box is dragged
  44591. */
  44592. onScaleBoxDragObservable: Observable<{}>;
  44593. /**
  44594. * Fired when a scale box drag is ended
  44595. */
  44596. onScaleBoxDragEndObservable: Observable<{}>;
  44597. /**
  44598. * Fired when a rotation sphere is dragged
  44599. */
  44600. onRotationSphereDragObservable: Observable<{}>;
  44601. /**
  44602. * Fired when a rotation sphere drag is ended
  44603. */
  44604. onRotationSphereDragEndObservable: Observable<{}>;
  44605. /**
  44606. * 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)
  44607. */
  44608. scalePivot: Nullable<Vector3>;
  44609. /**
  44610. * Mesh used as a pivot to rotate the attached mesh
  44611. */
  44612. private _anchorMesh;
  44613. private _existingMeshScale;
  44614. private _dragMesh;
  44615. private pointerDragBehavior;
  44616. private coloredMaterial;
  44617. private hoverColoredMaterial;
  44618. /**
  44619. * Sets the color of the bounding box gizmo
  44620. * @param color the color to set
  44621. */
  44622. setColor(color: Color3): void;
  44623. /**
  44624. * Creates an BoundingBoxGizmo
  44625. * @param gizmoLayer The utility layer the gizmo will be added to
  44626. * @param color The color of the gizmo
  44627. */
  44628. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44629. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44630. private _selectNode;
  44631. /**
  44632. * Updates the bounding box information for the Gizmo
  44633. */
  44634. updateBoundingBox(): void;
  44635. private _updateRotationSpheres;
  44636. private _updateScaleBoxes;
  44637. /**
  44638. * Enables rotation on the specified axis and disables rotation on the others
  44639. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44640. */
  44641. setEnabledRotationAxis(axis: string): void;
  44642. /**
  44643. * Enables/disables scaling
  44644. * @param enable if scaling should be enabled
  44645. */
  44646. setEnabledScaling(enable: boolean): void;
  44647. private _updateDummy;
  44648. /**
  44649. * Enables a pointer drag behavior on the bounding box of the gizmo
  44650. */
  44651. enableDragBehavior(): void;
  44652. /**
  44653. * Disposes of the gizmo
  44654. */
  44655. dispose(): void;
  44656. /**
  44657. * 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)
  44658. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44659. * @returns the bounding box mesh with the passed in mesh as a child
  44660. */
  44661. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44662. /**
  44663. * CustomMeshes are not supported by this gizmo
  44664. * @param mesh The mesh to replace the default mesh of the gizmo
  44665. */
  44666. setCustomMesh(mesh: Mesh): void;
  44667. }
  44668. }
  44669. declare module BABYLON {
  44670. /**
  44671. * Single plane rotation gizmo
  44672. */
  44673. export class PlaneRotationGizmo extends Gizmo {
  44674. /**
  44675. * Drag behavior responsible for the gizmos dragging interactions
  44676. */
  44677. dragBehavior: PointerDragBehavior;
  44678. private _pointerObserver;
  44679. /**
  44680. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44681. */
  44682. snapDistance: number;
  44683. /**
  44684. * Event that fires each time the gizmo snaps to a new location.
  44685. * * snapDistance is the the change in distance
  44686. */
  44687. onSnapObservable: Observable<{
  44688. snapDistance: number;
  44689. }>;
  44690. private _isEnabled;
  44691. private _parent;
  44692. /**
  44693. * Creates a PlaneRotationGizmo
  44694. * @param gizmoLayer The utility layer the gizmo will be added to
  44695. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44696. * @param color The color of the gizmo
  44697. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44698. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44699. */
  44700. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  44701. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44702. /**
  44703. * If the gizmo is enabled
  44704. */
  44705. isEnabled: boolean;
  44706. /**
  44707. * Disposes of the gizmo
  44708. */
  44709. dispose(): void;
  44710. }
  44711. }
  44712. declare module BABYLON {
  44713. /**
  44714. * Gizmo that enables rotating a mesh along 3 axis
  44715. */
  44716. export class RotationGizmo extends Gizmo {
  44717. /**
  44718. * Internal gizmo used for interactions on the x axis
  44719. */
  44720. xGizmo: PlaneRotationGizmo;
  44721. /**
  44722. * Internal gizmo used for interactions on the y axis
  44723. */
  44724. yGizmo: PlaneRotationGizmo;
  44725. /**
  44726. * Internal gizmo used for interactions on the z axis
  44727. */
  44728. zGizmo: PlaneRotationGizmo;
  44729. /** Fires an event when any of it's sub gizmos are dragged */
  44730. onDragStartObservable: Observable<unknown>;
  44731. /** Fires an event when any of it's sub gizmos are released from dragging */
  44732. onDragEndObservable: Observable<unknown>;
  44733. private _meshAttached;
  44734. attachedMesh: Nullable<AbstractMesh>;
  44735. /**
  44736. * Creates a RotationGizmo
  44737. * @param gizmoLayer The utility layer the gizmo will be added to
  44738. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44739. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44740. */
  44741. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  44742. updateGizmoRotationToMatchAttachedMesh: boolean;
  44743. /**
  44744. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44745. */
  44746. snapDistance: number;
  44747. /**
  44748. * Ratio for the scale of the gizmo (Default: 1)
  44749. */
  44750. scaleRatio: number;
  44751. /**
  44752. * Disposes of the gizmo
  44753. */
  44754. dispose(): void;
  44755. /**
  44756. * CustomMeshes are not supported by this gizmo
  44757. * @param mesh The mesh to replace the default mesh of the gizmo
  44758. */
  44759. setCustomMesh(mesh: Mesh): void;
  44760. }
  44761. }
  44762. declare module BABYLON {
  44763. /**
  44764. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44765. */
  44766. export class GizmoManager implements IDisposable {
  44767. private scene;
  44768. /**
  44769. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44770. */
  44771. gizmos: {
  44772. positionGizmo: Nullable<PositionGizmo>;
  44773. rotationGizmo: Nullable<RotationGizmo>;
  44774. scaleGizmo: Nullable<ScaleGizmo>;
  44775. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44776. };
  44777. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44778. clearGizmoOnEmptyPointerEvent: boolean;
  44779. /** Fires an event when the manager is attached to a mesh */
  44780. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44781. private _gizmosEnabled;
  44782. private _pointerObserver;
  44783. private _attachedMesh;
  44784. private _boundingBoxColor;
  44785. private _defaultUtilityLayer;
  44786. private _defaultKeepDepthUtilityLayer;
  44787. /**
  44788. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44789. */
  44790. boundingBoxDragBehavior: SixDofDragBehavior;
  44791. /**
  44792. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44793. */
  44794. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44795. /**
  44796. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44797. */
  44798. usePointerToAttachGizmos: boolean;
  44799. /**
  44800. * Utility layer that the bounding box gizmo belongs to
  44801. */
  44802. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  44803. /**
  44804. * Utility layer that all gizmos besides bounding box belong to
  44805. */
  44806. readonly utilityLayer: UtilityLayerRenderer;
  44807. /**
  44808. * Instatiates a gizmo manager
  44809. * @param scene the scene to overlay the gizmos on top of
  44810. */
  44811. constructor(scene: Scene);
  44812. /**
  44813. * Attaches a set of gizmos to the specified mesh
  44814. * @param mesh The mesh the gizmo's should be attached to
  44815. */
  44816. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44817. /**
  44818. * If the position gizmo is enabled
  44819. */
  44820. positionGizmoEnabled: boolean;
  44821. /**
  44822. * If the rotation gizmo is enabled
  44823. */
  44824. rotationGizmoEnabled: boolean;
  44825. /**
  44826. * If the scale gizmo is enabled
  44827. */
  44828. scaleGizmoEnabled: boolean;
  44829. /**
  44830. * If the boundingBox gizmo is enabled
  44831. */
  44832. boundingBoxGizmoEnabled: boolean;
  44833. /**
  44834. * Disposes of the gizmo manager
  44835. */
  44836. dispose(): void;
  44837. }
  44838. }
  44839. declare module BABYLON {
  44840. /**
  44841. * A directional light is defined by a direction (what a surprise!).
  44842. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44843. * 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.
  44844. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44845. */
  44846. export class DirectionalLight extends ShadowLight {
  44847. private _shadowFrustumSize;
  44848. /**
  44849. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44850. */
  44851. /**
  44852. * Specifies a fix frustum size for the shadow generation.
  44853. */
  44854. shadowFrustumSize: number;
  44855. private _shadowOrthoScale;
  44856. /**
  44857. * Gets the shadow projection scale against the optimal computed one.
  44858. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44859. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44860. */
  44861. /**
  44862. * Sets the shadow projection scale against the optimal computed one.
  44863. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44864. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44865. */
  44866. shadowOrthoScale: number;
  44867. /**
  44868. * Automatically compute the projection matrix to best fit (including all the casters)
  44869. * on each frame.
  44870. */
  44871. autoUpdateExtends: boolean;
  44872. private _orthoLeft;
  44873. private _orthoRight;
  44874. private _orthoTop;
  44875. private _orthoBottom;
  44876. /**
  44877. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44878. * The directional light is emitted from everywhere in the given direction.
  44879. * It can cast shadows.
  44880. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44881. * @param name The friendly name of the light
  44882. * @param direction The direction of the light
  44883. * @param scene The scene the light belongs to
  44884. */
  44885. constructor(name: string, direction: Vector3, scene: Scene);
  44886. /**
  44887. * Returns the string "DirectionalLight".
  44888. * @return The class name
  44889. */
  44890. getClassName(): string;
  44891. /**
  44892. * Returns the integer 1.
  44893. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44894. */
  44895. getTypeID(): number;
  44896. /**
  44897. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44898. * Returns the DirectionalLight Shadow projection matrix.
  44899. */
  44900. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44901. /**
  44902. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44903. * Returns the DirectionalLight Shadow projection matrix.
  44904. */
  44905. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44906. /**
  44907. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44908. * Returns the DirectionalLight Shadow projection matrix.
  44909. */
  44910. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44911. protected _buildUniformLayout(): void;
  44912. /**
  44913. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44914. * @param effect The effect to update
  44915. * @param lightIndex The index of the light in the effect to update
  44916. * @returns The directional light
  44917. */
  44918. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44919. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  44920. /**
  44921. * Gets the minZ used for shadow according to both the scene and the light.
  44922. *
  44923. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44924. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44925. * @param activeCamera The camera we are returning the min for
  44926. * @returns the depth min z
  44927. */
  44928. getDepthMinZ(activeCamera: Camera): number;
  44929. /**
  44930. * Gets the maxZ used for shadow according to both the scene and the light.
  44931. *
  44932. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44933. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44934. * @param activeCamera The camera we are returning the max for
  44935. * @returns the depth max z
  44936. */
  44937. getDepthMaxZ(activeCamera: Camera): number;
  44938. /**
  44939. * Prepares the list of defines specific to the light type.
  44940. * @param defines the list of defines
  44941. * @param lightIndex defines the index of the light for the effect
  44942. */
  44943. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44944. }
  44945. }
  44946. declare module BABYLON {
  44947. /**
  44948. * Class containing static functions to help procedurally build meshes
  44949. */
  44950. export class HemisphereBuilder {
  44951. /**
  44952. * Creates a hemisphere mesh
  44953. * @param name defines the name of the mesh
  44954. * @param options defines the options used to create the mesh
  44955. * @param scene defines the hosting scene
  44956. * @returns the hemisphere mesh
  44957. */
  44958. static CreateHemisphere(name: string, options: {
  44959. segments?: number;
  44960. diameter?: number;
  44961. sideOrientation?: number;
  44962. }, scene: any): Mesh;
  44963. }
  44964. }
  44965. declare module BABYLON {
  44966. /**
  44967. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44968. * These values define a cone of light starting from the position, emitting toward the direction.
  44969. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44970. * and the exponent defines the speed of the decay of the light with distance (reach).
  44971. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44972. */
  44973. export class SpotLight extends ShadowLight {
  44974. private _angle;
  44975. private _innerAngle;
  44976. private _cosHalfAngle;
  44977. private _lightAngleScale;
  44978. private _lightAngleOffset;
  44979. /**
  44980. * Gets the cone angle of the spot light in Radians.
  44981. */
  44982. /**
  44983. * Sets the cone angle of the spot light in Radians.
  44984. */
  44985. angle: number;
  44986. /**
  44987. * Only used in gltf falloff mode, this defines the angle where
  44988. * the directional falloff will start before cutting at angle which could be seen
  44989. * as outer angle.
  44990. */
  44991. /**
  44992. * Only used in gltf falloff mode, this defines the angle where
  44993. * the directional falloff will start before cutting at angle which could be seen
  44994. * as outer angle.
  44995. */
  44996. innerAngle: number;
  44997. private _shadowAngleScale;
  44998. /**
  44999. * Allows scaling the angle of the light for shadow generation only.
  45000. */
  45001. /**
  45002. * Allows scaling the angle of the light for shadow generation only.
  45003. */
  45004. shadowAngleScale: number;
  45005. /**
  45006. * The light decay speed with the distance from the emission spot.
  45007. */
  45008. exponent: number;
  45009. private _projectionTextureMatrix;
  45010. /**
  45011. * Allows reading the projecton texture
  45012. */
  45013. readonly projectionTextureMatrix: Matrix;
  45014. protected _projectionTextureLightNear: number;
  45015. /**
  45016. * Gets the near clip of the Spotlight for texture projection.
  45017. */
  45018. /**
  45019. * Sets the near clip of the Spotlight for texture projection.
  45020. */
  45021. projectionTextureLightNear: number;
  45022. protected _projectionTextureLightFar: number;
  45023. /**
  45024. * Gets the far clip of the Spotlight for texture projection.
  45025. */
  45026. /**
  45027. * Sets the far clip of the Spotlight for texture projection.
  45028. */
  45029. projectionTextureLightFar: number;
  45030. protected _projectionTextureUpDirection: Vector3;
  45031. /**
  45032. * Gets the Up vector of the Spotlight for texture projection.
  45033. */
  45034. /**
  45035. * Sets the Up vector of the Spotlight for texture projection.
  45036. */
  45037. projectionTextureUpDirection: Vector3;
  45038. private _projectionTexture;
  45039. /**
  45040. * Gets the projection texture of the light.
  45041. */
  45042. /**
  45043. * Sets the projection texture of the light.
  45044. */
  45045. projectionTexture: Nullable<BaseTexture>;
  45046. private _projectionTextureViewLightDirty;
  45047. private _projectionTextureProjectionLightDirty;
  45048. private _projectionTextureDirty;
  45049. private _projectionTextureViewTargetVector;
  45050. private _projectionTextureViewLightMatrix;
  45051. private _projectionTextureProjectionLightMatrix;
  45052. private _projectionTextureScalingMatrix;
  45053. /**
  45054. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45055. * It can cast shadows.
  45056. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45057. * @param name The light friendly name
  45058. * @param position The position of the spot light in the scene
  45059. * @param direction The direction of the light in the scene
  45060. * @param angle The cone angle of the light in Radians
  45061. * @param exponent The light decay speed with the distance from the emission spot
  45062. * @param scene The scene the lights belongs to
  45063. */
  45064. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45065. /**
  45066. * Returns the string "SpotLight".
  45067. * @returns the class name
  45068. */
  45069. getClassName(): string;
  45070. /**
  45071. * Returns the integer 2.
  45072. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45073. */
  45074. getTypeID(): number;
  45075. /**
  45076. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45077. */
  45078. protected _setDirection(value: Vector3): void;
  45079. /**
  45080. * Overrides the position setter to recompute the projection texture view light Matrix.
  45081. */
  45082. protected _setPosition(value: Vector3): void;
  45083. /**
  45084. * 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.
  45085. * Returns the SpotLight.
  45086. */
  45087. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45088. protected _computeProjectionTextureViewLightMatrix(): void;
  45089. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45090. /**
  45091. * Main function for light texture projection matrix computing.
  45092. */
  45093. protected _computeProjectionTextureMatrix(): void;
  45094. protected _buildUniformLayout(): void;
  45095. private _computeAngleValues;
  45096. /**
  45097. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45098. * @param effect The effect to update
  45099. * @param lightIndex The index of the light in the effect to update
  45100. * @returns The spot light
  45101. */
  45102. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45103. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45104. /**
  45105. * Disposes the light and the associated resources.
  45106. */
  45107. dispose(): void;
  45108. /**
  45109. * Prepares the list of defines specific to the light type.
  45110. * @param defines the list of defines
  45111. * @param lightIndex defines the index of the light for the effect
  45112. */
  45113. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45114. }
  45115. }
  45116. declare module BABYLON {
  45117. /**
  45118. * Gizmo that enables viewing a light
  45119. */
  45120. export class LightGizmo extends Gizmo {
  45121. private _lightMesh;
  45122. private _material;
  45123. private cachedPosition;
  45124. private cachedForward;
  45125. /**
  45126. * Creates a LightGizmo
  45127. * @param gizmoLayer The utility layer the gizmo will be added to
  45128. */
  45129. constructor(gizmoLayer?: UtilityLayerRenderer);
  45130. private _light;
  45131. /**
  45132. * The light that the gizmo is attached to
  45133. */
  45134. light: Nullable<Light>;
  45135. /**
  45136. * Gets the material used to render the light gizmo
  45137. */
  45138. readonly material: StandardMaterial;
  45139. /**
  45140. * @hidden
  45141. * Updates the gizmo to match the attached mesh's position/rotation
  45142. */
  45143. protected _update(): void;
  45144. private static _Scale;
  45145. /**
  45146. * Creates the lines for a light mesh
  45147. */
  45148. private static _createLightLines;
  45149. /**
  45150. * Disposes of the light gizmo
  45151. */
  45152. dispose(): void;
  45153. private static _CreateHemisphericLightMesh;
  45154. private static _CreatePointLightMesh;
  45155. private static _CreateSpotLightMesh;
  45156. private static _CreateDirectionalLightMesh;
  45157. }
  45158. }
  45159. declare module BABYLON {
  45160. /** @hidden */
  45161. export var backgroundFragmentDeclaration: {
  45162. name: string;
  45163. shader: string;
  45164. };
  45165. }
  45166. declare module BABYLON {
  45167. /** @hidden */
  45168. export var backgroundUboDeclaration: {
  45169. name: string;
  45170. shader: string;
  45171. };
  45172. }
  45173. declare module BABYLON {
  45174. /** @hidden */
  45175. export var backgroundPixelShader: {
  45176. name: string;
  45177. shader: string;
  45178. };
  45179. }
  45180. declare module BABYLON {
  45181. /** @hidden */
  45182. export var backgroundVertexDeclaration: {
  45183. name: string;
  45184. shader: string;
  45185. };
  45186. }
  45187. declare module BABYLON {
  45188. /** @hidden */
  45189. export var backgroundVertexShader: {
  45190. name: string;
  45191. shader: string;
  45192. };
  45193. }
  45194. declare module BABYLON {
  45195. /**
  45196. * Background material used to create an efficient environement around your scene.
  45197. */
  45198. export class BackgroundMaterial extends PushMaterial {
  45199. /**
  45200. * Standard reflectance value at parallel view angle.
  45201. */
  45202. static StandardReflectance0: number;
  45203. /**
  45204. * Standard reflectance value at grazing angle.
  45205. */
  45206. static StandardReflectance90: number;
  45207. protected _primaryColor: Color3;
  45208. /**
  45209. * Key light Color (multiply against the environement texture)
  45210. */
  45211. primaryColor: Color3;
  45212. protected __perceptualColor: Nullable<Color3>;
  45213. /**
  45214. * Experimental Internal Use Only.
  45215. *
  45216. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45217. * This acts as a helper to set the primary color to a more "human friendly" value.
  45218. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45219. * output color as close as possible from the chosen value.
  45220. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45221. * part of lighting setup.)
  45222. */
  45223. _perceptualColor: Nullable<Color3>;
  45224. protected _primaryColorShadowLevel: float;
  45225. /**
  45226. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45227. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45228. */
  45229. primaryColorShadowLevel: float;
  45230. protected _primaryColorHighlightLevel: float;
  45231. /**
  45232. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45233. * The primary color is used at the level chosen to define what the white area would look.
  45234. */
  45235. primaryColorHighlightLevel: float;
  45236. protected _reflectionTexture: Nullable<BaseTexture>;
  45237. /**
  45238. * Reflection Texture used in the material.
  45239. * Should be author in a specific way for the best result (refer to the documentation).
  45240. */
  45241. reflectionTexture: Nullable<BaseTexture>;
  45242. protected _reflectionBlur: float;
  45243. /**
  45244. * Reflection Texture level of blur.
  45245. *
  45246. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45247. * texture twice.
  45248. */
  45249. reflectionBlur: float;
  45250. protected _diffuseTexture: Nullable<BaseTexture>;
  45251. /**
  45252. * Diffuse Texture used in the material.
  45253. * Should be author in a specific way for the best result (refer to the documentation).
  45254. */
  45255. diffuseTexture: Nullable<BaseTexture>;
  45256. protected _shadowLights: Nullable<IShadowLight[]>;
  45257. /**
  45258. * Specify the list of lights casting shadow on the material.
  45259. * All scene shadow lights will be included if null.
  45260. */
  45261. shadowLights: Nullable<IShadowLight[]>;
  45262. protected _shadowLevel: float;
  45263. /**
  45264. * Helps adjusting the shadow to a softer level if required.
  45265. * 0 means black shadows and 1 means no shadows.
  45266. */
  45267. shadowLevel: float;
  45268. protected _sceneCenter: Vector3;
  45269. /**
  45270. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45271. * It is usually zero but might be interesting to modify according to your setup.
  45272. */
  45273. sceneCenter: Vector3;
  45274. protected _opacityFresnel: boolean;
  45275. /**
  45276. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45277. * This helps ensuring a nice transition when the camera goes under the ground.
  45278. */
  45279. opacityFresnel: boolean;
  45280. protected _reflectionFresnel: boolean;
  45281. /**
  45282. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45283. * This helps adding a mirror texture on the ground.
  45284. */
  45285. reflectionFresnel: boolean;
  45286. protected _reflectionFalloffDistance: number;
  45287. /**
  45288. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45289. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45290. */
  45291. reflectionFalloffDistance: number;
  45292. protected _reflectionAmount: number;
  45293. /**
  45294. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45295. */
  45296. reflectionAmount: number;
  45297. protected _reflectionReflectance0: number;
  45298. /**
  45299. * This specifies the weight of the reflection at grazing angle.
  45300. */
  45301. reflectionReflectance0: number;
  45302. protected _reflectionReflectance90: number;
  45303. /**
  45304. * This specifies the weight of the reflection at a perpendicular point of view.
  45305. */
  45306. reflectionReflectance90: number;
  45307. /**
  45308. * Sets the reflection reflectance fresnel values according to the default standard
  45309. * empirically know to work well :-)
  45310. */
  45311. reflectionStandardFresnelWeight: number;
  45312. protected _useRGBColor: boolean;
  45313. /**
  45314. * Helps to directly use the maps channels instead of their level.
  45315. */
  45316. useRGBColor: boolean;
  45317. protected _enableNoise: boolean;
  45318. /**
  45319. * This helps reducing the banding effect that could occur on the background.
  45320. */
  45321. enableNoise: boolean;
  45322. /**
  45323. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45324. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45325. * Recommended to be keep at 1.0 except for special cases.
  45326. */
  45327. fovMultiplier: number;
  45328. private _fovMultiplier;
  45329. /**
  45330. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45331. */
  45332. useEquirectangularFOV: boolean;
  45333. private _maxSimultaneousLights;
  45334. /**
  45335. * Number of Simultaneous lights allowed on the material.
  45336. */
  45337. maxSimultaneousLights: int;
  45338. /**
  45339. * Default configuration related to image processing available in the Background Material.
  45340. */
  45341. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45342. /**
  45343. * Keep track of the image processing observer to allow dispose and replace.
  45344. */
  45345. private _imageProcessingObserver;
  45346. /**
  45347. * Attaches a new image processing configuration to the PBR Material.
  45348. * @param configuration (if null the scene configuration will be use)
  45349. */
  45350. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45351. /**
  45352. * Gets the image processing configuration used either in this material.
  45353. */
  45354. /**
  45355. * Sets the Default image processing configuration used either in the this material.
  45356. *
  45357. * If sets to null, the scene one is in use.
  45358. */
  45359. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45360. /**
  45361. * Gets wether the color curves effect is enabled.
  45362. */
  45363. /**
  45364. * Sets wether the color curves effect is enabled.
  45365. */
  45366. cameraColorCurvesEnabled: boolean;
  45367. /**
  45368. * Gets wether the color grading effect is enabled.
  45369. */
  45370. /**
  45371. * Gets wether the color grading effect is enabled.
  45372. */
  45373. cameraColorGradingEnabled: boolean;
  45374. /**
  45375. * Gets wether tonemapping is enabled or not.
  45376. */
  45377. /**
  45378. * Sets wether tonemapping is enabled or not
  45379. */
  45380. cameraToneMappingEnabled: boolean;
  45381. /**
  45382. * The camera exposure used on this material.
  45383. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45384. * This corresponds to a photographic exposure.
  45385. */
  45386. /**
  45387. * The camera exposure used on this material.
  45388. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45389. * This corresponds to a photographic exposure.
  45390. */
  45391. cameraExposure: float;
  45392. /**
  45393. * Gets The camera contrast used on this material.
  45394. */
  45395. /**
  45396. * Sets The camera contrast used on this material.
  45397. */
  45398. cameraContrast: float;
  45399. /**
  45400. * Gets the Color Grading 2D Lookup Texture.
  45401. */
  45402. /**
  45403. * Sets the Color Grading 2D Lookup Texture.
  45404. */
  45405. cameraColorGradingTexture: Nullable<BaseTexture>;
  45406. /**
  45407. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45408. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45409. * 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;
  45410. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45411. */
  45412. /**
  45413. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45414. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45415. * 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;
  45416. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45417. */
  45418. cameraColorCurves: Nullable<ColorCurves>;
  45419. /**
  45420. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45421. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45422. */
  45423. switchToBGR: boolean;
  45424. private _renderTargets;
  45425. private _reflectionControls;
  45426. private _white;
  45427. private _primaryShadowColor;
  45428. private _primaryHighlightColor;
  45429. /**
  45430. * Instantiates a Background Material in the given scene
  45431. * @param name The friendly name of the material
  45432. * @param scene The scene to add the material to
  45433. */
  45434. constructor(name: string, scene: Scene);
  45435. /**
  45436. * Gets a boolean indicating that current material needs to register RTT
  45437. */
  45438. readonly hasRenderTargetTextures: boolean;
  45439. /**
  45440. * The entire material has been created in order to prevent overdraw.
  45441. * @returns false
  45442. */
  45443. needAlphaTesting(): boolean;
  45444. /**
  45445. * The entire material has been created in order to prevent overdraw.
  45446. * @returns true if blending is enable
  45447. */
  45448. needAlphaBlending(): boolean;
  45449. /**
  45450. * Checks wether the material is ready to be rendered for a given mesh.
  45451. * @param mesh The mesh to render
  45452. * @param subMesh The submesh to check against
  45453. * @param useInstances Specify wether or not the material is used with instances
  45454. * @returns true if all the dependencies are ready (Textures, Effects...)
  45455. */
  45456. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45457. /**
  45458. * Compute the primary color according to the chosen perceptual color.
  45459. */
  45460. private _computePrimaryColorFromPerceptualColor;
  45461. /**
  45462. * Compute the highlights and shadow colors according to their chosen levels.
  45463. */
  45464. private _computePrimaryColors;
  45465. /**
  45466. * Build the uniform buffer used in the material.
  45467. */
  45468. buildUniformLayout(): void;
  45469. /**
  45470. * Unbind the material.
  45471. */
  45472. unbind(): void;
  45473. /**
  45474. * Bind only the world matrix to the material.
  45475. * @param world The world matrix to bind.
  45476. */
  45477. bindOnlyWorldMatrix(world: Matrix): void;
  45478. /**
  45479. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45480. * @param world The world matrix to bind.
  45481. * @param subMesh The submesh to bind for.
  45482. */
  45483. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45484. /**
  45485. * Checks to see if a texture is used in the material.
  45486. * @param texture - Base texture to use.
  45487. * @returns - Boolean specifying if a texture is used in the material.
  45488. */
  45489. hasTexture(texture: BaseTexture): boolean;
  45490. /**
  45491. * Dispose the material.
  45492. * @param forceDisposeEffect Force disposal of the associated effect.
  45493. * @param forceDisposeTextures Force disposal of the associated textures.
  45494. */
  45495. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45496. /**
  45497. * Clones the material.
  45498. * @param name The cloned name.
  45499. * @returns The cloned material.
  45500. */
  45501. clone(name: string): BackgroundMaterial;
  45502. /**
  45503. * Serializes the current material to its JSON representation.
  45504. * @returns The JSON representation.
  45505. */
  45506. serialize(): any;
  45507. /**
  45508. * Gets the class name of the material
  45509. * @returns "BackgroundMaterial"
  45510. */
  45511. getClassName(): string;
  45512. /**
  45513. * Parse a JSON input to create back a background material.
  45514. * @param source The JSON data to parse
  45515. * @param scene The scene to create the parsed material in
  45516. * @param rootUrl The root url of the assets the material depends upon
  45517. * @returns the instantiated BackgroundMaterial.
  45518. */
  45519. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45520. }
  45521. }
  45522. declare module BABYLON {
  45523. /**
  45524. * Represents the different options available during the creation of
  45525. * a Environment helper.
  45526. *
  45527. * This can control the default ground, skybox and image processing setup of your scene.
  45528. */
  45529. export interface IEnvironmentHelperOptions {
  45530. /**
  45531. * Specifies wether or not to create a ground.
  45532. * True by default.
  45533. */
  45534. createGround: boolean;
  45535. /**
  45536. * Specifies the ground size.
  45537. * 15 by default.
  45538. */
  45539. groundSize: number;
  45540. /**
  45541. * The texture used on the ground for the main color.
  45542. * Comes from the BabylonJS CDN by default.
  45543. *
  45544. * Remarks: Can be either a texture or a url.
  45545. */
  45546. groundTexture: string | BaseTexture;
  45547. /**
  45548. * The color mixed in the ground texture by default.
  45549. * BabylonJS clearColor by default.
  45550. */
  45551. groundColor: Color3;
  45552. /**
  45553. * Specifies the ground opacity.
  45554. * 1 by default.
  45555. */
  45556. groundOpacity: number;
  45557. /**
  45558. * Enables the ground to receive shadows.
  45559. * True by default.
  45560. */
  45561. enableGroundShadow: boolean;
  45562. /**
  45563. * Helps preventing the shadow to be fully black on the ground.
  45564. * 0.5 by default.
  45565. */
  45566. groundShadowLevel: number;
  45567. /**
  45568. * Creates a mirror texture attach to the ground.
  45569. * false by default.
  45570. */
  45571. enableGroundMirror: boolean;
  45572. /**
  45573. * Specifies the ground mirror size ratio.
  45574. * 0.3 by default as the default kernel is 64.
  45575. */
  45576. groundMirrorSizeRatio: number;
  45577. /**
  45578. * Specifies the ground mirror blur kernel size.
  45579. * 64 by default.
  45580. */
  45581. groundMirrorBlurKernel: number;
  45582. /**
  45583. * Specifies the ground mirror visibility amount.
  45584. * 1 by default
  45585. */
  45586. groundMirrorAmount: number;
  45587. /**
  45588. * Specifies the ground mirror reflectance weight.
  45589. * This uses the standard weight of the background material to setup the fresnel effect
  45590. * of the mirror.
  45591. * 1 by default.
  45592. */
  45593. groundMirrorFresnelWeight: number;
  45594. /**
  45595. * Specifies the ground mirror Falloff distance.
  45596. * This can helps reducing the size of the reflection.
  45597. * 0 by Default.
  45598. */
  45599. groundMirrorFallOffDistance: number;
  45600. /**
  45601. * Specifies the ground mirror texture type.
  45602. * Unsigned Int by Default.
  45603. */
  45604. groundMirrorTextureType: number;
  45605. /**
  45606. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45607. * the shown objects.
  45608. */
  45609. groundYBias: number;
  45610. /**
  45611. * Specifies wether or not to create a skybox.
  45612. * True by default.
  45613. */
  45614. createSkybox: boolean;
  45615. /**
  45616. * Specifies the skybox size.
  45617. * 20 by default.
  45618. */
  45619. skyboxSize: number;
  45620. /**
  45621. * The texture used on the skybox for the main color.
  45622. * Comes from the BabylonJS CDN by default.
  45623. *
  45624. * Remarks: Can be either a texture or a url.
  45625. */
  45626. skyboxTexture: string | BaseTexture;
  45627. /**
  45628. * The color mixed in the skybox texture by default.
  45629. * BabylonJS clearColor by default.
  45630. */
  45631. skyboxColor: Color3;
  45632. /**
  45633. * The background rotation around the Y axis of the scene.
  45634. * This helps aligning the key lights of your scene with the background.
  45635. * 0 by default.
  45636. */
  45637. backgroundYRotation: number;
  45638. /**
  45639. * Compute automatically the size of the elements to best fit with the scene.
  45640. */
  45641. sizeAuto: boolean;
  45642. /**
  45643. * Default position of the rootMesh if autoSize is not true.
  45644. */
  45645. rootPosition: Vector3;
  45646. /**
  45647. * Sets up the image processing in the scene.
  45648. * true by default.
  45649. */
  45650. setupImageProcessing: boolean;
  45651. /**
  45652. * The texture used as your environment texture in the scene.
  45653. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45654. *
  45655. * Remarks: Can be either a texture or a url.
  45656. */
  45657. environmentTexture: string | BaseTexture;
  45658. /**
  45659. * The value of the exposure to apply to the scene.
  45660. * 0.6 by default if setupImageProcessing is true.
  45661. */
  45662. cameraExposure: number;
  45663. /**
  45664. * The value of the contrast to apply to the scene.
  45665. * 1.6 by default if setupImageProcessing is true.
  45666. */
  45667. cameraContrast: number;
  45668. /**
  45669. * Specifies wether or not tonemapping should be enabled in the scene.
  45670. * true by default if setupImageProcessing is true.
  45671. */
  45672. toneMappingEnabled: boolean;
  45673. }
  45674. /**
  45675. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45676. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45677. * It also helps with the default setup of your imageProcessing configuration.
  45678. */
  45679. export class EnvironmentHelper {
  45680. /**
  45681. * Default ground texture URL.
  45682. */
  45683. private static _groundTextureCDNUrl;
  45684. /**
  45685. * Default skybox texture URL.
  45686. */
  45687. private static _skyboxTextureCDNUrl;
  45688. /**
  45689. * Default environment texture URL.
  45690. */
  45691. private static _environmentTextureCDNUrl;
  45692. /**
  45693. * Creates the default options for the helper.
  45694. */
  45695. private static _getDefaultOptions;
  45696. private _rootMesh;
  45697. /**
  45698. * Gets the root mesh created by the helper.
  45699. */
  45700. readonly rootMesh: Mesh;
  45701. private _skybox;
  45702. /**
  45703. * Gets the skybox created by the helper.
  45704. */
  45705. readonly skybox: Nullable<Mesh>;
  45706. private _skyboxTexture;
  45707. /**
  45708. * Gets the skybox texture created by the helper.
  45709. */
  45710. readonly skyboxTexture: Nullable<BaseTexture>;
  45711. private _skyboxMaterial;
  45712. /**
  45713. * Gets the skybox material created by the helper.
  45714. */
  45715. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45716. private _ground;
  45717. /**
  45718. * Gets the ground mesh created by the helper.
  45719. */
  45720. readonly ground: Nullable<Mesh>;
  45721. private _groundTexture;
  45722. /**
  45723. * Gets the ground texture created by the helper.
  45724. */
  45725. readonly groundTexture: Nullable<BaseTexture>;
  45726. private _groundMirror;
  45727. /**
  45728. * Gets the ground mirror created by the helper.
  45729. */
  45730. readonly groundMirror: Nullable<MirrorTexture>;
  45731. /**
  45732. * Gets the ground mirror render list to helps pushing the meshes
  45733. * you wish in the ground reflection.
  45734. */
  45735. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45736. private _groundMaterial;
  45737. /**
  45738. * Gets the ground material created by the helper.
  45739. */
  45740. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45741. /**
  45742. * Stores the creation options.
  45743. */
  45744. private readonly _scene;
  45745. private _options;
  45746. /**
  45747. * This observable will be notified with any error during the creation of the environment,
  45748. * mainly texture creation errors.
  45749. */
  45750. onErrorObservable: Observable<{
  45751. message?: string;
  45752. exception?: any;
  45753. }>;
  45754. /**
  45755. * constructor
  45756. * @param options Defines the options we want to customize the helper
  45757. * @param scene The scene to add the material to
  45758. */
  45759. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45760. /**
  45761. * Updates the background according to the new options
  45762. * @param options
  45763. */
  45764. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45765. /**
  45766. * Sets the primary color of all the available elements.
  45767. * @param color the main color to affect to the ground and the background
  45768. */
  45769. setMainColor(color: Color3): void;
  45770. /**
  45771. * Setup the image processing according to the specified options.
  45772. */
  45773. private _setupImageProcessing;
  45774. /**
  45775. * Setup the environment texture according to the specified options.
  45776. */
  45777. private _setupEnvironmentTexture;
  45778. /**
  45779. * Setup the background according to the specified options.
  45780. */
  45781. private _setupBackground;
  45782. /**
  45783. * Get the scene sizes according to the setup.
  45784. */
  45785. private _getSceneSize;
  45786. /**
  45787. * Setup the ground according to the specified options.
  45788. */
  45789. private _setupGround;
  45790. /**
  45791. * Setup the ground material according to the specified options.
  45792. */
  45793. private _setupGroundMaterial;
  45794. /**
  45795. * Setup the ground diffuse texture according to the specified options.
  45796. */
  45797. private _setupGroundDiffuseTexture;
  45798. /**
  45799. * Setup the ground mirror texture according to the specified options.
  45800. */
  45801. private _setupGroundMirrorTexture;
  45802. /**
  45803. * Setup the ground to receive the mirror texture.
  45804. */
  45805. private _setupMirrorInGroundMaterial;
  45806. /**
  45807. * Setup the skybox according to the specified options.
  45808. */
  45809. private _setupSkybox;
  45810. /**
  45811. * Setup the skybox material according to the specified options.
  45812. */
  45813. private _setupSkyboxMaterial;
  45814. /**
  45815. * Setup the skybox reflection texture according to the specified options.
  45816. */
  45817. private _setupSkyboxReflectionTexture;
  45818. private _errorHandler;
  45819. /**
  45820. * Dispose all the elements created by the Helper.
  45821. */
  45822. dispose(): void;
  45823. }
  45824. }
  45825. declare module BABYLON {
  45826. /**
  45827. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45828. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45829. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45830. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45831. */
  45832. export class PhotoDome extends TransformNode {
  45833. /**
  45834. * Define the image as a Monoscopic panoramic 360 image.
  45835. */
  45836. static readonly MODE_MONOSCOPIC: number;
  45837. /**
  45838. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45839. */
  45840. static readonly MODE_TOPBOTTOM: number;
  45841. /**
  45842. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45843. */
  45844. static readonly MODE_SIDEBYSIDE: number;
  45845. private _useDirectMapping;
  45846. /**
  45847. * The texture being displayed on the sphere
  45848. */
  45849. protected _photoTexture: Texture;
  45850. /**
  45851. * Gets or sets the texture being displayed on the sphere
  45852. */
  45853. photoTexture: Texture;
  45854. /**
  45855. * Observable raised when an error occured while loading the 360 image
  45856. */
  45857. onLoadErrorObservable: Observable<string>;
  45858. /**
  45859. * The skybox material
  45860. */
  45861. protected _material: BackgroundMaterial;
  45862. /**
  45863. * The surface used for the skybox
  45864. */
  45865. protected _mesh: Mesh;
  45866. /**
  45867. * Gets the mesh used for the skybox.
  45868. */
  45869. readonly mesh: Mesh;
  45870. /**
  45871. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45872. * Also see the options.resolution property.
  45873. */
  45874. fovMultiplier: number;
  45875. private _imageMode;
  45876. /**
  45877. * Gets or set the current video mode for the video. It can be:
  45878. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45879. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45880. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45881. */
  45882. imageMode: number;
  45883. /**
  45884. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45885. * @param name Element's name, child elements will append suffixes for their own names.
  45886. * @param urlsOfPhoto defines the url of the photo to display
  45887. * @param options defines an object containing optional or exposed sub element properties
  45888. * @param onError defines a callback called when an error occured while loading the texture
  45889. */
  45890. constructor(name: string, urlOfPhoto: string, options: {
  45891. resolution?: number;
  45892. size?: number;
  45893. useDirectMapping?: boolean;
  45894. faceForward?: boolean;
  45895. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45896. private _onBeforeCameraRenderObserver;
  45897. private _changeImageMode;
  45898. /**
  45899. * Releases resources associated with this node.
  45900. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45901. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45902. */
  45903. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45904. }
  45905. }
  45906. declare module BABYLON {
  45907. /**
  45908. * Class used to host RGBD texture specific utilities
  45909. */
  45910. export class RGBDTextureTools {
  45911. /**
  45912. * Expand the RGBD Texture from RGBD to Half Float if possible.
  45913. * @param texture the texture to expand.
  45914. */
  45915. static ExpandRGBDTexture(texture: Texture): void;
  45916. }
  45917. }
  45918. declare module BABYLON {
  45919. /**
  45920. * Class used to host texture specific utilities
  45921. */
  45922. export class BRDFTextureTools {
  45923. /**
  45924. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45925. * @param scene defines the hosting scene
  45926. * @returns the environment BRDF texture
  45927. */
  45928. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45929. private static _environmentBRDFBase64Texture;
  45930. }
  45931. }
  45932. declare module BABYLON {
  45933. /**
  45934. * @hidden
  45935. */
  45936. export interface IMaterialClearCoatDefines {
  45937. CLEARCOAT: boolean;
  45938. CLEARCOAT_DEFAULTIOR: boolean;
  45939. CLEARCOAT_TEXTURE: boolean;
  45940. CLEARCOAT_TEXTUREDIRECTUV: number;
  45941. CLEARCOAT_BUMP: boolean;
  45942. CLEARCOAT_BUMPDIRECTUV: number;
  45943. CLEARCOAT_TINT: boolean;
  45944. CLEARCOAT_TINT_TEXTURE: boolean;
  45945. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45946. /** @hidden */
  45947. _areTexturesDirty: boolean;
  45948. }
  45949. /**
  45950. * Define the code related to the clear coat parameters of the pbr material.
  45951. */
  45952. export class PBRClearCoatConfiguration {
  45953. /**
  45954. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45955. * The default fits with a polyurethane material.
  45956. */
  45957. private static readonly _DefaultIndexOfRefraction;
  45958. private _isEnabled;
  45959. /**
  45960. * Defines if the clear coat is enabled in the material.
  45961. */
  45962. isEnabled: boolean;
  45963. /**
  45964. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45965. */
  45966. intensity: number;
  45967. /**
  45968. * Defines the clear coat layer roughness.
  45969. */
  45970. roughness: number;
  45971. private _indexOfRefraction;
  45972. /**
  45973. * Defines the index of refraction of the clear coat.
  45974. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45975. * The default fits with a polyurethane material.
  45976. * Changing the default value is more performance intensive.
  45977. */
  45978. indexOfRefraction: number;
  45979. private _texture;
  45980. /**
  45981. * Stores the clear coat values in a texture.
  45982. */
  45983. texture: Nullable<BaseTexture>;
  45984. private _bumpTexture;
  45985. /**
  45986. * Define the clear coat specific bump texture.
  45987. */
  45988. bumpTexture: Nullable<BaseTexture>;
  45989. private _isTintEnabled;
  45990. /**
  45991. * Defines if the clear coat tint is enabled in the material.
  45992. */
  45993. isTintEnabled: boolean;
  45994. /**
  45995. * Defines the clear coat tint of the material.
  45996. * This is only use if tint is enabled
  45997. */
  45998. tintColor: Color3;
  45999. /**
  46000. * Defines the distance at which the tint color should be found in the
  46001. * clear coat media.
  46002. * This is only use if tint is enabled
  46003. */
  46004. tintColorAtDistance: number;
  46005. /**
  46006. * Defines the clear coat layer thickness.
  46007. * This is only use if tint is enabled
  46008. */
  46009. tintThickness: number;
  46010. private _tintTexture;
  46011. /**
  46012. * Stores the clear tint values in a texture.
  46013. * rgb is tint
  46014. * a is a thickness factor
  46015. */
  46016. tintTexture: Nullable<BaseTexture>;
  46017. /** @hidden */
  46018. private _internalMarkAllSubMeshesAsTexturesDirty;
  46019. /** @hidden */
  46020. _markAllSubMeshesAsTexturesDirty(): void;
  46021. /**
  46022. * Instantiate a new istance of clear coat configuration.
  46023. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46024. */
  46025. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46026. /**
  46027. * Gets wehter the submesh is ready to be used or not.
  46028. * @param defines the list of "defines" to update.
  46029. * @param scene defines the scene the material belongs to.
  46030. * @param engine defines the engine the material belongs to.
  46031. * @param disableBumpMap defines wether the material disables bump or not.
  46032. * @returns - boolean indicating that the submesh is ready or not.
  46033. */
  46034. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46035. /**
  46036. * Checks to see if a texture is used in the material.
  46037. * @param defines the list of "defines" to update.
  46038. * @param scene defines the scene to the material belongs to.
  46039. */
  46040. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46041. /**
  46042. * Binds the material data.
  46043. * @param uniformBuffer defines the Uniform buffer to fill in.
  46044. * @param scene defines the scene the material belongs to.
  46045. * @param engine defines the engine the material belongs to.
  46046. * @param disableBumpMap defines wether the material disables bump or not.
  46047. * @param isFrozen defines wether the material is frozen or not.
  46048. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46049. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46050. */
  46051. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46052. /**
  46053. * Checks to see if a texture is used in the material.
  46054. * @param texture - Base texture to use.
  46055. * @returns - Boolean specifying if a texture is used in the material.
  46056. */
  46057. hasTexture(texture: BaseTexture): boolean;
  46058. /**
  46059. * Returns an array of the actively used textures.
  46060. * @param activeTextures Array of BaseTextures
  46061. */
  46062. getActiveTextures(activeTextures: BaseTexture[]): void;
  46063. /**
  46064. * Returns the animatable textures.
  46065. * @param animatables Array of animatable textures.
  46066. */
  46067. getAnimatables(animatables: IAnimatable[]): void;
  46068. /**
  46069. * Disposes the resources of the material.
  46070. * @param forceDisposeTextures - Forces the disposal of all textures.
  46071. */
  46072. dispose(forceDisposeTextures?: boolean): void;
  46073. /**
  46074. * Get the current class name of the texture useful for serialization or dynamic coding.
  46075. * @returns "PBRClearCoatConfiguration"
  46076. */
  46077. getClassName(): string;
  46078. /**
  46079. * Add fallbacks to the effect fallbacks list.
  46080. * @param defines defines the Base texture to use.
  46081. * @param fallbacks defines the current fallback list.
  46082. * @param currentRank defines the current fallback rank.
  46083. * @returns the new fallback rank.
  46084. */
  46085. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46086. /**
  46087. * Add the required uniforms to the current list.
  46088. * @param uniforms defines the current uniform list.
  46089. */
  46090. static AddUniforms(uniforms: string[]): void;
  46091. /**
  46092. * Add the required samplers to the current list.
  46093. * @param samplers defines the current sampler list.
  46094. */
  46095. static AddSamplers(samplers: string[]): void;
  46096. /**
  46097. * Add the required uniforms to the current buffer.
  46098. * @param uniformBuffer defines the current uniform buffer.
  46099. */
  46100. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46101. /**
  46102. * Makes a duplicate of the current configuration into another one.
  46103. * @param clearCoatConfiguration define the config where to copy the info
  46104. */
  46105. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46106. /**
  46107. * Serializes this clear coat configuration.
  46108. * @returns - An object with the serialized config.
  46109. */
  46110. serialize(): any;
  46111. /**
  46112. * Parses a anisotropy Configuration from a serialized object.
  46113. * @param source - Serialized object.
  46114. * @param scene Defines the scene we are parsing for
  46115. * @param rootUrl Defines the rootUrl to load from
  46116. */
  46117. parse(source: any, scene: Scene, rootUrl: string): void;
  46118. }
  46119. }
  46120. declare module BABYLON {
  46121. /**
  46122. * @hidden
  46123. */
  46124. export interface IMaterialAnisotropicDefines {
  46125. ANISOTROPIC: boolean;
  46126. ANISOTROPIC_TEXTURE: boolean;
  46127. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46128. MAINUV1: boolean;
  46129. _areTexturesDirty: boolean;
  46130. _needUVs: boolean;
  46131. }
  46132. /**
  46133. * Define the code related to the anisotropic parameters of the pbr material.
  46134. */
  46135. export class PBRAnisotropicConfiguration {
  46136. private _isEnabled;
  46137. /**
  46138. * Defines if the anisotropy is enabled in the material.
  46139. */
  46140. isEnabled: boolean;
  46141. /**
  46142. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46143. */
  46144. intensity: number;
  46145. /**
  46146. * Defines if the effect is along the tangents, bitangents or in between.
  46147. * By default, the effect is "strectching" the highlights along the tangents.
  46148. */
  46149. direction: Vector2;
  46150. private _texture;
  46151. /**
  46152. * Stores the anisotropy values in a texture.
  46153. * rg is direction (like normal from -1 to 1)
  46154. * b is a intensity
  46155. */
  46156. texture: Nullable<BaseTexture>;
  46157. /** @hidden */
  46158. private _internalMarkAllSubMeshesAsTexturesDirty;
  46159. /** @hidden */
  46160. _markAllSubMeshesAsTexturesDirty(): void;
  46161. /**
  46162. * Instantiate a new istance of anisotropy configuration.
  46163. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46164. */
  46165. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46166. /**
  46167. * Specifies that the submesh is ready to be used.
  46168. * @param defines the list of "defines" to update.
  46169. * @param scene defines the scene the material belongs to.
  46170. * @returns - boolean indicating that the submesh is ready or not.
  46171. */
  46172. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46173. /**
  46174. * Checks to see if a texture is used in the material.
  46175. * @param defines the list of "defines" to update.
  46176. * @param mesh the mesh we are preparing the defines for.
  46177. * @param scene defines the scene the material belongs to.
  46178. */
  46179. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46180. /**
  46181. * Binds the material data.
  46182. * @param uniformBuffer defines the Uniform buffer to fill in.
  46183. * @param scene defines the scene the material belongs to.
  46184. * @param isFrozen defines wether the material is frozen or not.
  46185. */
  46186. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46187. /**
  46188. * Checks to see if a texture is used in the material.
  46189. * @param texture - Base texture to use.
  46190. * @returns - Boolean specifying if a texture is used in the material.
  46191. */
  46192. hasTexture(texture: BaseTexture): boolean;
  46193. /**
  46194. * Returns an array of the actively used textures.
  46195. * @param activeTextures Array of BaseTextures
  46196. */
  46197. getActiveTextures(activeTextures: BaseTexture[]): void;
  46198. /**
  46199. * Returns the animatable textures.
  46200. * @param animatables Array of animatable textures.
  46201. */
  46202. getAnimatables(animatables: IAnimatable[]): void;
  46203. /**
  46204. * Disposes the resources of the material.
  46205. * @param forceDisposeTextures - Forces the disposal of all textures.
  46206. */
  46207. dispose(forceDisposeTextures?: boolean): void;
  46208. /**
  46209. * Get the current class name of the texture useful for serialization or dynamic coding.
  46210. * @returns "PBRAnisotropicConfiguration"
  46211. */
  46212. getClassName(): string;
  46213. /**
  46214. * Add fallbacks to the effect fallbacks list.
  46215. * @param defines defines the Base texture to use.
  46216. * @param fallbacks defines the current fallback list.
  46217. * @param currentRank defines the current fallback rank.
  46218. * @returns the new fallback rank.
  46219. */
  46220. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46221. /**
  46222. * Add the required uniforms to the current list.
  46223. * @param uniforms defines the current uniform list.
  46224. */
  46225. static AddUniforms(uniforms: string[]): void;
  46226. /**
  46227. * Add the required uniforms to the current buffer.
  46228. * @param uniformBuffer defines the current uniform buffer.
  46229. */
  46230. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46231. /**
  46232. * Add the required samplers to the current list.
  46233. * @param samplers defines the current sampler list.
  46234. */
  46235. static AddSamplers(samplers: string[]): void;
  46236. /**
  46237. * Makes a duplicate of the current configuration into another one.
  46238. * @param anisotropicConfiguration define the config where to copy the info
  46239. */
  46240. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46241. /**
  46242. * Serializes this anisotropy configuration.
  46243. * @returns - An object with the serialized config.
  46244. */
  46245. serialize(): any;
  46246. /**
  46247. * Parses a anisotropy Configuration from a serialized object.
  46248. * @param source - Serialized object.
  46249. * @param scene Defines the scene we are parsing for
  46250. * @param rootUrl Defines the rootUrl to load from
  46251. */
  46252. parse(source: any, scene: Scene, rootUrl: string): void;
  46253. }
  46254. }
  46255. declare module BABYLON {
  46256. /**
  46257. * @hidden
  46258. */
  46259. export interface IMaterialBRDFDefines {
  46260. BRDF_V_HEIGHT_CORRELATED: boolean;
  46261. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46262. SPHERICAL_HARMONICS: boolean;
  46263. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46264. /** @hidden */
  46265. _areMiscDirty: boolean;
  46266. }
  46267. /**
  46268. * Define the code related to the BRDF parameters of the pbr material.
  46269. */
  46270. export class PBRBRDFConfiguration {
  46271. /**
  46272. * Default value used for the energy conservation.
  46273. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46274. */
  46275. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46276. /**
  46277. * Default value used for the Smith Visibility Height Correlated mode.
  46278. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46279. */
  46280. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46281. /**
  46282. * Default value used for the IBL diffuse part.
  46283. * This can help switching back to the polynomials mode globally which is a tiny bit
  46284. * less GPU intensive at the drawback of a lower quality.
  46285. */
  46286. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46287. /**
  46288. * Default value used for activating energy conservation for the specular workflow.
  46289. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46290. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46291. */
  46292. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  46293. private _useEnergyConservation;
  46294. /**
  46295. * Defines if the material uses energy conservation.
  46296. */
  46297. useEnergyConservation: boolean;
  46298. private _useSmithVisibilityHeightCorrelated;
  46299. /**
  46300. * LEGACY Mode set to false
  46301. * Defines if the material uses height smith correlated visibility term.
  46302. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46303. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46304. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46305. * Not relying on height correlated will also disable energy conservation.
  46306. */
  46307. useSmithVisibilityHeightCorrelated: boolean;
  46308. private _useSphericalHarmonics;
  46309. /**
  46310. * LEGACY Mode set to false
  46311. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46312. * diffuse part of the IBL.
  46313. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46314. * to the ground truth.
  46315. */
  46316. useSphericalHarmonics: boolean;
  46317. private _useSpecularGlossinessInputEnergyConservation;
  46318. /**
  46319. * Defines if the material uses energy conservation, when the specular workflow is active.
  46320. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46321. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46322. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  46323. */
  46324. useSpecularGlossinessInputEnergyConservation: boolean;
  46325. /** @hidden */
  46326. private _internalMarkAllSubMeshesAsMiscDirty;
  46327. /** @hidden */
  46328. _markAllSubMeshesAsMiscDirty(): void;
  46329. /**
  46330. * Instantiate a new istance of clear coat configuration.
  46331. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46332. */
  46333. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46334. /**
  46335. * Checks to see if a texture is used in the material.
  46336. * @param defines the list of "defines" to update.
  46337. */
  46338. prepareDefines(defines: IMaterialBRDFDefines): void;
  46339. /**
  46340. * Get the current class name of the texture useful for serialization or dynamic coding.
  46341. * @returns "PBRClearCoatConfiguration"
  46342. */
  46343. getClassName(): string;
  46344. /**
  46345. * Makes a duplicate of the current configuration into another one.
  46346. * @param brdfConfiguration define the config where to copy the info
  46347. */
  46348. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46349. /**
  46350. * Serializes this BRDF configuration.
  46351. * @returns - An object with the serialized config.
  46352. */
  46353. serialize(): any;
  46354. /**
  46355. * Parses a anisotropy Configuration from a serialized object.
  46356. * @param source - Serialized object.
  46357. * @param scene Defines the scene we are parsing for
  46358. * @param rootUrl Defines the rootUrl to load from
  46359. */
  46360. parse(source: any, scene: Scene, rootUrl: string): void;
  46361. }
  46362. }
  46363. declare module BABYLON {
  46364. /**
  46365. * @hidden
  46366. */
  46367. export interface IMaterialSheenDefines {
  46368. SHEEN: boolean;
  46369. SHEEN_TEXTURE: boolean;
  46370. SHEEN_TEXTUREDIRECTUV: number;
  46371. SHEEN_LINKWITHALBEDO: boolean;
  46372. /** @hidden */
  46373. _areTexturesDirty: boolean;
  46374. }
  46375. /**
  46376. * Define the code related to the Sheen parameters of the pbr material.
  46377. */
  46378. export class PBRSheenConfiguration {
  46379. private _isEnabled;
  46380. /**
  46381. * Defines if the material uses sheen.
  46382. */
  46383. isEnabled: boolean;
  46384. private _linkSheenWithAlbedo;
  46385. /**
  46386. * Defines if the sheen is linked to the sheen color.
  46387. */
  46388. linkSheenWithAlbedo: boolean;
  46389. /**
  46390. * Defines the sheen intensity.
  46391. */
  46392. intensity: number;
  46393. /**
  46394. * Defines the sheen color.
  46395. */
  46396. color: Color3;
  46397. private _texture;
  46398. /**
  46399. * Stores the sheen tint values in a texture.
  46400. * rgb is tint
  46401. * a is a intensity
  46402. */
  46403. texture: Nullable<BaseTexture>;
  46404. /** @hidden */
  46405. private _internalMarkAllSubMeshesAsTexturesDirty;
  46406. /** @hidden */
  46407. _markAllSubMeshesAsTexturesDirty(): void;
  46408. /**
  46409. * Instantiate a new istance of clear coat configuration.
  46410. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46411. */
  46412. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46413. /**
  46414. * Specifies that the submesh is ready to be used.
  46415. * @param defines the list of "defines" to update.
  46416. * @param scene defines the scene the material belongs to.
  46417. * @returns - boolean indicating that the submesh is ready or not.
  46418. */
  46419. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46420. /**
  46421. * Checks to see if a texture is used in the material.
  46422. * @param defines the list of "defines" to update.
  46423. * @param scene defines the scene the material belongs to.
  46424. */
  46425. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46426. /**
  46427. * Binds the material data.
  46428. * @param uniformBuffer defines the Uniform buffer to fill in.
  46429. * @param scene defines the scene the material belongs to.
  46430. * @param isFrozen defines wether the material is frozen or not.
  46431. */
  46432. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46433. /**
  46434. * Checks to see if a texture is used in the material.
  46435. * @param texture - Base texture to use.
  46436. * @returns - Boolean specifying if a texture is used in the material.
  46437. */
  46438. hasTexture(texture: BaseTexture): boolean;
  46439. /**
  46440. * Returns an array of the actively used textures.
  46441. * @param activeTextures Array of BaseTextures
  46442. */
  46443. getActiveTextures(activeTextures: BaseTexture[]): void;
  46444. /**
  46445. * Returns the animatable textures.
  46446. * @param animatables Array of animatable textures.
  46447. */
  46448. getAnimatables(animatables: IAnimatable[]): void;
  46449. /**
  46450. * Disposes the resources of the material.
  46451. * @param forceDisposeTextures - Forces the disposal of all textures.
  46452. */
  46453. dispose(forceDisposeTextures?: boolean): void;
  46454. /**
  46455. * Get the current class name of the texture useful for serialization or dynamic coding.
  46456. * @returns "PBRSheenConfiguration"
  46457. */
  46458. getClassName(): string;
  46459. /**
  46460. * Add fallbacks to the effect fallbacks list.
  46461. * @param defines defines the Base texture to use.
  46462. * @param fallbacks defines the current fallback list.
  46463. * @param currentRank defines the current fallback rank.
  46464. * @returns the new fallback rank.
  46465. */
  46466. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46467. /**
  46468. * Add the required uniforms to the current list.
  46469. * @param uniforms defines the current uniform list.
  46470. */
  46471. static AddUniforms(uniforms: string[]): void;
  46472. /**
  46473. * Add the required uniforms to the current buffer.
  46474. * @param uniformBuffer defines the current uniform buffer.
  46475. */
  46476. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46477. /**
  46478. * Add the required samplers to the current list.
  46479. * @param samplers defines the current sampler list.
  46480. */
  46481. static AddSamplers(samplers: string[]): void;
  46482. /**
  46483. * Makes a duplicate of the current configuration into another one.
  46484. * @param sheenConfiguration define the config where to copy the info
  46485. */
  46486. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46487. /**
  46488. * Serializes this BRDF configuration.
  46489. * @returns - An object with the serialized config.
  46490. */
  46491. serialize(): any;
  46492. /**
  46493. * Parses a anisotropy Configuration from a serialized object.
  46494. * @param source - Serialized object.
  46495. * @param scene Defines the scene we are parsing for
  46496. * @param rootUrl Defines the rootUrl to load from
  46497. */
  46498. parse(source: any, scene: Scene, rootUrl: string): void;
  46499. }
  46500. }
  46501. declare module BABYLON {
  46502. /**
  46503. * @hidden
  46504. */
  46505. export interface IMaterialSubSurfaceDefines {
  46506. SUBSURFACE: boolean;
  46507. SS_REFRACTION: boolean;
  46508. SS_TRANSLUCENCY: boolean;
  46509. SS_SCATERRING: boolean;
  46510. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46511. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46512. SS_REFRACTIONMAP_3D: boolean;
  46513. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46514. SS_LODINREFRACTIONALPHA: boolean;
  46515. SS_GAMMAREFRACTION: boolean;
  46516. SS_RGBDREFRACTION: boolean;
  46517. SS_LINEARSPECULARREFRACTION: boolean;
  46518. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46519. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46520. /** @hidden */
  46521. _areTexturesDirty: boolean;
  46522. }
  46523. /**
  46524. * Define the code related to the sub surface parameters of the pbr material.
  46525. */
  46526. export class PBRSubSurfaceConfiguration {
  46527. private _isRefractionEnabled;
  46528. /**
  46529. * Defines if the refraction is enabled in the material.
  46530. */
  46531. isRefractionEnabled: boolean;
  46532. private _isTranslucencyEnabled;
  46533. /**
  46534. * Defines if the translucency is enabled in the material.
  46535. */
  46536. isTranslucencyEnabled: boolean;
  46537. private _isScatteringEnabled;
  46538. /**
  46539. * Defines the refraction intensity of the material.
  46540. * The refraction when enabled replaces the Diffuse part of the material.
  46541. * The intensity helps transitionning between diffuse and refraction.
  46542. */
  46543. refractionIntensity: number;
  46544. /**
  46545. * Defines the translucency intensity of the material.
  46546. * When translucency has been enabled, this defines how much of the "translucency"
  46547. * is addded to the diffuse part of the material.
  46548. */
  46549. translucencyIntensity: number;
  46550. /**
  46551. * Defines the scattering intensity of the material.
  46552. * When scattering has been enabled, this defines how much of the "scattered light"
  46553. * is addded to the diffuse part of the material.
  46554. */
  46555. scatteringIntensity: number;
  46556. private _thicknessTexture;
  46557. /**
  46558. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46559. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46560. * 0 would mean minimumThickness
  46561. * 1 would mean maximumThickness
  46562. * The other channels might be use as a mask to vary the different effects intensity.
  46563. */
  46564. thicknessTexture: Nullable<BaseTexture>;
  46565. private _refractionTexture;
  46566. /**
  46567. * Defines the texture to use for refraction.
  46568. */
  46569. refractionTexture: Nullable<BaseTexture>;
  46570. private _indexOfRefraction;
  46571. /**
  46572. * Defines the index of refraction used in the material.
  46573. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46574. */
  46575. indexOfRefraction: number;
  46576. private _invertRefractionY;
  46577. /**
  46578. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46579. */
  46580. invertRefractionY: boolean;
  46581. private _linkRefractionWithTransparency;
  46582. /**
  46583. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46584. * Materials half opaque for instance using refraction could benefit from this control.
  46585. */
  46586. linkRefractionWithTransparency: boolean;
  46587. /**
  46588. * Defines the minimum thickness stored in the thickness map.
  46589. * If no thickness map is defined, this value will be used to simulate thickness.
  46590. */
  46591. minimumThickness: number;
  46592. /**
  46593. * Defines the maximum thickness stored in the thickness map.
  46594. */
  46595. maximumThickness: number;
  46596. /**
  46597. * Defines the volume tint of the material.
  46598. * This is used for both translucency and scattering.
  46599. */
  46600. tintColor: Color3;
  46601. /**
  46602. * Defines the distance at which the tint color should be found in the media.
  46603. * This is used for refraction only.
  46604. */
  46605. tintColorAtDistance: number;
  46606. /**
  46607. * Defines how far each channel transmit through the media.
  46608. * It is defined as a color to simplify it selection.
  46609. */
  46610. diffusionDistance: Color3;
  46611. private _useMaskFromThicknessTexture;
  46612. /**
  46613. * Stores the intensity of the different subsurface effects in the thickness texture.
  46614. * * the green channel is the translucency intensity.
  46615. * * the blue channel is the scattering intensity.
  46616. * * the alpha channel is the refraction intensity.
  46617. */
  46618. useMaskFromThicknessTexture: boolean;
  46619. /** @hidden */
  46620. private _internalMarkAllSubMeshesAsTexturesDirty;
  46621. /** @hidden */
  46622. _markAllSubMeshesAsTexturesDirty(): void;
  46623. /**
  46624. * Instantiate a new istance of sub surface configuration.
  46625. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46626. */
  46627. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46628. /**
  46629. * Gets wehter the submesh is ready to be used or not.
  46630. * @param defines the list of "defines" to update.
  46631. * @param scene defines the scene the material belongs to.
  46632. * @returns - boolean indicating that the submesh is ready or not.
  46633. */
  46634. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46635. /**
  46636. * Checks to see if a texture is used in the material.
  46637. * @param defines the list of "defines" to update.
  46638. * @param scene defines the scene to the material belongs to.
  46639. */
  46640. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46641. /**
  46642. * Binds the material data.
  46643. * @param uniformBuffer defines the Uniform buffer to fill in.
  46644. * @param scene defines the scene the material belongs to.
  46645. * @param engine defines the engine the material belongs to.
  46646. * @param isFrozen defines wether the material is frozen or not.
  46647. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46648. */
  46649. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46650. /**
  46651. * Unbinds the material from the mesh.
  46652. * @param activeEffect defines the effect that should be unbound from.
  46653. * @returns true if unbound, otherwise false
  46654. */
  46655. unbind(activeEffect: Effect): boolean;
  46656. /**
  46657. * Returns the texture used for refraction or null if none is used.
  46658. * @param scene defines the scene the material belongs to.
  46659. * @returns - Refraction texture if present. If no refraction texture and refraction
  46660. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46661. */
  46662. private _getRefractionTexture;
  46663. /**
  46664. * Returns true if alpha blending should be disabled.
  46665. */
  46666. readonly disableAlphaBlending: boolean;
  46667. /**
  46668. * Fills the list of render target textures.
  46669. * @param renderTargets the list of render targets to update
  46670. */
  46671. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46672. /**
  46673. * Checks to see if a texture is used in the material.
  46674. * @param texture - Base texture to use.
  46675. * @returns - Boolean specifying if a texture is used in the material.
  46676. */
  46677. hasTexture(texture: BaseTexture): boolean;
  46678. /**
  46679. * Gets a boolean indicating that current material needs to register RTT
  46680. * @returns true if this uses a render target otherwise false.
  46681. */
  46682. hasRenderTargetTextures(): boolean;
  46683. /**
  46684. * Returns an array of the actively used textures.
  46685. * @param activeTextures Array of BaseTextures
  46686. */
  46687. getActiveTextures(activeTextures: BaseTexture[]): void;
  46688. /**
  46689. * Returns the animatable textures.
  46690. * @param animatables Array of animatable textures.
  46691. */
  46692. getAnimatables(animatables: IAnimatable[]): void;
  46693. /**
  46694. * Disposes the resources of the material.
  46695. * @param forceDisposeTextures - Forces the disposal of all textures.
  46696. */
  46697. dispose(forceDisposeTextures?: boolean): void;
  46698. /**
  46699. * Get the current class name of the texture useful for serialization or dynamic coding.
  46700. * @returns "PBRSubSurfaceConfiguration"
  46701. */
  46702. getClassName(): string;
  46703. /**
  46704. * Add fallbacks to the effect fallbacks list.
  46705. * @param defines defines the Base texture to use.
  46706. * @param fallbacks defines the current fallback list.
  46707. * @param currentRank defines the current fallback rank.
  46708. * @returns the new fallback rank.
  46709. */
  46710. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46711. /**
  46712. * Add the required uniforms to the current list.
  46713. * @param uniforms defines the current uniform list.
  46714. */
  46715. static AddUniforms(uniforms: string[]): void;
  46716. /**
  46717. * Add the required samplers to the current list.
  46718. * @param samplers defines the current sampler list.
  46719. */
  46720. static AddSamplers(samplers: string[]): void;
  46721. /**
  46722. * Add the required uniforms to the current buffer.
  46723. * @param uniformBuffer defines the current uniform buffer.
  46724. */
  46725. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46726. /**
  46727. * Makes a duplicate of the current configuration into another one.
  46728. * @param configuration define the config where to copy the info
  46729. */
  46730. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46731. /**
  46732. * Serializes this Sub Surface configuration.
  46733. * @returns - An object with the serialized config.
  46734. */
  46735. serialize(): any;
  46736. /**
  46737. * Parses a anisotropy Configuration from a serialized object.
  46738. * @param source - Serialized object.
  46739. * @param scene Defines the scene we are parsing for
  46740. * @param rootUrl Defines the rootUrl to load from
  46741. */
  46742. parse(source: any, scene: Scene, rootUrl: string): void;
  46743. }
  46744. }
  46745. declare module BABYLON {
  46746. /** @hidden */
  46747. export var pbrFragmentDeclaration: {
  46748. name: string;
  46749. shader: string;
  46750. };
  46751. }
  46752. declare module BABYLON {
  46753. /** @hidden */
  46754. export var pbrUboDeclaration: {
  46755. name: string;
  46756. shader: string;
  46757. };
  46758. }
  46759. declare module BABYLON {
  46760. /** @hidden */
  46761. export var pbrFragmentExtraDeclaration: {
  46762. name: string;
  46763. shader: string;
  46764. };
  46765. }
  46766. declare module BABYLON {
  46767. /** @hidden */
  46768. export var pbrFragmentSamplersDeclaration: {
  46769. name: string;
  46770. shader: string;
  46771. };
  46772. }
  46773. declare module BABYLON {
  46774. /** @hidden */
  46775. export var pbrHelperFunctions: {
  46776. name: string;
  46777. shader: string;
  46778. };
  46779. }
  46780. declare module BABYLON {
  46781. /** @hidden */
  46782. export var harmonicsFunctions: {
  46783. name: string;
  46784. shader: string;
  46785. };
  46786. }
  46787. declare module BABYLON {
  46788. /** @hidden */
  46789. export var pbrDirectLightingSetupFunctions: {
  46790. name: string;
  46791. shader: string;
  46792. };
  46793. }
  46794. declare module BABYLON {
  46795. /** @hidden */
  46796. export var pbrDirectLightingFalloffFunctions: {
  46797. name: string;
  46798. shader: string;
  46799. };
  46800. }
  46801. declare module BABYLON {
  46802. /** @hidden */
  46803. export var pbrBRDFFunctions: {
  46804. name: string;
  46805. shader: string;
  46806. };
  46807. }
  46808. declare module BABYLON {
  46809. /** @hidden */
  46810. export var pbrDirectLightingFunctions: {
  46811. name: string;
  46812. shader: string;
  46813. };
  46814. }
  46815. declare module BABYLON {
  46816. /** @hidden */
  46817. export var pbrIBLFunctions: {
  46818. name: string;
  46819. shader: string;
  46820. };
  46821. }
  46822. declare module BABYLON {
  46823. /** @hidden */
  46824. export var pbrDebug: {
  46825. name: string;
  46826. shader: string;
  46827. };
  46828. }
  46829. declare module BABYLON {
  46830. /** @hidden */
  46831. export var pbrPixelShader: {
  46832. name: string;
  46833. shader: string;
  46834. };
  46835. }
  46836. declare module BABYLON {
  46837. /** @hidden */
  46838. export var pbrVertexDeclaration: {
  46839. name: string;
  46840. shader: string;
  46841. };
  46842. }
  46843. declare module BABYLON {
  46844. /** @hidden */
  46845. export var pbrVertexShader: {
  46846. name: string;
  46847. shader: string;
  46848. };
  46849. }
  46850. declare module BABYLON {
  46851. /**
  46852. * Manages the defines for the PBR Material.
  46853. * @hidden
  46854. */
  46855. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46856. PBR: boolean;
  46857. MAINUV1: boolean;
  46858. MAINUV2: boolean;
  46859. UV1: boolean;
  46860. UV2: boolean;
  46861. ALBEDO: boolean;
  46862. ALBEDODIRECTUV: number;
  46863. VERTEXCOLOR: boolean;
  46864. AMBIENT: boolean;
  46865. AMBIENTDIRECTUV: number;
  46866. AMBIENTINGRAYSCALE: boolean;
  46867. OPACITY: boolean;
  46868. VERTEXALPHA: boolean;
  46869. OPACITYDIRECTUV: number;
  46870. OPACITYRGB: boolean;
  46871. ALPHATEST: boolean;
  46872. DEPTHPREPASS: boolean;
  46873. ALPHABLEND: boolean;
  46874. ALPHAFROMALBEDO: boolean;
  46875. ALPHATESTVALUE: string;
  46876. SPECULAROVERALPHA: boolean;
  46877. RADIANCEOVERALPHA: boolean;
  46878. ALPHAFRESNEL: boolean;
  46879. LINEARALPHAFRESNEL: boolean;
  46880. PREMULTIPLYALPHA: boolean;
  46881. EMISSIVE: boolean;
  46882. EMISSIVEDIRECTUV: number;
  46883. REFLECTIVITY: boolean;
  46884. REFLECTIVITYDIRECTUV: number;
  46885. SPECULARTERM: boolean;
  46886. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46887. MICROSURFACEAUTOMATIC: boolean;
  46888. LODBASEDMICROSFURACE: boolean;
  46889. MICROSURFACEMAP: boolean;
  46890. MICROSURFACEMAPDIRECTUV: number;
  46891. METALLICWORKFLOW: boolean;
  46892. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46893. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46894. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46895. AOSTOREINMETALMAPRED: boolean;
  46896. ENVIRONMENTBRDF: boolean;
  46897. ENVIRONMENTBRDF_RGBD: boolean;
  46898. NORMAL: boolean;
  46899. TANGENT: boolean;
  46900. BUMP: boolean;
  46901. BUMPDIRECTUV: number;
  46902. OBJECTSPACE_NORMALMAP: boolean;
  46903. PARALLAX: boolean;
  46904. PARALLAXOCCLUSION: boolean;
  46905. NORMALXYSCALE: boolean;
  46906. LIGHTMAP: boolean;
  46907. LIGHTMAPDIRECTUV: number;
  46908. USELIGHTMAPASSHADOWMAP: boolean;
  46909. GAMMALIGHTMAP: boolean;
  46910. RGBDLIGHTMAP: boolean;
  46911. REFLECTION: boolean;
  46912. REFLECTIONMAP_3D: boolean;
  46913. REFLECTIONMAP_SPHERICAL: boolean;
  46914. REFLECTIONMAP_PLANAR: boolean;
  46915. REFLECTIONMAP_CUBIC: boolean;
  46916. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46917. REFLECTIONMAP_PROJECTION: boolean;
  46918. REFLECTIONMAP_SKYBOX: boolean;
  46919. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46920. REFLECTIONMAP_EXPLICIT: boolean;
  46921. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46922. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46923. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46924. INVERTCUBICMAP: boolean;
  46925. USESPHERICALFROMREFLECTIONMAP: boolean;
  46926. USEIRRADIANCEMAP: boolean;
  46927. SPHERICAL_HARMONICS: boolean;
  46928. USESPHERICALINVERTEX: boolean;
  46929. REFLECTIONMAP_OPPOSITEZ: boolean;
  46930. LODINREFLECTIONALPHA: boolean;
  46931. GAMMAREFLECTION: boolean;
  46932. RGBDREFLECTION: boolean;
  46933. LINEARSPECULARREFLECTION: boolean;
  46934. RADIANCEOCCLUSION: boolean;
  46935. HORIZONOCCLUSION: boolean;
  46936. INSTANCES: boolean;
  46937. NUM_BONE_INFLUENCERS: number;
  46938. BonesPerMesh: number;
  46939. BONETEXTURE: boolean;
  46940. NONUNIFORMSCALING: boolean;
  46941. MORPHTARGETS: boolean;
  46942. MORPHTARGETS_NORMAL: boolean;
  46943. MORPHTARGETS_TANGENT: boolean;
  46944. MORPHTARGETS_UV: boolean;
  46945. NUM_MORPH_INFLUENCERS: number;
  46946. IMAGEPROCESSING: boolean;
  46947. VIGNETTE: boolean;
  46948. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46949. VIGNETTEBLENDMODEOPAQUE: boolean;
  46950. TONEMAPPING: boolean;
  46951. TONEMAPPING_ACES: boolean;
  46952. CONTRAST: boolean;
  46953. COLORCURVES: boolean;
  46954. COLORGRADING: boolean;
  46955. COLORGRADING3D: boolean;
  46956. SAMPLER3DGREENDEPTH: boolean;
  46957. SAMPLER3DBGRMAP: boolean;
  46958. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46959. EXPOSURE: boolean;
  46960. MULTIVIEW: boolean;
  46961. USEPHYSICALLIGHTFALLOFF: boolean;
  46962. USEGLTFLIGHTFALLOFF: boolean;
  46963. TWOSIDEDLIGHTING: boolean;
  46964. SHADOWFLOAT: boolean;
  46965. CLIPPLANE: boolean;
  46966. CLIPPLANE2: boolean;
  46967. CLIPPLANE3: boolean;
  46968. CLIPPLANE4: boolean;
  46969. POINTSIZE: boolean;
  46970. FOG: boolean;
  46971. LOGARITHMICDEPTH: boolean;
  46972. FORCENORMALFORWARD: boolean;
  46973. SPECULARAA: boolean;
  46974. CLEARCOAT: boolean;
  46975. CLEARCOAT_DEFAULTIOR: boolean;
  46976. CLEARCOAT_TEXTURE: boolean;
  46977. CLEARCOAT_TEXTUREDIRECTUV: number;
  46978. CLEARCOAT_BUMP: boolean;
  46979. CLEARCOAT_BUMPDIRECTUV: number;
  46980. CLEARCOAT_TINT: boolean;
  46981. CLEARCOAT_TINT_TEXTURE: boolean;
  46982. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46983. ANISOTROPIC: boolean;
  46984. ANISOTROPIC_TEXTURE: boolean;
  46985. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46986. BRDF_V_HEIGHT_CORRELATED: boolean;
  46987. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46988. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46989. SHEEN: boolean;
  46990. SHEEN_TEXTURE: boolean;
  46991. SHEEN_TEXTUREDIRECTUV: number;
  46992. SHEEN_LINKWITHALBEDO: boolean;
  46993. SUBSURFACE: boolean;
  46994. SS_REFRACTION: boolean;
  46995. SS_TRANSLUCENCY: boolean;
  46996. SS_SCATERRING: boolean;
  46997. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46998. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46999. SS_REFRACTIONMAP_3D: boolean;
  47000. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47001. SS_LODINREFRACTIONALPHA: boolean;
  47002. SS_GAMMAREFRACTION: boolean;
  47003. SS_RGBDREFRACTION: boolean;
  47004. SS_LINEARSPECULARREFRACTION: boolean;
  47005. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47006. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47007. UNLIT: boolean;
  47008. DEBUGMODE: number;
  47009. /**
  47010. * Initializes the PBR Material defines.
  47011. */
  47012. constructor();
  47013. /**
  47014. * Resets the PBR Material defines.
  47015. */
  47016. reset(): void;
  47017. }
  47018. /**
  47019. * The Physically based material base class of BJS.
  47020. *
  47021. * This offers the main features of a standard PBR material.
  47022. * For more information, please refer to the documentation :
  47023. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47024. */
  47025. export abstract class PBRBaseMaterial extends PushMaterial {
  47026. /**
  47027. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47028. */
  47029. static readonly PBRMATERIAL_OPAQUE: number;
  47030. /**
  47031. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47032. */
  47033. static readonly PBRMATERIAL_ALPHATEST: number;
  47034. /**
  47035. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47036. */
  47037. static readonly PBRMATERIAL_ALPHABLEND: number;
  47038. /**
  47039. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47040. * They are also discarded below the alpha cutoff threshold to improve performances.
  47041. */
  47042. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47043. /**
  47044. * Defines the default value of how much AO map is occluding the analytical lights
  47045. * (point spot...).
  47046. */
  47047. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47048. /**
  47049. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47050. */
  47051. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47052. /**
  47053. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47054. * to enhance interoperability with other engines.
  47055. */
  47056. static readonly LIGHTFALLOFF_GLTF: number;
  47057. /**
  47058. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47059. * to enhance interoperability with other materials.
  47060. */
  47061. static readonly LIGHTFALLOFF_STANDARD: number;
  47062. /**
  47063. * Intensity of the direct lights e.g. the four lights available in your scene.
  47064. * This impacts both the direct diffuse and specular highlights.
  47065. */
  47066. protected _directIntensity: number;
  47067. /**
  47068. * Intensity of the emissive part of the material.
  47069. * This helps controlling the emissive effect without modifying the emissive color.
  47070. */
  47071. protected _emissiveIntensity: number;
  47072. /**
  47073. * Intensity of the environment e.g. how much the environment will light the object
  47074. * either through harmonics for rough material or through the refelction for shiny ones.
  47075. */
  47076. protected _environmentIntensity: number;
  47077. /**
  47078. * This is a special control allowing the reduction of the specular highlights coming from the
  47079. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47080. */
  47081. protected _specularIntensity: number;
  47082. /**
  47083. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47084. */
  47085. private _lightingInfos;
  47086. /**
  47087. * Debug Control allowing disabling the bump map on this material.
  47088. */
  47089. protected _disableBumpMap: boolean;
  47090. /**
  47091. * AKA Diffuse Texture in standard nomenclature.
  47092. */
  47093. protected _albedoTexture: Nullable<BaseTexture>;
  47094. /**
  47095. * AKA Occlusion Texture in other nomenclature.
  47096. */
  47097. protected _ambientTexture: Nullable<BaseTexture>;
  47098. /**
  47099. * AKA Occlusion Texture Intensity in other nomenclature.
  47100. */
  47101. protected _ambientTextureStrength: number;
  47102. /**
  47103. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47104. * 1 means it completely occludes it
  47105. * 0 mean it has no impact
  47106. */
  47107. protected _ambientTextureImpactOnAnalyticalLights: number;
  47108. /**
  47109. * Stores the alpha values in a texture.
  47110. */
  47111. protected _opacityTexture: Nullable<BaseTexture>;
  47112. /**
  47113. * Stores the reflection values in a texture.
  47114. */
  47115. protected _reflectionTexture: Nullable<BaseTexture>;
  47116. /**
  47117. * Stores the emissive values in a texture.
  47118. */
  47119. protected _emissiveTexture: Nullable<BaseTexture>;
  47120. /**
  47121. * AKA Specular texture in other nomenclature.
  47122. */
  47123. protected _reflectivityTexture: Nullable<BaseTexture>;
  47124. /**
  47125. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47126. */
  47127. protected _metallicTexture: Nullable<BaseTexture>;
  47128. /**
  47129. * Specifies the metallic scalar of the metallic/roughness workflow.
  47130. * Can also be used to scale the metalness values of the metallic texture.
  47131. */
  47132. protected _metallic: Nullable<number>;
  47133. /**
  47134. * Specifies the roughness scalar of the metallic/roughness workflow.
  47135. * Can also be used to scale the roughness values of the metallic texture.
  47136. */
  47137. protected _roughness: Nullable<number>;
  47138. /**
  47139. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47140. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47141. */
  47142. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47143. /**
  47144. * Stores surface normal data used to displace a mesh in a texture.
  47145. */
  47146. protected _bumpTexture: Nullable<BaseTexture>;
  47147. /**
  47148. * Stores the pre-calculated light information of a mesh in a texture.
  47149. */
  47150. protected _lightmapTexture: Nullable<BaseTexture>;
  47151. /**
  47152. * The color of a material in ambient lighting.
  47153. */
  47154. protected _ambientColor: Color3;
  47155. /**
  47156. * AKA Diffuse Color in other nomenclature.
  47157. */
  47158. protected _albedoColor: Color3;
  47159. /**
  47160. * AKA Specular Color in other nomenclature.
  47161. */
  47162. protected _reflectivityColor: Color3;
  47163. /**
  47164. * The color applied when light is reflected from a material.
  47165. */
  47166. protected _reflectionColor: Color3;
  47167. /**
  47168. * The color applied when light is emitted from a material.
  47169. */
  47170. protected _emissiveColor: Color3;
  47171. /**
  47172. * AKA Glossiness in other nomenclature.
  47173. */
  47174. protected _microSurface: number;
  47175. /**
  47176. * Specifies that the material will use the light map as a show map.
  47177. */
  47178. protected _useLightmapAsShadowmap: boolean;
  47179. /**
  47180. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47181. * makes the reflect vector face the model (under horizon).
  47182. */
  47183. protected _useHorizonOcclusion: boolean;
  47184. /**
  47185. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47186. * too much the area relying on ambient texture to define their ambient occlusion.
  47187. */
  47188. protected _useRadianceOcclusion: boolean;
  47189. /**
  47190. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47191. */
  47192. protected _useAlphaFromAlbedoTexture: boolean;
  47193. /**
  47194. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47195. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47196. */
  47197. protected _useSpecularOverAlpha: boolean;
  47198. /**
  47199. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47200. */
  47201. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47202. /**
  47203. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47204. */
  47205. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47206. /**
  47207. * Specifies if the metallic texture contains the roughness information in its green channel.
  47208. */
  47209. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47210. /**
  47211. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47212. */
  47213. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47214. /**
  47215. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47216. */
  47217. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47218. /**
  47219. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47220. */
  47221. protected _useAmbientInGrayScale: boolean;
  47222. /**
  47223. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47224. * The material will try to infer what glossiness each pixel should be.
  47225. */
  47226. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47227. /**
  47228. * Defines the falloff type used in this material.
  47229. * It by default is Physical.
  47230. */
  47231. protected _lightFalloff: number;
  47232. /**
  47233. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47234. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47235. */
  47236. protected _useRadianceOverAlpha: boolean;
  47237. /**
  47238. * Allows using an object space normal map (instead of tangent space).
  47239. */
  47240. protected _useObjectSpaceNormalMap: boolean;
  47241. /**
  47242. * Allows using the bump map in parallax mode.
  47243. */
  47244. protected _useParallax: boolean;
  47245. /**
  47246. * Allows using the bump map in parallax occlusion mode.
  47247. */
  47248. protected _useParallaxOcclusion: boolean;
  47249. /**
  47250. * Controls the scale bias of the parallax mode.
  47251. */
  47252. protected _parallaxScaleBias: number;
  47253. /**
  47254. * If sets to true, disables all the lights affecting the material.
  47255. */
  47256. protected _disableLighting: boolean;
  47257. /**
  47258. * Number of Simultaneous lights allowed on the material.
  47259. */
  47260. protected _maxSimultaneousLights: number;
  47261. /**
  47262. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47263. */
  47264. protected _invertNormalMapX: boolean;
  47265. /**
  47266. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47267. */
  47268. protected _invertNormalMapY: boolean;
  47269. /**
  47270. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47271. */
  47272. protected _twoSidedLighting: boolean;
  47273. /**
  47274. * Defines the alpha limits in alpha test mode.
  47275. */
  47276. protected _alphaCutOff: number;
  47277. /**
  47278. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47279. */
  47280. protected _forceAlphaTest: boolean;
  47281. /**
  47282. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47283. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47284. */
  47285. protected _useAlphaFresnel: boolean;
  47286. /**
  47287. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47288. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47289. */
  47290. protected _useLinearAlphaFresnel: boolean;
  47291. /**
  47292. * The transparency mode of the material.
  47293. */
  47294. protected _transparencyMode: Nullable<number>;
  47295. /**
  47296. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47297. * from cos thetav and roughness:
  47298. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47299. */
  47300. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47301. /**
  47302. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47303. */
  47304. protected _forceIrradianceInFragment: boolean;
  47305. /**
  47306. * Force normal to face away from face.
  47307. */
  47308. protected _forceNormalForward: boolean;
  47309. /**
  47310. * Enables specular anti aliasing in the PBR shader.
  47311. * It will both interacts on the Geometry for analytical and IBL lighting.
  47312. * It also prefilter the roughness map based on the bump values.
  47313. */
  47314. protected _enableSpecularAntiAliasing: boolean;
  47315. /**
  47316. * Default configuration related to image processing available in the PBR Material.
  47317. */
  47318. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47319. /**
  47320. * Keep track of the image processing observer to allow dispose and replace.
  47321. */
  47322. private _imageProcessingObserver;
  47323. /**
  47324. * Attaches a new image processing configuration to the PBR Material.
  47325. * @param configuration
  47326. */
  47327. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47328. /**
  47329. * Stores the available render targets.
  47330. */
  47331. private _renderTargets;
  47332. /**
  47333. * Sets the global ambient color for the material used in lighting calculations.
  47334. */
  47335. private _globalAmbientColor;
  47336. /**
  47337. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47338. */
  47339. private _useLogarithmicDepth;
  47340. /**
  47341. * If set to true, no lighting calculations will be applied.
  47342. */
  47343. private _unlit;
  47344. private _debugMode;
  47345. /**
  47346. * @hidden
  47347. * This is reserved for the inspector.
  47348. * Defines the material debug mode.
  47349. * It helps seeing only some components of the material while troubleshooting.
  47350. */
  47351. debugMode: number;
  47352. /**
  47353. * @hidden
  47354. * This is reserved for the inspector.
  47355. * Specify from where on screen the debug mode should start.
  47356. * The value goes from -1 (full screen) to 1 (not visible)
  47357. * It helps with side by side comparison against the final render
  47358. * This defaults to -1
  47359. */
  47360. private debugLimit;
  47361. /**
  47362. * @hidden
  47363. * This is reserved for the inspector.
  47364. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47365. * You can use the factor to better multiply the final value.
  47366. */
  47367. private debugFactor;
  47368. /**
  47369. * Defines the clear coat layer parameters for the material.
  47370. */
  47371. readonly clearCoat: PBRClearCoatConfiguration;
  47372. /**
  47373. * Defines the anisotropic parameters for the material.
  47374. */
  47375. readonly anisotropy: PBRAnisotropicConfiguration;
  47376. /**
  47377. * Defines the BRDF parameters for the material.
  47378. */
  47379. readonly brdf: PBRBRDFConfiguration;
  47380. /**
  47381. * Defines the Sheen parameters for the material.
  47382. */
  47383. readonly sheen: PBRSheenConfiguration;
  47384. /**
  47385. * Defines the SubSurface parameters for the material.
  47386. */
  47387. readonly subSurface: PBRSubSurfaceConfiguration;
  47388. /**
  47389. * Custom callback helping to override the default shader used in the material.
  47390. */
  47391. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47392. protected _rebuildInParallel: boolean;
  47393. /**
  47394. * Instantiates a new PBRMaterial instance.
  47395. *
  47396. * @param name The material name
  47397. * @param scene The scene the material will be use in.
  47398. */
  47399. constructor(name: string, scene: Scene);
  47400. /**
  47401. * Gets a boolean indicating that current material needs to register RTT
  47402. */
  47403. readonly hasRenderTargetTextures: boolean;
  47404. /**
  47405. * Gets the name of the material class.
  47406. */
  47407. getClassName(): string;
  47408. /**
  47409. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47410. */
  47411. /**
  47412. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47413. */
  47414. useLogarithmicDepth: boolean;
  47415. /**
  47416. * Gets the current transparency mode.
  47417. */
  47418. /**
  47419. * Sets the transparency mode of the material.
  47420. *
  47421. * | Value | Type | Description |
  47422. * | ----- | ----------------------------------- | ----------- |
  47423. * | 0 | OPAQUE | |
  47424. * | 1 | ALPHATEST | |
  47425. * | 2 | ALPHABLEND | |
  47426. * | 3 | ALPHATESTANDBLEND | |
  47427. *
  47428. */
  47429. transparencyMode: Nullable<number>;
  47430. /**
  47431. * Returns true if alpha blending should be disabled.
  47432. */
  47433. private readonly _disableAlphaBlending;
  47434. /**
  47435. * Specifies whether or not this material should be rendered in alpha blend mode.
  47436. */
  47437. needAlphaBlending(): boolean;
  47438. /**
  47439. * Specifies if the mesh will require alpha blending.
  47440. * @param mesh - BJS mesh.
  47441. */
  47442. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47443. /**
  47444. * Specifies whether or not this material should be rendered in alpha test mode.
  47445. */
  47446. needAlphaTesting(): boolean;
  47447. /**
  47448. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47449. */
  47450. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47451. /**
  47452. * Gets the texture used for the alpha test.
  47453. */
  47454. getAlphaTestTexture(): Nullable<BaseTexture>;
  47455. /**
  47456. * Specifies that the submesh is ready to be used.
  47457. * @param mesh - BJS mesh.
  47458. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47459. * @param useInstances - Specifies that instances should be used.
  47460. * @returns - boolean indicating that the submesh is ready or not.
  47461. */
  47462. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47463. /**
  47464. * Specifies if the material uses metallic roughness workflow.
  47465. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47466. */
  47467. isMetallicWorkflow(): boolean;
  47468. private _prepareEffect;
  47469. private _prepareDefines;
  47470. /**
  47471. * Force shader compilation
  47472. */
  47473. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47474. clipPlane: boolean;
  47475. }>): void;
  47476. /**
  47477. * Initializes the uniform buffer layout for the shader.
  47478. */
  47479. buildUniformLayout(): void;
  47480. /**
  47481. * Unbinds the material from the mesh
  47482. */
  47483. unbind(): void;
  47484. /**
  47485. * Binds the submesh data.
  47486. * @param world - The world matrix.
  47487. * @param mesh - The BJS mesh.
  47488. * @param subMesh - A submesh of the BJS mesh.
  47489. */
  47490. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47491. /**
  47492. * Returns the animatable textures.
  47493. * @returns - Array of animatable textures.
  47494. */
  47495. getAnimatables(): IAnimatable[];
  47496. /**
  47497. * Returns the texture used for reflections.
  47498. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47499. */
  47500. private _getReflectionTexture;
  47501. /**
  47502. * Returns an array of the actively used textures.
  47503. * @returns - Array of BaseTextures
  47504. */
  47505. getActiveTextures(): BaseTexture[];
  47506. /**
  47507. * Checks to see if a texture is used in the material.
  47508. * @param texture - Base texture to use.
  47509. * @returns - Boolean specifying if a texture is used in the material.
  47510. */
  47511. hasTexture(texture: BaseTexture): boolean;
  47512. /**
  47513. * Disposes the resources of the material.
  47514. * @param forceDisposeEffect - Forces the disposal of effects.
  47515. * @param forceDisposeTextures - Forces the disposal of all textures.
  47516. */
  47517. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47518. }
  47519. }
  47520. declare module BABYLON {
  47521. /**
  47522. * The Physically based material of BJS.
  47523. *
  47524. * This offers the main features of a standard PBR material.
  47525. * For more information, please refer to the documentation :
  47526. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47527. */
  47528. export class PBRMaterial extends PBRBaseMaterial {
  47529. /**
  47530. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47531. */
  47532. static readonly PBRMATERIAL_OPAQUE: number;
  47533. /**
  47534. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47535. */
  47536. static readonly PBRMATERIAL_ALPHATEST: number;
  47537. /**
  47538. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47539. */
  47540. static readonly PBRMATERIAL_ALPHABLEND: number;
  47541. /**
  47542. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47543. * They are also discarded below the alpha cutoff threshold to improve performances.
  47544. */
  47545. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47546. /**
  47547. * Defines the default value of how much AO map is occluding the analytical lights
  47548. * (point spot...).
  47549. */
  47550. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47551. /**
  47552. * Intensity of the direct lights e.g. the four lights available in your scene.
  47553. * This impacts both the direct diffuse and specular highlights.
  47554. */
  47555. directIntensity: number;
  47556. /**
  47557. * Intensity of the emissive part of the material.
  47558. * This helps controlling the emissive effect without modifying the emissive color.
  47559. */
  47560. emissiveIntensity: number;
  47561. /**
  47562. * Intensity of the environment e.g. how much the environment will light the object
  47563. * either through harmonics for rough material or through the refelction for shiny ones.
  47564. */
  47565. environmentIntensity: number;
  47566. /**
  47567. * This is a special control allowing the reduction of the specular highlights coming from the
  47568. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47569. */
  47570. specularIntensity: number;
  47571. /**
  47572. * Debug Control allowing disabling the bump map on this material.
  47573. */
  47574. disableBumpMap: boolean;
  47575. /**
  47576. * AKA Diffuse Texture in standard nomenclature.
  47577. */
  47578. albedoTexture: BaseTexture;
  47579. /**
  47580. * AKA Occlusion Texture in other nomenclature.
  47581. */
  47582. ambientTexture: BaseTexture;
  47583. /**
  47584. * AKA Occlusion Texture Intensity in other nomenclature.
  47585. */
  47586. ambientTextureStrength: number;
  47587. /**
  47588. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47589. * 1 means it completely occludes it
  47590. * 0 mean it has no impact
  47591. */
  47592. ambientTextureImpactOnAnalyticalLights: number;
  47593. /**
  47594. * Stores the alpha values in a texture.
  47595. */
  47596. opacityTexture: BaseTexture;
  47597. /**
  47598. * Stores the reflection values in a texture.
  47599. */
  47600. reflectionTexture: Nullable<BaseTexture>;
  47601. /**
  47602. * Stores the emissive values in a texture.
  47603. */
  47604. emissiveTexture: BaseTexture;
  47605. /**
  47606. * AKA Specular texture in other nomenclature.
  47607. */
  47608. reflectivityTexture: BaseTexture;
  47609. /**
  47610. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47611. */
  47612. metallicTexture: BaseTexture;
  47613. /**
  47614. * Specifies the metallic scalar of the metallic/roughness workflow.
  47615. * Can also be used to scale the metalness values of the metallic texture.
  47616. */
  47617. metallic: Nullable<number>;
  47618. /**
  47619. * Specifies the roughness scalar of the metallic/roughness workflow.
  47620. * Can also be used to scale the roughness values of the metallic texture.
  47621. */
  47622. roughness: Nullable<number>;
  47623. /**
  47624. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47625. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47626. */
  47627. microSurfaceTexture: BaseTexture;
  47628. /**
  47629. * Stores surface normal data used to displace a mesh in a texture.
  47630. */
  47631. bumpTexture: BaseTexture;
  47632. /**
  47633. * Stores the pre-calculated light information of a mesh in a texture.
  47634. */
  47635. lightmapTexture: BaseTexture;
  47636. /**
  47637. * Stores the refracted light information in a texture.
  47638. */
  47639. refractionTexture: Nullable<BaseTexture>;
  47640. /**
  47641. * The color of a material in ambient lighting.
  47642. */
  47643. ambientColor: Color3;
  47644. /**
  47645. * AKA Diffuse Color in other nomenclature.
  47646. */
  47647. albedoColor: Color3;
  47648. /**
  47649. * AKA Specular Color in other nomenclature.
  47650. */
  47651. reflectivityColor: Color3;
  47652. /**
  47653. * The color reflected from the material.
  47654. */
  47655. reflectionColor: Color3;
  47656. /**
  47657. * The color emitted from the material.
  47658. */
  47659. emissiveColor: Color3;
  47660. /**
  47661. * AKA Glossiness in other nomenclature.
  47662. */
  47663. microSurface: number;
  47664. /**
  47665. * source material index of refraction (IOR)' / 'destination material IOR.
  47666. */
  47667. indexOfRefraction: number;
  47668. /**
  47669. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47670. */
  47671. invertRefractionY: boolean;
  47672. /**
  47673. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47674. * Materials half opaque for instance using refraction could benefit from this control.
  47675. */
  47676. linkRefractionWithTransparency: boolean;
  47677. /**
  47678. * If true, the light map contains occlusion information instead of lighting info.
  47679. */
  47680. useLightmapAsShadowmap: boolean;
  47681. /**
  47682. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47683. */
  47684. useAlphaFromAlbedoTexture: boolean;
  47685. /**
  47686. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47687. */
  47688. forceAlphaTest: boolean;
  47689. /**
  47690. * Defines the alpha limits in alpha test mode.
  47691. */
  47692. alphaCutOff: number;
  47693. /**
  47694. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47695. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47696. */
  47697. useSpecularOverAlpha: boolean;
  47698. /**
  47699. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47700. */
  47701. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47702. /**
  47703. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47704. */
  47705. useRoughnessFromMetallicTextureAlpha: boolean;
  47706. /**
  47707. * Specifies if the metallic texture contains the roughness information in its green channel.
  47708. */
  47709. useRoughnessFromMetallicTextureGreen: boolean;
  47710. /**
  47711. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47712. */
  47713. useMetallnessFromMetallicTextureBlue: boolean;
  47714. /**
  47715. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47716. */
  47717. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47718. /**
  47719. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47720. */
  47721. useAmbientInGrayScale: boolean;
  47722. /**
  47723. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47724. * The material will try to infer what glossiness each pixel should be.
  47725. */
  47726. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47727. /**
  47728. * BJS is using an harcoded light falloff based on a manually sets up range.
  47729. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47730. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47731. */
  47732. /**
  47733. * BJS is using an harcoded light falloff based on a manually sets up range.
  47734. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47735. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47736. */
  47737. usePhysicalLightFalloff: boolean;
  47738. /**
  47739. * In order to support the falloff compatibility with gltf, a special mode has been added
  47740. * to reproduce the gltf light falloff.
  47741. */
  47742. /**
  47743. * In order to support the falloff compatibility with gltf, a special mode has been added
  47744. * to reproduce the gltf light falloff.
  47745. */
  47746. useGLTFLightFalloff: boolean;
  47747. /**
  47748. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47749. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47750. */
  47751. useRadianceOverAlpha: boolean;
  47752. /**
  47753. * Allows using an object space normal map (instead of tangent space).
  47754. */
  47755. useObjectSpaceNormalMap: boolean;
  47756. /**
  47757. * Allows using the bump map in parallax mode.
  47758. */
  47759. useParallax: boolean;
  47760. /**
  47761. * Allows using the bump map in parallax occlusion mode.
  47762. */
  47763. useParallaxOcclusion: boolean;
  47764. /**
  47765. * Controls the scale bias of the parallax mode.
  47766. */
  47767. parallaxScaleBias: number;
  47768. /**
  47769. * If sets to true, disables all the lights affecting the material.
  47770. */
  47771. disableLighting: boolean;
  47772. /**
  47773. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47774. */
  47775. forceIrradianceInFragment: boolean;
  47776. /**
  47777. * Number of Simultaneous lights allowed on the material.
  47778. */
  47779. maxSimultaneousLights: number;
  47780. /**
  47781. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47782. */
  47783. invertNormalMapX: boolean;
  47784. /**
  47785. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47786. */
  47787. invertNormalMapY: boolean;
  47788. /**
  47789. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47790. */
  47791. twoSidedLighting: boolean;
  47792. /**
  47793. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47794. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47795. */
  47796. useAlphaFresnel: boolean;
  47797. /**
  47798. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47799. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47800. */
  47801. useLinearAlphaFresnel: boolean;
  47802. /**
  47803. * Let user defines the brdf lookup texture used for IBL.
  47804. * A default 8bit version is embedded but you could point at :
  47805. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  47806. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47807. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  47808. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47809. */
  47810. environmentBRDFTexture: Nullable<BaseTexture>;
  47811. /**
  47812. * Force normal to face away from face.
  47813. */
  47814. forceNormalForward: boolean;
  47815. /**
  47816. * Enables specular anti aliasing in the PBR shader.
  47817. * It will both interacts on the Geometry for analytical and IBL lighting.
  47818. * It also prefilter the roughness map based on the bump values.
  47819. */
  47820. enableSpecularAntiAliasing: boolean;
  47821. /**
  47822. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47823. * makes the reflect vector face the model (under horizon).
  47824. */
  47825. useHorizonOcclusion: boolean;
  47826. /**
  47827. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47828. * too much the area relying on ambient texture to define their ambient occlusion.
  47829. */
  47830. useRadianceOcclusion: boolean;
  47831. /**
  47832. * If set to true, no lighting calculations will be applied.
  47833. */
  47834. unlit: boolean;
  47835. /**
  47836. * Gets the image processing configuration used either in this material.
  47837. */
  47838. /**
  47839. * Sets the Default image processing configuration used either in the this material.
  47840. *
  47841. * If sets to null, the scene one is in use.
  47842. */
  47843. imageProcessingConfiguration: ImageProcessingConfiguration;
  47844. /**
  47845. * Gets wether the color curves effect is enabled.
  47846. */
  47847. /**
  47848. * Sets wether the color curves effect is enabled.
  47849. */
  47850. cameraColorCurvesEnabled: boolean;
  47851. /**
  47852. * Gets wether the color grading effect is enabled.
  47853. */
  47854. /**
  47855. * Gets wether the color grading effect is enabled.
  47856. */
  47857. cameraColorGradingEnabled: boolean;
  47858. /**
  47859. * Gets wether tonemapping is enabled or not.
  47860. */
  47861. /**
  47862. * Sets wether tonemapping is enabled or not
  47863. */
  47864. cameraToneMappingEnabled: boolean;
  47865. /**
  47866. * The camera exposure used on this material.
  47867. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47868. * This corresponds to a photographic exposure.
  47869. */
  47870. /**
  47871. * The camera exposure used on this material.
  47872. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47873. * This corresponds to a photographic exposure.
  47874. */
  47875. cameraExposure: number;
  47876. /**
  47877. * Gets The camera contrast used on this material.
  47878. */
  47879. /**
  47880. * Sets The camera contrast used on this material.
  47881. */
  47882. cameraContrast: number;
  47883. /**
  47884. * Gets the Color Grading 2D Lookup Texture.
  47885. */
  47886. /**
  47887. * Sets the Color Grading 2D Lookup Texture.
  47888. */
  47889. cameraColorGradingTexture: Nullable<BaseTexture>;
  47890. /**
  47891. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47892. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47893. * 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;
  47894. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47895. */
  47896. /**
  47897. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47898. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47899. * 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;
  47900. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47901. */
  47902. cameraColorCurves: Nullable<ColorCurves>;
  47903. /**
  47904. * Instantiates a new PBRMaterial instance.
  47905. *
  47906. * @param name The material name
  47907. * @param scene The scene the material will be use in.
  47908. */
  47909. constructor(name: string, scene: Scene);
  47910. /**
  47911. * Returns the name of this material class.
  47912. */
  47913. getClassName(): string;
  47914. /**
  47915. * Makes a duplicate of the current material.
  47916. * @param name - name to use for the new material.
  47917. */
  47918. clone(name: string): PBRMaterial;
  47919. /**
  47920. * Serializes this PBR Material.
  47921. * @returns - An object with the serialized material.
  47922. */
  47923. serialize(): any;
  47924. /**
  47925. * Parses a PBR Material from a serialized object.
  47926. * @param source - Serialized object.
  47927. * @param scene - BJS scene instance.
  47928. * @param rootUrl - url for the scene object
  47929. * @returns - PBRMaterial
  47930. */
  47931. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47932. }
  47933. }
  47934. declare module BABYLON {
  47935. /**
  47936. * Direct draw surface info
  47937. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47938. */
  47939. export interface DDSInfo {
  47940. /**
  47941. * Width of the texture
  47942. */
  47943. width: number;
  47944. /**
  47945. * Width of the texture
  47946. */
  47947. height: number;
  47948. /**
  47949. * Number of Mipmaps for the texture
  47950. * @see https://en.wikipedia.org/wiki/Mipmap
  47951. */
  47952. mipmapCount: number;
  47953. /**
  47954. * If the textures format is a known fourCC format
  47955. * @see https://www.fourcc.org/
  47956. */
  47957. isFourCC: boolean;
  47958. /**
  47959. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47960. */
  47961. isRGB: boolean;
  47962. /**
  47963. * If the texture is a lumincance format
  47964. */
  47965. isLuminance: boolean;
  47966. /**
  47967. * If this is a cube texture
  47968. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47969. */
  47970. isCube: boolean;
  47971. /**
  47972. * If the texture is a compressed format eg. FOURCC_DXT1
  47973. */
  47974. isCompressed: boolean;
  47975. /**
  47976. * The dxgiFormat of the texture
  47977. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47978. */
  47979. dxgiFormat: number;
  47980. /**
  47981. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47982. */
  47983. textureType: number;
  47984. /**
  47985. * Sphericle polynomial created for the dds texture
  47986. */
  47987. sphericalPolynomial?: SphericalPolynomial;
  47988. }
  47989. /**
  47990. * Class used to provide DDS decompression tools
  47991. */
  47992. export class DDSTools {
  47993. /**
  47994. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47995. */
  47996. static StoreLODInAlphaChannel: boolean;
  47997. /**
  47998. * Gets DDS information from an array buffer
  47999. * @param arrayBuffer defines the array buffer to read data from
  48000. * @returns the DDS information
  48001. */
  48002. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48003. private static _FloatView;
  48004. private static _Int32View;
  48005. private static _ToHalfFloat;
  48006. private static _FromHalfFloat;
  48007. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48008. private static _GetHalfFloatRGBAArrayBuffer;
  48009. private static _GetFloatRGBAArrayBuffer;
  48010. private static _GetFloatAsUIntRGBAArrayBuffer;
  48011. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48012. private static _GetRGBAArrayBuffer;
  48013. private static _ExtractLongWordOrder;
  48014. private static _GetRGBArrayBuffer;
  48015. private static _GetLuminanceArrayBuffer;
  48016. /**
  48017. * Uploads DDS Levels to a Babylon Texture
  48018. * @hidden
  48019. */
  48020. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48021. }
  48022. interface Engine {
  48023. /**
  48024. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48025. * @param rootUrl defines the url where the file to load is located
  48026. * @param scene defines the current scene
  48027. * @param lodScale defines scale to apply to the mip map selection
  48028. * @param lodOffset defines offset to apply to the mip map selection
  48029. * @param onLoad defines an optional callback raised when the texture is loaded
  48030. * @param onError defines an optional callback raised if there is an issue to load the texture
  48031. * @param format defines the format of the data
  48032. * @param forcedExtension defines the extension to use to pick the right loader
  48033. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48034. * @returns the cube texture as an InternalTexture
  48035. */
  48036. 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;
  48037. }
  48038. }
  48039. declare module BABYLON {
  48040. /**
  48041. * Implementation of the DDS Texture Loader.
  48042. * @hidden
  48043. */
  48044. export class _DDSTextureLoader implements IInternalTextureLoader {
  48045. /**
  48046. * Defines wether the loader supports cascade loading the different faces.
  48047. */
  48048. readonly supportCascades: boolean;
  48049. /**
  48050. * This returns if the loader support the current file information.
  48051. * @param extension defines the file extension of the file being loaded
  48052. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48053. * @param fallback defines the fallback internal texture if any
  48054. * @param isBase64 defines whether the texture is encoded as a base64
  48055. * @param isBuffer defines whether the texture data are stored as a buffer
  48056. * @returns true if the loader can load the specified file
  48057. */
  48058. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48059. /**
  48060. * Transform the url before loading if required.
  48061. * @param rootUrl the url of the texture
  48062. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48063. * @returns the transformed texture
  48064. */
  48065. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48066. /**
  48067. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48068. * @param rootUrl the url of the texture
  48069. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48070. * @returns the fallback texture
  48071. */
  48072. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48073. /**
  48074. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48075. * @param data contains the texture data
  48076. * @param texture defines the BabylonJS internal texture
  48077. * @param createPolynomials will be true if polynomials have been requested
  48078. * @param onLoad defines the callback to trigger once the texture is ready
  48079. * @param onError defines the callback to trigger in case of error
  48080. */
  48081. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48082. /**
  48083. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48084. * @param data contains the texture data
  48085. * @param texture defines the BabylonJS internal texture
  48086. * @param callback defines the method to call once ready to upload
  48087. */
  48088. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48089. }
  48090. }
  48091. declare module BABYLON {
  48092. /**
  48093. * Implementation of the ENV Texture Loader.
  48094. * @hidden
  48095. */
  48096. export class _ENVTextureLoader implements IInternalTextureLoader {
  48097. /**
  48098. * Defines wether the loader supports cascade loading the different faces.
  48099. */
  48100. readonly supportCascades: boolean;
  48101. /**
  48102. * This returns if the loader support the current file information.
  48103. * @param extension defines the file extension of the file being loaded
  48104. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48105. * @param fallback defines the fallback internal texture if any
  48106. * @param isBase64 defines whether the texture is encoded as a base64
  48107. * @param isBuffer defines whether the texture data are stored as a buffer
  48108. * @returns true if the loader can load the specified file
  48109. */
  48110. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48111. /**
  48112. * Transform the url before loading if required.
  48113. * @param rootUrl the url of the texture
  48114. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48115. * @returns the transformed texture
  48116. */
  48117. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48118. /**
  48119. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48120. * @param rootUrl the url of the texture
  48121. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48122. * @returns the fallback texture
  48123. */
  48124. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48125. /**
  48126. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48127. * @param data contains the texture data
  48128. * @param texture defines the BabylonJS internal texture
  48129. * @param createPolynomials will be true if polynomials have been requested
  48130. * @param onLoad defines the callback to trigger once the texture is ready
  48131. * @param onError defines the callback to trigger in case of error
  48132. */
  48133. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48134. /**
  48135. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48136. * @param data contains the texture data
  48137. * @param texture defines the BabylonJS internal texture
  48138. * @param callback defines the method to call once ready to upload
  48139. */
  48140. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48141. }
  48142. }
  48143. declare module BABYLON {
  48144. /**
  48145. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48146. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48147. */
  48148. export class KhronosTextureContainer {
  48149. /** contents of the KTX container file */
  48150. arrayBuffer: any;
  48151. private static HEADER_LEN;
  48152. private static COMPRESSED_2D;
  48153. private static COMPRESSED_3D;
  48154. private static TEX_2D;
  48155. private static TEX_3D;
  48156. /**
  48157. * Gets the openGL type
  48158. */
  48159. glType: number;
  48160. /**
  48161. * Gets the openGL type size
  48162. */
  48163. glTypeSize: number;
  48164. /**
  48165. * Gets the openGL format
  48166. */
  48167. glFormat: number;
  48168. /**
  48169. * Gets the openGL internal format
  48170. */
  48171. glInternalFormat: number;
  48172. /**
  48173. * Gets the base internal format
  48174. */
  48175. glBaseInternalFormat: number;
  48176. /**
  48177. * Gets image width in pixel
  48178. */
  48179. pixelWidth: number;
  48180. /**
  48181. * Gets image height in pixel
  48182. */
  48183. pixelHeight: number;
  48184. /**
  48185. * Gets image depth in pixels
  48186. */
  48187. pixelDepth: number;
  48188. /**
  48189. * Gets the number of array elements
  48190. */
  48191. numberOfArrayElements: number;
  48192. /**
  48193. * Gets the number of faces
  48194. */
  48195. numberOfFaces: number;
  48196. /**
  48197. * Gets the number of mipmap levels
  48198. */
  48199. numberOfMipmapLevels: number;
  48200. /**
  48201. * Gets the bytes of key value data
  48202. */
  48203. bytesOfKeyValueData: number;
  48204. /**
  48205. * Gets the load type
  48206. */
  48207. loadType: number;
  48208. /**
  48209. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48210. */
  48211. isInvalid: boolean;
  48212. /**
  48213. * Creates a new KhronosTextureContainer
  48214. * @param arrayBuffer contents of the KTX container file
  48215. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48216. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48217. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48218. */
  48219. constructor(
  48220. /** contents of the KTX container file */
  48221. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48222. /**
  48223. * Uploads KTX content to a Babylon Texture.
  48224. * It is assumed that the texture has already been created & is currently bound
  48225. * @hidden
  48226. */
  48227. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48228. private _upload2DCompressedLevels;
  48229. }
  48230. }
  48231. declare module BABYLON {
  48232. /**
  48233. * Implementation of the KTX Texture Loader.
  48234. * @hidden
  48235. */
  48236. export class _KTXTextureLoader implements IInternalTextureLoader {
  48237. /**
  48238. * Defines wether the loader supports cascade loading the different faces.
  48239. */
  48240. readonly supportCascades: boolean;
  48241. /**
  48242. * This returns if the loader support the current file information.
  48243. * @param extension defines the file extension of the file being loaded
  48244. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48245. * @param fallback defines the fallback internal texture if any
  48246. * @param isBase64 defines whether the texture is encoded as a base64
  48247. * @param isBuffer defines whether the texture data are stored as a buffer
  48248. * @returns true if the loader can load the specified file
  48249. */
  48250. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48251. /**
  48252. * Transform the url before loading if required.
  48253. * @param rootUrl the url of the texture
  48254. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48255. * @returns the transformed texture
  48256. */
  48257. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48258. /**
  48259. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48260. * @param rootUrl the url of the texture
  48261. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48262. * @returns the fallback texture
  48263. */
  48264. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48265. /**
  48266. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48267. * @param data contains the texture data
  48268. * @param texture defines the BabylonJS internal texture
  48269. * @param createPolynomials will be true if polynomials have been requested
  48270. * @param onLoad defines the callback to trigger once the texture is ready
  48271. * @param onError defines the callback to trigger in case of error
  48272. */
  48273. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48274. /**
  48275. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48276. * @param data contains the texture data
  48277. * @param texture defines the BabylonJS internal texture
  48278. * @param callback defines the method to call once ready to upload
  48279. */
  48280. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48281. }
  48282. }
  48283. declare module BABYLON {
  48284. /**
  48285. * Options for the default xr helper
  48286. */
  48287. export class WebXRDefaultExperienceOptions {
  48288. /**
  48289. * Floor meshes that should be used for teleporting
  48290. */
  48291. floorMeshes: Array<AbstractMesh>;
  48292. }
  48293. /**
  48294. * Default experience which provides a similar setup to the previous webVRExperience
  48295. */
  48296. export class WebXRDefaultExperience {
  48297. /**
  48298. * Base experience
  48299. */
  48300. baseExperience: WebXRExperienceHelper;
  48301. /**
  48302. * Input experience extension
  48303. */
  48304. input: WebXRInput;
  48305. /**
  48306. * Loads the controller models
  48307. */
  48308. controllerModelLoader: WebXRControllerModelLoader;
  48309. /**
  48310. * Enables laser pointer and selection
  48311. */
  48312. pointerSelection: WebXRControllerPointerSelection;
  48313. /**
  48314. * Enables teleportation
  48315. */
  48316. teleportation: WebXRControllerTeleportation;
  48317. /**
  48318. * Enables ui for enetering/exiting xr
  48319. */
  48320. enterExitUI: WebXREnterExitUI;
  48321. /**
  48322. * Default output canvas xr should render to
  48323. */
  48324. outputCanvas: WebXRManagedOutputCanvas;
  48325. /**
  48326. * Creates the default xr experience
  48327. * @param scene scene
  48328. * @param options options for basic configuration
  48329. * @returns resulting WebXRDefaultExperience
  48330. */
  48331. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48332. private constructor();
  48333. /**
  48334. * DIsposes of the experience helper
  48335. */
  48336. dispose(): void;
  48337. }
  48338. }
  48339. declare module BABYLON {
  48340. /** @hidden */
  48341. export var _forceSceneHelpersToBundle: boolean;
  48342. interface Scene {
  48343. /**
  48344. * Creates a default light for the scene.
  48345. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48346. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48347. */
  48348. createDefaultLight(replace?: boolean): void;
  48349. /**
  48350. * Creates a default camera for the scene.
  48351. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48352. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48353. * @param replace has default false, when true replaces the active camera in the scene
  48354. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48355. */
  48356. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48357. /**
  48358. * Creates a default camera and a default light.
  48359. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48360. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48361. * @param replace has the default false, when true replaces the active camera/light in the scene
  48362. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48363. */
  48364. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48365. /**
  48366. * Creates a new sky box
  48367. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48368. * @param environmentTexture defines the texture to use as environment texture
  48369. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48370. * @param scale defines the overall scale of the skybox
  48371. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48372. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48373. * @returns a new mesh holding the sky box
  48374. */
  48375. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48376. /**
  48377. * Creates a new environment
  48378. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48379. * @param options defines the options you can use to configure the environment
  48380. * @returns the new EnvironmentHelper
  48381. */
  48382. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48383. /**
  48384. * Creates a new VREXperienceHelper
  48385. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48386. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48387. * @returns a new VREXperienceHelper
  48388. */
  48389. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48390. /**
  48391. * Creates a new WebXRDefaultExperience
  48392. * @see http://doc.babylonjs.com/how_to/webxr
  48393. * @param options experience options
  48394. * @returns a promise for a new WebXRDefaultExperience
  48395. */
  48396. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48397. }
  48398. }
  48399. declare module BABYLON {
  48400. /**
  48401. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48402. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48403. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48404. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48405. */
  48406. export class VideoDome extends TransformNode {
  48407. /**
  48408. * Define the video source as a Monoscopic panoramic 360 video.
  48409. */
  48410. static readonly MODE_MONOSCOPIC: number;
  48411. /**
  48412. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48413. */
  48414. static readonly MODE_TOPBOTTOM: number;
  48415. /**
  48416. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48417. */
  48418. static readonly MODE_SIDEBYSIDE: number;
  48419. private _halfDome;
  48420. private _useDirectMapping;
  48421. /**
  48422. * The video texture being displayed on the sphere
  48423. */
  48424. protected _videoTexture: VideoTexture;
  48425. /**
  48426. * Gets the video texture being displayed on the sphere
  48427. */
  48428. readonly videoTexture: VideoTexture;
  48429. /**
  48430. * The skybox material
  48431. */
  48432. protected _material: BackgroundMaterial;
  48433. /**
  48434. * The surface used for the skybox
  48435. */
  48436. protected _mesh: Mesh;
  48437. /**
  48438. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48439. */
  48440. private _halfDomeMask;
  48441. /**
  48442. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48443. * Also see the options.resolution property.
  48444. */
  48445. fovMultiplier: number;
  48446. private _videoMode;
  48447. /**
  48448. * Gets or set the current video mode for the video. It can be:
  48449. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48450. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48451. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48452. */
  48453. videoMode: number;
  48454. /**
  48455. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48456. *
  48457. */
  48458. /**
  48459. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48460. */
  48461. halfDome: boolean;
  48462. /**
  48463. * Oberserver used in Stereoscopic VR Mode.
  48464. */
  48465. private _onBeforeCameraRenderObserver;
  48466. /**
  48467. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48468. * @param name Element's name, child elements will append suffixes for their own names.
  48469. * @param urlsOrVideo defines the url(s) or the video element to use
  48470. * @param options An object containing optional or exposed sub element properties
  48471. */
  48472. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48473. resolution?: number;
  48474. clickToPlay?: boolean;
  48475. autoPlay?: boolean;
  48476. loop?: boolean;
  48477. size?: number;
  48478. poster?: string;
  48479. faceForward?: boolean;
  48480. useDirectMapping?: boolean;
  48481. halfDomeMode?: boolean;
  48482. }, scene: Scene);
  48483. private _changeVideoMode;
  48484. /**
  48485. * Releases resources associated with this node.
  48486. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48487. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48488. */
  48489. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48490. }
  48491. }
  48492. declare module BABYLON {
  48493. /**
  48494. * This class can be used to get instrumentation data from a Babylon engine
  48495. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48496. */
  48497. export class EngineInstrumentation implements IDisposable {
  48498. /**
  48499. * Define the instrumented engine.
  48500. */
  48501. engine: Engine;
  48502. private _captureGPUFrameTime;
  48503. private _gpuFrameTimeToken;
  48504. private _gpuFrameTime;
  48505. private _captureShaderCompilationTime;
  48506. private _shaderCompilationTime;
  48507. private _onBeginFrameObserver;
  48508. private _onEndFrameObserver;
  48509. private _onBeforeShaderCompilationObserver;
  48510. private _onAfterShaderCompilationObserver;
  48511. /**
  48512. * Gets the perf counter used for GPU frame time
  48513. */
  48514. readonly gpuFrameTimeCounter: PerfCounter;
  48515. /**
  48516. * Gets the GPU frame time capture status
  48517. */
  48518. /**
  48519. * Enable or disable the GPU frame time capture
  48520. */
  48521. captureGPUFrameTime: boolean;
  48522. /**
  48523. * Gets the perf counter used for shader compilation time
  48524. */
  48525. readonly shaderCompilationTimeCounter: PerfCounter;
  48526. /**
  48527. * Gets the shader compilation time capture status
  48528. */
  48529. /**
  48530. * Enable or disable the shader compilation time capture
  48531. */
  48532. captureShaderCompilationTime: boolean;
  48533. /**
  48534. * Instantiates a new engine instrumentation.
  48535. * This class can be used to get instrumentation data from a Babylon engine
  48536. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48537. * @param engine Defines the engine to instrument
  48538. */
  48539. constructor(
  48540. /**
  48541. * Define the instrumented engine.
  48542. */
  48543. engine: Engine);
  48544. /**
  48545. * Dispose and release associated resources.
  48546. */
  48547. dispose(): void;
  48548. }
  48549. }
  48550. declare module BABYLON {
  48551. /**
  48552. * This class can be used to get instrumentation data from a Babylon engine
  48553. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48554. */
  48555. export class SceneInstrumentation implements IDisposable {
  48556. /**
  48557. * Defines the scene to instrument
  48558. */
  48559. scene: Scene;
  48560. private _captureActiveMeshesEvaluationTime;
  48561. private _activeMeshesEvaluationTime;
  48562. private _captureRenderTargetsRenderTime;
  48563. private _renderTargetsRenderTime;
  48564. private _captureFrameTime;
  48565. private _frameTime;
  48566. private _captureRenderTime;
  48567. private _renderTime;
  48568. private _captureInterFrameTime;
  48569. private _interFrameTime;
  48570. private _captureParticlesRenderTime;
  48571. private _particlesRenderTime;
  48572. private _captureSpritesRenderTime;
  48573. private _spritesRenderTime;
  48574. private _capturePhysicsTime;
  48575. private _physicsTime;
  48576. private _captureAnimationsTime;
  48577. private _animationsTime;
  48578. private _captureCameraRenderTime;
  48579. private _cameraRenderTime;
  48580. private _onBeforeActiveMeshesEvaluationObserver;
  48581. private _onAfterActiveMeshesEvaluationObserver;
  48582. private _onBeforeRenderTargetsRenderObserver;
  48583. private _onAfterRenderTargetsRenderObserver;
  48584. private _onAfterRenderObserver;
  48585. private _onBeforeDrawPhaseObserver;
  48586. private _onAfterDrawPhaseObserver;
  48587. private _onBeforeAnimationsObserver;
  48588. private _onBeforeParticlesRenderingObserver;
  48589. private _onAfterParticlesRenderingObserver;
  48590. private _onBeforeSpritesRenderingObserver;
  48591. private _onAfterSpritesRenderingObserver;
  48592. private _onBeforePhysicsObserver;
  48593. private _onAfterPhysicsObserver;
  48594. private _onAfterAnimationsObserver;
  48595. private _onBeforeCameraRenderObserver;
  48596. private _onAfterCameraRenderObserver;
  48597. /**
  48598. * Gets the perf counter used for active meshes evaluation time
  48599. */
  48600. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48601. /**
  48602. * Gets the active meshes evaluation time capture status
  48603. */
  48604. /**
  48605. * Enable or disable the active meshes evaluation time capture
  48606. */
  48607. captureActiveMeshesEvaluationTime: boolean;
  48608. /**
  48609. * Gets the perf counter used for render targets render time
  48610. */
  48611. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48612. /**
  48613. * Gets the render targets render time capture status
  48614. */
  48615. /**
  48616. * Enable or disable the render targets render time capture
  48617. */
  48618. captureRenderTargetsRenderTime: boolean;
  48619. /**
  48620. * Gets the perf counter used for particles render time
  48621. */
  48622. readonly particlesRenderTimeCounter: PerfCounter;
  48623. /**
  48624. * Gets the particles render time capture status
  48625. */
  48626. /**
  48627. * Enable or disable the particles render time capture
  48628. */
  48629. captureParticlesRenderTime: boolean;
  48630. /**
  48631. * Gets the perf counter used for sprites render time
  48632. */
  48633. readonly spritesRenderTimeCounter: PerfCounter;
  48634. /**
  48635. * Gets the sprites render time capture status
  48636. */
  48637. /**
  48638. * Enable or disable the sprites render time capture
  48639. */
  48640. captureSpritesRenderTime: boolean;
  48641. /**
  48642. * Gets the perf counter used for physics time
  48643. */
  48644. readonly physicsTimeCounter: PerfCounter;
  48645. /**
  48646. * Gets the physics time capture status
  48647. */
  48648. /**
  48649. * Enable or disable the physics time capture
  48650. */
  48651. capturePhysicsTime: boolean;
  48652. /**
  48653. * Gets the perf counter used for animations time
  48654. */
  48655. readonly animationsTimeCounter: PerfCounter;
  48656. /**
  48657. * Gets the animations time capture status
  48658. */
  48659. /**
  48660. * Enable or disable the animations time capture
  48661. */
  48662. captureAnimationsTime: boolean;
  48663. /**
  48664. * Gets the perf counter used for frame time capture
  48665. */
  48666. readonly frameTimeCounter: PerfCounter;
  48667. /**
  48668. * Gets the frame time capture status
  48669. */
  48670. /**
  48671. * Enable or disable the frame time capture
  48672. */
  48673. captureFrameTime: boolean;
  48674. /**
  48675. * Gets the perf counter used for inter-frames time capture
  48676. */
  48677. readonly interFrameTimeCounter: PerfCounter;
  48678. /**
  48679. * Gets the inter-frames time capture status
  48680. */
  48681. /**
  48682. * Enable or disable the inter-frames time capture
  48683. */
  48684. captureInterFrameTime: boolean;
  48685. /**
  48686. * Gets the perf counter used for render time capture
  48687. */
  48688. readonly renderTimeCounter: PerfCounter;
  48689. /**
  48690. * Gets the render time capture status
  48691. */
  48692. /**
  48693. * Enable or disable the render time capture
  48694. */
  48695. captureRenderTime: boolean;
  48696. /**
  48697. * Gets the perf counter used for camera render time capture
  48698. */
  48699. readonly cameraRenderTimeCounter: PerfCounter;
  48700. /**
  48701. * Gets the camera render time capture status
  48702. */
  48703. /**
  48704. * Enable or disable the camera render time capture
  48705. */
  48706. captureCameraRenderTime: boolean;
  48707. /**
  48708. * Gets the perf counter used for draw calls
  48709. */
  48710. readonly drawCallsCounter: PerfCounter;
  48711. /**
  48712. * Instantiates a new scene instrumentation.
  48713. * This class can be used to get instrumentation data from a Babylon engine
  48714. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48715. * @param scene Defines the scene to instrument
  48716. */
  48717. constructor(
  48718. /**
  48719. * Defines the scene to instrument
  48720. */
  48721. scene: Scene);
  48722. /**
  48723. * Dispose and release associated resources.
  48724. */
  48725. dispose(): void;
  48726. }
  48727. }
  48728. declare module BABYLON {
  48729. /** @hidden */
  48730. export var glowMapGenerationPixelShader: {
  48731. name: string;
  48732. shader: string;
  48733. };
  48734. }
  48735. declare module BABYLON {
  48736. /** @hidden */
  48737. export var glowMapGenerationVertexShader: {
  48738. name: string;
  48739. shader: string;
  48740. };
  48741. }
  48742. declare module BABYLON {
  48743. /**
  48744. * Effect layer options. This helps customizing the behaviour
  48745. * of the effect layer.
  48746. */
  48747. export interface IEffectLayerOptions {
  48748. /**
  48749. * Multiplication factor apply to the canvas size to compute the render target size
  48750. * used to generated the objects (the smaller the faster).
  48751. */
  48752. mainTextureRatio: number;
  48753. /**
  48754. * Enforces a fixed size texture to ensure effect stability across devices.
  48755. */
  48756. mainTextureFixedSize?: number;
  48757. /**
  48758. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48759. */
  48760. alphaBlendingMode: number;
  48761. /**
  48762. * The camera attached to the layer.
  48763. */
  48764. camera: Nullable<Camera>;
  48765. /**
  48766. * The rendering group to draw the layer in.
  48767. */
  48768. renderingGroupId: number;
  48769. }
  48770. /**
  48771. * The effect layer Helps adding post process effect blended with the main pass.
  48772. *
  48773. * This can be for instance use to generate glow or higlight effects on the scene.
  48774. *
  48775. * The effect layer class can not be used directly and is intented to inherited from to be
  48776. * customized per effects.
  48777. */
  48778. export abstract class EffectLayer {
  48779. private _vertexBuffers;
  48780. private _indexBuffer;
  48781. private _cachedDefines;
  48782. private _effectLayerMapGenerationEffect;
  48783. private _effectLayerOptions;
  48784. private _mergeEffect;
  48785. protected _scene: Scene;
  48786. protected _engine: Engine;
  48787. protected _maxSize: number;
  48788. protected _mainTextureDesiredSize: ISize;
  48789. protected _mainTexture: RenderTargetTexture;
  48790. protected _shouldRender: boolean;
  48791. protected _postProcesses: PostProcess[];
  48792. protected _textures: BaseTexture[];
  48793. protected _emissiveTextureAndColor: {
  48794. texture: Nullable<BaseTexture>;
  48795. color: Color4;
  48796. };
  48797. /**
  48798. * The name of the layer
  48799. */
  48800. name: string;
  48801. /**
  48802. * The clear color of the texture used to generate the glow map.
  48803. */
  48804. neutralColor: Color4;
  48805. /**
  48806. * Specifies wether the highlight layer is enabled or not.
  48807. */
  48808. isEnabled: boolean;
  48809. /**
  48810. * Gets the camera attached to the layer.
  48811. */
  48812. readonly camera: Nullable<Camera>;
  48813. /**
  48814. * Gets the rendering group id the layer should render in.
  48815. */
  48816. renderingGroupId: number;
  48817. /**
  48818. * An event triggered when the effect layer has been disposed.
  48819. */
  48820. onDisposeObservable: Observable<EffectLayer>;
  48821. /**
  48822. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48823. */
  48824. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48825. /**
  48826. * An event triggered when the generated texture is being merged in the scene.
  48827. */
  48828. onBeforeComposeObservable: Observable<EffectLayer>;
  48829. /**
  48830. * An event triggered when the generated texture has been merged in the scene.
  48831. */
  48832. onAfterComposeObservable: Observable<EffectLayer>;
  48833. /**
  48834. * An event triggered when the efffect layer changes its size.
  48835. */
  48836. onSizeChangedObservable: Observable<EffectLayer>;
  48837. /** @hidden */
  48838. static _SceneComponentInitialization: (scene: Scene) => void;
  48839. /**
  48840. * Instantiates a new effect Layer and references it in the scene.
  48841. * @param name The name of the layer
  48842. * @param scene The scene to use the layer in
  48843. */
  48844. constructor(
  48845. /** The Friendly of the effect in the scene */
  48846. name: string, scene: Scene);
  48847. /**
  48848. * Get the effect name of the layer.
  48849. * @return The effect name
  48850. */
  48851. abstract getEffectName(): string;
  48852. /**
  48853. * Checks for the readiness of the element composing the layer.
  48854. * @param subMesh the mesh to check for
  48855. * @param useInstances specify wether or not to use instances to render the mesh
  48856. * @return true if ready otherwise, false
  48857. */
  48858. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48859. /**
  48860. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48861. * @returns true if the effect requires stencil during the main canvas render pass.
  48862. */
  48863. abstract needStencil(): boolean;
  48864. /**
  48865. * Create the merge effect. This is the shader use to blit the information back
  48866. * to the main canvas at the end of the scene rendering.
  48867. * @returns The effect containing the shader used to merge the effect on the main canvas
  48868. */
  48869. protected abstract _createMergeEffect(): Effect;
  48870. /**
  48871. * Creates the render target textures and post processes used in the effect layer.
  48872. */
  48873. protected abstract _createTextureAndPostProcesses(): void;
  48874. /**
  48875. * Implementation specific of rendering the generating effect on the main canvas.
  48876. * @param effect The effect used to render through
  48877. */
  48878. protected abstract _internalRender(effect: Effect): void;
  48879. /**
  48880. * Sets the required values for both the emissive texture and and the main color.
  48881. */
  48882. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48883. /**
  48884. * Free any resources and references associated to a mesh.
  48885. * Internal use
  48886. * @param mesh The mesh to free.
  48887. */
  48888. abstract _disposeMesh(mesh: Mesh): void;
  48889. /**
  48890. * Serializes this layer (Glow or Highlight for example)
  48891. * @returns a serialized layer object
  48892. */
  48893. abstract serialize?(): any;
  48894. /**
  48895. * Initializes the effect layer with the required options.
  48896. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48897. */
  48898. protected _init(options: Partial<IEffectLayerOptions>): void;
  48899. /**
  48900. * Generates the index buffer of the full screen quad blending to the main canvas.
  48901. */
  48902. private _generateIndexBuffer;
  48903. /**
  48904. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48905. */
  48906. private _generateVertexBuffer;
  48907. /**
  48908. * Sets the main texture desired size which is the closest power of two
  48909. * of the engine canvas size.
  48910. */
  48911. private _setMainTextureSize;
  48912. /**
  48913. * Creates the main texture for the effect layer.
  48914. */
  48915. protected _createMainTexture(): void;
  48916. /**
  48917. * Adds specific effects defines.
  48918. * @param defines The defines to add specifics to.
  48919. */
  48920. protected _addCustomEffectDefines(defines: string[]): void;
  48921. /**
  48922. * Checks for the readiness of the element composing the layer.
  48923. * @param subMesh the mesh to check for
  48924. * @param useInstances specify wether or not to use instances to render the mesh
  48925. * @param emissiveTexture the associated emissive texture used to generate the glow
  48926. * @return true if ready otherwise, false
  48927. */
  48928. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48929. /**
  48930. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48931. */
  48932. render(): void;
  48933. /**
  48934. * Determine if a given mesh will be used in the current effect.
  48935. * @param mesh mesh to test
  48936. * @returns true if the mesh will be used
  48937. */
  48938. hasMesh(mesh: AbstractMesh): boolean;
  48939. /**
  48940. * Returns true if the layer contains information to display, otherwise false.
  48941. * @returns true if the glow layer should be rendered
  48942. */
  48943. shouldRender(): boolean;
  48944. /**
  48945. * Returns true if the mesh should render, otherwise false.
  48946. * @param mesh The mesh to render
  48947. * @returns true if it should render otherwise false
  48948. */
  48949. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48950. /**
  48951. * Returns true if the mesh can be rendered, otherwise false.
  48952. * @param mesh The mesh to render
  48953. * @param material The material used on the mesh
  48954. * @returns true if it can be rendered otherwise false
  48955. */
  48956. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48957. /**
  48958. * Returns true if the mesh should render, otherwise false.
  48959. * @param mesh The mesh to render
  48960. * @returns true if it should render otherwise false
  48961. */
  48962. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48963. /**
  48964. * Renders the submesh passed in parameter to the generation map.
  48965. */
  48966. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48967. /**
  48968. * Rebuild the required buffers.
  48969. * @hidden Internal use only.
  48970. */
  48971. _rebuild(): void;
  48972. /**
  48973. * Dispose only the render target textures and post process.
  48974. */
  48975. private _disposeTextureAndPostProcesses;
  48976. /**
  48977. * Dispose the highlight layer and free resources.
  48978. */
  48979. dispose(): void;
  48980. /**
  48981. * Gets the class name of the effect layer
  48982. * @returns the string with the class name of the effect layer
  48983. */
  48984. getClassName(): string;
  48985. /**
  48986. * Creates an effect layer from parsed effect layer data
  48987. * @param parsedEffectLayer defines effect layer data
  48988. * @param scene defines the current scene
  48989. * @param rootUrl defines the root URL containing the effect layer information
  48990. * @returns a parsed effect Layer
  48991. */
  48992. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48993. }
  48994. }
  48995. declare module BABYLON {
  48996. interface AbstractScene {
  48997. /**
  48998. * The list of effect layers (highlights/glow) added to the scene
  48999. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49000. * @see http://doc.babylonjs.com/how_to/glow_layer
  49001. */
  49002. effectLayers: Array<EffectLayer>;
  49003. /**
  49004. * Removes the given effect layer from this scene.
  49005. * @param toRemove defines the effect layer to remove
  49006. * @returns the index of the removed effect layer
  49007. */
  49008. removeEffectLayer(toRemove: EffectLayer): number;
  49009. /**
  49010. * Adds the given effect layer to this scene
  49011. * @param newEffectLayer defines the effect layer to add
  49012. */
  49013. addEffectLayer(newEffectLayer: EffectLayer): void;
  49014. }
  49015. /**
  49016. * Defines the layer scene component responsible to manage any effect layers
  49017. * in a given scene.
  49018. */
  49019. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49020. /**
  49021. * The component name helpfull to identify the component in the list of scene components.
  49022. */
  49023. readonly name: string;
  49024. /**
  49025. * The scene the component belongs to.
  49026. */
  49027. scene: Scene;
  49028. private _engine;
  49029. private _renderEffects;
  49030. private _needStencil;
  49031. private _previousStencilState;
  49032. /**
  49033. * Creates a new instance of the component for the given scene
  49034. * @param scene Defines the scene to register the component in
  49035. */
  49036. constructor(scene: Scene);
  49037. /**
  49038. * Registers the component in a given scene
  49039. */
  49040. register(): void;
  49041. /**
  49042. * Rebuilds the elements related to this component in case of
  49043. * context lost for instance.
  49044. */
  49045. rebuild(): void;
  49046. /**
  49047. * Serializes the component data to the specified json object
  49048. * @param serializationObject The object to serialize to
  49049. */
  49050. serialize(serializationObject: any): void;
  49051. /**
  49052. * Adds all the elements from the container to the scene
  49053. * @param container the container holding the elements
  49054. */
  49055. addFromContainer(container: AbstractScene): void;
  49056. /**
  49057. * Removes all the elements in the container from the scene
  49058. * @param container contains the elements to remove
  49059. * @param dispose if the removed element should be disposed (default: false)
  49060. */
  49061. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49062. /**
  49063. * Disposes the component and the associated ressources.
  49064. */
  49065. dispose(): void;
  49066. private _isReadyForMesh;
  49067. private _renderMainTexture;
  49068. private _setStencil;
  49069. private _setStencilBack;
  49070. private _draw;
  49071. private _drawCamera;
  49072. private _drawRenderingGroup;
  49073. }
  49074. }
  49075. declare module BABYLON {
  49076. /** @hidden */
  49077. export var glowMapMergePixelShader: {
  49078. name: string;
  49079. shader: string;
  49080. };
  49081. }
  49082. declare module BABYLON {
  49083. /** @hidden */
  49084. export var glowMapMergeVertexShader: {
  49085. name: string;
  49086. shader: string;
  49087. };
  49088. }
  49089. declare module BABYLON {
  49090. interface AbstractScene {
  49091. /**
  49092. * Return a the first highlight layer of the scene with a given name.
  49093. * @param name The name of the highlight layer to look for.
  49094. * @return The highlight layer if found otherwise null.
  49095. */
  49096. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49097. }
  49098. /**
  49099. * Glow layer options. This helps customizing the behaviour
  49100. * of the glow layer.
  49101. */
  49102. export interface IGlowLayerOptions {
  49103. /**
  49104. * Multiplication factor apply to the canvas size to compute the render target size
  49105. * used to generated the glowing objects (the smaller the faster).
  49106. */
  49107. mainTextureRatio: number;
  49108. /**
  49109. * Enforces a fixed size texture to ensure resize independant blur.
  49110. */
  49111. mainTextureFixedSize?: number;
  49112. /**
  49113. * How big is the kernel of the blur texture.
  49114. */
  49115. blurKernelSize: number;
  49116. /**
  49117. * The camera attached to the layer.
  49118. */
  49119. camera: Nullable<Camera>;
  49120. /**
  49121. * Enable MSAA by chosing the number of samples.
  49122. */
  49123. mainTextureSamples?: number;
  49124. /**
  49125. * The rendering group to draw the layer in.
  49126. */
  49127. renderingGroupId: number;
  49128. }
  49129. /**
  49130. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49131. *
  49132. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49133. * glowy meshes to your scene.
  49134. *
  49135. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49136. */
  49137. export class GlowLayer extends EffectLayer {
  49138. /**
  49139. * Effect Name of the layer.
  49140. */
  49141. static readonly EffectName: string;
  49142. /**
  49143. * The default blur kernel size used for the glow.
  49144. */
  49145. static DefaultBlurKernelSize: number;
  49146. /**
  49147. * The default texture size ratio used for the glow.
  49148. */
  49149. static DefaultTextureRatio: number;
  49150. /**
  49151. * Sets the kernel size of the blur.
  49152. */
  49153. /**
  49154. * Gets the kernel size of the blur.
  49155. */
  49156. blurKernelSize: number;
  49157. /**
  49158. * Sets the glow intensity.
  49159. */
  49160. /**
  49161. * Gets the glow intensity.
  49162. */
  49163. intensity: number;
  49164. private _options;
  49165. private _intensity;
  49166. private _horizontalBlurPostprocess1;
  49167. private _verticalBlurPostprocess1;
  49168. private _horizontalBlurPostprocess2;
  49169. private _verticalBlurPostprocess2;
  49170. private _blurTexture1;
  49171. private _blurTexture2;
  49172. private _postProcesses1;
  49173. private _postProcesses2;
  49174. private _includedOnlyMeshes;
  49175. private _excludedMeshes;
  49176. /**
  49177. * Callback used to let the user override the color selection on a per mesh basis
  49178. */
  49179. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49180. /**
  49181. * Callback used to let the user override the texture selection on a per mesh basis
  49182. */
  49183. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49184. /**
  49185. * Instantiates a new glow Layer and references it to the scene.
  49186. * @param name The name of the layer
  49187. * @param scene The scene to use the layer in
  49188. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49189. */
  49190. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49191. /**
  49192. * Get the effect name of the layer.
  49193. * @return The effect name
  49194. */
  49195. getEffectName(): string;
  49196. /**
  49197. * Create the merge effect. This is the shader use to blit the information back
  49198. * to the main canvas at the end of the scene rendering.
  49199. */
  49200. protected _createMergeEffect(): Effect;
  49201. /**
  49202. * Creates the render target textures and post processes used in the glow layer.
  49203. */
  49204. protected _createTextureAndPostProcesses(): void;
  49205. /**
  49206. * Checks for the readiness of the element composing the layer.
  49207. * @param subMesh the mesh to check for
  49208. * @param useInstances specify wether or not to use instances to render the mesh
  49209. * @param emissiveTexture the associated emissive texture used to generate the glow
  49210. * @return true if ready otherwise, false
  49211. */
  49212. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49213. /**
  49214. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49215. */
  49216. needStencil(): boolean;
  49217. /**
  49218. * Returns true if the mesh can be rendered, otherwise false.
  49219. * @param mesh The mesh to render
  49220. * @param material The material used on the mesh
  49221. * @returns true if it can be rendered otherwise false
  49222. */
  49223. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49224. /**
  49225. * Implementation specific of rendering the generating effect on the main canvas.
  49226. * @param effect The effect used to render through
  49227. */
  49228. protected _internalRender(effect: Effect): void;
  49229. /**
  49230. * Sets the required values for both the emissive texture and and the main color.
  49231. */
  49232. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49233. /**
  49234. * Returns true if the mesh should render, otherwise false.
  49235. * @param mesh The mesh to render
  49236. * @returns true if it should render otherwise false
  49237. */
  49238. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49239. /**
  49240. * Adds specific effects defines.
  49241. * @param defines The defines to add specifics to.
  49242. */
  49243. protected _addCustomEffectDefines(defines: string[]): void;
  49244. /**
  49245. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49246. * @param mesh The mesh to exclude from the glow layer
  49247. */
  49248. addExcludedMesh(mesh: Mesh): void;
  49249. /**
  49250. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49251. * @param mesh The mesh to remove
  49252. */
  49253. removeExcludedMesh(mesh: Mesh): void;
  49254. /**
  49255. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49256. * @param mesh The mesh to include in the glow layer
  49257. */
  49258. addIncludedOnlyMesh(mesh: Mesh): void;
  49259. /**
  49260. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49261. * @param mesh The mesh to remove
  49262. */
  49263. removeIncludedOnlyMesh(mesh: Mesh): void;
  49264. /**
  49265. * Determine if a given mesh will be used in the glow layer
  49266. * @param mesh The mesh to test
  49267. * @returns true if the mesh will be highlighted by the current glow layer
  49268. */
  49269. hasMesh(mesh: AbstractMesh): boolean;
  49270. /**
  49271. * Free any resources and references associated to a mesh.
  49272. * Internal use
  49273. * @param mesh The mesh to free.
  49274. * @hidden
  49275. */
  49276. _disposeMesh(mesh: Mesh): void;
  49277. /**
  49278. * Gets the class name of the effect layer
  49279. * @returns the string with the class name of the effect layer
  49280. */
  49281. getClassName(): string;
  49282. /**
  49283. * Serializes this glow layer
  49284. * @returns a serialized glow layer object
  49285. */
  49286. serialize(): any;
  49287. /**
  49288. * Creates a Glow Layer from parsed glow layer data
  49289. * @param parsedGlowLayer defines glow layer data
  49290. * @param scene defines the current scene
  49291. * @param rootUrl defines the root URL containing the glow layer information
  49292. * @returns a parsed Glow Layer
  49293. */
  49294. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49295. }
  49296. }
  49297. declare module BABYLON {
  49298. /** @hidden */
  49299. export var glowBlurPostProcessPixelShader: {
  49300. name: string;
  49301. shader: string;
  49302. };
  49303. }
  49304. declare module BABYLON {
  49305. interface AbstractScene {
  49306. /**
  49307. * Return a the first highlight layer of the scene with a given name.
  49308. * @param name The name of the highlight layer to look for.
  49309. * @return The highlight layer if found otherwise null.
  49310. */
  49311. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49312. }
  49313. /**
  49314. * Highlight layer options. This helps customizing the behaviour
  49315. * of the highlight layer.
  49316. */
  49317. export interface IHighlightLayerOptions {
  49318. /**
  49319. * Multiplication factor apply to the canvas size to compute the render target size
  49320. * used to generated the glowing objects (the smaller the faster).
  49321. */
  49322. mainTextureRatio: number;
  49323. /**
  49324. * Enforces a fixed size texture to ensure resize independant blur.
  49325. */
  49326. mainTextureFixedSize?: number;
  49327. /**
  49328. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49329. * of the picture to blur (the smaller the faster).
  49330. */
  49331. blurTextureSizeRatio: number;
  49332. /**
  49333. * How big in texel of the blur texture is the vertical blur.
  49334. */
  49335. blurVerticalSize: number;
  49336. /**
  49337. * How big in texel of the blur texture is the horizontal blur.
  49338. */
  49339. blurHorizontalSize: number;
  49340. /**
  49341. * Alpha blending mode used to apply the blur. Default is combine.
  49342. */
  49343. alphaBlendingMode: number;
  49344. /**
  49345. * The camera attached to the layer.
  49346. */
  49347. camera: Nullable<Camera>;
  49348. /**
  49349. * Should we display highlight as a solid stroke?
  49350. */
  49351. isStroke?: boolean;
  49352. /**
  49353. * The rendering group to draw the layer in.
  49354. */
  49355. renderingGroupId: number;
  49356. }
  49357. /**
  49358. * The highlight layer Helps adding a glow effect around a mesh.
  49359. *
  49360. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49361. * glowy meshes to your scene.
  49362. *
  49363. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49364. */
  49365. export class HighlightLayer extends EffectLayer {
  49366. name: string;
  49367. /**
  49368. * Effect Name of the highlight layer.
  49369. */
  49370. static readonly EffectName: string;
  49371. /**
  49372. * The neutral color used during the preparation of the glow effect.
  49373. * This is black by default as the blend operation is a blend operation.
  49374. */
  49375. static NeutralColor: Color4;
  49376. /**
  49377. * Stencil value used for glowing meshes.
  49378. */
  49379. static GlowingMeshStencilReference: number;
  49380. /**
  49381. * Stencil value used for the other meshes in the scene.
  49382. */
  49383. static NormalMeshStencilReference: number;
  49384. /**
  49385. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49386. */
  49387. innerGlow: boolean;
  49388. /**
  49389. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49390. */
  49391. outerGlow: boolean;
  49392. /**
  49393. * Specifies the horizontal size of the blur.
  49394. */
  49395. /**
  49396. * Gets the horizontal size of the blur.
  49397. */
  49398. blurHorizontalSize: number;
  49399. /**
  49400. * Specifies the vertical size of the blur.
  49401. */
  49402. /**
  49403. * Gets the vertical size of the blur.
  49404. */
  49405. blurVerticalSize: number;
  49406. /**
  49407. * An event triggered when the highlight layer is being blurred.
  49408. */
  49409. onBeforeBlurObservable: Observable<HighlightLayer>;
  49410. /**
  49411. * An event triggered when the highlight layer has been blurred.
  49412. */
  49413. onAfterBlurObservable: Observable<HighlightLayer>;
  49414. private _instanceGlowingMeshStencilReference;
  49415. private _options;
  49416. private _downSamplePostprocess;
  49417. private _horizontalBlurPostprocess;
  49418. private _verticalBlurPostprocess;
  49419. private _blurTexture;
  49420. private _meshes;
  49421. private _excludedMeshes;
  49422. /**
  49423. * Instantiates a new highlight Layer and references it to the scene..
  49424. * @param name The name of the layer
  49425. * @param scene The scene to use the layer in
  49426. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49427. */
  49428. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49429. /**
  49430. * Get the effect name of the layer.
  49431. * @return The effect name
  49432. */
  49433. getEffectName(): string;
  49434. /**
  49435. * Create the merge effect. This is the shader use to blit the information back
  49436. * to the main canvas at the end of the scene rendering.
  49437. */
  49438. protected _createMergeEffect(): Effect;
  49439. /**
  49440. * Creates the render target textures and post processes used in the highlight layer.
  49441. */
  49442. protected _createTextureAndPostProcesses(): void;
  49443. /**
  49444. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49445. */
  49446. needStencil(): boolean;
  49447. /**
  49448. * Checks for the readiness of the element composing the layer.
  49449. * @param subMesh the mesh to check for
  49450. * @param useInstances specify wether or not to use instances to render the mesh
  49451. * @param emissiveTexture the associated emissive texture used to generate the glow
  49452. * @return true if ready otherwise, false
  49453. */
  49454. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49455. /**
  49456. * Implementation specific of rendering the generating effect on the main canvas.
  49457. * @param effect The effect used to render through
  49458. */
  49459. protected _internalRender(effect: Effect): void;
  49460. /**
  49461. * Returns true if the layer contains information to display, otherwise false.
  49462. */
  49463. shouldRender(): boolean;
  49464. /**
  49465. * Returns true if the mesh should render, otherwise false.
  49466. * @param mesh The mesh to render
  49467. * @returns true if it should render otherwise false
  49468. */
  49469. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49470. /**
  49471. * Sets the required values for both the emissive texture and and the main color.
  49472. */
  49473. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49474. /**
  49475. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49476. * @param mesh The mesh to exclude from the highlight layer
  49477. */
  49478. addExcludedMesh(mesh: Mesh): void;
  49479. /**
  49480. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49481. * @param mesh The mesh to highlight
  49482. */
  49483. removeExcludedMesh(mesh: Mesh): void;
  49484. /**
  49485. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49486. * @param mesh mesh to test
  49487. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49488. */
  49489. hasMesh(mesh: AbstractMesh): boolean;
  49490. /**
  49491. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49492. * @param mesh The mesh to highlight
  49493. * @param color The color of the highlight
  49494. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49495. */
  49496. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49497. /**
  49498. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49499. * @param mesh The mesh to highlight
  49500. */
  49501. removeMesh(mesh: Mesh): void;
  49502. /**
  49503. * Force the stencil to the normal expected value for none glowing parts
  49504. */
  49505. private _defaultStencilReference;
  49506. /**
  49507. * Free any resources and references associated to a mesh.
  49508. * Internal use
  49509. * @param mesh The mesh to free.
  49510. * @hidden
  49511. */
  49512. _disposeMesh(mesh: Mesh): void;
  49513. /**
  49514. * Dispose the highlight layer and free resources.
  49515. */
  49516. dispose(): void;
  49517. /**
  49518. * Gets the class name of the effect layer
  49519. * @returns the string with the class name of the effect layer
  49520. */
  49521. getClassName(): string;
  49522. /**
  49523. * Serializes this Highlight layer
  49524. * @returns a serialized Highlight layer object
  49525. */
  49526. serialize(): any;
  49527. /**
  49528. * Creates a Highlight layer from parsed Highlight layer data
  49529. * @param parsedHightlightLayer defines the Highlight layer data
  49530. * @param scene defines the current scene
  49531. * @param rootUrl defines the root URL containing the Highlight layer information
  49532. * @returns a parsed Highlight layer
  49533. */
  49534. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49535. }
  49536. }
  49537. declare module BABYLON {
  49538. interface AbstractScene {
  49539. /**
  49540. * The list of layers (background and foreground) of the scene
  49541. */
  49542. layers: Array<Layer>;
  49543. }
  49544. /**
  49545. * Defines the layer scene component responsible to manage any layers
  49546. * in a given scene.
  49547. */
  49548. export class LayerSceneComponent implements ISceneComponent {
  49549. /**
  49550. * The component name helpfull to identify the component in the list of scene components.
  49551. */
  49552. readonly name: string;
  49553. /**
  49554. * The scene the component belongs to.
  49555. */
  49556. scene: Scene;
  49557. private _engine;
  49558. /**
  49559. * Creates a new instance of the component for the given scene
  49560. * @param scene Defines the scene to register the component in
  49561. */
  49562. constructor(scene: Scene);
  49563. /**
  49564. * Registers the component in a given scene
  49565. */
  49566. register(): void;
  49567. /**
  49568. * Rebuilds the elements related to this component in case of
  49569. * context lost for instance.
  49570. */
  49571. rebuild(): void;
  49572. /**
  49573. * Disposes the component and the associated ressources.
  49574. */
  49575. dispose(): void;
  49576. private _draw;
  49577. private _drawCameraPredicate;
  49578. private _drawCameraBackground;
  49579. private _drawCameraForeground;
  49580. private _drawRenderTargetPredicate;
  49581. private _drawRenderTargetBackground;
  49582. private _drawRenderTargetForeground;
  49583. /**
  49584. * Adds all the elements from the container to the scene
  49585. * @param container the container holding the elements
  49586. */
  49587. addFromContainer(container: AbstractScene): void;
  49588. /**
  49589. * Removes all the elements in the container from the scene
  49590. * @param container contains the elements to remove
  49591. * @param dispose if the removed element should be disposed (default: false)
  49592. */
  49593. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49594. }
  49595. }
  49596. declare module BABYLON {
  49597. /** @hidden */
  49598. export var layerPixelShader: {
  49599. name: string;
  49600. shader: string;
  49601. };
  49602. }
  49603. declare module BABYLON {
  49604. /** @hidden */
  49605. export var layerVertexShader: {
  49606. name: string;
  49607. shader: string;
  49608. };
  49609. }
  49610. declare module BABYLON {
  49611. /**
  49612. * This represents a full screen 2d layer.
  49613. * This can be useful to display a picture in the background of your scene for instance.
  49614. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49615. */
  49616. export class Layer {
  49617. /**
  49618. * Define the name of the layer.
  49619. */
  49620. name: string;
  49621. /**
  49622. * Define the texture the layer should display.
  49623. */
  49624. texture: Nullable<Texture>;
  49625. /**
  49626. * Is the layer in background or foreground.
  49627. */
  49628. isBackground: boolean;
  49629. /**
  49630. * Define the color of the layer (instead of texture).
  49631. */
  49632. color: Color4;
  49633. /**
  49634. * Define the scale of the layer in order to zoom in out of the texture.
  49635. */
  49636. scale: Vector2;
  49637. /**
  49638. * Define an offset for the layer in order to shift the texture.
  49639. */
  49640. offset: Vector2;
  49641. /**
  49642. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  49643. */
  49644. alphaBlendingMode: number;
  49645. /**
  49646. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  49647. * Alpha test will not mix with the background color in case of transparency.
  49648. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  49649. */
  49650. alphaTest: boolean;
  49651. /**
  49652. * Define a mask to restrict the layer to only some of the scene cameras.
  49653. */
  49654. layerMask: number;
  49655. /**
  49656. * Define the list of render target the layer is visible into.
  49657. */
  49658. renderTargetTextures: RenderTargetTexture[];
  49659. /**
  49660. * Define if the layer is only used in renderTarget or if it also
  49661. * renders in the main frame buffer of the canvas.
  49662. */
  49663. renderOnlyInRenderTargetTextures: boolean;
  49664. private _scene;
  49665. private _vertexBuffers;
  49666. private _indexBuffer;
  49667. private _effect;
  49668. private _alphaTestEffect;
  49669. /**
  49670. * An event triggered when the layer is disposed.
  49671. */
  49672. onDisposeObservable: Observable<Layer>;
  49673. private _onDisposeObserver;
  49674. /**
  49675. * Back compatibility with callback before the onDisposeObservable existed.
  49676. * The set callback will be triggered when the layer has been disposed.
  49677. */
  49678. onDispose: () => void;
  49679. /**
  49680. * An event triggered before rendering the scene
  49681. */
  49682. onBeforeRenderObservable: Observable<Layer>;
  49683. private _onBeforeRenderObserver;
  49684. /**
  49685. * Back compatibility with callback before the onBeforeRenderObservable existed.
  49686. * The set callback will be triggered just before rendering the layer.
  49687. */
  49688. onBeforeRender: () => void;
  49689. /**
  49690. * An event triggered after rendering the scene
  49691. */
  49692. onAfterRenderObservable: Observable<Layer>;
  49693. private _onAfterRenderObserver;
  49694. /**
  49695. * Back compatibility with callback before the onAfterRenderObservable existed.
  49696. * The set callback will be triggered just after rendering the layer.
  49697. */
  49698. onAfterRender: () => void;
  49699. /**
  49700. * Instantiates a new layer.
  49701. * This represents a full screen 2d layer.
  49702. * This can be useful to display a picture in the background of your scene for instance.
  49703. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49704. * @param name Define the name of the layer in the scene
  49705. * @param imgUrl Define the url of the texture to display in the layer
  49706. * @param scene Define the scene the layer belongs to
  49707. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  49708. * @param color Defines a color for the layer
  49709. */
  49710. constructor(
  49711. /**
  49712. * Define the name of the layer.
  49713. */
  49714. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  49715. private _createIndexBuffer;
  49716. /** @hidden */
  49717. _rebuild(): void;
  49718. /**
  49719. * Renders the layer in the scene.
  49720. */
  49721. render(): void;
  49722. /**
  49723. * Disposes and releases the associated ressources.
  49724. */
  49725. dispose(): void;
  49726. }
  49727. }
  49728. declare module BABYLON {
  49729. /** @hidden */
  49730. export var lensFlarePixelShader: {
  49731. name: string;
  49732. shader: string;
  49733. };
  49734. }
  49735. declare module BABYLON {
  49736. /** @hidden */
  49737. export var lensFlareVertexShader: {
  49738. name: string;
  49739. shader: string;
  49740. };
  49741. }
  49742. declare module BABYLON {
  49743. /**
  49744. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49745. * It is usually composed of several `lensFlare`.
  49746. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49747. */
  49748. export class LensFlareSystem {
  49749. /**
  49750. * Define the name of the lens flare system
  49751. */
  49752. name: string;
  49753. /**
  49754. * List of lens flares used in this system.
  49755. */
  49756. lensFlares: LensFlare[];
  49757. /**
  49758. * Define a limit from the border the lens flare can be visible.
  49759. */
  49760. borderLimit: number;
  49761. /**
  49762. * Define a viewport border we do not want to see the lens flare in.
  49763. */
  49764. viewportBorder: number;
  49765. /**
  49766. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49767. */
  49768. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49769. /**
  49770. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49771. */
  49772. layerMask: number;
  49773. /**
  49774. * Define the id of the lens flare system in the scene.
  49775. * (equal to name by default)
  49776. */
  49777. id: string;
  49778. private _scene;
  49779. private _emitter;
  49780. private _vertexBuffers;
  49781. private _indexBuffer;
  49782. private _effect;
  49783. private _positionX;
  49784. private _positionY;
  49785. private _isEnabled;
  49786. /** @hidden */
  49787. static _SceneComponentInitialization: (scene: Scene) => void;
  49788. /**
  49789. * Instantiates a lens flare system.
  49790. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49791. * It is usually composed of several `lensFlare`.
  49792. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49793. * @param name Define the name of the lens flare system in the scene
  49794. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49795. * @param scene Define the scene the lens flare system belongs to
  49796. */
  49797. constructor(
  49798. /**
  49799. * Define the name of the lens flare system
  49800. */
  49801. name: string, emitter: any, scene: Scene);
  49802. /**
  49803. * Define if the lens flare system is enabled.
  49804. */
  49805. isEnabled: boolean;
  49806. /**
  49807. * Get the scene the effects belongs to.
  49808. * @returns the scene holding the lens flare system
  49809. */
  49810. getScene(): Scene;
  49811. /**
  49812. * Get the emitter of the lens flare system.
  49813. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49814. * @returns the emitter of the lens flare system
  49815. */
  49816. getEmitter(): any;
  49817. /**
  49818. * Set the emitter of the lens flare system.
  49819. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49820. * @param newEmitter Define the new emitter of the system
  49821. */
  49822. setEmitter(newEmitter: any): void;
  49823. /**
  49824. * Get the lens flare system emitter position.
  49825. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49826. * @returns the position
  49827. */
  49828. getEmitterPosition(): Vector3;
  49829. /**
  49830. * @hidden
  49831. */
  49832. computeEffectivePosition(globalViewport: Viewport): boolean;
  49833. /** @hidden */
  49834. _isVisible(): boolean;
  49835. /**
  49836. * @hidden
  49837. */
  49838. render(): boolean;
  49839. /**
  49840. * Dispose and release the lens flare with its associated resources.
  49841. */
  49842. dispose(): void;
  49843. /**
  49844. * Parse a lens flare system from a JSON repressentation
  49845. * @param parsedLensFlareSystem Define the JSON to parse
  49846. * @param scene Define the scene the parsed system should be instantiated in
  49847. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49848. * @returns the parsed system
  49849. */
  49850. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49851. /**
  49852. * Serialize the current Lens Flare System into a JSON representation.
  49853. * @returns the serialized JSON
  49854. */
  49855. serialize(): any;
  49856. }
  49857. }
  49858. declare module BABYLON {
  49859. /**
  49860. * This represents one of the lens effect in a `lensFlareSystem`.
  49861. * It controls one of the indiviual texture used in the effect.
  49862. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49863. */
  49864. export class LensFlare {
  49865. /**
  49866. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49867. */
  49868. size: number;
  49869. /**
  49870. * 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.
  49871. */
  49872. position: number;
  49873. /**
  49874. * Define the lens color.
  49875. */
  49876. color: Color3;
  49877. /**
  49878. * Define the lens texture.
  49879. */
  49880. texture: Nullable<Texture>;
  49881. /**
  49882. * Define the alpha mode to render this particular lens.
  49883. */
  49884. alphaMode: number;
  49885. private _system;
  49886. /**
  49887. * Creates a new Lens Flare.
  49888. * This represents one of the lens effect in a `lensFlareSystem`.
  49889. * It controls one of the indiviual texture used in the effect.
  49890. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49891. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49892. * @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.
  49893. * @param color Define the lens color
  49894. * @param imgUrl Define the lens texture url
  49895. * @param system Define the `lensFlareSystem` this flare is part of
  49896. * @returns The newly created Lens Flare
  49897. */
  49898. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49899. /**
  49900. * Instantiates a new Lens Flare.
  49901. * This represents one of the lens effect in a `lensFlareSystem`.
  49902. * It controls one of the indiviual texture used in the effect.
  49903. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49904. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49905. * @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.
  49906. * @param color Define the lens color
  49907. * @param imgUrl Define the lens texture url
  49908. * @param system Define the `lensFlareSystem` this flare is part of
  49909. */
  49910. constructor(
  49911. /**
  49912. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49913. */
  49914. size: number,
  49915. /**
  49916. * 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.
  49917. */
  49918. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49919. /**
  49920. * Dispose and release the lens flare with its associated resources.
  49921. */
  49922. dispose(): void;
  49923. }
  49924. }
  49925. declare module BABYLON {
  49926. interface AbstractScene {
  49927. /**
  49928. * The list of lens flare system added to the scene
  49929. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49930. */
  49931. lensFlareSystems: Array<LensFlareSystem>;
  49932. /**
  49933. * Removes the given lens flare system from this scene.
  49934. * @param toRemove The lens flare system to remove
  49935. * @returns The index of the removed lens flare system
  49936. */
  49937. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49938. /**
  49939. * Adds the given lens flare system to this scene
  49940. * @param newLensFlareSystem The lens flare system to add
  49941. */
  49942. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49943. /**
  49944. * Gets a lens flare system using its name
  49945. * @param name defines the name to look for
  49946. * @returns the lens flare system or null if not found
  49947. */
  49948. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49949. /**
  49950. * Gets a lens flare system using its id
  49951. * @param id defines the id to look for
  49952. * @returns the lens flare system or null if not found
  49953. */
  49954. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49955. }
  49956. /**
  49957. * Defines the lens flare scene component responsible to manage any lens flares
  49958. * in a given scene.
  49959. */
  49960. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49961. /**
  49962. * The component name helpfull to identify the component in the list of scene components.
  49963. */
  49964. readonly name: string;
  49965. /**
  49966. * The scene the component belongs to.
  49967. */
  49968. scene: Scene;
  49969. /**
  49970. * Creates a new instance of the component for the given scene
  49971. * @param scene Defines the scene to register the component in
  49972. */
  49973. constructor(scene: Scene);
  49974. /**
  49975. * Registers the component in a given scene
  49976. */
  49977. register(): void;
  49978. /**
  49979. * Rebuilds the elements related to this component in case of
  49980. * context lost for instance.
  49981. */
  49982. rebuild(): void;
  49983. /**
  49984. * Adds all the elements from the container to the scene
  49985. * @param container the container holding the elements
  49986. */
  49987. addFromContainer(container: AbstractScene): void;
  49988. /**
  49989. * Removes all the elements in the container from the scene
  49990. * @param container contains the elements to remove
  49991. * @param dispose if the removed element should be disposed (default: false)
  49992. */
  49993. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49994. /**
  49995. * Serializes the component data to the specified json object
  49996. * @param serializationObject The object to serialize to
  49997. */
  49998. serialize(serializationObject: any): void;
  49999. /**
  50000. * Disposes the component and the associated ressources.
  50001. */
  50002. dispose(): void;
  50003. private _draw;
  50004. }
  50005. }
  50006. declare module BABYLON {
  50007. /**
  50008. * Defines the shadow generator component responsible to manage any shadow generators
  50009. * in a given scene.
  50010. */
  50011. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50012. /**
  50013. * The component name helpfull to identify the component in the list of scene components.
  50014. */
  50015. readonly name: string;
  50016. /**
  50017. * The scene the component belongs to.
  50018. */
  50019. scene: Scene;
  50020. /**
  50021. * Creates a new instance of the component for the given scene
  50022. * @param scene Defines the scene to register the component in
  50023. */
  50024. constructor(scene: Scene);
  50025. /**
  50026. * Registers the component in a given scene
  50027. */
  50028. register(): void;
  50029. /**
  50030. * Rebuilds the elements related to this component in case of
  50031. * context lost for instance.
  50032. */
  50033. rebuild(): void;
  50034. /**
  50035. * Serializes the component data to the specified json object
  50036. * @param serializationObject The object to serialize to
  50037. */
  50038. serialize(serializationObject: any): void;
  50039. /**
  50040. * Adds all the elements from the container to the scene
  50041. * @param container the container holding the elements
  50042. */
  50043. addFromContainer(container: AbstractScene): void;
  50044. /**
  50045. * Removes all the elements in the container from the scene
  50046. * @param container contains the elements to remove
  50047. * @param dispose if the removed element should be disposed (default: false)
  50048. */
  50049. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50050. /**
  50051. * Rebuilds the elements related to this component in case of
  50052. * context lost for instance.
  50053. */
  50054. dispose(): void;
  50055. private _gatherRenderTargets;
  50056. }
  50057. }
  50058. declare module BABYLON {
  50059. /**
  50060. * A point light is a light defined by an unique point in world space.
  50061. * The light is emitted in every direction from this point.
  50062. * A good example of a point light is a standard light bulb.
  50063. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50064. */
  50065. export class PointLight extends ShadowLight {
  50066. private _shadowAngle;
  50067. /**
  50068. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50069. * This specifies what angle the shadow will use to be created.
  50070. *
  50071. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50072. */
  50073. /**
  50074. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50075. * This specifies what angle the shadow will use to be created.
  50076. *
  50077. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50078. */
  50079. shadowAngle: number;
  50080. /**
  50081. * Gets the direction if it has been set.
  50082. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50083. */
  50084. /**
  50085. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50086. */
  50087. direction: Vector3;
  50088. /**
  50089. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50090. * A PointLight emits the light in every direction.
  50091. * It can cast shadows.
  50092. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50093. * ```javascript
  50094. * var pointLight = new PointLight("pl", camera.position, scene);
  50095. * ```
  50096. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50097. * @param name The light friendly name
  50098. * @param position The position of the point light in the scene
  50099. * @param scene The scene the lights belongs to
  50100. */
  50101. constructor(name: string, position: Vector3, scene: Scene);
  50102. /**
  50103. * Returns the string "PointLight"
  50104. * @returns the class name
  50105. */
  50106. getClassName(): string;
  50107. /**
  50108. * Returns the integer 0.
  50109. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50110. */
  50111. getTypeID(): number;
  50112. /**
  50113. * Specifies wether or not the shadowmap should be a cube texture.
  50114. * @returns true if the shadowmap needs to be a cube texture.
  50115. */
  50116. needCube(): boolean;
  50117. /**
  50118. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50119. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50120. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50121. */
  50122. getShadowDirection(faceIndex?: number): Vector3;
  50123. /**
  50124. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50125. * - fov = PI / 2
  50126. * - aspect ratio : 1.0
  50127. * - z-near and far equal to the active camera minZ and maxZ.
  50128. * Returns the PointLight.
  50129. */
  50130. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50131. protected _buildUniformLayout(): void;
  50132. /**
  50133. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50134. * @param effect The effect to update
  50135. * @param lightIndex The index of the light in the effect to update
  50136. * @returns The point light
  50137. */
  50138. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50139. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50140. /**
  50141. * Prepares the list of defines specific to the light type.
  50142. * @param defines the list of defines
  50143. * @param lightIndex defines the index of the light for the effect
  50144. */
  50145. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50146. }
  50147. }
  50148. declare module BABYLON {
  50149. /**
  50150. * Header information of HDR texture files.
  50151. */
  50152. export interface HDRInfo {
  50153. /**
  50154. * The height of the texture in pixels.
  50155. */
  50156. height: number;
  50157. /**
  50158. * The width of the texture in pixels.
  50159. */
  50160. width: number;
  50161. /**
  50162. * The index of the beginning of the data in the binary file.
  50163. */
  50164. dataPosition: number;
  50165. }
  50166. /**
  50167. * This groups tools to convert HDR texture to native colors array.
  50168. */
  50169. export class HDRTools {
  50170. private static Ldexp;
  50171. private static Rgbe2float;
  50172. private static readStringLine;
  50173. /**
  50174. * Reads header information from an RGBE texture stored in a native array.
  50175. * More information on this format are available here:
  50176. * https://en.wikipedia.org/wiki/RGBE_image_format
  50177. *
  50178. * @param uint8array The binary file stored in native array.
  50179. * @return The header information.
  50180. */
  50181. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50182. /**
  50183. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50184. * This RGBE texture needs to store the information as a panorama.
  50185. *
  50186. * More information on this format are available here:
  50187. * https://en.wikipedia.org/wiki/RGBE_image_format
  50188. *
  50189. * @param buffer The binary file stored in an array buffer.
  50190. * @param size The expected size of the extracted cubemap.
  50191. * @return The Cube Map information.
  50192. */
  50193. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50194. /**
  50195. * Returns the pixels data extracted from an RGBE texture.
  50196. * This pixels will be stored left to right up to down in the R G B order in one array.
  50197. *
  50198. * More information on this format are available here:
  50199. * https://en.wikipedia.org/wiki/RGBE_image_format
  50200. *
  50201. * @param uint8array The binary file stored in an array buffer.
  50202. * @param hdrInfo The header information of the file.
  50203. * @return The pixels data in RGB right to left up to down order.
  50204. */
  50205. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50206. private static RGBE_ReadPixels_RLE;
  50207. }
  50208. }
  50209. declare module BABYLON {
  50210. /**
  50211. * This represents a texture coming from an HDR input.
  50212. *
  50213. * The only supported format is currently panorama picture stored in RGBE format.
  50214. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50215. */
  50216. export class HDRCubeTexture extends BaseTexture {
  50217. private static _facesMapping;
  50218. private _generateHarmonics;
  50219. private _noMipmap;
  50220. private _textureMatrix;
  50221. private _size;
  50222. private _onLoad;
  50223. private _onError;
  50224. /**
  50225. * The texture URL.
  50226. */
  50227. url: string;
  50228. /**
  50229. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50230. */
  50231. coordinatesMode: number;
  50232. protected _isBlocking: boolean;
  50233. /**
  50234. * Sets wether or not the texture is blocking during loading.
  50235. */
  50236. /**
  50237. * Gets wether or not the texture is blocking during loading.
  50238. */
  50239. isBlocking: boolean;
  50240. protected _rotationY: number;
  50241. /**
  50242. * Sets texture matrix rotation angle around Y axis in radians.
  50243. */
  50244. /**
  50245. * Gets texture matrix rotation angle around Y axis radians.
  50246. */
  50247. rotationY: number;
  50248. /**
  50249. * Gets or sets the center of the bounding box associated with the cube texture
  50250. * It must define where the camera used to render the texture was set
  50251. */
  50252. boundingBoxPosition: Vector3;
  50253. private _boundingBoxSize;
  50254. /**
  50255. * Gets or sets the size of the bounding box associated with the cube texture
  50256. * When defined, the cubemap will switch to local mode
  50257. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50258. * @example https://www.babylonjs-playground.com/#RNASML
  50259. */
  50260. boundingBoxSize: Vector3;
  50261. /**
  50262. * Instantiates an HDRTexture from the following parameters.
  50263. *
  50264. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50265. * @param scene The scene the texture will be used in
  50266. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50267. * @param noMipmap Forces to not generate the mipmap if true
  50268. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50269. * @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)
  50270. * @param reserved Reserved flag for internal use.
  50271. */
  50272. 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>);
  50273. /**
  50274. * Get the current class name of the texture useful for serialization or dynamic coding.
  50275. * @returns "HDRCubeTexture"
  50276. */
  50277. getClassName(): string;
  50278. /**
  50279. * Occurs when the file is raw .hdr file.
  50280. */
  50281. private loadTexture;
  50282. clone(): HDRCubeTexture;
  50283. delayLoad(): void;
  50284. /**
  50285. * Get the texture reflection matrix used to rotate/transform the reflection.
  50286. * @returns the reflection matrix
  50287. */
  50288. getReflectionTextureMatrix(): Matrix;
  50289. /**
  50290. * Set the texture reflection matrix used to rotate/transform the reflection.
  50291. * @param value Define the reflection matrix to set
  50292. */
  50293. setReflectionTextureMatrix(value: Matrix): void;
  50294. /**
  50295. * Parses a JSON representation of an HDR Texture in order to create the texture
  50296. * @param parsedTexture Define the JSON representation
  50297. * @param scene Define the scene the texture should be created in
  50298. * @param rootUrl Define the root url in case we need to load relative dependencies
  50299. * @returns the newly created texture after parsing
  50300. */
  50301. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50302. serialize(): any;
  50303. }
  50304. }
  50305. declare module BABYLON {
  50306. /**
  50307. * Class used to control physics engine
  50308. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50309. */
  50310. export class PhysicsEngine implements IPhysicsEngine {
  50311. private _physicsPlugin;
  50312. /**
  50313. * Global value used to control the smallest number supported by the simulation
  50314. */
  50315. static Epsilon: number;
  50316. private _impostors;
  50317. private _joints;
  50318. /**
  50319. * Gets the gravity vector used by the simulation
  50320. */
  50321. gravity: Vector3;
  50322. /**
  50323. * Factory used to create the default physics plugin.
  50324. * @returns The default physics plugin
  50325. */
  50326. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50327. /**
  50328. * Creates a new Physics Engine
  50329. * @param gravity defines the gravity vector used by the simulation
  50330. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50331. */
  50332. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50333. /**
  50334. * Sets the gravity vector used by the simulation
  50335. * @param gravity defines the gravity vector to use
  50336. */
  50337. setGravity(gravity: Vector3): void;
  50338. /**
  50339. * Set the time step of the physics engine.
  50340. * Default is 1/60.
  50341. * To slow it down, enter 1/600 for example.
  50342. * To speed it up, 1/30
  50343. * @param newTimeStep defines the new timestep to apply to this world.
  50344. */
  50345. setTimeStep(newTimeStep?: number): void;
  50346. /**
  50347. * Get the time step of the physics engine.
  50348. * @returns the current time step
  50349. */
  50350. getTimeStep(): number;
  50351. /**
  50352. * Release all resources
  50353. */
  50354. dispose(): void;
  50355. /**
  50356. * Gets the name of the current physics plugin
  50357. * @returns the name of the plugin
  50358. */
  50359. getPhysicsPluginName(): string;
  50360. /**
  50361. * Adding a new impostor for the impostor tracking.
  50362. * This will be done by the impostor itself.
  50363. * @param impostor the impostor to add
  50364. */
  50365. addImpostor(impostor: PhysicsImpostor): void;
  50366. /**
  50367. * Remove an impostor from the engine.
  50368. * This impostor and its mesh will not longer be updated by the physics engine.
  50369. * @param impostor the impostor to remove
  50370. */
  50371. removeImpostor(impostor: PhysicsImpostor): void;
  50372. /**
  50373. * Add a joint to the physics engine
  50374. * @param mainImpostor defines the main impostor to which the joint is added.
  50375. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50376. * @param joint defines the joint that will connect both impostors.
  50377. */
  50378. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50379. /**
  50380. * Removes a joint from the simulation
  50381. * @param mainImpostor defines the impostor used with the joint
  50382. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50383. * @param joint defines the joint to remove
  50384. */
  50385. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50386. /**
  50387. * Called by the scene. No need to call it.
  50388. * @param delta defines the timespam between frames
  50389. */
  50390. _step(delta: number): void;
  50391. /**
  50392. * Gets the current plugin used to run the simulation
  50393. * @returns current plugin
  50394. */
  50395. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50396. /**
  50397. * Gets the list of physic impostors
  50398. * @returns an array of PhysicsImpostor
  50399. */
  50400. getImpostors(): Array<PhysicsImpostor>;
  50401. /**
  50402. * Gets the impostor for a physics enabled object
  50403. * @param object defines the object impersonated by the impostor
  50404. * @returns the PhysicsImpostor or null if not found
  50405. */
  50406. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50407. /**
  50408. * Gets the impostor for a physics body object
  50409. * @param body defines physics body used by the impostor
  50410. * @returns the PhysicsImpostor or null if not found
  50411. */
  50412. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50413. /**
  50414. * Does a raycast in the physics world
  50415. * @param from when should the ray start?
  50416. * @param to when should the ray end?
  50417. * @returns PhysicsRaycastResult
  50418. */
  50419. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50420. }
  50421. }
  50422. declare module BABYLON {
  50423. /** @hidden */
  50424. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50425. private _useDeltaForWorldStep;
  50426. world: any;
  50427. name: string;
  50428. private _physicsMaterials;
  50429. private _fixedTimeStep;
  50430. private _cannonRaycastResult;
  50431. private _raycastResult;
  50432. private _physicsBodysToRemoveAfterStep;
  50433. BJSCANNON: any;
  50434. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50435. setGravity(gravity: Vector3): void;
  50436. setTimeStep(timeStep: number): void;
  50437. getTimeStep(): number;
  50438. executeStep(delta: number): void;
  50439. private _removeMarkedPhysicsBodiesFromWorld;
  50440. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50441. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50442. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50443. private _processChildMeshes;
  50444. removePhysicsBody(impostor: PhysicsImpostor): void;
  50445. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50446. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50447. private _addMaterial;
  50448. private _checkWithEpsilon;
  50449. private _createShape;
  50450. private _createHeightmap;
  50451. private _minus90X;
  50452. private _plus90X;
  50453. private _tmpPosition;
  50454. private _tmpDeltaPosition;
  50455. private _tmpUnityRotation;
  50456. private _updatePhysicsBodyTransformation;
  50457. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50458. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50459. isSupported(): boolean;
  50460. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50461. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50462. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50463. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50464. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50465. getBodyMass(impostor: PhysicsImpostor): number;
  50466. getBodyFriction(impostor: PhysicsImpostor): number;
  50467. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50468. getBodyRestitution(impostor: PhysicsImpostor): number;
  50469. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50470. sleepBody(impostor: PhysicsImpostor): void;
  50471. wakeUpBody(impostor: PhysicsImpostor): void;
  50472. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50473. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50474. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50475. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50476. getRadius(impostor: PhysicsImpostor): number;
  50477. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50478. dispose(): void;
  50479. private _extendNamespace;
  50480. /**
  50481. * Does a raycast in the physics world
  50482. * @param from when should the ray start?
  50483. * @param to when should the ray end?
  50484. * @returns PhysicsRaycastResult
  50485. */
  50486. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50487. }
  50488. }
  50489. declare module BABYLON {
  50490. /** @hidden */
  50491. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50492. world: any;
  50493. name: string;
  50494. BJSOIMO: any;
  50495. private _raycastResult;
  50496. constructor(iterations?: number, oimoInjection?: any);
  50497. setGravity(gravity: Vector3): void;
  50498. setTimeStep(timeStep: number): void;
  50499. getTimeStep(): number;
  50500. private _tmpImpostorsArray;
  50501. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50502. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50503. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50504. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50505. private _tmpPositionVector;
  50506. removePhysicsBody(impostor: PhysicsImpostor): void;
  50507. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50508. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50509. isSupported(): boolean;
  50510. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50511. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50512. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50513. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50514. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50515. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50516. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50517. getBodyMass(impostor: PhysicsImpostor): number;
  50518. getBodyFriction(impostor: PhysicsImpostor): number;
  50519. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50520. getBodyRestitution(impostor: PhysicsImpostor): number;
  50521. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50522. sleepBody(impostor: PhysicsImpostor): void;
  50523. wakeUpBody(impostor: PhysicsImpostor): void;
  50524. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50525. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50526. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50527. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50528. getRadius(impostor: PhysicsImpostor): number;
  50529. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50530. dispose(): void;
  50531. /**
  50532. * Does a raycast in the physics world
  50533. * @param from when should the ray start?
  50534. * @param to when should the ray end?
  50535. * @returns PhysicsRaycastResult
  50536. */
  50537. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50538. }
  50539. }
  50540. declare module BABYLON {
  50541. /**
  50542. * Class containing static functions to help procedurally build meshes
  50543. */
  50544. export class RibbonBuilder {
  50545. /**
  50546. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50547. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50548. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50549. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50550. * * 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
  50551. * * 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
  50552. * * 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
  50553. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50554. * * 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
  50555. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50556. * * 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
  50557. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50558. * * 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
  50559. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50561. * @param name defines the name of the mesh
  50562. * @param options defines the options used to create the mesh
  50563. * @param scene defines the hosting scene
  50564. * @returns the ribbon mesh
  50565. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50566. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50567. */
  50568. static CreateRibbon(name: string, options: {
  50569. pathArray: Vector3[][];
  50570. closeArray?: boolean;
  50571. closePath?: boolean;
  50572. offset?: number;
  50573. updatable?: boolean;
  50574. sideOrientation?: number;
  50575. frontUVs?: Vector4;
  50576. backUVs?: Vector4;
  50577. instance?: Mesh;
  50578. invertUV?: boolean;
  50579. uvs?: Vector2[];
  50580. colors?: Color4[];
  50581. }, scene?: Nullable<Scene>): Mesh;
  50582. }
  50583. }
  50584. declare module BABYLON {
  50585. /**
  50586. * Class containing static functions to help procedurally build meshes
  50587. */
  50588. export class ShapeBuilder {
  50589. /**
  50590. * 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.
  50591. * * 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.
  50592. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50593. * * 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.
  50594. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50595. * * 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
  50596. * * 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
  50597. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50598. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50599. * * 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
  50600. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50602. * @param name defines the name of the mesh
  50603. * @param options defines the options used to create the mesh
  50604. * @param scene defines the hosting scene
  50605. * @returns the extruded shape mesh
  50606. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50607. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50608. */
  50609. static ExtrudeShape(name: string, options: {
  50610. shape: Vector3[];
  50611. path: Vector3[];
  50612. scale?: number;
  50613. rotation?: number;
  50614. cap?: number;
  50615. updatable?: boolean;
  50616. sideOrientation?: number;
  50617. frontUVs?: Vector4;
  50618. backUVs?: Vector4;
  50619. instance?: Mesh;
  50620. invertUV?: boolean;
  50621. }, scene?: Nullable<Scene>): Mesh;
  50622. /**
  50623. * Creates an custom extruded shape mesh.
  50624. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50625. * * 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.
  50626. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50627. * * 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
  50628. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50629. * * 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
  50630. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50631. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50632. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50633. * * 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
  50634. * * 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
  50635. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50636. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50637. * * 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
  50638. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50640. * @param name defines the name of the mesh
  50641. * @param options defines the options used to create the mesh
  50642. * @param scene defines the hosting scene
  50643. * @returns the custom extruded shape mesh
  50644. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50645. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50646. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50647. */
  50648. static ExtrudeShapeCustom(name: string, options: {
  50649. shape: Vector3[];
  50650. path: Vector3[];
  50651. scaleFunction?: any;
  50652. rotationFunction?: any;
  50653. ribbonCloseArray?: boolean;
  50654. ribbonClosePath?: boolean;
  50655. cap?: number;
  50656. updatable?: boolean;
  50657. sideOrientation?: number;
  50658. frontUVs?: Vector4;
  50659. backUVs?: Vector4;
  50660. instance?: Mesh;
  50661. invertUV?: boolean;
  50662. }, scene?: Nullable<Scene>): Mesh;
  50663. private static _ExtrudeShapeGeneric;
  50664. }
  50665. }
  50666. declare module BABYLON {
  50667. /**
  50668. * AmmoJS Physics plugin
  50669. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50670. * @see https://github.com/kripken/ammo.js/
  50671. */
  50672. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50673. private _useDeltaForWorldStep;
  50674. /**
  50675. * Reference to the Ammo library
  50676. */
  50677. bjsAMMO: any;
  50678. /**
  50679. * Created ammoJS world which physics bodies are added to
  50680. */
  50681. world: any;
  50682. /**
  50683. * Name of the plugin
  50684. */
  50685. name: string;
  50686. private _timeStep;
  50687. private _fixedTimeStep;
  50688. private _maxSteps;
  50689. private _tmpQuaternion;
  50690. private _tmpAmmoTransform;
  50691. private _tmpAmmoQuaternion;
  50692. private _tmpAmmoConcreteContactResultCallback;
  50693. private _collisionConfiguration;
  50694. private _dispatcher;
  50695. private _overlappingPairCache;
  50696. private _solver;
  50697. private _softBodySolver;
  50698. private _tmpAmmoVectorA;
  50699. private _tmpAmmoVectorB;
  50700. private _tmpAmmoVectorC;
  50701. private _tmpAmmoVectorD;
  50702. private _tmpContactCallbackResult;
  50703. private _tmpAmmoVectorRCA;
  50704. private _tmpAmmoVectorRCB;
  50705. private _raycastResult;
  50706. private static readonly DISABLE_COLLISION_FLAG;
  50707. private static readonly KINEMATIC_FLAG;
  50708. private static readonly DISABLE_DEACTIVATION_FLAG;
  50709. /**
  50710. * Initializes the ammoJS plugin
  50711. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50712. * @param ammoInjection can be used to inject your own ammo reference
  50713. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  50714. */
  50715. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  50716. /**
  50717. * Sets the gravity of the physics world (m/(s^2))
  50718. * @param gravity Gravity to set
  50719. */
  50720. setGravity(gravity: Vector3): void;
  50721. /**
  50722. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50723. * @param timeStep timestep to use in seconds
  50724. */
  50725. setTimeStep(timeStep: number): void;
  50726. /**
  50727. * 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)
  50728. * @param fixedTimeStep fixedTimeStep to use in seconds
  50729. */
  50730. setFixedTimeStep(fixedTimeStep: number): void;
  50731. /**
  50732. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50733. * @param maxSteps the maximum number of steps by the physics engine per frame
  50734. */
  50735. setMaxSteps(maxSteps: number): void;
  50736. /**
  50737. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50738. * @returns the current timestep in seconds
  50739. */
  50740. getTimeStep(): number;
  50741. private _isImpostorInContact;
  50742. private _isImpostorPairInContact;
  50743. private _stepSimulation;
  50744. /**
  50745. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50746. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50747. * After the step the babylon meshes are set to the position of the physics imposters
  50748. * @param delta amount of time to step forward
  50749. * @param impostors array of imposters to update before/after the step
  50750. */
  50751. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50752. /**
  50753. * Update babylon mesh to match physics world object
  50754. * @param impostor imposter to match
  50755. */
  50756. private _afterSoftStep;
  50757. /**
  50758. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50759. * @param impostor imposter to match
  50760. */
  50761. private _ropeStep;
  50762. /**
  50763. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50764. * @param impostor imposter to match
  50765. */
  50766. private _softbodyOrClothStep;
  50767. private _tmpVector;
  50768. private _tmpMatrix;
  50769. /**
  50770. * Applies an impulse on the imposter
  50771. * @param impostor imposter to apply impulse to
  50772. * @param force amount of force to be applied to the imposter
  50773. * @param contactPoint the location to apply the impulse on the imposter
  50774. */
  50775. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50776. /**
  50777. * Applies a force on the imposter
  50778. * @param impostor imposter to apply force
  50779. * @param force amount of force to be applied to the imposter
  50780. * @param contactPoint the location to apply the force on the imposter
  50781. */
  50782. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50783. /**
  50784. * Creates a physics body using the plugin
  50785. * @param impostor the imposter to create the physics body on
  50786. */
  50787. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50788. /**
  50789. * Removes the physics body from the imposter and disposes of the body's memory
  50790. * @param impostor imposter to remove the physics body from
  50791. */
  50792. removePhysicsBody(impostor: PhysicsImpostor): void;
  50793. /**
  50794. * Generates a joint
  50795. * @param impostorJoint the imposter joint to create the joint with
  50796. */
  50797. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50798. /**
  50799. * Removes a joint
  50800. * @param impostorJoint the imposter joint to remove the joint from
  50801. */
  50802. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50803. private _addMeshVerts;
  50804. /**
  50805. * Initialise the soft body vertices to match its object's (mesh) vertices
  50806. * Softbody vertices (nodes) are in world space and to match this
  50807. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50808. * @param impostor to create the softbody for
  50809. */
  50810. private _softVertexData;
  50811. /**
  50812. * Create an impostor's soft body
  50813. * @param impostor to create the softbody for
  50814. */
  50815. private _createSoftbody;
  50816. /**
  50817. * Create cloth for an impostor
  50818. * @param impostor to create the softbody for
  50819. */
  50820. private _createCloth;
  50821. /**
  50822. * Create rope for an impostor
  50823. * @param impostor to create the softbody for
  50824. */
  50825. private _createRope;
  50826. private _addHullVerts;
  50827. private _createShape;
  50828. /**
  50829. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50830. * @param impostor imposter containing the physics body and babylon object
  50831. */
  50832. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50833. /**
  50834. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50835. * @param impostor imposter containing the physics body and babylon object
  50836. * @param newPosition new position
  50837. * @param newRotation new rotation
  50838. */
  50839. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50840. /**
  50841. * If this plugin is supported
  50842. * @returns true if its supported
  50843. */
  50844. isSupported(): boolean;
  50845. /**
  50846. * Sets the linear velocity of the physics body
  50847. * @param impostor imposter to set the velocity on
  50848. * @param velocity velocity to set
  50849. */
  50850. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50851. /**
  50852. * Sets the angular velocity of the physics body
  50853. * @param impostor imposter to set the velocity on
  50854. * @param velocity velocity to set
  50855. */
  50856. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50857. /**
  50858. * gets the linear velocity
  50859. * @param impostor imposter to get linear velocity from
  50860. * @returns linear velocity
  50861. */
  50862. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50863. /**
  50864. * gets the angular velocity
  50865. * @param impostor imposter to get angular velocity from
  50866. * @returns angular velocity
  50867. */
  50868. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50869. /**
  50870. * Sets the mass of physics body
  50871. * @param impostor imposter to set the mass on
  50872. * @param mass mass to set
  50873. */
  50874. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50875. /**
  50876. * Gets the mass of the physics body
  50877. * @param impostor imposter to get the mass from
  50878. * @returns mass
  50879. */
  50880. getBodyMass(impostor: PhysicsImpostor): number;
  50881. /**
  50882. * Gets friction of the impostor
  50883. * @param impostor impostor to get friction from
  50884. * @returns friction value
  50885. */
  50886. getBodyFriction(impostor: PhysicsImpostor): number;
  50887. /**
  50888. * Sets friction of the impostor
  50889. * @param impostor impostor to set friction on
  50890. * @param friction friction value
  50891. */
  50892. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50893. /**
  50894. * Gets restitution of the impostor
  50895. * @param impostor impostor to get restitution from
  50896. * @returns restitution value
  50897. */
  50898. getBodyRestitution(impostor: PhysicsImpostor): number;
  50899. /**
  50900. * Sets resitution of the impostor
  50901. * @param impostor impostor to set resitution on
  50902. * @param restitution resitution value
  50903. */
  50904. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50905. /**
  50906. * Gets pressure inside the impostor
  50907. * @param impostor impostor to get pressure from
  50908. * @returns pressure value
  50909. */
  50910. getBodyPressure(impostor: PhysicsImpostor): number;
  50911. /**
  50912. * Sets pressure inside a soft body impostor
  50913. * Cloth and rope must remain 0 pressure
  50914. * @param impostor impostor to set pressure on
  50915. * @param pressure pressure value
  50916. */
  50917. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50918. /**
  50919. * Gets stiffness of the impostor
  50920. * @param impostor impostor to get stiffness from
  50921. * @returns pressure value
  50922. */
  50923. getBodyStiffness(impostor: PhysicsImpostor): number;
  50924. /**
  50925. * Sets stiffness of the impostor
  50926. * @param impostor impostor to set stiffness on
  50927. * @param stiffness stiffness value from 0 to 1
  50928. */
  50929. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50930. /**
  50931. * Gets velocityIterations of the impostor
  50932. * @param impostor impostor to get velocity iterations from
  50933. * @returns velocityIterations value
  50934. */
  50935. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50936. /**
  50937. * Sets velocityIterations of the impostor
  50938. * @param impostor impostor to set velocity iterations on
  50939. * @param velocityIterations velocityIterations value
  50940. */
  50941. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50942. /**
  50943. * Gets positionIterations of the impostor
  50944. * @param impostor impostor to get position iterations from
  50945. * @returns positionIterations value
  50946. */
  50947. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50948. /**
  50949. * Sets positionIterations of the impostor
  50950. * @param impostor impostor to set position on
  50951. * @param positionIterations positionIterations value
  50952. */
  50953. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50954. /**
  50955. * Append an anchor to a cloth object
  50956. * @param impostor is the cloth impostor to add anchor to
  50957. * @param otherImpostor is the rigid impostor to anchor to
  50958. * @param width ratio across width from 0 to 1
  50959. * @param height ratio up height from 0 to 1
  50960. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50961. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50962. */
  50963. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50964. /**
  50965. * Append an hook to a rope object
  50966. * @param impostor is the rope impostor to add hook to
  50967. * @param otherImpostor is the rigid impostor to hook to
  50968. * @param length ratio along the rope from 0 to 1
  50969. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50970. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50971. */
  50972. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50973. /**
  50974. * Sleeps the physics body and stops it from being active
  50975. * @param impostor impostor to sleep
  50976. */
  50977. sleepBody(impostor: PhysicsImpostor): void;
  50978. /**
  50979. * Activates the physics body
  50980. * @param impostor impostor to activate
  50981. */
  50982. wakeUpBody(impostor: PhysicsImpostor): void;
  50983. /**
  50984. * Updates the distance parameters of the joint
  50985. * @param joint joint to update
  50986. * @param maxDistance maximum distance of the joint
  50987. * @param minDistance minimum distance of the joint
  50988. */
  50989. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50990. /**
  50991. * Sets a motor on the joint
  50992. * @param joint joint to set motor on
  50993. * @param speed speed of the motor
  50994. * @param maxForce maximum force of the motor
  50995. * @param motorIndex index of the motor
  50996. */
  50997. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50998. /**
  50999. * Sets the motors limit
  51000. * @param joint joint to set limit on
  51001. * @param upperLimit upper limit
  51002. * @param lowerLimit lower limit
  51003. */
  51004. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51005. /**
  51006. * Syncs the position and rotation of a mesh with the impostor
  51007. * @param mesh mesh to sync
  51008. * @param impostor impostor to update the mesh with
  51009. */
  51010. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51011. /**
  51012. * Gets the radius of the impostor
  51013. * @param impostor impostor to get radius from
  51014. * @returns the radius
  51015. */
  51016. getRadius(impostor: PhysicsImpostor): number;
  51017. /**
  51018. * Gets the box size of the impostor
  51019. * @param impostor impostor to get box size from
  51020. * @param result the resulting box size
  51021. */
  51022. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51023. /**
  51024. * Disposes of the impostor
  51025. */
  51026. dispose(): void;
  51027. /**
  51028. * Does a raycast in the physics world
  51029. * @param from when should the ray start?
  51030. * @param to when should the ray end?
  51031. * @returns PhysicsRaycastResult
  51032. */
  51033. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51034. }
  51035. }
  51036. declare module BABYLON {
  51037. interface AbstractScene {
  51038. /**
  51039. * The list of reflection probes added to the scene
  51040. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51041. */
  51042. reflectionProbes: Array<ReflectionProbe>;
  51043. /**
  51044. * Removes the given reflection probe from this scene.
  51045. * @param toRemove The reflection probe to remove
  51046. * @returns The index of the removed reflection probe
  51047. */
  51048. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51049. /**
  51050. * Adds the given reflection probe to this scene.
  51051. * @param newReflectionProbe The reflection probe to add
  51052. */
  51053. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51054. }
  51055. /**
  51056. * Class used to generate realtime reflection / refraction cube textures
  51057. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51058. */
  51059. export class ReflectionProbe {
  51060. /** defines the name of the probe */
  51061. name: string;
  51062. private _scene;
  51063. private _renderTargetTexture;
  51064. private _projectionMatrix;
  51065. private _viewMatrix;
  51066. private _target;
  51067. private _add;
  51068. private _attachedMesh;
  51069. private _invertYAxis;
  51070. /** Gets or sets probe position (center of the cube map) */
  51071. position: Vector3;
  51072. /**
  51073. * Creates a new reflection probe
  51074. * @param name defines the name of the probe
  51075. * @param size defines the texture resolution (for each face)
  51076. * @param scene defines the hosting scene
  51077. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51078. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51079. */
  51080. constructor(
  51081. /** defines the name of the probe */
  51082. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51083. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51084. samples: number;
  51085. /** Gets or sets the refresh rate to use (on every frame by default) */
  51086. refreshRate: number;
  51087. /**
  51088. * Gets the hosting scene
  51089. * @returns a Scene
  51090. */
  51091. getScene(): Scene;
  51092. /** Gets the internal CubeTexture used to render to */
  51093. readonly cubeTexture: RenderTargetTexture;
  51094. /** Gets the list of meshes to render */
  51095. readonly renderList: Nullable<AbstractMesh[]>;
  51096. /**
  51097. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51098. * @param mesh defines the mesh to attach to
  51099. */
  51100. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51101. /**
  51102. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51103. * @param renderingGroupId The rendering group id corresponding to its index
  51104. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51105. */
  51106. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51107. /**
  51108. * Clean all associated resources
  51109. */
  51110. dispose(): void;
  51111. /**
  51112. * Converts the reflection probe information to a readable string for debug purpose.
  51113. * @param fullDetails Supports for multiple levels of logging within scene loading
  51114. * @returns the human readable reflection probe info
  51115. */
  51116. toString(fullDetails?: boolean): string;
  51117. /**
  51118. * Get the class name of the relfection probe.
  51119. * @returns "ReflectionProbe"
  51120. */
  51121. getClassName(): string;
  51122. /**
  51123. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51124. * @returns The JSON representation of the texture
  51125. */
  51126. serialize(): any;
  51127. /**
  51128. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51129. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51130. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51131. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51132. * @returns The parsed reflection probe if successful
  51133. */
  51134. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51135. }
  51136. }
  51137. declare module BABYLON {
  51138. /** @hidden */
  51139. export var _BabylonLoaderRegistered: boolean;
  51140. }
  51141. declare module BABYLON {
  51142. /**
  51143. * The Physically based simple base material of BJS.
  51144. *
  51145. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51146. * It is used as the base class for both the specGloss and metalRough conventions.
  51147. */
  51148. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51149. /**
  51150. * Number of Simultaneous lights allowed on the material.
  51151. */
  51152. maxSimultaneousLights: number;
  51153. /**
  51154. * If sets to true, disables all the lights affecting the material.
  51155. */
  51156. disableLighting: boolean;
  51157. /**
  51158. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51159. */
  51160. environmentTexture: BaseTexture;
  51161. /**
  51162. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51163. */
  51164. invertNormalMapX: boolean;
  51165. /**
  51166. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51167. */
  51168. invertNormalMapY: boolean;
  51169. /**
  51170. * Normal map used in the model.
  51171. */
  51172. normalTexture: BaseTexture;
  51173. /**
  51174. * Emissivie color used to self-illuminate the model.
  51175. */
  51176. emissiveColor: Color3;
  51177. /**
  51178. * Emissivie texture used to self-illuminate the model.
  51179. */
  51180. emissiveTexture: BaseTexture;
  51181. /**
  51182. * Occlusion Channel Strenght.
  51183. */
  51184. occlusionStrength: number;
  51185. /**
  51186. * Occlusion Texture of the material (adding extra occlusion effects).
  51187. */
  51188. occlusionTexture: BaseTexture;
  51189. /**
  51190. * Defines the alpha limits in alpha test mode.
  51191. */
  51192. alphaCutOff: number;
  51193. /**
  51194. * Gets the current double sided mode.
  51195. */
  51196. /**
  51197. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51198. */
  51199. doubleSided: boolean;
  51200. /**
  51201. * Stores the pre-calculated light information of a mesh in a texture.
  51202. */
  51203. lightmapTexture: BaseTexture;
  51204. /**
  51205. * If true, the light map contains occlusion information instead of lighting info.
  51206. */
  51207. useLightmapAsShadowmap: boolean;
  51208. /**
  51209. * Instantiates a new PBRMaterial instance.
  51210. *
  51211. * @param name The material name
  51212. * @param scene The scene the material will be use in.
  51213. */
  51214. constructor(name: string, scene: Scene);
  51215. getClassName(): string;
  51216. }
  51217. }
  51218. declare module BABYLON {
  51219. /**
  51220. * The PBR material of BJS following the metal roughness convention.
  51221. *
  51222. * This fits to the PBR convention in the GLTF definition:
  51223. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51224. */
  51225. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51226. /**
  51227. * The base color has two different interpretations depending on the value of metalness.
  51228. * When the material is a metal, the base color is the specific measured reflectance value
  51229. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51230. * of the material.
  51231. */
  51232. baseColor: Color3;
  51233. /**
  51234. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51235. * well as opacity information in the alpha channel.
  51236. */
  51237. baseTexture: BaseTexture;
  51238. /**
  51239. * Specifies the metallic scalar value of the material.
  51240. * Can also be used to scale the metalness values of the metallic texture.
  51241. */
  51242. metallic: number;
  51243. /**
  51244. * Specifies the roughness scalar value of the material.
  51245. * Can also be used to scale the roughness values of the metallic texture.
  51246. */
  51247. roughness: number;
  51248. /**
  51249. * Texture containing both the metallic value in the B channel and the
  51250. * roughness value in the G channel to keep better precision.
  51251. */
  51252. metallicRoughnessTexture: BaseTexture;
  51253. /**
  51254. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51255. *
  51256. * @param name The material name
  51257. * @param scene The scene the material will be use in.
  51258. */
  51259. constructor(name: string, scene: Scene);
  51260. /**
  51261. * Return the currrent class name of the material.
  51262. */
  51263. getClassName(): string;
  51264. /**
  51265. * Makes a duplicate of the current material.
  51266. * @param name - name to use for the new material.
  51267. */
  51268. clone(name: string): PBRMetallicRoughnessMaterial;
  51269. /**
  51270. * Serialize the material to a parsable JSON object.
  51271. */
  51272. serialize(): any;
  51273. /**
  51274. * Parses a JSON object correponding to the serialize function.
  51275. */
  51276. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51277. }
  51278. }
  51279. declare module BABYLON {
  51280. /**
  51281. * The PBR material of BJS following the specular glossiness convention.
  51282. *
  51283. * This fits to the PBR convention in the GLTF definition:
  51284. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51285. */
  51286. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51287. /**
  51288. * Specifies the diffuse color of the material.
  51289. */
  51290. diffuseColor: Color3;
  51291. /**
  51292. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51293. * channel.
  51294. */
  51295. diffuseTexture: BaseTexture;
  51296. /**
  51297. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51298. */
  51299. specularColor: Color3;
  51300. /**
  51301. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51302. */
  51303. glossiness: number;
  51304. /**
  51305. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51306. */
  51307. specularGlossinessTexture: BaseTexture;
  51308. /**
  51309. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51310. *
  51311. * @param name The material name
  51312. * @param scene The scene the material will be use in.
  51313. */
  51314. constructor(name: string, scene: Scene);
  51315. /**
  51316. * Return the currrent class name of the material.
  51317. */
  51318. getClassName(): string;
  51319. /**
  51320. * Makes a duplicate of the current material.
  51321. * @param name - name to use for the new material.
  51322. */
  51323. clone(name: string): PBRSpecularGlossinessMaterial;
  51324. /**
  51325. * Serialize the material to a parsable JSON object.
  51326. */
  51327. serialize(): any;
  51328. /**
  51329. * Parses a JSON object correponding to the serialize function.
  51330. */
  51331. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51332. }
  51333. }
  51334. declare module BABYLON {
  51335. /**
  51336. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51337. * It can help converting any input color in a desired output one. This can then be used to create effects
  51338. * from sepia, black and white to sixties or futuristic rendering...
  51339. *
  51340. * The only supported format is currently 3dl.
  51341. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51342. */
  51343. export class ColorGradingTexture extends BaseTexture {
  51344. /**
  51345. * The current texture matrix. (will always be identity in color grading texture)
  51346. */
  51347. private _textureMatrix;
  51348. /**
  51349. * The texture URL.
  51350. */
  51351. url: string;
  51352. /**
  51353. * Empty line regex stored for GC.
  51354. */
  51355. private static _noneEmptyLineRegex;
  51356. private _engine;
  51357. /**
  51358. * Instantiates a ColorGradingTexture from the following parameters.
  51359. *
  51360. * @param url The location of the color gradind data (currently only supporting 3dl)
  51361. * @param scene The scene the texture will be used in
  51362. */
  51363. constructor(url: string, scene: Scene);
  51364. /**
  51365. * Returns the texture matrix used in most of the material.
  51366. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51367. */
  51368. getTextureMatrix(): Matrix;
  51369. /**
  51370. * Occurs when the file being loaded is a .3dl LUT file.
  51371. */
  51372. private load3dlTexture;
  51373. /**
  51374. * Starts the loading process of the texture.
  51375. */
  51376. private loadTexture;
  51377. /**
  51378. * Clones the color gradind texture.
  51379. */
  51380. clone(): ColorGradingTexture;
  51381. /**
  51382. * Called during delayed load for textures.
  51383. */
  51384. delayLoad(): void;
  51385. /**
  51386. * Parses a color grading texture serialized by Babylon.
  51387. * @param parsedTexture The texture information being parsedTexture
  51388. * @param scene The scene to load the texture in
  51389. * @param rootUrl The root url of the data assets to load
  51390. * @return A color gradind texture
  51391. */
  51392. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51393. /**
  51394. * Serializes the LUT texture to json format.
  51395. */
  51396. serialize(): any;
  51397. }
  51398. }
  51399. declare module BABYLON {
  51400. /**
  51401. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51402. */
  51403. export class EquiRectangularCubeTexture extends BaseTexture {
  51404. /** The six faces of the cube. */
  51405. private static _FacesMapping;
  51406. private _noMipmap;
  51407. private _onLoad;
  51408. private _onError;
  51409. /** The size of the cubemap. */
  51410. private _size;
  51411. /** The buffer of the image. */
  51412. private _buffer;
  51413. /** The width of the input image. */
  51414. private _width;
  51415. /** The height of the input image. */
  51416. private _height;
  51417. /** The URL to the image. */
  51418. url: string;
  51419. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51420. coordinatesMode: number;
  51421. /**
  51422. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51423. * @param url The location of the image
  51424. * @param scene The scene the texture will be used in
  51425. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51426. * @param noMipmap Forces to not generate the mipmap if true
  51427. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51428. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51429. * @param onLoad — defines a callback called when texture is loaded
  51430. * @param onError — defines a callback called if there is an error
  51431. */
  51432. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51433. /**
  51434. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51435. */
  51436. private loadImage;
  51437. /**
  51438. * Convert the image buffer into a cubemap and create a CubeTexture.
  51439. */
  51440. private loadTexture;
  51441. /**
  51442. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51443. * @param buffer The ArrayBuffer that should be converted.
  51444. * @returns The buffer as Float32Array.
  51445. */
  51446. private getFloat32ArrayFromArrayBuffer;
  51447. /**
  51448. * Get the current class name of the texture useful for serialization or dynamic coding.
  51449. * @returns "EquiRectangularCubeTexture"
  51450. */
  51451. getClassName(): string;
  51452. /**
  51453. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51454. * @returns A clone of the current EquiRectangularCubeTexture.
  51455. */
  51456. clone(): EquiRectangularCubeTexture;
  51457. }
  51458. }
  51459. declare module BABYLON {
  51460. /**
  51461. * Based on jsTGALoader - Javascript loader for TGA file
  51462. * By Vincent Thibault
  51463. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51464. */
  51465. export class TGATools {
  51466. private static _TYPE_INDEXED;
  51467. private static _TYPE_RGB;
  51468. private static _TYPE_GREY;
  51469. private static _TYPE_RLE_INDEXED;
  51470. private static _TYPE_RLE_RGB;
  51471. private static _TYPE_RLE_GREY;
  51472. private static _ORIGIN_MASK;
  51473. private static _ORIGIN_SHIFT;
  51474. private static _ORIGIN_BL;
  51475. private static _ORIGIN_BR;
  51476. private static _ORIGIN_UL;
  51477. private static _ORIGIN_UR;
  51478. /**
  51479. * Gets the header of a TGA file
  51480. * @param data defines the TGA data
  51481. * @returns the header
  51482. */
  51483. static GetTGAHeader(data: Uint8Array): any;
  51484. /**
  51485. * Uploads TGA content to a Babylon Texture
  51486. * @hidden
  51487. */
  51488. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51489. /** @hidden */
  51490. 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;
  51491. /** @hidden */
  51492. 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;
  51493. /** @hidden */
  51494. 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;
  51495. /** @hidden */
  51496. 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;
  51497. /** @hidden */
  51498. 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;
  51499. /** @hidden */
  51500. 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;
  51501. }
  51502. }
  51503. declare module BABYLON {
  51504. /**
  51505. * Implementation of the TGA Texture Loader.
  51506. * @hidden
  51507. */
  51508. export class _TGATextureLoader implements IInternalTextureLoader {
  51509. /**
  51510. * Defines wether the loader supports cascade loading the different faces.
  51511. */
  51512. readonly supportCascades: boolean;
  51513. /**
  51514. * This returns if the loader support the current file information.
  51515. * @param extension defines the file extension of the file being loaded
  51516. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51517. * @param fallback defines the fallback internal texture if any
  51518. * @param isBase64 defines whether the texture is encoded as a base64
  51519. * @param isBuffer defines whether the texture data are stored as a buffer
  51520. * @returns true if the loader can load the specified file
  51521. */
  51522. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51523. /**
  51524. * Transform the url before loading if required.
  51525. * @param rootUrl the url of the texture
  51526. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51527. * @returns the transformed texture
  51528. */
  51529. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51530. /**
  51531. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51532. * @param rootUrl the url of the texture
  51533. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51534. * @returns the fallback texture
  51535. */
  51536. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51537. /**
  51538. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51539. * @param data contains the texture data
  51540. * @param texture defines the BabylonJS internal texture
  51541. * @param createPolynomials will be true if polynomials have been requested
  51542. * @param onLoad defines the callback to trigger once the texture is ready
  51543. * @param onError defines the callback to trigger in case of error
  51544. */
  51545. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51546. /**
  51547. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51548. * @param data contains the texture data
  51549. * @param texture defines the BabylonJS internal texture
  51550. * @param callback defines the method to call once ready to upload
  51551. */
  51552. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51553. }
  51554. }
  51555. declare module BABYLON {
  51556. /**
  51557. * Info about the .basis files
  51558. */
  51559. class BasisFileInfo {
  51560. /**
  51561. * If the file has alpha
  51562. */
  51563. hasAlpha: boolean;
  51564. /**
  51565. * Info about each image of the basis file
  51566. */
  51567. images: Array<{
  51568. levels: Array<{
  51569. width: number;
  51570. height: number;
  51571. transcodedPixels: ArrayBufferView;
  51572. }>;
  51573. }>;
  51574. }
  51575. /**
  51576. * Result of transcoding a basis file
  51577. */
  51578. class TranscodeResult {
  51579. /**
  51580. * Info about the .basis file
  51581. */
  51582. fileInfo: BasisFileInfo;
  51583. /**
  51584. * Format to use when loading the file
  51585. */
  51586. format: number;
  51587. }
  51588. /**
  51589. * Configuration options for the Basis transcoder
  51590. */
  51591. export class BasisTranscodeConfiguration {
  51592. /**
  51593. * Supported compression formats used to determine the supported output format of the transcoder
  51594. */
  51595. supportedCompressionFormats?: {
  51596. /**
  51597. * etc1 compression format
  51598. */
  51599. etc1?: boolean;
  51600. /**
  51601. * s3tc compression format
  51602. */
  51603. s3tc?: boolean;
  51604. /**
  51605. * pvrtc compression format
  51606. */
  51607. pvrtc?: boolean;
  51608. /**
  51609. * etc2 compression format
  51610. */
  51611. etc2?: boolean;
  51612. };
  51613. /**
  51614. * If mipmap levels should be loaded for transcoded images (Default: true)
  51615. */
  51616. loadMipmapLevels?: boolean;
  51617. /**
  51618. * Index of a single image to load (Default: all images)
  51619. */
  51620. loadSingleImage?: number;
  51621. }
  51622. /**
  51623. * Used to load .Basis files
  51624. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  51625. */
  51626. export class BasisTools {
  51627. private static _IgnoreSupportedFormats;
  51628. /**
  51629. * URL to use when loading the basis transcoder
  51630. */
  51631. static JSModuleURL: string;
  51632. /**
  51633. * URL to use when loading the wasm module for the transcoder
  51634. */
  51635. static WasmModuleURL: string;
  51636. /**
  51637. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  51638. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  51639. * @returns internal format corresponding to the Basis format
  51640. */
  51641. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  51642. private static _WorkerPromise;
  51643. private static _Worker;
  51644. private static _actionId;
  51645. private static _CreateWorkerAsync;
  51646. /**
  51647. * Transcodes a loaded image file to compressed pixel data
  51648. * @param imageData image data to transcode
  51649. * @param config configuration options for the transcoding
  51650. * @returns a promise resulting in the transcoded image
  51651. */
  51652. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  51653. /**
  51654. * Loads a texture from the transcode result
  51655. * @param texture texture load to
  51656. * @param transcodeResult the result of transcoding the basis file to load from
  51657. */
  51658. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  51659. }
  51660. }
  51661. declare module BABYLON {
  51662. /**
  51663. * Loader for .basis file format
  51664. */
  51665. export class _BasisTextureLoader implements IInternalTextureLoader {
  51666. /**
  51667. * Defines whether the loader supports cascade loading the different faces.
  51668. */
  51669. readonly supportCascades: boolean;
  51670. /**
  51671. * This returns if the loader support the current file information.
  51672. * @param extension defines the file extension of the file being loaded
  51673. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51674. * @param fallback defines the fallback internal texture if any
  51675. * @param isBase64 defines whether the texture is encoded as a base64
  51676. * @param isBuffer defines whether the texture data are stored as a buffer
  51677. * @returns true if the loader can load the specified file
  51678. */
  51679. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51680. /**
  51681. * Transform the url before loading if required.
  51682. * @param rootUrl the url of the texture
  51683. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51684. * @returns the transformed texture
  51685. */
  51686. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51687. /**
  51688. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51689. * @param rootUrl the url of the texture
  51690. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51691. * @returns the fallback texture
  51692. */
  51693. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51694. /**
  51695. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  51696. * @param data contains the texture data
  51697. * @param texture defines the BabylonJS internal texture
  51698. * @param createPolynomials will be true if polynomials have been requested
  51699. * @param onLoad defines the callback to trigger once the texture is ready
  51700. * @param onError defines the callback to trigger in case of error
  51701. */
  51702. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51703. /**
  51704. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51705. * @param data contains the texture data
  51706. * @param texture defines the BabylonJS internal texture
  51707. * @param callback defines the method to call once ready to upload
  51708. */
  51709. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51710. }
  51711. }
  51712. declare module BABYLON {
  51713. /**
  51714. * 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.
  51715. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51716. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51717. */
  51718. export class CustomProceduralTexture extends ProceduralTexture {
  51719. private _animate;
  51720. private _time;
  51721. private _config;
  51722. private _texturePath;
  51723. /**
  51724. * Instantiates a new Custom Procedural Texture.
  51725. * 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.
  51726. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51727. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51728. * @param name Define the name of the texture
  51729. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51730. * @param size Define the size of the texture to create
  51731. * @param scene Define the scene the texture belongs to
  51732. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51733. * @param generateMipMaps Define if the texture should creates mip maps or not
  51734. */
  51735. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51736. private _loadJson;
  51737. /**
  51738. * Is the texture ready to be used ? (rendered at least once)
  51739. * @returns true if ready, otherwise, false.
  51740. */
  51741. isReady(): boolean;
  51742. /**
  51743. * Render the texture to its associated render target.
  51744. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51745. */
  51746. render(useCameraPostProcess?: boolean): void;
  51747. /**
  51748. * Update the list of dependant textures samplers in the shader.
  51749. */
  51750. updateTextures(): void;
  51751. /**
  51752. * Update the uniform values of the procedural texture in the shader.
  51753. */
  51754. updateShaderUniforms(): void;
  51755. /**
  51756. * Define if the texture animates or not.
  51757. */
  51758. animate: boolean;
  51759. }
  51760. }
  51761. declare module BABYLON {
  51762. /** @hidden */
  51763. export var noisePixelShader: {
  51764. name: string;
  51765. shader: string;
  51766. };
  51767. }
  51768. declare module BABYLON {
  51769. /**
  51770. * Class used to generate noise procedural textures
  51771. */
  51772. export class NoiseProceduralTexture extends ProceduralTexture {
  51773. private _time;
  51774. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51775. brightness: number;
  51776. /** Defines the number of octaves to process */
  51777. octaves: number;
  51778. /** Defines the level of persistence (0.8 by default) */
  51779. persistence: number;
  51780. /** Gets or sets animation speed factor (default is 1) */
  51781. animationSpeedFactor: number;
  51782. /**
  51783. * Creates a new NoiseProceduralTexture
  51784. * @param name defines the name fo the texture
  51785. * @param size defines the size of the texture (default is 256)
  51786. * @param scene defines the hosting scene
  51787. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51788. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51789. */
  51790. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51791. private _updateShaderUniforms;
  51792. protected _getDefines(): string;
  51793. /** Generate the current state of the procedural texture */
  51794. render(useCameraPostProcess?: boolean): void;
  51795. /**
  51796. * Serializes this noise procedural texture
  51797. * @returns a serialized noise procedural texture object
  51798. */
  51799. serialize(): any;
  51800. /**
  51801. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51802. * @param parsedTexture defines parsed texture data
  51803. * @param scene defines the current scene
  51804. * @param rootUrl defines the root URL containing noise procedural texture information
  51805. * @returns a parsed NoiseProceduralTexture
  51806. */
  51807. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51808. }
  51809. }
  51810. declare module BABYLON {
  51811. /**
  51812. * Raw cube texture where the raw buffers are passed in
  51813. */
  51814. export class RawCubeTexture extends CubeTexture {
  51815. /**
  51816. * Creates a cube texture where the raw buffers are passed in.
  51817. * @param scene defines the scene the texture is attached to
  51818. * @param data defines the array of data to use to create each face
  51819. * @param size defines the size of the textures
  51820. * @param format defines the format of the data
  51821. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51822. * @param generateMipMaps defines if the engine should generate the mip levels
  51823. * @param invertY defines if data must be stored with Y axis inverted
  51824. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51825. * @param compression defines the compression used (null by default)
  51826. */
  51827. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51828. /**
  51829. * Updates the raw cube texture.
  51830. * @param data defines the data to store
  51831. * @param format defines the data format
  51832. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51833. * @param invertY defines if data must be stored with Y axis inverted
  51834. * @param compression defines the compression used (null by default)
  51835. * @param level defines which level of the texture to update
  51836. */
  51837. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51838. /**
  51839. * Updates a raw cube texture with RGBD encoded data.
  51840. * @param data defines the array of data [mipmap][face] to use to create each face
  51841. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51842. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51843. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51844. * @returns a promsie that resolves when the operation is complete
  51845. */
  51846. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51847. /**
  51848. * Clones the raw cube texture.
  51849. * @return a new cube texture
  51850. */
  51851. clone(): CubeTexture;
  51852. /** @hidden */
  51853. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51854. }
  51855. }
  51856. declare module BABYLON {
  51857. /**
  51858. * Class used to store 3D textures containing user data
  51859. */
  51860. export class RawTexture3D extends Texture {
  51861. /** Gets or sets the texture format to use */
  51862. format: number;
  51863. private _engine;
  51864. /**
  51865. * Create a new RawTexture3D
  51866. * @param data defines the data of the texture
  51867. * @param width defines the width of the texture
  51868. * @param height defines the height of the texture
  51869. * @param depth defines the depth of the texture
  51870. * @param format defines the texture format to use
  51871. * @param scene defines the hosting scene
  51872. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51873. * @param invertY defines if texture must be stored with Y axis inverted
  51874. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51875. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51876. */
  51877. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51878. /** Gets or sets the texture format to use */
  51879. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51880. /**
  51881. * Update the texture with new data
  51882. * @param data defines the data to store in the texture
  51883. */
  51884. update(data: ArrayBufferView): void;
  51885. }
  51886. }
  51887. declare module BABYLON {
  51888. /**
  51889. * Creates a refraction texture used by refraction channel of the standard material.
  51890. * It is like a mirror but to see through a material.
  51891. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51892. */
  51893. export class RefractionTexture extends RenderTargetTexture {
  51894. /**
  51895. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51896. * 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.
  51897. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51898. */
  51899. refractionPlane: Plane;
  51900. /**
  51901. * Define how deep under the surface we should see.
  51902. */
  51903. depth: number;
  51904. /**
  51905. * Creates a refraction texture used by refraction channel of the standard material.
  51906. * It is like a mirror but to see through a material.
  51907. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51908. * @param name Define the texture name
  51909. * @param size Define the size of the underlying texture
  51910. * @param scene Define the scene the refraction belongs to
  51911. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51912. */
  51913. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51914. /**
  51915. * Clone the refraction texture.
  51916. * @returns the cloned texture
  51917. */
  51918. clone(): RefractionTexture;
  51919. /**
  51920. * Serialize the texture to a JSON representation you could use in Parse later on
  51921. * @returns the serialized JSON representation
  51922. */
  51923. serialize(): any;
  51924. }
  51925. }
  51926. declare module BABYLON {
  51927. /**
  51928. * Defines the options related to the creation of an HtmlElementTexture
  51929. */
  51930. export interface IHtmlElementTextureOptions {
  51931. /**
  51932. * Defines wether mip maps should be created or not.
  51933. */
  51934. generateMipMaps?: boolean;
  51935. /**
  51936. * Defines the sampling mode of the texture.
  51937. */
  51938. samplingMode?: number;
  51939. /**
  51940. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51941. */
  51942. engine: Nullable<Engine>;
  51943. /**
  51944. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51945. */
  51946. scene: Nullable<Scene>;
  51947. }
  51948. /**
  51949. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51950. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51951. * is automatically managed.
  51952. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51953. * in your application.
  51954. *
  51955. * As the update is not automatic, you need to call them manually.
  51956. */
  51957. export class HtmlElementTexture extends BaseTexture {
  51958. /**
  51959. * The texture URL.
  51960. */
  51961. element: HTMLVideoElement | HTMLCanvasElement;
  51962. private static readonly DefaultOptions;
  51963. private _textureMatrix;
  51964. private _engine;
  51965. private _isVideo;
  51966. private _generateMipMaps;
  51967. private _samplingMode;
  51968. /**
  51969. * Instantiates a HtmlElementTexture from the following parameters.
  51970. *
  51971. * @param name Defines the name of the texture
  51972. * @param element Defines the video or canvas the texture is filled with
  51973. * @param options Defines the other none mandatory texture creation options
  51974. */
  51975. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51976. private _createInternalTexture;
  51977. /**
  51978. * Returns the texture matrix used in most of the material.
  51979. */
  51980. getTextureMatrix(): Matrix;
  51981. /**
  51982. * Updates the content of the texture.
  51983. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51984. */
  51985. update(invertY?: Nullable<boolean>): void;
  51986. }
  51987. }
  51988. declare module BABYLON {
  51989. /**
  51990. * Enum used to define the target of a block
  51991. */
  51992. export enum NodeMaterialBlockTargets {
  51993. /** Vertex shader */
  51994. Vertex = 1,
  51995. /** Fragment shader */
  51996. Fragment = 2,
  51997. /** Neutral */
  51998. Neutral = 4,
  51999. /** Vertex and Fragment */
  52000. VertexAndFragment = 3
  52001. }
  52002. }
  52003. declare module BABYLON {
  52004. /**
  52005. * Defines the kind of connection point for node based material
  52006. */
  52007. export enum NodeMaterialBlockConnectionPointTypes {
  52008. /** Float */
  52009. Float = 1,
  52010. /** Int */
  52011. Int = 2,
  52012. /** Vector2 */
  52013. Vector2 = 4,
  52014. /** Vector3 */
  52015. Vector3 = 8,
  52016. /** Vector4 */
  52017. Vector4 = 16,
  52018. /** Color3 */
  52019. Color3 = 32,
  52020. /** Color4 */
  52021. Color4 = 64,
  52022. /** Matrix */
  52023. Matrix = 128,
  52024. /** Detect type based on connection */
  52025. AutoDetect = 1024,
  52026. /** Output type that will be defined by input type */
  52027. BasedOnInput = 2048
  52028. }
  52029. }
  52030. declare module BABYLON {
  52031. /**
  52032. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52033. */
  52034. export enum NodeMaterialBlockConnectionPointMode {
  52035. /** Value is an uniform */
  52036. Uniform = 0,
  52037. /** Value is a mesh attribute */
  52038. Attribute = 1,
  52039. /** Value is a varying between vertex and fragment shaders */
  52040. Varying = 2,
  52041. /** Mode is undefined */
  52042. Undefined = 3
  52043. }
  52044. }
  52045. declare module BABYLON {
  52046. /**
  52047. * Enum used to define system values e.g. values automatically provided by the system
  52048. */
  52049. export enum NodeMaterialSystemValues {
  52050. /** World */
  52051. World = 1,
  52052. /** View */
  52053. View = 2,
  52054. /** Projection */
  52055. Projection = 3,
  52056. /** ViewProjection */
  52057. ViewProjection = 4,
  52058. /** WorldView */
  52059. WorldView = 5,
  52060. /** WorldViewProjection */
  52061. WorldViewProjection = 6,
  52062. /** CameraPosition */
  52063. CameraPosition = 7,
  52064. /** Fog Color */
  52065. FogColor = 8
  52066. }
  52067. }
  52068. declare module BABYLON {
  52069. /**
  52070. * Root class for all node material optimizers
  52071. */
  52072. export class NodeMaterialOptimizer {
  52073. /**
  52074. * Function used to optimize a NodeMaterial graph
  52075. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52076. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52077. */
  52078. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52079. }
  52080. }
  52081. declare module BABYLON {
  52082. /**
  52083. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  52084. */
  52085. export class TransformBlock extends NodeMaterialBlock {
  52086. /**
  52087. * Defines the value to use to complement W value to transform it to a Vector4
  52088. */
  52089. complementW: number;
  52090. /**
  52091. * Defines the value to use to complement z value to transform it to a Vector4
  52092. */
  52093. complementZ: number;
  52094. /**
  52095. * Creates a new TransformBlock
  52096. * @param name defines the block name
  52097. */
  52098. constructor(name: string);
  52099. /**
  52100. * Gets the current class name
  52101. * @returns the class name
  52102. */
  52103. getClassName(): string;
  52104. /**
  52105. * Gets the vector input
  52106. */
  52107. readonly vector: NodeMaterialConnectionPoint;
  52108. /**
  52109. * Gets the output component
  52110. */
  52111. readonly output: NodeMaterialConnectionPoint;
  52112. /**
  52113. * Gets the matrix transform input
  52114. */
  52115. readonly transform: NodeMaterialConnectionPoint;
  52116. protected _buildBlock(state: NodeMaterialBuildState): this;
  52117. serialize(): any;
  52118. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52119. protected _dumpPropertiesCode(): string;
  52120. }
  52121. }
  52122. declare module BABYLON {
  52123. /**
  52124. * Block used to output the vertex position
  52125. */
  52126. export class VertexOutputBlock extends NodeMaterialBlock {
  52127. /**
  52128. * Creates a new VertexOutputBlock
  52129. * @param name defines the block name
  52130. */
  52131. constructor(name: string);
  52132. /**
  52133. * Gets the current class name
  52134. * @returns the class name
  52135. */
  52136. getClassName(): string;
  52137. /**
  52138. * Gets the vector input component
  52139. */
  52140. readonly vector: NodeMaterialConnectionPoint;
  52141. protected _buildBlock(state: NodeMaterialBuildState): this;
  52142. }
  52143. }
  52144. declare module BABYLON {
  52145. /**
  52146. * Block used to output the final color
  52147. */
  52148. export class FragmentOutputBlock extends NodeMaterialBlock {
  52149. /**
  52150. * Create a new FragmentOutputBlock
  52151. * @param name defines the block name
  52152. */
  52153. constructor(name: string);
  52154. /**
  52155. * Gets the current class name
  52156. * @returns the class name
  52157. */
  52158. getClassName(): string;
  52159. /**
  52160. * Gets the rgba input component
  52161. */
  52162. readonly rgba: NodeMaterialConnectionPoint;
  52163. /**
  52164. * Gets the rgb input component
  52165. */
  52166. readonly rgb: NodeMaterialConnectionPoint;
  52167. /**
  52168. * Gets the a input component
  52169. */
  52170. readonly a: NodeMaterialConnectionPoint;
  52171. protected _buildBlock(state: NodeMaterialBuildState): this;
  52172. }
  52173. }
  52174. declare module BABYLON {
  52175. /**
  52176. * Block used to read a reflection texture from a sampler
  52177. */
  52178. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52179. private _define3DName;
  52180. private _defineCubicName;
  52181. private _defineExplicitName;
  52182. private _defineProjectionName;
  52183. private _defineLocalCubicName;
  52184. private _defineSphericalName;
  52185. private _definePlanarName;
  52186. private _defineEquirectangularName;
  52187. private _defineMirroredEquirectangularFixedName;
  52188. private _defineEquirectangularFixedName;
  52189. private _defineSkyboxName;
  52190. private _cubeSamplerName;
  52191. private _2DSamplerName;
  52192. private _positionUVWName;
  52193. private _directionWName;
  52194. private _reflectionCoordsName;
  52195. private _reflection2DCoordsName;
  52196. private _reflectionColorName;
  52197. private _reflectionMatrixName;
  52198. /**
  52199. * Gets or sets the texture associated with the node
  52200. */
  52201. texture: Nullable<BaseTexture>;
  52202. /**
  52203. * Create a new TextureBlock
  52204. * @param name defines the block name
  52205. */
  52206. constructor(name: string);
  52207. /**
  52208. * Gets the current class name
  52209. * @returns the class name
  52210. */
  52211. getClassName(): string;
  52212. /**
  52213. * Gets the world position input component
  52214. */
  52215. readonly position: NodeMaterialConnectionPoint;
  52216. /**
  52217. * Gets the world position input component
  52218. */
  52219. readonly worldPosition: NodeMaterialConnectionPoint;
  52220. /**
  52221. * Gets the world normal input component
  52222. */
  52223. readonly worldNormal: NodeMaterialConnectionPoint;
  52224. /**
  52225. * Gets the world input component
  52226. */
  52227. readonly world: NodeMaterialConnectionPoint;
  52228. /**
  52229. * Gets the camera (or eye) position component
  52230. */
  52231. readonly cameraPosition: NodeMaterialConnectionPoint;
  52232. /**
  52233. * Gets the view input component
  52234. */
  52235. readonly view: NodeMaterialConnectionPoint;
  52236. /**
  52237. * Gets the rgb output component
  52238. */
  52239. readonly rgb: NodeMaterialConnectionPoint;
  52240. /**
  52241. * Gets the r output component
  52242. */
  52243. readonly r: NodeMaterialConnectionPoint;
  52244. /**
  52245. * Gets the g output component
  52246. */
  52247. readonly g: NodeMaterialConnectionPoint;
  52248. /**
  52249. * Gets the b output component
  52250. */
  52251. readonly b: NodeMaterialConnectionPoint;
  52252. autoConfigure(material: NodeMaterial): void;
  52253. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52254. isReady(): boolean;
  52255. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52256. private _injectVertexCode;
  52257. private _writeOutput;
  52258. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52259. serialize(): any;
  52260. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52261. }
  52262. }
  52263. declare module BABYLON {
  52264. /**
  52265. * Interface used to configure the node material editor
  52266. */
  52267. export interface INodeMaterialEditorOptions {
  52268. /** Define the URl to load node editor script */
  52269. editorURL?: string;
  52270. }
  52271. /** @hidden */
  52272. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52273. /** BONES */
  52274. NUM_BONE_INFLUENCERS: number;
  52275. BonesPerMesh: number;
  52276. BONETEXTURE: boolean;
  52277. /** MORPH TARGETS */
  52278. MORPHTARGETS: boolean;
  52279. MORPHTARGETS_NORMAL: boolean;
  52280. MORPHTARGETS_TANGENT: boolean;
  52281. MORPHTARGETS_UV: boolean;
  52282. NUM_MORPH_INFLUENCERS: number;
  52283. /** IMAGE PROCESSING */
  52284. IMAGEPROCESSING: boolean;
  52285. VIGNETTE: boolean;
  52286. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52287. VIGNETTEBLENDMODEOPAQUE: boolean;
  52288. TONEMAPPING: boolean;
  52289. TONEMAPPING_ACES: boolean;
  52290. CONTRAST: boolean;
  52291. EXPOSURE: boolean;
  52292. COLORCURVES: boolean;
  52293. COLORGRADING: boolean;
  52294. COLORGRADING3D: boolean;
  52295. SAMPLER3DGREENDEPTH: boolean;
  52296. SAMPLER3DBGRMAP: boolean;
  52297. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52298. /** MISC. */
  52299. BUMPDIRECTUV: number;
  52300. constructor();
  52301. setValue(name: string, value: boolean): void;
  52302. }
  52303. /**
  52304. * Class used to configure NodeMaterial
  52305. */
  52306. export interface INodeMaterialOptions {
  52307. /**
  52308. * Defines if blocks should emit comments
  52309. */
  52310. emitComments: boolean;
  52311. }
  52312. /**
  52313. * Class used to create a node based material built by assembling shader blocks
  52314. */
  52315. export class NodeMaterial extends PushMaterial {
  52316. private static _BuildIdGenerator;
  52317. private _options;
  52318. private _vertexCompilationState;
  52319. private _fragmentCompilationState;
  52320. private _sharedData;
  52321. private _buildId;
  52322. private _buildWasSuccessful;
  52323. private _cachedWorldViewMatrix;
  52324. private _cachedWorldViewProjectionMatrix;
  52325. private _optimizers;
  52326. private _animationFrame;
  52327. /** Define the URl to load node editor script */
  52328. static EditorURL: string;
  52329. private BJSNODEMATERIALEDITOR;
  52330. /** Get the inspector from bundle or global */
  52331. private _getGlobalNodeMaterialEditor;
  52332. /**
  52333. * 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)
  52334. */
  52335. ignoreAlpha: boolean;
  52336. /**
  52337. * Defines the maximum number of lights that can be used in the material
  52338. */
  52339. maxSimultaneousLights: number;
  52340. /**
  52341. * Observable raised when the material is built
  52342. */
  52343. onBuildObservable: Observable<NodeMaterial>;
  52344. /**
  52345. * Gets or sets the root nodes of the material vertex shader
  52346. */
  52347. _vertexOutputNodes: NodeMaterialBlock[];
  52348. /**
  52349. * Gets or sets the root nodes of the material fragment (pixel) shader
  52350. */
  52351. _fragmentOutputNodes: NodeMaterialBlock[];
  52352. /** Gets or sets options to control the node material overall behavior */
  52353. options: INodeMaterialOptions;
  52354. /**
  52355. * Default configuration related to image processing available in the standard Material.
  52356. */
  52357. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52358. /**
  52359. * Gets the image processing configuration used either in this material.
  52360. */
  52361. /**
  52362. * Sets the Default image processing configuration used either in the this material.
  52363. *
  52364. * If sets to null, the scene one is in use.
  52365. */
  52366. imageProcessingConfiguration: ImageProcessingConfiguration;
  52367. /**
  52368. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52369. */
  52370. attachedBlocks: NodeMaterialBlock[];
  52371. /**
  52372. * Create a new node based material
  52373. * @param name defines the material name
  52374. * @param scene defines the hosting scene
  52375. * @param options defines creation option
  52376. */
  52377. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52378. /**
  52379. * Gets the current class name of the material e.g. "NodeMaterial"
  52380. * @returns the class name
  52381. */
  52382. getClassName(): string;
  52383. /**
  52384. * Keep track of the image processing observer to allow dispose and replace.
  52385. */
  52386. private _imageProcessingObserver;
  52387. /**
  52388. * Attaches a new image processing configuration to the Standard Material.
  52389. * @param configuration
  52390. */
  52391. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52392. /**
  52393. * Get a block by its name
  52394. * @param name defines the name of the block to retrieve
  52395. * @returns the required block or null if not found
  52396. */
  52397. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52398. /**
  52399. * Get a block by its name
  52400. * @param predicate defines the predicate used to find the good candidate
  52401. * @returns the required block or null if not found
  52402. */
  52403. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52404. /**
  52405. * Get an input block by its name
  52406. * @param predicate defines the predicate used to find the good candidate
  52407. * @returns the required input block or null if not found
  52408. */
  52409. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52410. /**
  52411. * Gets the list of input blocks attached to this material
  52412. * @returns an array of InputBlocks
  52413. */
  52414. getInputBlocks(): InputBlock[];
  52415. /**
  52416. * Adds a new optimizer to the list of optimizers
  52417. * @param optimizer defines the optimizers to add
  52418. * @returns the current material
  52419. */
  52420. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52421. /**
  52422. * Remove an optimizer from the list of optimizers
  52423. * @param optimizer defines the optimizers to remove
  52424. * @returns the current material
  52425. */
  52426. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52427. /**
  52428. * Add a new block to the list of output nodes
  52429. * @param node defines the node to add
  52430. * @returns the current material
  52431. */
  52432. addOutputNode(node: NodeMaterialBlock): this;
  52433. /**
  52434. * Remove a block from the list of root nodes
  52435. * @param node defines the node to remove
  52436. * @returns the current material
  52437. */
  52438. removeOutputNode(node: NodeMaterialBlock): this;
  52439. private _addVertexOutputNode;
  52440. private _removeVertexOutputNode;
  52441. private _addFragmentOutputNode;
  52442. private _removeFragmentOutputNode;
  52443. /**
  52444. * Specifies if the material will require alpha blending
  52445. * @returns a boolean specifying if alpha blending is needed
  52446. */
  52447. needAlphaBlending(): boolean;
  52448. /**
  52449. * Specifies if this material should be rendered in alpha test mode
  52450. * @returns a boolean specifying if an alpha test is needed.
  52451. */
  52452. needAlphaTesting(): boolean;
  52453. private _initializeBlock;
  52454. private _resetDualBlocks;
  52455. /**
  52456. * Build the material and generates the inner effect
  52457. * @param verbose defines if the build should log activity
  52458. */
  52459. build(verbose?: boolean): void;
  52460. /**
  52461. * Runs an otpimization phase to try to improve the shader code
  52462. */
  52463. optimize(): void;
  52464. private _prepareDefinesForAttributes;
  52465. /**
  52466. * Get if the submesh is ready to be used and all its information available.
  52467. * Child classes can use it to update shaders
  52468. * @param mesh defines the mesh to check
  52469. * @param subMesh defines which submesh to check
  52470. * @param useInstances specifies that instances should be used
  52471. * @returns a boolean indicating that the submesh is ready or not
  52472. */
  52473. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52474. /**
  52475. * Get a string representing the shaders built by the current node graph
  52476. */
  52477. readonly compiledShaders: string;
  52478. /**
  52479. * Binds the world matrix to the material
  52480. * @param world defines the world transformation matrix
  52481. */
  52482. bindOnlyWorldMatrix(world: Matrix): void;
  52483. /**
  52484. * Binds the submesh to this material by preparing the effect and shader to draw
  52485. * @param world defines the world transformation matrix
  52486. * @param mesh defines the mesh containing the submesh
  52487. * @param subMesh defines the submesh to bind the material to
  52488. */
  52489. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52490. /**
  52491. * Gets the active textures from the material
  52492. * @returns an array of textures
  52493. */
  52494. getActiveTextures(): BaseTexture[];
  52495. /**
  52496. * Gets the list of texture blocks
  52497. * @returns an array of texture blocks
  52498. */
  52499. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  52500. /**
  52501. * Specifies if the material uses a texture
  52502. * @param texture defines the texture to check against the material
  52503. * @returns a boolean specifying if the material uses the texture
  52504. */
  52505. hasTexture(texture: BaseTexture): boolean;
  52506. /**
  52507. * Disposes the material
  52508. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52509. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52510. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52511. */
  52512. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52513. /** Creates the node editor window. */
  52514. private _createNodeEditor;
  52515. /**
  52516. * Launch the node material editor
  52517. * @param config Define the configuration of the editor
  52518. * @return a promise fulfilled when the node editor is visible
  52519. */
  52520. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  52521. /**
  52522. * Clear the current material
  52523. */
  52524. clear(): void;
  52525. /**
  52526. * Clear the current material and set it to a default state
  52527. */
  52528. setToDefault(): void;
  52529. /**
  52530. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  52531. * @param url defines the url to load from
  52532. * @returns a promise that will fullfil when the material is fully loaded
  52533. */
  52534. loadAsync(url: string): Promise<unknown>;
  52535. private _gatherBlocks;
  52536. /**
  52537. * Generate a string containing the code declaration required to create an equivalent of this material
  52538. * @returns a string
  52539. */
  52540. generateCode(): string;
  52541. /**
  52542. * Serializes this material in a JSON representation
  52543. * @returns the serialized material object
  52544. */
  52545. serialize(): any;
  52546. private _restoreConnections;
  52547. /**
  52548. * Clear the current graph and load a new one from a serialization object
  52549. * @param source defines the JSON representation of the material
  52550. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52551. */
  52552. loadFromSerialization(source: any, rootUrl?: string): void;
  52553. /**
  52554. * Creates a node material from parsed material data
  52555. * @param source defines the JSON representation of the material
  52556. * @param scene defines the hosting scene
  52557. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52558. * @returns a new node material
  52559. */
  52560. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  52561. /**
  52562. * Creates a new node material set to default basic configuration
  52563. * @param name defines the name of the material
  52564. * @param scene defines the hosting scene
  52565. * @returns a new NodeMaterial
  52566. */
  52567. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  52568. }
  52569. }
  52570. declare module BABYLON {
  52571. /**
  52572. * Block used to read a texture from a sampler
  52573. */
  52574. export class TextureBlock extends NodeMaterialBlock {
  52575. private _defineName;
  52576. private _samplerName;
  52577. private _transformedUVName;
  52578. private _textureTransformName;
  52579. private _textureInfoName;
  52580. private _mainUVName;
  52581. private _mainUVDefineName;
  52582. /**
  52583. * Gets or sets the texture associated with the node
  52584. */
  52585. texture: Nullable<Texture>;
  52586. /**
  52587. * Create a new TextureBlock
  52588. * @param name defines the block name
  52589. */
  52590. constructor(name: string);
  52591. /**
  52592. * Gets the current class name
  52593. * @returns the class name
  52594. */
  52595. getClassName(): string;
  52596. /**
  52597. * Gets the uv input component
  52598. */
  52599. readonly uv: NodeMaterialConnectionPoint;
  52600. /**
  52601. * Gets the rgba output component
  52602. */
  52603. readonly rgba: NodeMaterialConnectionPoint;
  52604. /**
  52605. * Gets the rgb output component
  52606. */
  52607. readonly rgb: NodeMaterialConnectionPoint;
  52608. /**
  52609. * Gets the r output component
  52610. */
  52611. readonly r: NodeMaterialConnectionPoint;
  52612. /**
  52613. * Gets the g output component
  52614. */
  52615. readonly g: NodeMaterialConnectionPoint;
  52616. /**
  52617. * Gets the b output component
  52618. */
  52619. readonly b: NodeMaterialConnectionPoint;
  52620. /**
  52621. * Gets the a output component
  52622. */
  52623. readonly a: NodeMaterialConnectionPoint;
  52624. readonly target: NodeMaterialBlockTargets;
  52625. autoConfigure(material: NodeMaterial): void;
  52626. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52627. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52628. isReady(): boolean;
  52629. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52630. private readonly _isMixed;
  52631. private _injectVertexCode;
  52632. private _writeOutput;
  52633. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52634. protected _dumpPropertiesCode(): string;
  52635. serialize(): any;
  52636. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52637. }
  52638. }
  52639. declare module BABYLON {
  52640. /**
  52641. * Class used to store shared data between 2 NodeMaterialBuildState
  52642. */
  52643. export class NodeMaterialBuildStateSharedData {
  52644. /**
  52645. * Gets the list of emitted varyings
  52646. */
  52647. temps: string[];
  52648. /**
  52649. * Gets the list of emitted varyings
  52650. */
  52651. varyings: string[];
  52652. /**
  52653. * Gets the varying declaration string
  52654. */
  52655. varyingDeclaration: string;
  52656. /**
  52657. * Input blocks
  52658. */
  52659. inputBlocks: InputBlock[];
  52660. /**
  52661. * Input blocks
  52662. */
  52663. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  52664. /**
  52665. * Bindable blocks (Blocks that need to set data to the effect)
  52666. */
  52667. bindableBlocks: NodeMaterialBlock[];
  52668. /**
  52669. * List of blocks that can provide a compilation fallback
  52670. */
  52671. blocksWithFallbacks: NodeMaterialBlock[];
  52672. /**
  52673. * List of blocks that can provide a define update
  52674. */
  52675. blocksWithDefines: NodeMaterialBlock[];
  52676. /**
  52677. * List of blocks that can provide a repeatable content
  52678. */
  52679. repeatableContentBlocks: NodeMaterialBlock[];
  52680. /**
  52681. * List of blocks that can provide a dynamic list of uniforms
  52682. */
  52683. dynamicUniformBlocks: NodeMaterialBlock[];
  52684. /**
  52685. * List of blocks that can block the isReady function for the material
  52686. */
  52687. blockingBlocks: NodeMaterialBlock[];
  52688. /**
  52689. * Gets the list of animated inputs
  52690. */
  52691. animatedInputs: InputBlock[];
  52692. /**
  52693. * Build Id used to avoid multiple recompilations
  52694. */
  52695. buildId: number;
  52696. /** List of emitted variables */
  52697. variableNames: {
  52698. [key: string]: number;
  52699. };
  52700. /** List of emitted defines */
  52701. defineNames: {
  52702. [key: string]: number;
  52703. };
  52704. /** Should emit comments? */
  52705. emitComments: boolean;
  52706. /** Emit build activity */
  52707. verbose: boolean;
  52708. /** Gets or sets the hosting scene */
  52709. scene: Scene;
  52710. /**
  52711. * Gets the compilation hints emitted at compilation time
  52712. */
  52713. hints: {
  52714. needWorldViewMatrix: boolean;
  52715. needWorldViewProjectionMatrix: boolean;
  52716. needAlphaBlending: boolean;
  52717. needAlphaTesting: boolean;
  52718. };
  52719. /**
  52720. * List of compilation checks
  52721. */
  52722. checks: {
  52723. emitVertex: boolean;
  52724. emitFragment: boolean;
  52725. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52726. };
  52727. /** Creates a new shared data */
  52728. constructor();
  52729. /**
  52730. * Emits console errors and exceptions if there is a failing check
  52731. */
  52732. emitErrors(): void;
  52733. }
  52734. }
  52735. declare module BABYLON {
  52736. /**
  52737. * Class used to store node based material build state
  52738. */
  52739. export class NodeMaterialBuildState {
  52740. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  52741. supportUniformBuffers: boolean;
  52742. /**
  52743. * Gets the list of emitted attributes
  52744. */
  52745. attributes: string[];
  52746. /**
  52747. * Gets the list of emitted uniforms
  52748. */
  52749. uniforms: string[];
  52750. /**
  52751. * Gets the list of emitted constants
  52752. */
  52753. constants: string[];
  52754. /**
  52755. * Gets the list of emitted uniform buffers
  52756. */
  52757. uniformBuffers: string[];
  52758. /**
  52759. * Gets the list of emitted samplers
  52760. */
  52761. samplers: string[];
  52762. /**
  52763. * Gets the list of emitted functions
  52764. */
  52765. functions: {
  52766. [key: string]: string;
  52767. };
  52768. /**
  52769. * Gets the list of emitted extensions
  52770. */
  52771. extensions: {
  52772. [key: string]: string;
  52773. };
  52774. /**
  52775. * Gets the target of the compilation state
  52776. */
  52777. target: NodeMaterialBlockTargets;
  52778. /**
  52779. * Gets the list of emitted counters
  52780. */
  52781. counters: {
  52782. [key: string]: number;
  52783. };
  52784. /**
  52785. * Shared data between multiple NodeMaterialBuildState instances
  52786. */
  52787. sharedData: NodeMaterialBuildStateSharedData;
  52788. /** @hidden */
  52789. _vertexState: NodeMaterialBuildState;
  52790. /** @hidden */
  52791. _attributeDeclaration: string;
  52792. /** @hidden */
  52793. _uniformDeclaration: string;
  52794. /** @hidden */
  52795. _constantDeclaration: string;
  52796. /** @hidden */
  52797. _samplerDeclaration: string;
  52798. /** @hidden */
  52799. _varyingTransfer: string;
  52800. private _repeatableContentAnchorIndex;
  52801. /** @hidden */
  52802. _builtCompilationString: string;
  52803. /**
  52804. * Gets the emitted compilation strings
  52805. */
  52806. compilationString: string;
  52807. /**
  52808. * Finalize the compilation strings
  52809. * @param state defines the current compilation state
  52810. */
  52811. finalize(state: NodeMaterialBuildState): void;
  52812. /** @hidden */
  52813. readonly _repeatableContentAnchor: string;
  52814. /** @hidden */
  52815. _getFreeVariableName(prefix: string): string;
  52816. /** @hidden */
  52817. _getFreeDefineName(prefix: string): string;
  52818. /** @hidden */
  52819. _excludeVariableName(name: string): void;
  52820. /** @hidden */
  52821. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52822. /** @hidden */
  52823. _emitExtension(name: string, extension: string): void;
  52824. /** @hidden */
  52825. _emitFunction(name: string, code: string, comments: string): void;
  52826. /** @hidden */
  52827. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52828. replaceStrings?: {
  52829. search: RegExp;
  52830. replace: string;
  52831. }[];
  52832. repeatKey?: string;
  52833. }): string;
  52834. /** @hidden */
  52835. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52836. repeatKey?: string;
  52837. removeAttributes?: boolean;
  52838. removeUniforms?: boolean;
  52839. removeVaryings?: boolean;
  52840. removeIfDef?: boolean;
  52841. replaceStrings?: {
  52842. search: RegExp;
  52843. replace: string;
  52844. }[];
  52845. }, storeKey?: string): void;
  52846. /** @hidden */
  52847. _registerTempVariable(name: string): boolean;
  52848. /** @hidden */
  52849. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  52850. /** @hidden */
  52851. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  52852. }
  52853. }
  52854. declare module BABYLON {
  52855. /**
  52856. * Defines a block that can be used inside a node based material
  52857. */
  52858. export class NodeMaterialBlock {
  52859. private _buildId;
  52860. private _buildTarget;
  52861. private _target;
  52862. private _isFinalMerger;
  52863. private _isInput;
  52864. /** @hidden */
  52865. _codeVariableName: string;
  52866. /** @hidden */
  52867. _inputs: NodeMaterialConnectionPoint[];
  52868. /** @hidden */
  52869. _outputs: NodeMaterialConnectionPoint[];
  52870. /** @hidden */
  52871. _preparationId: number;
  52872. /**
  52873. * Gets or sets the name of the block
  52874. */
  52875. name: string;
  52876. /**
  52877. * Gets or sets the unique id of the node
  52878. */
  52879. uniqueId: number;
  52880. /**
  52881. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  52882. */
  52883. readonly isFinalMerger: boolean;
  52884. /**
  52885. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  52886. */
  52887. readonly isInput: boolean;
  52888. /**
  52889. * Gets or sets the build Id
  52890. */
  52891. buildId: number;
  52892. /**
  52893. * Gets or sets the target of the block
  52894. */
  52895. target: NodeMaterialBlockTargets;
  52896. /**
  52897. * Gets the list of input points
  52898. */
  52899. readonly inputs: NodeMaterialConnectionPoint[];
  52900. /** Gets the list of output points */
  52901. readonly outputs: NodeMaterialConnectionPoint[];
  52902. /**
  52903. * Find an input by its name
  52904. * @param name defines the name of the input to look for
  52905. * @returns the input or null if not found
  52906. */
  52907. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52908. /**
  52909. * Find an output by its name
  52910. * @param name defines the name of the outputto look for
  52911. * @returns the output or null if not found
  52912. */
  52913. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52914. /**
  52915. * Creates a new NodeMaterialBlock
  52916. * @param name defines the block name
  52917. * @param target defines the target of that block (Vertex by default)
  52918. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52919. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  52920. */
  52921. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  52922. /**
  52923. * Initialize the block and prepare the context for build
  52924. * @param state defines the state that will be used for the build
  52925. */
  52926. initialize(state: NodeMaterialBuildState): void;
  52927. /**
  52928. * Bind data to effect. Will only be called for blocks with isBindable === true
  52929. * @param effect defines the effect to bind data to
  52930. * @param nodeMaterial defines the hosting NodeMaterial
  52931. * @param mesh defines the mesh that will be rendered
  52932. */
  52933. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52934. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52935. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52936. protected _writeFloat(value: number): string;
  52937. /**
  52938. * Gets the current class name e.g. "NodeMaterialBlock"
  52939. * @returns the class name
  52940. */
  52941. getClassName(): string;
  52942. /**
  52943. * Register a new input. Must be called inside a block constructor
  52944. * @param name defines the connection point name
  52945. * @param type defines the connection point type
  52946. * @param isOptional defines a boolean indicating that this input can be omitted
  52947. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52948. * @returns the current block
  52949. */
  52950. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  52951. /**
  52952. * Register a new output. Must be called inside a block constructor
  52953. * @param name defines the connection point name
  52954. * @param type defines the connection point type
  52955. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52956. * @returns the current block
  52957. */
  52958. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  52959. /**
  52960. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  52961. * @param forOutput defines an optional connection point to check compatibility with
  52962. * @returns the first available input or null
  52963. */
  52964. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  52965. /**
  52966. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  52967. * @param forBlock defines an optional block to check compatibility with
  52968. * @returns the first available input or null
  52969. */
  52970. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  52971. /**
  52972. * Gets the sibling of the given output
  52973. * @param current defines the current output
  52974. * @returns the next output in the list or null
  52975. */
  52976. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  52977. /**
  52978. * Connect current block with another block
  52979. * @param other defines the block to connect with
  52980. * @param options define the various options to help pick the right connections
  52981. * @returns the current block
  52982. */
  52983. connectTo(other: NodeMaterialBlock, options?: {
  52984. input?: string;
  52985. output?: string;
  52986. outputSwizzle?: string;
  52987. }): this | undefined;
  52988. protected _buildBlock(state: NodeMaterialBuildState): void;
  52989. /**
  52990. * Add uniforms, samplers and uniform buffers at compilation time
  52991. * @param state defines the state to update
  52992. * @param nodeMaterial defines the node material requesting the update
  52993. * @param defines defines the material defines to update
  52994. */
  52995. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52996. /**
  52997. * Add potential fallbacks if shader compilation fails
  52998. * @param mesh defines the mesh to be rendered
  52999. * @param fallbacks defines the current prioritized list of fallbacks
  53000. */
  53001. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53002. /**
  53003. * Initialize defines for shader compilation
  53004. * @param mesh defines the mesh to be rendered
  53005. * @param nodeMaterial defines the node material requesting the update
  53006. * @param defines defines the material defines to update
  53007. * @param useInstances specifies that instances should be used
  53008. */
  53009. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53010. /**
  53011. * Update defines for shader compilation
  53012. * @param mesh defines the mesh to be rendered
  53013. * @param nodeMaterial defines the node material requesting the update
  53014. * @param defines defines the material defines to update
  53015. * @param useInstances specifies that instances should be used
  53016. */
  53017. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53018. /**
  53019. * Lets the block try to connect some inputs automatically
  53020. * @param material defines the hosting NodeMaterial
  53021. */
  53022. autoConfigure(material: NodeMaterial): void;
  53023. /**
  53024. * Function called when a block is declared as repeatable content generator
  53025. * @param vertexShaderState defines the current compilation state for the vertex shader
  53026. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53027. * @param mesh defines the mesh to be rendered
  53028. * @param defines defines the material defines to update
  53029. */
  53030. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53031. /**
  53032. * Checks if the block is ready
  53033. * @param mesh defines the mesh to be rendered
  53034. * @param nodeMaterial defines the node material requesting the update
  53035. * @param defines defines the material defines to update
  53036. * @param useInstances specifies that instances should be used
  53037. * @returns true if the block is ready
  53038. */
  53039. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53040. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  53041. private _processBuild;
  53042. /**
  53043. * Compile the current node and generate the shader code
  53044. * @param state defines the current compilation state (uniforms, samplers, current string)
  53045. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  53046. * @returns true if already built
  53047. */
  53048. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  53049. protected _inputRename(name: string): string;
  53050. protected _outputRename(name: string): string;
  53051. protected _dumpPropertiesCode(): string;
  53052. /** @hidden */
  53053. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  53054. /**
  53055. * Clone the current block to a new identical block
  53056. * @param scene defines the hosting scene
  53057. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53058. * @returns a copy of the current block
  53059. */
  53060. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  53061. /**
  53062. * Serializes this block in a JSON representation
  53063. * @returns the serialized block object
  53064. */
  53065. serialize(): any;
  53066. /** @hidden */
  53067. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53068. }
  53069. }
  53070. declare module BABYLON {
  53071. /**
  53072. * Enum defining the type of animations supported by InputBlock
  53073. */
  53074. export enum AnimatedInputBlockTypes {
  53075. /** No animation */
  53076. None = 0,
  53077. /** Time based animation. Will only work for floats */
  53078. Time = 1
  53079. }
  53080. }
  53081. declare module BABYLON {
  53082. /**
  53083. * Block used to expose an input value
  53084. */
  53085. export class InputBlock extends NodeMaterialBlock {
  53086. private _mode;
  53087. private _associatedVariableName;
  53088. private _storedValue;
  53089. private _valueCallback;
  53090. private _type;
  53091. private _animationType;
  53092. /** Gets or set a value used to limit the range of float values */
  53093. min: number;
  53094. /** Gets or set a value used to limit the range of float values */
  53095. max: number;
  53096. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  53097. matrixMode: number;
  53098. /** @hidden */
  53099. _systemValue: Nullable<NodeMaterialSystemValues>;
  53100. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  53101. visibleInInspector: boolean;
  53102. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  53103. isConstant: boolean;
  53104. /**
  53105. * Gets or sets the connection point type (default is float)
  53106. */
  53107. readonly type: NodeMaterialBlockConnectionPointTypes;
  53108. /**
  53109. * Creates a new InputBlock
  53110. * @param name defines the block name
  53111. * @param target defines the target of that block (Vertex by default)
  53112. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53113. */
  53114. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53115. /**
  53116. * Gets the output component
  53117. */
  53118. readonly output: NodeMaterialConnectionPoint;
  53119. /**
  53120. * Set the source of this connection point to a vertex attribute
  53121. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53122. * @returns the current connection point
  53123. */
  53124. setAsAttribute(attributeName?: string): InputBlock;
  53125. /**
  53126. * Set the source of this connection point to a system value
  53127. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  53128. * @returns the current connection point
  53129. */
  53130. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  53131. /**
  53132. * Gets or sets the value of that point.
  53133. * Please note that this value will be ignored if valueCallback is defined
  53134. */
  53135. value: any;
  53136. /**
  53137. * Gets or sets a callback used to get the value of that point.
  53138. * Please note that setting this value will force the connection point to ignore the value property
  53139. */
  53140. valueCallback: () => any;
  53141. /**
  53142. * Gets or sets the associated variable name in the shader
  53143. */
  53144. associatedVariableName: string;
  53145. /** Gets or sets the type of animation applied to the input */
  53146. animationType: AnimatedInputBlockTypes;
  53147. /**
  53148. * Gets a boolean indicating that this connection point not defined yet
  53149. */
  53150. readonly isUndefined: boolean;
  53151. /**
  53152. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53153. * In this case the connection point name must be the name of the uniform to use.
  53154. * Can only be set on inputs
  53155. */
  53156. isUniform: boolean;
  53157. /**
  53158. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53159. * In this case the connection point name must be the name of the attribute to use
  53160. * Can only be set on inputs
  53161. */
  53162. isAttribute: boolean;
  53163. /**
  53164. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53165. * Can only be set on exit points
  53166. */
  53167. isVarying: boolean;
  53168. /**
  53169. * Gets a boolean indicating that the current connection point is a system value
  53170. */
  53171. readonly isSystemValue: boolean;
  53172. /**
  53173. * Gets or sets the current well known value or null if not defined as a system value
  53174. */
  53175. systemValue: Nullable<NodeMaterialSystemValues>;
  53176. /**
  53177. * Gets the current class name
  53178. * @returns the class name
  53179. */
  53180. getClassName(): string;
  53181. /**
  53182. * Animate the input if animationType !== None
  53183. * @param scene defines the rendering scene
  53184. */
  53185. animate(scene: Scene): void;
  53186. private _emitDefine;
  53187. initialize(state: NodeMaterialBuildState): void;
  53188. /**
  53189. * Set the input block to its default value (based on its type)
  53190. */
  53191. setDefaultValue(): void;
  53192. protected _dumpPropertiesCode(): string;
  53193. private _emitConstant;
  53194. private _emit;
  53195. /** @hidden */
  53196. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53197. /** @hidden */
  53198. _transmit(effect: Effect, scene: Scene): void;
  53199. protected _buildBlock(state: NodeMaterialBuildState): void;
  53200. serialize(): any;
  53201. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53202. }
  53203. }
  53204. declare module BABYLON {
  53205. /**
  53206. * Defines a connection point for a block
  53207. */
  53208. export class NodeMaterialConnectionPoint {
  53209. /** @hidden */
  53210. _ownerBlock: NodeMaterialBlock;
  53211. /** @hidden */
  53212. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53213. private _endpoints;
  53214. private _associatedVariableName;
  53215. /** @hidden */
  53216. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53217. /** @hidden */
  53218. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53219. private _type;
  53220. /** @hidden */
  53221. _enforceAssociatedVariableName: boolean;
  53222. /**
  53223. * Gets or sets the additional types supported byt this connection point
  53224. */
  53225. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53226. /**
  53227. * Gets or sets the associated variable name in the shader
  53228. */
  53229. associatedVariableName: string;
  53230. /**
  53231. * Gets or sets the connection point type (default is float)
  53232. */
  53233. type: NodeMaterialBlockConnectionPointTypes;
  53234. /**
  53235. * Gets or sets the connection point name
  53236. */
  53237. name: string;
  53238. /**
  53239. * Gets or sets a boolean indicating that this connection point can be omitted
  53240. */
  53241. isOptional: boolean;
  53242. /**
  53243. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53244. */
  53245. define: string;
  53246. /** Gets or sets the target of that connection point */
  53247. target: NodeMaterialBlockTargets;
  53248. /**
  53249. * Gets a boolean indicating that the current point is connected
  53250. */
  53251. readonly isConnected: boolean;
  53252. /**
  53253. * Gets a boolean indicating that the current point is connected to an input block
  53254. */
  53255. readonly isConnectedToInputBlock: boolean;
  53256. /**
  53257. * Gets a the connected input block (if any)
  53258. */
  53259. readonly connectInputBlock: Nullable<InputBlock>;
  53260. /** Get the other side of the connection (if any) */
  53261. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53262. /** Get the block that owns this connection point */
  53263. readonly ownerBlock: NodeMaterialBlock;
  53264. /** Get the block connected on the other side of this connection (if any) */
  53265. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53266. /** Get the block connected on the endpoints of this connection (if any) */
  53267. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53268. /** Gets the list of connected endpoints */
  53269. readonly endpoints: NodeMaterialConnectionPoint[];
  53270. /** Gets a boolean indicating if that output point is connected to at least one input */
  53271. readonly hasEndpoints: boolean;
  53272. /**
  53273. * Creates a new connection point
  53274. * @param name defines the connection point name
  53275. * @param ownerBlock defines the block hosting this connection point
  53276. */
  53277. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53278. /**
  53279. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53280. * @returns the class name
  53281. */
  53282. getClassName(): string;
  53283. /**
  53284. * Gets an boolean indicating if the current point can be connected to another point
  53285. * @param connectionPoint defines the other connection point
  53286. * @returns true if the connection is possible
  53287. */
  53288. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53289. /**
  53290. * Connect this point to another connection point
  53291. * @param connectionPoint defines the other connection point
  53292. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  53293. * @returns the current connection point
  53294. */
  53295. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  53296. /**
  53297. * Disconnect this point from one of his endpoint
  53298. * @param endpoint defines the other connection point
  53299. * @returns the current connection point
  53300. */
  53301. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53302. /**
  53303. * Serializes this point in a JSON representation
  53304. * @returns the serialized point object
  53305. */
  53306. serialize(): any;
  53307. }
  53308. }
  53309. declare module BABYLON {
  53310. /**
  53311. * Block used to add support for vertex skinning (bones)
  53312. */
  53313. export class BonesBlock extends NodeMaterialBlock {
  53314. /**
  53315. * Creates a new BonesBlock
  53316. * @param name defines the block name
  53317. */
  53318. constructor(name: string);
  53319. /**
  53320. * Initialize the block and prepare the context for build
  53321. * @param state defines the state that will be used for the build
  53322. */
  53323. initialize(state: NodeMaterialBuildState): void;
  53324. /**
  53325. * Gets the current class name
  53326. * @returns the class name
  53327. */
  53328. getClassName(): string;
  53329. /**
  53330. * Gets the matrix indices input component
  53331. */
  53332. readonly matricesIndices: NodeMaterialConnectionPoint;
  53333. /**
  53334. * Gets the matrix weights input component
  53335. */
  53336. readonly matricesWeights: NodeMaterialConnectionPoint;
  53337. /**
  53338. * Gets the extra matrix indices input component
  53339. */
  53340. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53341. /**
  53342. * Gets the extra matrix weights input component
  53343. */
  53344. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53345. /**
  53346. * Gets the world input component
  53347. */
  53348. readonly world: NodeMaterialConnectionPoint;
  53349. /**
  53350. * Gets the output component
  53351. */
  53352. readonly output: NodeMaterialConnectionPoint;
  53353. autoConfigure(material: NodeMaterial): void;
  53354. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53355. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53356. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53357. protected _buildBlock(state: NodeMaterialBuildState): this;
  53358. }
  53359. }
  53360. declare module BABYLON {
  53361. /**
  53362. * Block used to add support for instances
  53363. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53364. */
  53365. export class InstancesBlock extends NodeMaterialBlock {
  53366. /**
  53367. * Creates a new InstancesBlock
  53368. * @param name defines the block name
  53369. */
  53370. constructor(name: string);
  53371. /**
  53372. * Gets the current class name
  53373. * @returns the class name
  53374. */
  53375. getClassName(): string;
  53376. /**
  53377. * Gets the first world row input component
  53378. */
  53379. readonly world0: NodeMaterialConnectionPoint;
  53380. /**
  53381. * Gets the second world row input component
  53382. */
  53383. readonly world1: NodeMaterialConnectionPoint;
  53384. /**
  53385. * Gets the third world row input component
  53386. */
  53387. readonly world2: NodeMaterialConnectionPoint;
  53388. /**
  53389. * Gets the forth world row input component
  53390. */
  53391. readonly world3: NodeMaterialConnectionPoint;
  53392. /**
  53393. * Gets the world input component
  53394. */
  53395. readonly world: NodeMaterialConnectionPoint;
  53396. /**
  53397. * Gets the output component
  53398. */
  53399. readonly output: NodeMaterialConnectionPoint;
  53400. autoConfigure(material: NodeMaterial): void;
  53401. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53402. protected _buildBlock(state: NodeMaterialBuildState): this;
  53403. }
  53404. }
  53405. declare module BABYLON {
  53406. /**
  53407. * Block used to add morph targets support to vertex shader
  53408. */
  53409. export class MorphTargetsBlock extends NodeMaterialBlock {
  53410. private _repeatableContentAnchor;
  53411. private _repeatebleContentGenerated;
  53412. /**
  53413. * Create a new MorphTargetsBlock
  53414. * @param name defines the block name
  53415. */
  53416. constructor(name: string);
  53417. /**
  53418. * Gets the current class name
  53419. * @returns the class name
  53420. */
  53421. getClassName(): string;
  53422. /**
  53423. * Gets the position input component
  53424. */
  53425. readonly position: NodeMaterialConnectionPoint;
  53426. /**
  53427. * Gets the normal input component
  53428. */
  53429. readonly normal: NodeMaterialConnectionPoint;
  53430. /**
  53431. * Gets the tangent input component
  53432. */
  53433. readonly tangent: NodeMaterialConnectionPoint;
  53434. /**
  53435. * Gets the tangent input component
  53436. */
  53437. readonly uv: NodeMaterialConnectionPoint;
  53438. /**
  53439. * Gets the position output component
  53440. */
  53441. readonly positionOutput: NodeMaterialConnectionPoint;
  53442. /**
  53443. * Gets the normal output component
  53444. */
  53445. readonly normalOutput: NodeMaterialConnectionPoint;
  53446. /**
  53447. * Gets the tangent output component
  53448. */
  53449. readonly tangentOutput: NodeMaterialConnectionPoint;
  53450. /**
  53451. * Gets the tangent output component
  53452. */
  53453. readonly uvOutput: NodeMaterialConnectionPoint;
  53454. initialize(state: NodeMaterialBuildState): void;
  53455. autoConfigure(material: NodeMaterial): void;
  53456. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53457. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53458. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53459. protected _buildBlock(state: NodeMaterialBuildState): this;
  53460. }
  53461. }
  53462. declare module BABYLON {
  53463. /**
  53464. * Block used to get data information from a light
  53465. */
  53466. export class LightInformationBlock extends NodeMaterialBlock {
  53467. private _lightDataUniformName;
  53468. private _lightColorUniformName;
  53469. private _lightTypeDefineName;
  53470. /**
  53471. * Gets or sets the light associated with this block
  53472. */
  53473. light: Nullable<Light>;
  53474. /**
  53475. * Creates a new LightInformationBlock
  53476. * @param name defines the block name
  53477. */
  53478. constructor(name: string);
  53479. /**
  53480. * Gets the current class name
  53481. * @returns the class name
  53482. */
  53483. getClassName(): string;
  53484. /**
  53485. * Gets the world position input component
  53486. */
  53487. readonly worldPosition: NodeMaterialConnectionPoint;
  53488. /**
  53489. * Gets the direction output component
  53490. */
  53491. readonly direction: NodeMaterialConnectionPoint;
  53492. /**
  53493. * Gets the direction output component
  53494. */
  53495. readonly color: NodeMaterialConnectionPoint;
  53496. /**
  53497. * Gets the direction output component
  53498. */
  53499. readonly intensity: NodeMaterialConnectionPoint;
  53500. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53501. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53502. protected _buildBlock(state: NodeMaterialBuildState): this;
  53503. serialize(): any;
  53504. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53505. }
  53506. }
  53507. declare module BABYLON {
  53508. /**
  53509. * Block used to add image processing support to fragment shader
  53510. */
  53511. export class ImageProcessingBlock extends NodeMaterialBlock {
  53512. /**
  53513. * Create a new ImageProcessingBlock
  53514. * @param name defines the block name
  53515. */
  53516. constructor(name: string);
  53517. /**
  53518. * Gets the current class name
  53519. * @returns the class name
  53520. */
  53521. getClassName(): string;
  53522. /**
  53523. * Gets the color input component
  53524. */
  53525. readonly color: NodeMaterialConnectionPoint;
  53526. /**
  53527. * Gets the output component
  53528. */
  53529. readonly output: NodeMaterialConnectionPoint;
  53530. /**
  53531. * Initialize the block and prepare the context for build
  53532. * @param state defines the state that will be used for the build
  53533. */
  53534. initialize(state: NodeMaterialBuildState): void;
  53535. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53536. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53537. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53538. protected _buildBlock(state: NodeMaterialBuildState): this;
  53539. }
  53540. }
  53541. declare module BABYLON {
  53542. /**
  53543. * Block used to pertub normals based on a normal map
  53544. */
  53545. export class PerturbNormalBlock extends NodeMaterialBlock {
  53546. private _tangentSpaceParameterName;
  53547. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  53548. invertX: boolean;
  53549. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  53550. invertY: boolean;
  53551. /**
  53552. * Create a new PerturbNormalBlock
  53553. * @param name defines the block name
  53554. */
  53555. constructor(name: string);
  53556. /**
  53557. * Gets the current class name
  53558. * @returns the class name
  53559. */
  53560. getClassName(): string;
  53561. /**
  53562. * Gets the world position input component
  53563. */
  53564. readonly worldPosition: NodeMaterialConnectionPoint;
  53565. /**
  53566. * Gets the world normal input component
  53567. */
  53568. readonly worldNormal: NodeMaterialConnectionPoint;
  53569. /**
  53570. * Gets the uv input component
  53571. */
  53572. readonly uv: NodeMaterialConnectionPoint;
  53573. /**
  53574. * Gets the normal map color input component
  53575. */
  53576. readonly normalMapColor: NodeMaterialConnectionPoint;
  53577. /**
  53578. * Gets the strength input component
  53579. */
  53580. readonly strength: NodeMaterialConnectionPoint;
  53581. /**
  53582. * Gets the output component
  53583. */
  53584. readonly output: NodeMaterialConnectionPoint;
  53585. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53586. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53587. autoConfigure(material: NodeMaterial): void;
  53588. protected _buildBlock(state: NodeMaterialBuildState): this;
  53589. protected _dumpPropertiesCode(): string;
  53590. serialize(): any;
  53591. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53592. }
  53593. }
  53594. declare module BABYLON {
  53595. /**
  53596. * Block used to discard a pixel if a value is smaller than a cutoff
  53597. */
  53598. export class DiscardBlock extends NodeMaterialBlock {
  53599. /**
  53600. * Create a new DiscardBlock
  53601. * @param name defines the block name
  53602. */
  53603. constructor(name: string);
  53604. /**
  53605. * Gets the current class name
  53606. * @returns the class name
  53607. */
  53608. getClassName(): string;
  53609. /**
  53610. * Gets the color input component
  53611. */
  53612. readonly value: NodeMaterialConnectionPoint;
  53613. /**
  53614. * Gets the cutoff input component
  53615. */
  53616. readonly cutoff: NodeMaterialConnectionPoint;
  53617. protected _buildBlock(state: NodeMaterialBuildState): this;
  53618. }
  53619. }
  53620. declare module BABYLON {
  53621. /**
  53622. * Block used to add support for scene fog
  53623. */
  53624. export class FogBlock extends NodeMaterialBlock {
  53625. private _fogDistanceName;
  53626. private _fogParameters;
  53627. /**
  53628. * Create a new FogBlock
  53629. * @param name defines the block name
  53630. */
  53631. constructor(name: string);
  53632. /**
  53633. * Gets the current class name
  53634. * @returns the class name
  53635. */
  53636. getClassName(): string;
  53637. /**
  53638. * Gets the world position input component
  53639. */
  53640. readonly worldPosition: NodeMaterialConnectionPoint;
  53641. /**
  53642. * Gets the view input component
  53643. */
  53644. readonly view: NodeMaterialConnectionPoint;
  53645. /**
  53646. * Gets the color input component
  53647. */
  53648. readonly input: NodeMaterialConnectionPoint;
  53649. /**
  53650. * Gets the fog color input component
  53651. */
  53652. readonly fogColor: NodeMaterialConnectionPoint;
  53653. /**
  53654. * Gets the output component
  53655. */
  53656. readonly output: NodeMaterialConnectionPoint;
  53657. autoConfigure(material: NodeMaterial): void;
  53658. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53659. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53660. protected _buildBlock(state: NodeMaterialBuildState): this;
  53661. }
  53662. }
  53663. declare module BABYLON {
  53664. /**
  53665. * Block used to add light in the fragment shader
  53666. */
  53667. export class LightBlock extends NodeMaterialBlock {
  53668. private _lightId;
  53669. /**
  53670. * Gets or sets the light associated with this block
  53671. */
  53672. light: Nullable<Light>;
  53673. /**
  53674. * Create a new LightBlock
  53675. * @param name defines the block name
  53676. */
  53677. constructor(name: string);
  53678. /**
  53679. * Gets the current class name
  53680. * @returns the class name
  53681. */
  53682. getClassName(): string;
  53683. /**
  53684. * Gets the world position input component
  53685. */
  53686. readonly worldPosition: NodeMaterialConnectionPoint;
  53687. /**
  53688. * Gets the world normal input component
  53689. */
  53690. readonly worldNormal: NodeMaterialConnectionPoint;
  53691. /**
  53692. * Gets the camera (or eye) position component
  53693. */
  53694. readonly cameraPosition: NodeMaterialConnectionPoint;
  53695. /**
  53696. * Gets the diffuse output component
  53697. */
  53698. readonly diffuseOutput: NodeMaterialConnectionPoint;
  53699. /**
  53700. * Gets the specular output component
  53701. */
  53702. readonly specularOutput: NodeMaterialConnectionPoint;
  53703. autoConfigure(material: NodeMaterial): void;
  53704. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53705. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53706. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53707. private _injectVertexCode;
  53708. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53709. serialize(): any;
  53710. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53711. }
  53712. }
  53713. declare module BABYLON {
  53714. /**
  53715. * Block used to multiply 2 values
  53716. */
  53717. export class MultiplyBlock extends NodeMaterialBlock {
  53718. /**
  53719. * Creates a new MultiplyBlock
  53720. * @param name defines the block name
  53721. */
  53722. constructor(name: string);
  53723. /**
  53724. * Gets the current class name
  53725. * @returns the class name
  53726. */
  53727. getClassName(): string;
  53728. /**
  53729. * Gets the left operand input component
  53730. */
  53731. readonly left: NodeMaterialConnectionPoint;
  53732. /**
  53733. * Gets the right operand input component
  53734. */
  53735. readonly right: NodeMaterialConnectionPoint;
  53736. /**
  53737. * Gets the output component
  53738. */
  53739. readonly output: NodeMaterialConnectionPoint;
  53740. protected _buildBlock(state: NodeMaterialBuildState): this;
  53741. }
  53742. }
  53743. declare module BABYLON {
  53744. /**
  53745. * Block used to add 2 vectors
  53746. */
  53747. export class AddBlock extends NodeMaterialBlock {
  53748. /**
  53749. * Creates a new AddBlock
  53750. * @param name defines the block name
  53751. */
  53752. constructor(name: string);
  53753. /**
  53754. * Gets the current class name
  53755. * @returns the class name
  53756. */
  53757. getClassName(): string;
  53758. /**
  53759. * Gets the left operand input component
  53760. */
  53761. readonly left: NodeMaterialConnectionPoint;
  53762. /**
  53763. * Gets the right operand input component
  53764. */
  53765. readonly right: NodeMaterialConnectionPoint;
  53766. /**
  53767. * Gets the output component
  53768. */
  53769. readonly output: NodeMaterialConnectionPoint;
  53770. protected _buildBlock(state: NodeMaterialBuildState): this;
  53771. }
  53772. }
  53773. declare module BABYLON {
  53774. /**
  53775. * Block used to scale a vector by a float
  53776. */
  53777. export class ScaleBlock extends NodeMaterialBlock {
  53778. /**
  53779. * Creates a new ScaleBlock
  53780. * @param name defines the block name
  53781. */
  53782. constructor(name: string);
  53783. /**
  53784. * Gets the current class name
  53785. * @returns the class name
  53786. */
  53787. getClassName(): string;
  53788. /**
  53789. * Gets the input component
  53790. */
  53791. readonly input: NodeMaterialConnectionPoint;
  53792. /**
  53793. * Gets the factor input component
  53794. */
  53795. readonly factor: NodeMaterialConnectionPoint;
  53796. /**
  53797. * Gets the output component
  53798. */
  53799. readonly output: NodeMaterialConnectionPoint;
  53800. protected _buildBlock(state: NodeMaterialBuildState): this;
  53801. }
  53802. }
  53803. declare module BABYLON {
  53804. /**
  53805. * Block used to clamp a float
  53806. */
  53807. export class ClampBlock extends NodeMaterialBlock {
  53808. /** Gets or sets the minimum range */
  53809. minimum: number;
  53810. /** Gets or sets the maximum range */
  53811. maximum: number;
  53812. /**
  53813. * Creates a new ClampBlock
  53814. * @param name defines the block name
  53815. */
  53816. constructor(name: string);
  53817. /**
  53818. * Gets the current class name
  53819. * @returns the class name
  53820. */
  53821. getClassName(): string;
  53822. /**
  53823. * Gets the value input component
  53824. */
  53825. readonly value: NodeMaterialConnectionPoint;
  53826. /**
  53827. * Gets the output component
  53828. */
  53829. readonly output: NodeMaterialConnectionPoint;
  53830. protected _buildBlock(state: NodeMaterialBuildState): this;
  53831. protected _dumpPropertiesCode(): string;
  53832. serialize(): any;
  53833. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53834. }
  53835. }
  53836. declare module BABYLON {
  53837. /**
  53838. * Block used to apply a cross product between 2 vectors
  53839. */
  53840. export class CrossBlock extends NodeMaterialBlock {
  53841. /**
  53842. * Creates a new CrossBlock
  53843. * @param name defines the block name
  53844. */
  53845. constructor(name: string);
  53846. /**
  53847. * Gets the current class name
  53848. * @returns the class name
  53849. */
  53850. getClassName(): string;
  53851. /**
  53852. * Gets the left operand input component
  53853. */
  53854. readonly left: NodeMaterialConnectionPoint;
  53855. /**
  53856. * Gets the right operand input component
  53857. */
  53858. readonly right: NodeMaterialConnectionPoint;
  53859. /**
  53860. * Gets the output component
  53861. */
  53862. readonly output: NodeMaterialConnectionPoint;
  53863. protected _buildBlock(state: NodeMaterialBuildState): this;
  53864. }
  53865. }
  53866. declare module BABYLON {
  53867. /**
  53868. * Block used to apply a dot product between 2 vectors
  53869. */
  53870. export class DotBlock extends NodeMaterialBlock {
  53871. /**
  53872. * Creates a new DotBlock
  53873. * @param name defines the block name
  53874. */
  53875. constructor(name: string);
  53876. /**
  53877. * Gets the current class name
  53878. * @returns the class name
  53879. */
  53880. getClassName(): string;
  53881. /**
  53882. * Gets the left operand input component
  53883. */
  53884. readonly left: NodeMaterialConnectionPoint;
  53885. /**
  53886. * Gets the right operand input component
  53887. */
  53888. readonly right: NodeMaterialConnectionPoint;
  53889. /**
  53890. * Gets the output component
  53891. */
  53892. readonly output: NodeMaterialConnectionPoint;
  53893. protected _buildBlock(state: NodeMaterialBuildState): this;
  53894. }
  53895. }
  53896. declare module BABYLON {
  53897. /**
  53898. * Block used to remap a float from a range to a new one
  53899. */
  53900. export class RemapBlock extends NodeMaterialBlock {
  53901. /**
  53902. * Gets or sets the source range
  53903. */
  53904. sourceRange: Vector2;
  53905. /**
  53906. * Gets or sets the target range
  53907. */
  53908. targetRange: Vector2;
  53909. /**
  53910. * Creates a new RemapBlock
  53911. * @param name defines the block name
  53912. */
  53913. constructor(name: string);
  53914. /**
  53915. * Gets the current class name
  53916. * @returns the class name
  53917. */
  53918. getClassName(): string;
  53919. /**
  53920. * Gets the input component
  53921. */
  53922. readonly input: NodeMaterialConnectionPoint;
  53923. /**
  53924. * Gets the source min input component
  53925. */
  53926. readonly sourceMin: NodeMaterialConnectionPoint;
  53927. /**
  53928. * Gets the source max input component
  53929. */
  53930. readonly sourceMax: NodeMaterialConnectionPoint;
  53931. /**
  53932. * Gets the target min input component
  53933. */
  53934. readonly targetMin: NodeMaterialConnectionPoint;
  53935. /**
  53936. * Gets the target max input component
  53937. */
  53938. readonly targetMax: NodeMaterialConnectionPoint;
  53939. /**
  53940. * Gets the output component
  53941. */
  53942. readonly output: NodeMaterialConnectionPoint;
  53943. protected _buildBlock(state: NodeMaterialBuildState): this;
  53944. protected _dumpPropertiesCode(): string;
  53945. serialize(): any;
  53946. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53947. }
  53948. }
  53949. declare module BABYLON {
  53950. /**
  53951. * Block used to normalize a vector
  53952. */
  53953. export class NormalizeBlock extends NodeMaterialBlock {
  53954. /**
  53955. * Creates a new NormalizeBlock
  53956. * @param name defines the block name
  53957. */
  53958. constructor(name: string);
  53959. /**
  53960. * Gets the current class name
  53961. * @returns the class name
  53962. */
  53963. getClassName(): string;
  53964. /**
  53965. * Gets the input component
  53966. */
  53967. readonly input: NodeMaterialConnectionPoint;
  53968. /**
  53969. * Gets the output component
  53970. */
  53971. readonly output: NodeMaterialConnectionPoint;
  53972. protected _buildBlock(state: NodeMaterialBuildState): this;
  53973. }
  53974. }
  53975. declare module BABYLON {
  53976. /**
  53977. * Operations supported by the Trigonometry block
  53978. */
  53979. export enum TrigonometryBlockOperations {
  53980. /** Cos */
  53981. Cos = 0,
  53982. /** Sin */
  53983. Sin = 1,
  53984. /** Abs */
  53985. Abs = 2,
  53986. /** Exp */
  53987. Exp = 3,
  53988. /** Exp2 */
  53989. Exp2 = 4,
  53990. /** Round */
  53991. Round = 5,
  53992. /** Floor */
  53993. Floor = 6,
  53994. /** Ceiling */
  53995. Ceiling = 7,
  53996. /** Square root */
  53997. Sqrt = 8
  53998. }
  53999. /**
  54000. * Block used to apply trigonometry operation to floats
  54001. */
  54002. export class TrigonometryBlock extends NodeMaterialBlock {
  54003. /**
  54004. * Gets or sets the operation applied by the block
  54005. */
  54006. operation: TrigonometryBlockOperations;
  54007. /**
  54008. * Creates a new TrigonometryBlock
  54009. * @param name defines the block name
  54010. */
  54011. constructor(name: string);
  54012. /**
  54013. * Gets the current class name
  54014. * @returns the class name
  54015. */
  54016. getClassName(): string;
  54017. /**
  54018. * Gets the input component
  54019. */
  54020. readonly input: NodeMaterialConnectionPoint;
  54021. /**
  54022. * Gets the output component
  54023. */
  54024. readonly output: NodeMaterialConnectionPoint;
  54025. protected _buildBlock(state: NodeMaterialBuildState): this;
  54026. serialize(): any;
  54027. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54028. }
  54029. }
  54030. declare module BABYLON {
  54031. /**
  54032. * Block used to create a Color3/4 out of individual inputs (one for each component)
  54033. */
  54034. export class ColorMergerBlock extends NodeMaterialBlock {
  54035. /**
  54036. * Create a new ColorMergerBlock
  54037. * @param name defines the block name
  54038. */
  54039. constructor(name: string);
  54040. /**
  54041. * Gets the current class name
  54042. * @returns the class name
  54043. */
  54044. getClassName(): string;
  54045. /**
  54046. * Gets the r component (input)
  54047. */
  54048. readonly r: NodeMaterialConnectionPoint;
  54049. /**
  54050. * Gets the g component (input)
  54051. */
  54052. readonly g: NodeMaterialConnectionPoint;
  54053. /**
  54054. * Gets the b component (input)
  54055. */
  54056. readonly b: NodeMaterialConnectionPoint;
  54057. /**
  54058. * Gets the a component (input)
  54059. */
  54060. readonly a: NodeMaterialConnectionPoint;
  54061. /**
  54062. * Gets the rgba component (output)
  54063. */
  54064. readonly rgba: NodeMaterialConnectionPoint;
  54065. /**
  54066. * Gets the rgb component (output)
  54067. */
  54068. readonly rgb: NodeMaterialConnectionPoint;
  54069. protected _buildBlock(state: NodeMaterialBuildState): this;
  54070. }
  54071. }
  54072. declare module BABYLON {
  54073. /**
  54074. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  54075. */
  54076. export class VectorMergerBlock extends NodeMaterialBlock {
  54077. /**
  54078. * Create a new VectorMergerBlock
  54079. * @param name defines the block name
  54080. */
  54081. constructor(name: string);
  54082. /**
  54083. * Gets the current class name
  54084. * @returns the class name
  54085. */
  54086. getClassName(): string;
  54087. /**
  54088. * Gets the x component (input)
  54089. */
  54090. readonly x: NodeMaterialConnectionPoint;
  54091. /**
  54092. * Gets the y component (input)
  54093. */
  54094. readonly y: NodeMaterialConnectionPoint;
  54095. /**
  54096. * Gets the z component (input)
  54097. */
  54098. readonly z: NodeMaterialConnectionPoint;
  54099. /**
  54100. * Gets the w component (input)
  54101. */
  54102. readonly w: NodeMaterialConnectionPoint;
  54103. /**
  54104. * Gets the xyzw component (output)
  54105. */
  54106. readonly xyzw: NodeMaterialConnectionPoint;
  54107. /**
  54108. * Gets the xyz component (output)
  54109. */
  54110. readonly xyz: NodeMaterialConnectionPoint;
  54111. /**
  54112. * Gets the xy component (output)
  54113. */
  54114. readonly xy: NodeMaterialConnectionPoint;
  54115. protected _buildBlock(state: NodeMaterialBuildState): this;
  54116. }
  54117. }
  54118. declare module BABYLON {
  54119. /**
  54120. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  54121. */
  54122. export class ColorSplitterBlock extends NodeMaterialBlock {
  54123. /**
  54124. * Create a new ColorSplitterBlock
  54125. * @param name defines the block name
  54126. */
  54127. constructor(name: string);
  54128. /**
  54129. * Gets the current class name
  54130. * @returns the class name
  54131. */
  54132. getClassName(): string;
  54133. /**
  54134. * Gets the rgba component (input)
  54135. */
  54136. readonly rgba: NodeMaterialConnectionPoint;
  54137. /**
  54138. * Gets the rgb component (input)
  54139. */
  54140. readonly rgbIn: NodeMaterialConnectionPoint;
  54141. /**
  54142. * Gets the rgb component (output)
  54143. */
  54144. readonly rgbOut: NodeMaterialConnectionPoint;
  54145. /**
  54146. * Gets the r component (output)
  54147. */
  54148. readonly r: NodeMaterialConnectionPoint;
  54149. /**
  54150. * Gets the g component (output)
  54151. */
  54152. readonly g: NodeMaterialConnectionPoint;
  54153. /**
  54154. * Gets the b component (output)
  54155. */
  54156. readonly b: NodeMaterialConnectionPoint;
  54157. /**
  54158. * Gets the a component (output)
  54159. */
  54160. readonly a: NodeMaterialConnectionPoint;
  54161. protected _inputRename(name: string): string;
  54162. protected _outputRename(name: string): string;
  54163. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54164. }
  54165. }
  54166. declare module BABYLON {
  54167. /**
  54168. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54169. */
  54170. export class VectorSplitterBlock extends NodeMaterialBlock {
  54171. /**
  54172. * Create a new VectorSplitterBlock
  54173. * @param name defines the block name
  54174. */
  54175. constructor(name: string);
  54176. /**
  54177. * Gets the current class name
  54178. * @returns the class name
  54179. */
  54180. getClassName(): string;
  54181. /**
  54182. * Gets the xyzw component (input)
  54183. */
  54184. readonly xyzw: NodeMaterialConnectionPoint;
  54185. /**
  54186. * Gets the xyz component (input)
  54187. */
  54188. readonly xyzIn: NodeMaterialConnectionPoint;
  54189. /**
  54190. * Gets the xy component (input)
  54191. */
  54192. readonly xyIn: NodeMaterialConnectionPoint;
  54193. /**
  54194. * Gets the xyz component (output)
  54195. */
  54196. readonly xyzOut: NodeMaterialConnectionPoint;
  54197. /**
  54198. * Gets the xy component (output)
  54199. */
  54200. readonly xyOut: NodeMaterialConnectionPoint;
  54201. /**
  54202. * Gets the x component (output)
  54203. */
  54204. readonly x: NodeMaterialConnectionPoint;
  54205. /**
  54206. * Gets the y component (output)
  54207. */
  54208. readonly y: NodeMaterialConnectionPoint;
  54209. /**
  54210. * Gets the z component (output)
  54211. */
  54212. readonly z: NodeMaterialConnectionPoint;
  54213. /**
  54214. * Gets the w component (output)
  54215. */
  54216. readonly w: NodeMaterialConnectionPoint;
  54217. protected _inputRename(name: string): string;
  54218. protected _outputRename(name: string): string;
  54219. protected _buildBlock(state: NodeMaterialBuildState): this;
  54220. }
  54221. }
  54222. declare module BABYLON {
  54223. /**
  54224. * Block used to lerp 2 values
  54225. */
  54226. export class LerpBlock extends NodeMaterialBlock {
  54227. /**
  54228. * Creates a new LerpBlock
  54229. * @param name defines the block name
  54230. */
  54231. constructor(name: string);
  54232. /**
  54233. * Gets the current class name
  54234. * @returns the class name
  54235. */
  54236. getClassName(): string;
  54237. /**
  54238. * Gets the left operand input component
  54239. */
  54240. readonly left: NodeMaterialConnectionPoint;
  54241. /**
  54242. * Gets the right operand input component
  54243. */
  54244. readonly right: NodeMaterialConnectionPoint;
  54245. /**
  54246. * Gets the gradient operand input component
  54247. */
  54248. readonly gradient: NodeMaterialConnectionPoint;
  54249. /**
  54250. * Gets the output component
  54251. */
  54252. readonly output: NodeMaterialConnectionPoint;
  54253. protected _buildBlock(state: NodeMaterialBuildState): this;
  54254. }
  54255. }
  54256. declare module BABYLON {
  54257. /**
  54258. * Block used to divide 2 vectors
  54259. */
  54260. export class DivideBlock extends NodeMaterialBlock {
  54261. /**
  54262. * Creates a new DivideBlock
  54263. * @param name defines the block name
  54264. */
  54265. constructor(name: string);
  54266. /**
  54267. * Gets the current class name
  54268. * @returns the class name
  54269. */
  54270. getClassName(): string;
  54271. /**
  54272. * Gets the left operand input component
  54273. */
  54274. readonly left: NodeMaterialConnectionPoint;
  54275. /**
  54276. * Gets the right operand input component
  54277. */
  54278. readonly right: NodeMaterialConnectionPoint;
  54279. /**
  54280. * Gets the output component
  54281. */
  54282. readonly output: NodeMaterialConnectionPoint;
  54283. protected _buildBlock(state: NodeMaterialBuildState): this;
  54284. }
  54285. }
  54286. declare module BABYLON {
  54287. /**
  54288. * Block used to subtract 2 vectors
  54289. */
  54290. export class SubtractBlock extends NodeMaterialBlock {
  54291. /**
  54292. * Creates a new SubtractBlock
  54293. * @param name defines the block name
  54294. */
  54295. constructor(name: string);
  54296. /**
  54297. * Gets the current class name
  54298. * @returns the class name
  54299. */
  54300. getClassName(): string;
  54301. /**
  54302. * Gets the left operand input component
  54303. */
  54304. readonly left: NodeMaterialConnectionPoint;
  54305. /**
  54306. * Gets the right operand input component
  54307. */
  54308. readonly right: NodeMaterialConnectionPoint;
  54309. /**
  54310. * Gets the output component
  54311. */
  54312. readonly output: NodeMaterialConnectionPoint;
  54313. protected _buildBlock(state: NodeMaterialBuildState): this;
  54314. }
  54315. }
  54316. declare module BABYLON {
  54317. /**
  54318. * Block used to step a value
  54319. */
  54320. export class StepBlock extends NodeMaterialBlock {
  54321. /**
  54322. * Creates a new AddBlock
  54323. * @param name defines the block name
  54324. */
  54325. constructor(name: string);
  54326. /**
  54327. * Gets the current class name
  54328. * @returns the class name
  54329. */
  54330. getClassName(): string;
  54331. /**
  54332. * Gets the value operand input component
  54333. */
  54334. readonly value: NodeMaterialConnectionPoint;
  54335. /**
  54336. * Gets the edge operand input component
  54337. */
  54338. readonly edge: NodeMaterialConnectionPoint;
  54339. /**
  54340. * Gets the output component
  54341. */
  54342. readonly output: NodeMaterialConnectionPoint;
  54343. protected _buildBlock(state: NodeMaterialBuildState): this;
  54344. }
  54345. }
  54346. declare module BABYLON {
  54347. /**
  54348. * Block used to get the opposite (1 - x) of a value
  54349. */
  54350. export class OneMinusBlock extends NodeMaterialBlock {
  54351. /**
  54352. * Creates a new OneMinusBlock
  54353. * @param name defines the block name
  54354. */
  54355. constructor(name: string);
  54356. /**
  54357. * Gets the current class name
  54358. * @returns the class name
  54359. */
  54360. getClassName(): string;
  54361. /**
  54362. * Gets the input component
  54363. */
  54364. readonly input: NodeMaterialConnectionPoint;
  54365. /**
  54366. * Gets the output component
  54367. */
  54368. readonly output: NodeMaterialConnectionPoint;
  54369. protected _buildBlock(state: NodeMaterialBuildState): this;
  54370. }
  54371. }
  54372. declare module BABYLON {
  54373. /**
  54374. * Block used to get the view direction
  54375. */
  54376. export class ViewDirectionBlock extends NodeMaterialBlock {
  54377. /**
  54378. * Creates a new ViewDirectionBlock
  54379. * @param name defines the block name
  54380. */
  54381. constructor(name: string);
  54382. /**
  54383. * Gets the current class name
  54384. * @returns the class name
  54385. */
  54386. getClassName(): string;
  54387. /**
  54388. * Gets the world position component
  54389. */
  54390. readonly worldPosition: NodeMaterialConnectionPoint;
  54391. /**
  54392. * Gets the camera position component
  54393. */
  54394. readonly cameraPosition: NodeMaterialConnectionPoint;
  54395. /**
  54396. * Gets the output component
  54397. */
  54398. readonly output: NodeMaterialConnectionPoint;
  54399. autoConfigure(material: NodeMaterial): void;
  54400. protected _buildBlock(state: NodeMaterialBuildState): this;
  54401. }
  54402. }
  54403. declare module BABYLON {
  54404. /**
  54405. * Block used to compute fresnel value
  54406. */
  54407. export class FresnelBlock extends NodeMaterialBlock {
  54408. /**
  54409. * Create a new FresnelBlock
  54410. * @param name defines the block name
  54411. */
  54412. constructor(name: string);
  54413. /**
  54414. * Gets the current class name
  54415. * @returns the class name
  54416. */
  54417. getClassName(): string;
  54418. /**
  54419. * Gets the world normal input component
  54420. */
  54421. readonly worldNormal: NodeMaterialConnectionPoint;
  54422. /**
  54423. * Gets the view direction input component
  54424. */
  54425. readonly viewDirection: NodeMaterialConnectionPoint;
  54426. /**
  54427. * Gets the bias input component
  54428. */
  54429. readonly bias: NodeMaterialConnectionPoint;
  54430. /**
  54431. * Gets the camera (or eye) position component
  54432. */
  54433. readonly power: NodeMaterialConnectionPoint;
  54434. /**
  54435. * Gets the fresnel output component
  54436. */
  54437. readonly fresnel: NodeMaterialConnectionPoint;
  54438. autoConfigure(material: NodeMaterial): void;
  54439. protected _buildBlock(state: NodeMaterialBuildState): this;
  54440. }
  54441. }
  54442. declare module BABYLON {
  54443. /**
  54444. * Block used to get the max of 2 values
  54445. */
  54446. export class MaxBlock extends NodeMaterialBlock {
  54447. /**
  54448. * Creates a new MaxBlock
  54449. * @param name defines the block name
  54450. */
  54451. constructor(name: string);
  54452. /**
  54453. * Gets the current class name
  54454. * @returns the class name
  54455. */
  54456. getClassName(): string;
  54457. /**
  54458. * Gets the left operand input component
  54459. */
  54460. readonly left: NodeMaterialConnectionPoint;
  54461. /**
  54462. * Gets the right operand input component
  54463. */
  54464. readonly right: NodeMaterialConnectionPoint;
  54465. /**
  54466. * Gets the output component
  54467. */
  54468. readonly output: NodeMaterialConnectionPoint;
  54469. protected _buildBlock(state: NodeMaterialBuildState): this;
  54470. }
  54471. }
  54472. declare module BABYLON {
  54473. /**
  54474. * Block used to get the min of 2 values
  54475. */
  54476. export class MinBlock extends NodeMaterialBlock {
  54477. /**
  54478. * Creates a new MinBlock
  54479. * @param name defines the block name
  54480. */
  54481. constructor(name: string);
  54482. /**
  54483. * Gets the current class name
  54484. * @returns the class name
  54485. */
  54486. getClassName(): string;
  54487. /**
  54488. * Gets the left operand input component
  54489. */
  54490. readonly left: NodeMaterialConnectionPoint;
  54491. /**
  54492. * Gets the right operand input component
  54493. */
  54494. readonly right: NodeMaterialConnectionPoint;
  54495. /**
  54496. * Gets the output component
  54497. */
  54498. readonly output: NodeMaterialConnectionPoint;
  54499. protected _buildBlock(state: NodeMaterialBuildState): this;
  54500. }
  54501. }
  54502. declare module BABYLON {
  54503. /**
  54504. * Block used to get the distance between 2 values
  54505. */
  54506. export class DistanceBlock extends NodeMaterialBlock {
  54507. /**
  54508. * Creates a new DistanceBlock
  54509. * @param name defines the block name
  54510. */
  54511. constructor(name: string);
  54512. /**
  54513. * Gets the current class name
  54514. * @returns the class name
  54515. */
  54516. getClassName(): string;
  54517. /**
  54518. * Gets the left operand input component
  54519. */
  54520. readonly left: NodeMaterialConnectionPoint;
  54521. /**
  54522. * Gets the right operand input component
  54523. */
  54524. readonly right: NodeMaterialConnectionPoint;
  54525. /**
  54526. * Gets the output component
  54527. */
  54528. readonly output: NodeMaterialConnectionPoint;
  54529. protected _buildBlock(state: NodeMaterialBuildState): this;
  54530. }
  54531. }
  54532. declare module BABYLON {
  54533. /**
  54534. * Block used to get the length of a vector
  54535. */
  54536. export class LengthBlock extends NodeMaterialBlock {
  54537. /**
  54538. * Creates a new LengthBlock
  54539. * @param name defines the block name
  54540. */
  54541. constructor(name: string);
  54542. /**
  54543. * Gets the current class name
  54544. * @returns the class name
  54545. */
  54546. getClassName(): string;
  54547. /**
  54548. * Gets the value input component
  54549. */
  54550. readonly value: NodeMaterialConnectionPoint;
  54551. /**
  54552. * Gets the output component
  54553. */
  54554. readonly output: NodeMaterialConnectionPoint;
  54555. protected _buildBlock(state: NodeMaterialBuildState): this;
  54556. }
  54557. }
  54558. declare module BABYLON {
  54559. /**
  54560. * Block used to get negative version of a value (i.e. x * -1)
  54561. */
  54562. export class NegateBlock extends NodeMaterialBlock {
  54563. /**
  54564. * Creates a new NegateBlock
  54565. * @param name defines the block name
  54566. */
  54567. constructor(name: string);
  54568. /**
  54569. * Gets the current class name
  54570. * @returns the class name
  54571. */
  54572. getClassName(): string;
  54573. /**
  54574. * Gets the value input component
  54575. */
  54576. readonly value: NodeMaterialConnectionPoint;
  54577. /**
  54578. * Gets the output component
  54579. */
  54580. readonly output: NodeMaterialConnectionPoint;
  54581. protected _buildBlock(state: NodeMaterialBuildState): this;
  54582. }
  54583. }
  54584. declare module BABYLON {
  54585. /**
  54586. * Block used to get the value of the first parameter raised to the power of the second
  54587. */
  54588. export class PowBlock extends NodeMaterialBlock {
  54589. /**
  54590. * Creates a new PowBlock
  54591. * @param name defines the block name
  54592. */
  54593. constructor(name: string);
  54594. /**
  54595. * Gets the current class name
  54596. * @returns the class name
  54597. */
  54598. getClassName(): string;
  54599. /**
  54600. * Gets the value operand input component
  54601. */
  54602. readonly value: NodeMaterialConnectionPoint;
  54603. /**
  54604. * Gets the power operand input component
  54605. */
  54606. readonly power: NodeMaterialConnectionPoint;
  54607. /**
  54608. * Gets the output component
  54609. */
  54610. readonly output: NodeMaterialConnectionPoint;
  54611. protected _buildBlock(state: NodeMaterialBuildState): this;
  54612. }
  54613. }
  54614. declare module BABYLON {
  54615. /**
  54616. * Effect Render Options
  54617. */
  54618. export interface IEffectRendererOptions {
  54619. /**
  54620. * Defines the vertices positions.
  54621. */
  54622. positions?: number[];
  54623. /**
  54624. * Defines the indices.
  54625. */
  54626. indices?: number[];
  54627. }
  54628. /**
  54629. * Helper class to render one or more effects
  54630. */
  54631. export class EffectRenderer {
  54632. private engine;
  54633. private static _DefaultOptions;
  54634. private _vertexBuffers;
  54635. private _indexBuffer;
  54636. private _ringBufferIndex;
  54637. private _ringScreenBuffer;
  54638. private _fullscreenViewport;
  54639. private _getNextFrameBuffer;
  54640. /**
  54641. * Creates an effect renderer
  54642. * @param engine the engine to use for rendering
  54643. * @param options defines the options of the effect renderer
  54644. */
  54645. constructor(engine: Engine, options?: IEffectRendererOptions);
  54646. /**
  54647. * Sets the current viewport in normalized coordinates 0-1
  54648. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  54649. */
  54650. setViewport(viewport?: Viewport): void;
  54651. /**
  54652. * Binds the embedded attributes buffer to the effect.
  54653. * @param effect Defines the effect to bind the attributes for
  54654. */
  54655. bindBuffers(effect: Effect): void;
  54656. /**
  54657. * Sets the current effect wrapper to use during draw.
  54658. * The effect needs to be ready before calling this api.
  54659. * This also sets the default full screen position attribute.
  54660. * @param effectWrapper Defines the effect to draw with
  54661. */
  54662. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  54663. /**
  54664. * Draws a full screen quad.
  54665. */
  54666. draw(): void;
  54667. /**
  54668. * renders one or more effects to a specified texture
  54669. * @param effectWrappers list of effects to renderer
  54670. * @param outputTexture texture to draw to, if null it will render to the screen
  54671. */
  54672. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  54673. /**
  54674. * Disposes of the effect renderer
  54675. */
  54676. dispose(): void;
  54677. }
  54678. /**
  54679. * Options to create an EffectWrapper
  54680. */
  54681. interface EffectWrapperCreationOptions {
  54682. /**
  54683. * Engine to use to create the effect
  54684. */
  54685. engine: Engine;
  54686. /**
  54687. * Fragment shader for the effect
  54688. */
  54689. fragmentShader: string;
  54690. /**
  54691. * Vertex shader for the effect
  54692. */
  54693. vertexShader?: string;
  54694. /**
  54695. * Attributes to use in the shader
  54696. */
  54697. attributeNames?: Array<string>;
  54698. /**
  54699. * Uniforms to use in the shader
  54700. */
  54701. uniformNames?: Array<string>;
  54702. /**
  54703. * Texture sampler names to use in the shader
  54704. */
  54705. samplerNames?: Array<string>;
  54706. /**
  54707. * The friendly name of the effect displayed in Spector.
  54708. */
  54709. name?: string;
  54710. }
  54711. /**
  54712. * Wraps an effect to be used for rendering
  54713. */
  54714. export class EffectWrapper {
  54715. /**
  54716. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  54717. */
  54718. onApplyObservable: Observable<{}>;
  54719. /**
  54720. * The underlying effect
  54721. */
  54722. effect: Effect;
  54723. /**
  54724. * Creates an effect to be renderer
  54725. * @param creationOptions options to create the effect
  54726. */
  54727. constructor(creationOptions: EffectWrapperCreationOptions);
  54728. /**
  54729. * Disposes of the effect wrapper
  54730. */
  54731. dispose(): void;
  54732. }
  54733. }
  54734. declare module BABYLON {
  54735. /**
  54736. * Helper class to push actions to a pool of workers.
  54737. */
  54738. export class WorkerPool implements IDisposable {
  54739. private _workerInfos;
  54740. private _pendingActions;
  54741. /**
  54742. * Constructor
  54743. * @param workers Array of workers to use for actions
  54744. */
  54745. constructor(workers: Array<Worker>);
  54746. /**
  54747. * Terminates all workers and clears any pending actions.
  54748. */
  54749. dispose(): void;
  54750. /**
  54751. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54752. * pended until a worker has completed its action.
  54753. * @param action The action to perform. Call onComplete when the action is complete.
  54754. */
  54755. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54756. private _execute;
  54757. }
  54758. }
  54759. declare module BABYLON {
  54760. /**
  54761. * Configuration for Draco compression
  54762. */
  54763. export interface IDracoCompressionConfiguration {
  54764. /**
  54765. * Configuration for the decoder.
  54766. */
  54767. decoder: {
  54768. /**
  54769. * The url to the WebAssembly module.
  54770. */
  54771. wasmUrl?: string;
  54772. /**
  54773. * The url to the WebAssembly binary.
  54774. */
  54775. wasmBinaryUrl?: string;
  54776. /**
  54777. * The url to the fallback JavaScript module.
  54778. */
  54779. fallbackUrl?: string;
  54780. };
  54781. }
  54782. /**
  54783. * Draco compression (https://google.github.io/draco/)
  54784. *
  54785. * This class wraps the Draco module.
  54786. *
  54787. * **Encoder**
  54788. *
  54789. * The encoder is not currently implemented.
  54790. *
  54791. * **Decoder**
  54792. *
  54793. * 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.
  54794. *
  54795. * To update the configuration, use the following code:
  54796. * ```javascript
  54797. * DracoCompression.Configuration = {
  54798. * decoder: {
  54799. * wasmUrl: "<url to the WebAssembly library>",
  54800. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54801. * fallbackUrl: "<url to the fallback JavaScript library>",
  54802. * }
  54803. * };
  54804. * ```
  54805. *
  54806. * 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.
  54807. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54808. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54809. *
  54810. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54811. * ```javascript
  54812. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54813. * ```
  54814. *
  54815. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54816. */
  54817. export class DracoCompression implements IDisposable {
  54818. private _workerPoolPromise?;
  54819. private _decoderModulePromise?;
  54820. /**
  54821. * The configuration. Defaults to the following urls:
  54822. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54823. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54824. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54825. */
  54826. static Configuration: IDracoCompressionConfiguration;
  54827. /**
  54828. * Returns true if the decoder configuration is available.
  54829. */
  54830. static readonly DecoderAvailable: boolean;
  54831. /**
  54832. * Default number of workers to create when creating the draco compression object.
  54833. */
  54834. static DefaultNumWorkers: number;
  54835. private static GetDefaultNumWorkers;
  54836. private static _Default;
  54837. /**
  54838. * Default instance for the draco compression object.
  54839. */
  54840. static readonly Default: DracoCompression;
  54841. /**
  54842. * Constructor
  54843. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54844. */
  54845. constructor(numWorkers?: number);
  54846. /**
  54847. * Stop all async operations and release resources.
  54848. */
  54849. dispose(): void;
  54850. /**
  54851. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54852. * @returns a promise that resolves when ready
  54853. */
  54854. whenReadyAsync(): Promise<void>;
  54855. /**
  54856. * Decode Draco compressed mesh data to vertex data.
  54857. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54858. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54859. * @returns A promise that resolves with the decoded vertex data
  54860. */
  54861. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54862. [kind: string]: number;
  54863. }): Promise<VertexData>;
  54864. }
  54865. }
  54866. declare module BABYLON {
  54867. /**
  54868. * Class for building Constructive Solid Geometry
  54869. */
  54870. export class CSG {
  54871. private polygons;
  54872. /**
  54873. * The world matrix
  54874. */
  54875. matrix: Matrix;
  54876. /**
  54877. * Stores the position
  54878. */
  54879. position: Vector3;
  54880. /**
  54881. * Stores the rotation
  54882. */
  54883. rotation: Vector3;
  54884. /**
  54885. * Stores the rotation quaternion
  54886. */
  54887. rotationQuaternion: Nullable<Quaternion>;
  54888. /**
  54889. * Stores the scaling vector
  54890. */
  54891. scaling: Vector3;
  54892. /**
  54893. * Convert the Mesh to CSG
  54894. * @param mesh The Mesh to convert to CSG
  54895. * @returns A new CSG from the Mesh
  54896. */
  54897. static FromMesh(mesh: Mesh): CSG;
  54898. /**
  54899. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54900. * @param polygons Polygons used to construct a CSG solid
  54901. */
  54902. private static FromPolygons;
  54903. /**
  54904. * Clones, or makes a deep copy, of the CSG
  54905. * @returns A new CSG
  54906. */
  54907. clone(): CSG;
  54908. /**
  54909. * Unions this CSG with another CSG
  54910. * @param csg The CSG to union against this CSG
  54911. * @returns The unioned CSG
  54912. */
  54913. union(csg: CSG): CSG;
  54914. /**
  54915. * Unions this CSG with another CSG in place
  54916. * @param csg The CSG to union against this CSG
  54917. */
  54918. unionInPlace(csg: CSG): void;
  54919. /**
  54920. * Subtracts this CSG with another CSG
  54921. * @param csg The CSG to subtract against this CSG
  54922. * @returns A new CSG
  54923. */
  54924. subtract(csg: CSG): CSG;
  54925. /**
  54926. * Subtracts this CSG with another CSG in place
  54927. * @param csg The CSG to subtact against this CSG
  54928. */
  54929. subtractInPlace(csg: CSG): void;
  54930. /**
  54931. * Intersect this CSG with another CSG
  54932. * @param csg The CSG to intersect against this CSG
  54933. * @returns A new CSG
  54934. */
  54935. intersect(csg: CSG): CSG;
  54936. /**
  54937. * Intersects this CSG with another CSG in place
  54938. * @param csg The CSG to intersect against this CSG
  54939. */
  54940. intersectInPlace(csg: CSG): void;
  54941. /**
  54942. * Return a new CSG solid with solid and empty space switched. This solid is
  54943. * not modified.
  54944. * @returns A new CSG solid with solid and empty space switched
  54945. */
  54946. inverse(): CSG;
  54947. /**
  54948. * Inverses the CSG in place
  54949. */
  54950. inverseInPlace(): void;
  54951. /**
  54952. * This is used to keep meshes transformations so they can be restored
  54953. * when we build back a Babylon Mesh
  54954. * NB : All CSG operations are performed in world coordinates
  54955. * @param csg The CSG to copy the transform attributes from
  54956. * @returns This CSG
  54957. */
  54958. copyTransformAttributes(csg: CSG): CSG;
  54959. /**
  54960. * Build Raw mesh from CSG
  54961. * Coordinates here are in world space
  54962. * @param name The name of the mesh geometry
  54963. * @param scene The Scene
  54964. * @param keepSubMeshes Specifies if the submeshes should be kept
  54965. * @returns A new Mesh
  54966. */
  54967. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54968. /**
  54969. * Build Mesh from CSG taking material and transforms into account
  54970. * @param name The name of the Mesh
  54971. * @param material The material of the Mesh
  54972. * @param scene The Scene
  54973. * @param keepSubMeshes Specifies if submeshes should be kept
  54974. * @returns The new Mesh
  54975. */
  54976. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54977. }
  54978. }
  54979. declare module BABYLON {
  54980. /**
  54981. * Class used to create a trail following a mesh
  54982. */
  54983. export class TrailMesh extends Mesh {
  54984. private _generator;
  54985. private _autoStart;
  54986. private _running;
  54987. private _diameter;
  54988. private _length;
  54989. private _sectionPolygonPointsCount;
  54990. private _sectionVectors;
  54991. private _sectionNormalVectors;
  54992. private _beforeRenderObserver;
  54993. /**
  54994. * @constructor
  54995. * @param name The value used by scene.getMeshByName() to do a lookup.
  54996. * @param generator The mesh to generate a trail.
  54997. * @param scene The scene to add this mesh to.
  54998. * @param diameter Diameter of trailing mesh. Default is 1.
  54999. * @param length Length of trailing mesh. Default is 60.
  55000. * @param autoStart Automatically start trailing mesh. Default true.
  55001. */
  55002. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55003. /**
  55004. * "TrailMesh"
  55005. * @returns "TrailMesh"
  55006. */
  55007. getClassName(): string;
  55008. private _createMesh;
  55009. /**
  55010. * Start trailing mesh.
  55011. */
  55012. start(): void;
  55013. /**
  55014. * Stop trailing mesh.
  55015. */
  55016. stop(): void;
  55017. /**
  55018. * Update trailing mesh geometry.
  55019. */
  55020. update(): void;
  55021. /**
  55022. * Returns a new TrailMesh object.
  55023. * @param name is a string, the name given to the new mesh
  55024. * @param newGenerator use new generator object for cloned trail mesh
  55025. * @returns a new mesh
  55026. */
  55027. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55028. /**
  55029. * Serializes this trail mesh
  55030. * @param serializationObject object to write serialization to
  55031. */
  55032. serialize(serializationObject: any): void;
  55033. /**
  55034. * Parses a serialized trail mesh
  55035. * @param parsedMesh the serialized mesh
  55036. * @param scene the scene to create the trail mesh in
  55037. * @returns the created trail mesh
  55038. */
  55039. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55040. }
  55041. }
  55042. declare module BABYLON {
  55043. /**
  55044. * Class containing static functions to help procedurally build meshes
  55045. */
  55046. export class TiledBoxBuilder {
  55047. /**
  55048. * Creates a box mesh
  55049. * 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)
  55050. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55051. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55052. * * 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
  55053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55054. * @param name defines the name of the mesh
  55055. * @param options defines the options used to create the mesh
  55056. * @param scene defines the hosting scene
  55057. * @returns the box mesh
  55058. */
  55059. static CreateTiledBox(name: string, options: {
  55060. pattern?: number;
  55061. width?: number;
  55062. height?: number;
  55063. depth?: number;
  55064. tileSize?: number;
  55065. tileWidth?: number;
  55066. tileHeight?: number;
  55067. alignHorizontal?: number;
  55068. alignVertical?: number;
  55069. faceUV?: Vector4[];
  55070. faceColors?: Color4[];
  55071. sideOrientation?: number;
  55072. updatable?: boolean;
  55073. }, scene?: Nullable<Scene>): Mesh;
  55074. }
  55075. }
  55076. declare module BABYLON {
  55077. /**
  55078. * Class containing static functions to help procedurally build meshes
  55079. */
  55080. export class TorusKnotBuilder {
  55081. /**
  55082. * Creates a torus knot mesh
  55083. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55084. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55085. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55086. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55088. * * 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
  55089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55090. * @param name defines the name of the mesh
  55091. * @param options defines the options used to create the mesh
  55092. * @param scene defines the hosting scene
  55093. * @returns the torus knot mesh
  55094. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55095. */
  55096. static CreateTorusKnot(name: string, options: {
  55097. radius?: number;
  55098. tube?: number;
  55099. radialSegments?: number;
  55100. tubularSegments?: number;
  55101. p?: number;
  55102. q?: number;
  55103. updatable?: boolean;
  55104. sideOrientation?: number;
  55105. frontUVs?: Vector4;
  55106. backUVs?: Vector4;
  55107. }, scene: any): Mesh;
  55108. }
  55109. }
  55110. declare module BABYLON {
  55111. /**
  55112. * Polygon
  55113. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55114. */
  55115. export class Polygon {
  55116. /**
  55117. * Creates a rectangle
  55118. * @param xmin bottom X coord
  55119. * @param ymin bottom Y coord
  55120. * @param xmax top X coord
  55121. * @param ymax top Y coord
  55122. * @returns points that make the resulting rectation
  55123. */
  55124. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55125. /**
  55126. * Creates a circle
  55127. * @param radius radius of circle
  55128. * @param cx scale in x
  55129. * @param cy scale in y
  55130. * @param numberOfSides number of sides that make up the circle
  55131. * @returns points that make the resulting circle
  55132. */
  55133. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55134. /**
  55135. * Creates a polygon from input string
  55136. * @param input Input polygon data
  55137. * @returns the parsed points
  55138. */
  55139. static Parse(input: string): Vector2[];
  55140. /**
  55141. * Starts building a polygon from x and y coordinates
  55142. * @param x x coordinate
  55143. * @param y y coordinate
  55144. * @returns the started path2
  55145. */
  55146. static StartingAt(x: number, y: number): Path2;
  55147. }
  55148. /**
  55149. * Builds a polygon
  55150. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55151. */
  55152. export class PolygonMeshBuilder {
  55153. private _points;
  55154. private _outlinepoints;
  55155. private _holes;
  55156. private _name;
  55157. private _scene;
  55158. private _epoints;
  55159. private _eholes;
  55160. private _addToepoint;
  55161. /**
  55162. * Babylon reference to the earcut plugin.
  55163. */
  55164. bjsEarcut: any;
  55165. /**
  55166. * Creates a PolygonMeshBuilder
  55167. * @param name name of the builder
  55168. * @param contours Path of the polygon
  55169. * @param scene scene to add to when creating the mesh
  55170. * @param earcutInjection can be used to inject your own earcut reference
  55171. */
  55172. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55173. /**
  55174. * Adds a whole within the polygon
  55175. * @param hole Array of points defining the hole
  55176. * @returns this
  55177. */
  55178. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55179. /**
  55180. * Creates the polygon
  55181. * @param updatable If the mesh should be updatable
  55182. * @param depth The depth of the mesh created
  55183. * @returns the created mesh
  55184. */
  55185. build(updatable?: boolean, depth?: number): Mesh;
  55186. /**
  55187. * Creates the polygon
  55188. * @param depth The depth of the mesh created
  55189. * @returns the created VertexData
  55190. */
  55191. buildVertexData(depth?: number): VertexData;
  55192. /**
  55193. * Adds a side to the polygon
  55194. * @param positions points that make the polygon
  55195. * @param normals normals of the polygon
  55196. * @param uvs uvs of the polygon
  55197. * @param indices indices of the polygon
  55198. * @param bounds bounds of the polygon
  55199. * @param points points of the polygon
  55200. * @param depth depth of the polygon
  55201. * @param flip flip of the polygon
  55202. */
  55203. private addSide;
  55204. }
  55205. }
  55206. declare module BABYLON {
  55207. /**
  55208. * Class containing static functions to help procedurally build meshes
  55209. */
  55210. export class PolygonBuilder {
  55211. /**
  55212. * Creates a polygon mesh
  55213. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55214. * * 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
  55215. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55217. * * 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)
  55218. * * Remember you can only change the shape positions, not their number when updating a polygon
  55219. * @param name defines the name of the mesh
  55220. * @param options defines the options used to create the mesh
  55221. * @param scene defines the hosting scene
  55222. * @param earcutInjection can be used to inject your own earcut reference
  55223. * @returns the polygon mesh
  55224. */
  55225. static CreatePolygon(name: string, options: {
  55226. shape: Vector3[];
  55227. holes?: Vector3[][];
  55228. depth?: number;
  55229. faceUV?: Vector4[];
  55230. faceColors?: Color4[];
  55231. updatable?: boolean;
  55232. sideOrientation?: number;
  55233. frontUVs?: Vector4;
  55234. backUVs?: Vector4;
  55235. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55236. /**
  55237. * Creates an extruded polygon mesh, with depth in the Y direction.
  55238. * * 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)
  55239. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55240. * @param name defines the name of the mesh
  55241. * @param options defines the options used to create the mesh
  55242. * @param scene defines the hosting scene
  55243. * @param earcutInjection can be used to inject your own earcut reference
  55244. * @returns the polygon mesh
  55245. */
  55246. static ExtrudePolygon(name: string, options: {
  55247. shape: Vector3[];
  55248. holes?: Vector3[][];
  55249. depth?: number;
  55250. faceUV?: Vector4[];
  55251. faceColors?: Color4[];
  55252. updatable?: boolean;
  55253. sideOrientation?: number;
  55254. frontUVs?: Vector4;
  55255. backUVs?: Vector4;
  55256. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55257. }
  55258. }
  55259. declare module BABYLON {
  55260. /**
  55261. * Class containing static functions to help procedurally build meshes
  55262. */
  55263. export class LatheBuilder {
  55264. /**
  55265. * Creates lathe mesh.
  55266. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55267. * * 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
  55268. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55269. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55270. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55271. * * 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
  55272. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55273. * * 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
  55274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55275. * * 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
  55276. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55278. * @param name defines the name of the mesh
  55279. * @param options defines the options used to create the mesh
  55280. * @param scene defines the hosting scene
  55281. * @returns the lathe mesh
  55282. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55283. */
  55284. static CreateLathe(name: string, options: {
  55285. shape: Vector3[];
  55286. radius?: number;
  55287. tessellation?: number;
  55288. clip?: number;
  55289. arc?: number;
  55290. closed?: boolean;
  55291. updatable?: boolean;
  55292. sideOrientation?: number;
  55293. frontUVs?: Vector4;
  55294. backUVs?: Vector4;
  55295. cap?: number;
  55296. invertUV?: boolean;
  55297. }, scene?: Nullable<Scene>): Mesh;
  55298. }
  55299. }
  55300. declare module BABYLON {
  55301. /**
  55302. * Class containing static functions to help procedurally build meshes
  55303. */
  55304. export class TiledPlaneBuilder {
  55305. /**
  55306. * Creates a tiled plane mesh
  55307. * * The parameter `pattern` will, depending on value, do nothing or
  55308. * * * flip (reflect about central vertical) alternate tiles across and up
  55309. * * * flip every tile on alternate rows
  55310. * * * rotate (180 degs) alternate tiles across and up
  55311. * * * rotate every tile on alternate rows
  55312. * * * flip and rotate alternate tiles across and up
  55313. * * * flip and rotate every tile on alternate rows
  55314. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55315. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55316. * * 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
  55317. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55318. * * 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)
  55319. * * 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)
  55320. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55321. * @param name defines the name of the mesh
  55322. * @param options defines the options used to create the mesh
  55323. * @param scene defines the hosting scene
  55324. * @returns the box mesh
  55325. */
  55326. static CreateTiledPlane(name: string, options: {
  55327. pattern?: number;
  55328. tileSize?: number;
  55329. tileWidth?: number;
  55330. tileHeight?: number;
  55331. size?: number;
  55332. width?: number;
  55333. height?: number;
  55334. alignHorizontal?: number;
  55335. alignVertical?: number;
  55336. sideOrientation?: number;
  55337. frontUVs?: Vector4;
  55338. backUVs?: Vector4;
  55339. updatable?: boolean;
  55340. }, scene?: Nullable<Scene>): Mesh;
  55341. }
  55342. }
  55343. declare module BABYLON {
  55344. /**
  55345. * Class containing static functions to help procedurally build meshes
  55346. */
  55347. export class TubeBuilder {
  55348. /**
  55349. * Creates a tube mesh.
  55350. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55351. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55352. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55353. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55354. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55355. * * 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)
  55356. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55357. * * 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
  55358. * * 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
  55359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55360. * * 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
  55361. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55363. * @param name defines the name of the mesh
  55364. * @param options defines the options used to create the mesh
  55365. * @param scene defines the hosting scene
  55366. * @returns the tube mesh
  55367. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55368. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55369. */
  55370. static CreateTube(name: string, options: {
  55371. path: Vector3[];
  55372. radius?: number;
  55373. tessellation?: number;
  55374. radiusFunction?: {
  55375. (i: number, distance: number): number;
  55376. };
  55377. cap?: number;
  55378. arc?: number;
  55379. updatable?: boolean;
  55380. sideOrientation?: number;
  55381. frontUVs?: Vector4;
  55382. backUVs?: Vector4;
  55383. instance?: Mesh;
  55384. invertUV?: boolean;
  55385. }, scene?: Nullable<Scene>): Mesh;
  55386. }
  55387. }
  55388. declare module BABYLON {
  55389. /**
  55390. * Class containing static functions to help procedurally build meshes
  55391. */
  55392. export class IcoSphereBuilder {
  55393. /**
  55394. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55395. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55396. * * 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`)
  55397. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55398. * * 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
  55399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55400. * * 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
  55401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55402. * @param name defines the name of the mesh
  55403. * @param options defines the options used to create the mesh
  55404. * @param scene defines the hosting scene
  55405. * @returns the icosahedron mesh
  55406. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55407. */
  55408. static CreateIcoSphere(name: string, options: {
  55409. radius?: number;
  55410. radiusX?: number;
  55411. radiusY?: number;
  55412. radiusZ?: number;
  55413. flat?: boolean;
  55414. subdivisions?: number;
  55415. sideOrientation?: number;
  55416. frontUVs?: Vector4;
  55417. backUVs?: Vector4;
  55418. updatable?: boolean;
  55419. }, scene?: Nullable<Scene>): Mesh;
  55420. }
  55421. }
  55422. declare module BABYLON {
  55423. /**
  55424. * Class containing static functions to help procedurally build meshes
  55425. */
  55426. export class DecalBuilder {
  55427. /**
  55428. * Creates a decal mesh.
  55429. * 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
  55430. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55431. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55432. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55433. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55434. * @param name defines the name of the mesh
  55435. * @param sourceMesh defines the mesh where the decal must be applied
  55436. * @param options defines the options used to create the mesh
  55437. * @param scene defines the hosting scene
  55438. * @returns the decal mesh
  55439. * @see https://doc.babylonjs.com/how_to/decals
  55440. */
  55441. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55442. position?: Vector3;
  55443. normal?: Vector3;
  55444. size?: Vector3;
  55445. angle?: number;
  55446. }): Mesh;
  55447. }
  55448. }
  55449. declare module BABYLON {
  55450. /**
  55451. * Class containing static functions to help procedurally build meshes
  55452. */
  55453. export class MeshBuilder {
  55454. /**
  55455. * Creates a box mesh
  55456. * * The parameter `size` sets the size (float) of each box side (default 1)
  55457. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55458. * * 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)
  55459. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55461. * * 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
  55462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55463. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55464. * @param name defines the name of the mesh
  55465. * @param options defines the options used to create the mesh
  55466. * @param scene defines the hosting scene
  55467. * @returns the box mesh
  55468. */
  55469. static CreateBox(name: string, options: {
  55470. size?: number;
  55471. width?: number;
  55472. height?: number;
  55473. depth?: number;
  55474. faceUV?: Vector4[];
  55475. faceColors?: Color4[];
  55476. sideOrientation?: number;
  55477. frontUVs?: Vector4;
  55478. backUVs?: Vector4;
  55479. updatable?: boolean;
  55480. }, scene?: Nullable<Scene>): Mesh;
  55481. /**
  55482. * Creates a tiled box mesh
  55483. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55485. * @param name defines the name of the mesh
  55486. * @param options defines the options used to create the mesh
  55487. * @param scene defines the hosting scene
  55488. * @returns the tiled box mesh
  55489. */
  55490. static CreateTiledBox(name: string, options: {
  55491. pattern?: number;
  55492. size?: number;
  55493. width?: number;
  55494. height?: number;
  55495. depth: number;
  55496. tileSize?: number;
  55497. tileWidth?: number;
  55498. tileHeight?: number;
  55499. faceUV?: Vector4[];
  55500. faceColors?: Color4[];
  55501. alignHorizontal?: number;
  55502. alignVertical?: number;
  55503. sideOrientation?: number;
  55504. updatable?: boolean;
  55505. }, scene?: Nullable<Scene>): Mesh;
  55506. /**
  55507. * Creates a sphere mesh
  55508. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55509. * * 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`)
  55510. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55511. * * 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
  55512. * * 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)
  55513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55514. * * 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
  55515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55516. * @param name defines the name of the mesh
  55517. * @param options defines the options used to create the mesh
  55518. * @param scene defines the hosting scene
  55519. * @returns the sphere mesh
  55520. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55521. */
  55522. static CreateSphere(name: string, options: {
  55523. segments?: number;
  55524. diameter?: number;
  55525. diameterX?: number;
  55526. diameterY?: number;
  55527. diameterZ?: number;
  55528. arc?: number;
  55529. slice?: number;
  55530. sideOrientation?: number;
  55531. frontUVs?: Vector4;
  55532. backUVs?: Vector4;
  55533. updatable?: boolean;
  55534. }, scene?: Nullable<Scene>): Mesh;
  55535. /**
  55536. * Creates a plane polygonal mesh. By default, this is a disc
  55537. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55538. * * 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
  55539. * * 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
  55540. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55541. * * 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
  55542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55543. * @param name defines the name of the mesh
  55544. * @param options defines the options used to create the mesh
  55545. * @param scene defines the hosting scene
  55546. * @returns the plane polygonal mesh
  55547. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55548. */
  55549. static CreateDisc(name: string, options: {
  55550. radius?: number;
  55551. tessellation?: number;
  55552. arc?: number;
  55553. updatable?: boolean;
  55554. sideOrientation?: number;
  55555. frontUVs?: Vector4;
  55556. backUVs?: Vector4;
  55557. }, scene?: Nullable<Scene>): Mesh;
  55558. /**
  55559. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55560. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55561. * * 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`)
  55562. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55563. * * 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
  55564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55565. * * 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
  55566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55567. * @param name defines the name of the mesh
  55568. * @param options defines the options used to create the mesh
  55569. * @param scene defines the hosting scene
  55570. * @returns the icosahedron mesh
  55571. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55572. */
  55573. static CreateIcoSphere(name: string, options: {
  55574. radius?: number;
  55575. radiusX?: number;
  55576. radiusY?: number;
  55577. radiusZ?: number;
  55578. flat?: boolean;
  55579. subdivisions?: number;
  55580. sideOrientation?: number;
  55581. frontUVs?: Vector4;
  55582. backUVs?: Vector4;
  55583. updatable?: boolean;
  55584. }, scene?: Nullable<Scene>): Mesh;
  55585. /**
  55586. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55587. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55588. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55589. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55590. * * 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
  55591. * * 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
  55592. * * 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
  55593. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55594. * * 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
  55595. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55596. * * 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
  55597. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55598. * * 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
  55599. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55601. * @param name defines the name of the mesh
  55602. * @param options defines the options used to create the mesh
  55603. * @param scene defines the hosting scene
  55604. * @returns the ribbon mesh
  55605. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55606. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55607. */
  55608. static CreateRibbon(name: string, options: {
  55609. pathArray: Vector3[][];
  55610. closeArray?: boolean;
  55611. closePath?: boolean;
  55612. offset?: number;
  55613. updatable?: boolean;
  55614. sideOrientation?: number;
  55615. frontUVs?: Vector4;
  55616. backUVs?: Vector4;
  55617. instance?: Mesh;
  55618. invertUV?: boolean;
  55619. uvs?: Vector2[];
  55620. colors?: Color4[];
  55621. }, scene?: Nullable<Scene>): Mesh;
  55622. /**
  55623. * Creates a cylinder or a cone mesh
  55624. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55625. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55626. * * 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.
  55627. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55628. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55629. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55630. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55631. * * 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).
  55632. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55633. * * 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).
  55634. * * 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
  55635. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55636. * * 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
  55637. * * 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.
  55638. * * If `enclose` is false, a ring surface is one element.
  55639. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55640. * * 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
  55641. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55642. * * 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
  55643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55644. * @param name defines the name of the mesh
  55645. * @param options defines the options used to create the mesh
  55646. * @param scene defines the hosting scene
  55647. * @returns the cylinder mesh
  55648. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55649. */
  55650. static CreateCylinder(name: string, options: {
  55651. height?: number;
  55652. diameterTop?: number;
  55653. diameterBottom?: number;
  55654. diameter?: number;
  55655. tessellation?: number;
  55656. subdivisions?: number;
  55657. arc?: number;
  55658. faceColors?: Color4[];
  55659. faceUV?: Vector4[];
  55660. updatable?: boolean;
  55661. hasRings?: boolean;
  55662. enclose?: boolean;
  55663. cap?: number;
  55664. sideOrientation?: number;
  55665. frontUVs?: Vector4;
  55666. backUVs?: Vector4;
  55667. }, scene?: Nullable<Scene>): Mesh;
  55668. /**
  55669. * Creates a torus mesh
  55670. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55671. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55672. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55674. * * 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
  55675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55676. * @param name defines the name of the mesh
  55677. * @param options defines the options used to create the mesh
  55678. * @param scene defines the hosting scene
  55679. * @returns the torus mesh
  55680. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55681. */
  55682. static CreateTorus(name: string, options: {
  55683. diameter?: number;
  55684. thickness?: number;
  55685. tessellation?: number;
  55686. updatable?: boolean;
  55687. sideOrientation?: number;
  55688. frontUVs?: Vector4;
  55689. backUVs?: Vector4;
  55690. }, scene?: Nullable<Scene>): Mesh;
  55691. /**
  55692. * Creates a torus knot mesh
  55693. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55694. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55695. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55696. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55698. * * 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
  55699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55700. * @param name defines the name of the mesh
  55701. * @param options defines the options used to create the mesh
  55702. * @param scene defines the hosting scene
  55703. * @returns the torus knot mesh
  55704. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55705. */
  55706. static CreateTorusKnot(name: string, options: {
  55707. radius?: number;
  55708. tube?: number;
  55709. radialSegments?: number;
  55710. tubularSegments?: number;
  55711. p?: number;
  55712. q?: number;
  55713. updatable?: boolean;
  55714. sideOrientation?: number;
  55715. frontUVs?: Vector4;
  55716. backUVs?: Vector4;
  55717. }, scene?: Nullable<Scene>): Mesh;
  55718. /**
  55719. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55720. * * 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
  55721. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55722. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55723. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55724. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55725. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55726. * * 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
  55727. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55729. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55730. * @param name defines the name of the new line system
  55731. * @param options defines the options used to create the line system
  55732. * @param scene defines the hosting scene
  55733. * @returns a new line system mesh
  55734. */
  55735. static CreateLineSystem(name: string, options: {
  55736. lines: Vector3[][];
  55737. updatable?: boolean;
  55738. instance?: Nullable<LinesMesh>;
  55739. colors?: Nullable<Color4[][]>;
  55740. useVertexAlpha?: boolean;
  55741. }, scene: Nullable<Scene>): LinesMesh;
  55742. /**
  55743. * Creates a line mesh
  55744. * 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
  55745. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55746. * * The parameter `points` is an array successive Vector3
  55747. * * 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
  55748. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55749. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55750. * * When updating an instance, remember that only point positions can change, not the number of points
  55751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55752. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55753. * @param name defines the name of the new line system
  55754. * @param options defines the options used to create the line system
  55755. * @param scene defines the hosting scene
  55756. * @returns a new line mesh
  55757. */
  55758. static CreateLines(name: string, options: {
  55759. points: Vector3[];
  55760. updatable?: boolean;
  55761. instance?: Nullable<LinesMesh>;
  55762. colors?: Color4[];
  55763. useVertexAlpha?: boolean;
  55764. }, scene?: Nullable<Scene>): LinesMesh;
  55765. /**
  55766. * Creates a dashed line mesh
  55767. * * 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
  55768. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55769. * * The parameter `points` is an array successive Vector3
  55770. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55771. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55772. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55773. * * 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
  55774. * * When updating an instance, remember that only point positions can change, not the number of points
  55775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55776. * @param name defines the name of the mesh
  55777. * @param options defines the options used to create the mesh
  55778. * @param scene defines the hosting scene
  55779. * @returns the dashed line mesh
  55780. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55781. */
  55782. static CreateDashedLines(name: string, options: {
  55783. points: Vector3[];
  55784. dashSize?: number;
  55785. gapSize?: number;
  55786. dashNb?: number;
  55787. updatable?: boolean;
  55788. instance?: LinesMesh;
  55789. }, scene?: Nullable<Scene>): LinesMesh;
  55790. /**
  55791. * 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.
  55792. * * 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.
  55793. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55794. * * 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.
  55795. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55796. * * 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
  55797. * * 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
  55798. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55799. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55800. * * 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
  55801. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55802. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55803. * @param name defines the name of the mesh
  55804. * @param options defines the options used to create the mesh
  55805. * @param scene defines the hosting scene
  55806. * @returns the extruded shape mesh
  55807. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55808. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55809. */
  55810. static ExtrudeShape(name: string, options: {
  55811. shape: Vector3[];
  55812. path: Vector3[];
  55813. scale?: number;
  55814. rotation?: number;
  55815. cap?: number;
  55816. updatable?: boolean;
  55817. sideOrientation?: number;
  55818. frontUVs?: Vector4;
  55819. backUVs?: Vector4;
  55820. instance?: Mesh;
  55821. invertUV?: boolean;
  55822. }, scene?: Nullable<Scene>): Mesh;
  55823. /**
  55824. * Creates an custom extruded shape mesh.
  55825. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55826. * * 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.
  55827. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55828. * * 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
  55829. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55830. * * 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
  55831. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55832. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55833. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55834. * * 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
  55835. * * 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
  55836. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55838. * * 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
  55839. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55841. * @param name defines the name of the mesh
  55842. * @param options defines the options used to create the mesh
  55843. * @param scene defines the hosting scene
  55844. * @returns the custom extruded shape mesh
  55845. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55846. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55847. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55848. */
  55849. static ExtrudeShapeCustom(name: string, options: {
  55850. shape: Vector3[];
  55851. path: Vector3[];
  55852. scaleFunction?: any;
  55853. rotationFunction?: any;
  55854. ribbonCloseArray?: boolean;
  55855. ribbonClosePath?: boolean;
  55856. cap?: number;
  55857. updatable?: boolean;
  55858. sideOrientation?: number;
  55859. frontUVs?: Vector4;
  55860. backUVs?: Vector4;
  55861. instance?: Mesh;
  55862. invertUV?: boolean;
  55863. }, scene?: Nullable<Scene>): Mesh;
  55864. /**
  55865. * Creates lathe mesh.
  55866. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55867. * * 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
  55868. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55869. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55870. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55871. * * 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
  55872. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55873. * * 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
  55874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55875. * * 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
  55876. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55878. * @param name defines the name of the mesh
  55879. * @param options defines the options used to create the mesh
  55880. * @param scene defines the hosting scene
  55881. * @returns the lathe mesh
  55882. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55883. */
  55884. static CreateLathe(name: string, options: {
  55885. shape: Vector3[];
  55886. radius?: number;
  55887. tessellation?: number;
  55888. clip?: number;
  55889. arc?: number;
  55890. closed?: boolean;
  55891. updatable?: boolean;
  55892. sideOrientation?: number;
  55893. frontUVs?: Vector4;
  55894. backUVs?: Vector4;
  55895. cap?: number;
  55896. invertUV?: boolean;
  55897. }, scene?: Nullable<Scene>): Mesh;
  55898. /**
  55899. * Creates a tiled plane mesh
  55900. * * You can set a limited pattern arrangement with the tiles
  55901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55902. * * 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
  55903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55904. * @param name defines the name of the mesh
  55905. * @param options defines the options used to create the mesh
  55906. * @param scene defines the hosting scene
  55907. * @returns the plane mesh
  55908. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55909. */
  55910. static CreateTiledPlane(name: string, options: {
  55911. pattern?: number;
  55912. tileSize?: number;
  55913. tileWidth?: number;
  55914. tileHeight?: number;
  55915. size?: number;
  55916. width?: number;
  55917. height?: number;
  55918. alignHorizontal?: number;
  55919. alignVertical?: number;
  55920. sideOrientation?: number;
  55921. frontUVs?: Vector4;
  55922. backUVs?: Vector4;
  55923. updatable?: boolean;
  55924. }, scene?: Nullable<Scene>): Mesh;
  55925. /**
  55926. * Creates a plane mesh
  55927. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55928. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55929. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55931. * * 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
  55932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55933. * @param name defines the name of the mesh
  55934. * @param options defines the options used to create the mesh
  55935. * @param scene defines the hosting scene
  55936. * @returns the plane mesh
  55937. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55938. */
  55939. static CreatePlane(name: string, options: {
  55940. size?: number;
  55941. width?: number;
  55942. height?: number;
  55943. sideOrientation?: number;
  55944. frontUVs?: Vector4;
  55945. backUVs?: Vector4;
  55946. updatable?: boolean;
  55947. sourcePlane?: Plane;
  55948. }, scene?: Nullable<Scene>): Mesh;
  55949. /**
  55950. * Creates a ground mesh
  55951. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55952. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55954. * @param name defines the name of the mesh
  55955. * @param options defines the options used to create the mesh
  55956. * @param scene defines the hosting scene
  55957. * @returns the ground mesh
  55958. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55959. */
  55960. static CreateGround(name: string, options: {
  55961. width?: number;
  55962. height?: number;
  55963. subdivisions?: number;
  55964. subdivisionsX?: number;
  55965. subdivisionsY?: number;
  55966. updatable?: boolean;
  55967. }, scene?: Nullable<Scene>): Mesh;
  55968. /**
  55969. * Creates a tiled ground mesh
  55970. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55971. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55972. * * 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
  55973. * * 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
  55974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55975. * @param name defines the name of the mesh
  55976. * @param options defines the options used to create the mesh
  55977. * @param scene defines the hosting scene
  55978. * @returns the tiled ground mesh
  55979. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55980. */
  55981. static CreateTiledGround(name: string, options: {
  55982. xmin: number;
  55983. zmin: number;
  55984. xmax: number;
  55985. zmax: number;
  55986. subdivisions?: {
  55987. w: number;
  55988. h: number;
  55989. };
  55990. precision?: {
  55991. w: number;
  55992. h: number;
  55993. };
  55994. updatable?: boolean;
  55995. }, scene?: Nullable<Scene>): Mesh;
  55996. /**
  55997. * Creates a ground mesh from a height map
  55998. * * The parameter `url` sets the URL of the height map image resource.
  55999. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56000. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56001. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56002. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56003. * * 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.
  56004. * * 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).
  56005. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56007. * @param name defines the name of the mesh
  56008. * @param url defines the url to the height map
  56009. * @param options defines the options used to create the mesh
  56010. * @param scene defines the hosting scene
  56011. * @returns the ground mesh
  56012. * @see https://doc.babylonjs.com/babylon101/height_map
  56013. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56014. */
  56015. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56016. width?: number;
  56017. height?: number;
  56018. subdivisions?: number;
  56019. minHeight?: number;
  56020. maxHeight?: number;
  56021. colorFilter?: Color3;
  56022. alphaFilter?: number;
  56023. updatable?: boolean;
  56024. onReady?: (mesh: GroundMesh) => void;
  56025. }, scene?: Nullable<Scene>): GroundMesh;
  56026. /**
  56027. * Creates a polygon mesh
  56028. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56029. * * 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
  56030. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56032. * * 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)
  56033. * * Remember you can only change the shape positions, not their number when updating a polygon
  56034. * @param name defines the name of the mesh
  56035. * @param options defines the options used to create the mesh
  56036. * @param scene defines the hosting scene
  56037. * @param earcutInjection can be used to inject your own earcut reference
  56038. * @returns the polygon mesh
  56039. */
  56040. static CreatePolygon(name: string, options: {
  56041. shape: Vector3[];
  56042. holes?: Vector3[][];
  56043. depth?: number;
  56044. faceUV?: Vector4[];
  56045. faceColors?: Color4[];
  56046. updatable?: boolean;
  56047. sideOrientation?: number;
  56048. frontUVs?: Vector4;
  56049. backUVs?: Vector4;
  56050. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56051. /**
  56052. * Creates an extruded polygon mesh, with depth in the Y direction.
  56053. * * 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)
  56054. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56055. * @param name defines the name of the mesh
  56056. * @param options defines the options used to create the mesh
  56057. * @param scene defines the hosting scene
  56058. * @param earcutInjection can be used to inject your own earcut reference
  56059. * @returns the polygon mesh
  56060. */
  56061. static ExtrudePolygon(name: string, options: {
  56062. shape: Vector3[];
  56063. holes?: Vector3[][];
  56064. depth?: number;
  56065. faceUV?: Vector4[];
  56066. faceColors?: Color4[];
  56067. updatable?: boolean;
  56068. sideOrientation?: number;
  56069. frontUVs?: Vector4;
  56070. backUVs?: Vector4;
  56071. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56072. /**
  56073. * Creates a tube mesh.
  56074. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56075. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56076. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56077. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56078. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56079. * * 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)
  56080. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56081. * * 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
  56082. * * 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
  56083. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56084. * * 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
  56085. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56087. * @param name defines the name of the mesh
  56088. * @param options defines the options used to create the mesh
  56089. * @param scene defines the hosting scene
  56090. * @returns the tube mesh
  56091. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56092. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56093. */
  56094. static CreateTube(name: string, options: {
  56095. path: Vector3[];
  56096. radius?: number;
  56097. tessellation?: number;
  56098. radiusFunction?: {
  56099. (i: number, distance: number): number;
  56100. };
  56101. cap?: number;
  56102. arc?: number;
  56103. updatable?: boolean;
  56104. sideOrientation?: number;
  56105. frontUVs?: Vector4;
  56106. backUVs?: Vector4;
  56107. instance?: Mesh;
  56108. invertUV?: boolean;
  56109. }, scene?: Nullable<Scene>): Mesh;
  56110. /**
  56111. * Creates a polyhedron mesh
  56112. * * 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
  56113. * * The parameter `size` (positive float, default 1) sets the polygon size
  56114. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56115. * * 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`
  56116. * * 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
  56117. * * 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)`)
  56118. * * 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
  56119. * * 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
  56120. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56121. * * 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
  56122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56123. * @param name defines the name of the mesh
  56124. * @param options defines the options used to create the mesh
  56125. * @param scene defines the hosting scene
  56126. * @returns the polyhedron mesh
  56127. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56128. */
  56129. static CreatePolyhedron(name: string, options: {
  56130. type?: number;
  56131. size?: number;
  56132. sizeX?: number;
  56133. sizeY?: number;
  56134. sizeZ?: number;
  56135. custom?: any;
  56136. faceUV?: Vector4[];
  56137. faceColors?: Color4[];
  56138. flat?: boolean;
  56139. updatable?: boolean;
  56140. sideOrientation?: number;
  56141. frontUVs?: Vector4;
  56142. backUVs?: Vector4;
  56143. }, scene?: Nullable<Scene>): Mesh;
  56144. /**
  56145. * Creates a decal mesh.
  56146. * 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
  56147. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56148. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56149. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56150. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56151. * @param name defines the name of the mesh
  56152. * @param sourceMesh defines the mesh where the decal must be applied
  56153. * @param options defines the options used to create the mesh
  56154. * @param scene defines the hosting scene
  56155. * @returns the decal mesh
  56156. * @see https://doc.babylonjs.com/how_to/decals
  56157. */
  56158. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56159. position?: Vector3;
  56160. normal?: Vector3;
  56161. size?: Vector3;
  56162. angle?: number;
  56163. }): Mesh;
  56164. }
  56165. }
  56166. declare module BABYLON {
  56167. /**
  56168. * A simplifier interface for future simplification implementations
  56169. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56170. */
  56171. export interface ISimplifier {
  56172. /**
  56173. * Simplification of a given mesh according to the given settings.
  56174. * Since this requires computation, it is assumed that the function runs async.
  56175. * @param settings The settings of the simplification, including quality and distance
  56176. * @param successCallback A callback that will be called after the mesh was simplified.
  56177. * @param errorCallback in case of an error, this callback will be called. optional.
  56178. */
  56179. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56180. }
  56181. /**
  56182. * Expected simplification settings.
  56183. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56184. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56185. */
  56186. export interface ISimplificationSettings {
  56187. /**
  56188. * Gets or sets the expected quality
  56189. */
  56190. quality: number;
  56191. /**
  56192. * Gets or sets the distance when this optimized version should be used
  56193. */
  56194. distance: number;
  56195. /**
  56196. * Gets an already optimized mesh
  56197. */
  56198. optimizeMesh?: boolean;
  56199. }
  56200. /**
  56201. * Class used to specify simplification options
  56202. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56203. */
  56204. export class SimplificationSettings implements ISimplificationSettings {
  56205. /** expected quality */
  56206. quality: number;
  56207. /** distance when this optimized version should be used */
  56208. distance: number;
  56209. /** already optimized mesh */
  56210. optimizeMesh?: boolean | undefined;
  56211. /**
  56212. * Creates a SimplificationSettings
  56213. * @param quality expected quality
  56214. * @param distance distance when this optimized version should be used
  56215. * @param optimizeMesh already optimized mesh
  56216. */
  56217. constructor(
  56218. /** expected quality */
  56219. quality: number,
  56220. /** distance when this optimized version should be used */
  56221. distance: number,
  56222. /** already optimized mesh */
  56223. optimizeMesh?: boolean | undefined);
  56224. }
  56225. /**
  56226. * Interface used to define a simplification task
  56227. */
  56228. export interface ISimplificationTask {
  56229. /**
  56230. * Array of settings
  56231. */
  56232. settings: Array<ISimplificationSettings>;
  56233. /**
  56234. * Simplification type
  56235. */
  56236. simplificationType: SimplificationType;
  56237. /**
  56238. * Mesh to simplify
  56239. */
  56240. mesh: Mesh;
  56241. /**
  56242. * Callback called on success
  56243. */
  56244. successCallback?: () => void;
  56245. /**
  56246. * Defines if parallel processing can be used
  56247. */
  56248. parallelProcessing: boolean;
  56249. }
  56250. /**
  56251. * Queue used to order the simplification tasks
  56252. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56253. */
  56254. export class SimplificationQueue {
  56255. private _simplificationArray;
  56256. /**
  56257. * Gets a boolean indicating that the process is still running
  56258. */
  56259. running: boolean;
  56260. /**
  56261. * Creates a new queue
  56262. */
  56263. constructor();
  56264. /**
  56265. * Adds a new simplification task
  56266. * @param task defines a task to add
  56267. */
  56268. addTask(task: ISimplificationTask): void;
  56269. /**
  56270. * Execute next task
  56271. */
  56272. executeNext(): void;
  56273. /**
  56274. * Execute a simplification task
  56275. * @param task defines the task to run
  56276. */
  56277. runSimplification(task: ISimplificationTask): void;
  56278. private getSimplifier;
  56279. }
  56280. /**
  56281. * The implemented types of simplification
  56282. * At the moment only Quadratic Error Decimation is implemented
  56283. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56284. */
  56285. export enum SimplificationType {
  56286. /** Quadratic error decimation */
  56287. QUADRATIC = 0
  56288. }
  56289. }
  56290. declare module BABYLON {
  56291. interface Scene {
  56292. /** @hidden (Backing field) */
  56293. _simplificationQueue: SimplificationQueue;
  56294. /**
  56295. * Gets or sets the simplification queue attached to the scene
  56296. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56297. */
  56298. simplificationQueue: SimplificationQueue;
  56299. }
  56300. interface Mesh {
  56301. /**
  56302. * Simplify the mesh according to the given array of settings.
  56303. * Function will return immediately and will simplify async
  56304. * @param settings a collection of simplification settings
  56305. * @param parallelProcessing should all levels calculate parallel or one after the other
  56306. * @param simplificationType the type of simplification to run
  56307. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56308. * @returns the current mesh
  56309. */
  56310. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56311. }
  56312. /**
  56313. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56314. * created in a scene
  56315. */
  56316. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56317. /**
  56318. * The component name helpfull to identify the component in the list of scene components.
  56319. */
  56320. readonly name: string;
  56321. /**
  56322. * The scene the component belongs to.
  56323. */
  56324. scene: Scene;
  56325. /**
  56326. * Creates a new instance of the component for the given scene
  56327. * @param scene Defines the scene to register the component in
  56328. */
  56329. constructor(scene: Scene);
  56330. /**
  56331. * Registers the component in a given scene
  56332. */
  56333. register(): void;
  56334. /**
  56335. * Rebuilds the elements related to this component in case of
  56336. * context lost for instance.
  56337. */
  56338. rebuild(): void;
  56339. /**
  56340. * Disposes the component and the associated ressources
  56341. */
  56342. dispose(): void;
  56343. private _beforeCameraUpdate;
  56344. }
  56345. }
  56346. declare module BABYLON {
  56347. /**
  56348. * Navigation plugin interface to add navigation constrained by a navigation mesh
  56349. */
  56350. export interface INavigationEnginePlugin {
  56351. /**
  56352. * plugin name
  56353. */
  56354. name: string;
  56355. /**
  56356. * Creates a navigation mesh
  56357. * @param meshes array of all the geometry used to compute the navigatio mesh
  56358. * @param parameters bunch of parameters used to filter geometry
  56359. */
  56360. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56361. /**
  56362. * Create a navigation mesh debug mesh
  56363. * @param scene is where the mesh will be added
  56364. * @returns debug display mesh
  56365. */
  56366. createDebugNavMesh(scene: Scene): Mesh;
  56367. /**
  56368. * Get a navigation mesh constrained position, closest to the parameter position
  56369. * @param position world position
  56370. * @returns the closest point to position constrained by the navigation mesh
  56371. */
  56372. getClosestPoint(position: Vector3): Vector3;
  56373. /**
  56374. * Get a navigation mesh constrained position, within a particular radius
  56375. * @param position world position
  56376. * @param maxRadius the maximum distance to the constrained world position
  56377. * @returns the closest point to position constrained by the navigation mesh
  56378. */
  56379. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56380. /**
  56381. * Compute the final position from a segment made of destination-position
  56382. * @param position world position
  56383. * @param destination world position
  56384. * @returns the resulting point along the navmesh
  56385. */
  56386. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56387. /**
  56388. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56389. * @param start world position
  56390. * @param end world position
  56391. * @returns array containing world position composing the path
  56392. */
  56393. computePath(start: Vector3, end: Vector3): Vector3[];
  56394. /**
  56395. * If this plugin is supported
  56396. * @returns true if plugin is supported
  56397. */
  56398. isSupported(): boolean;
  56399. /**
  56400. * Create a new Crowd so you can add agents
  56401. * @param maxAgents the maximum agent count in the crowd
  56402. * @param maxAgentRadius the maximum radius an agent can have
  56403. * @param scene to attach the crowd to
  56404. * @returns the crowd you can add agents to
  56405. */
  56406. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56407. /**
  56408. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56409. * The queries will try to find a solution within those bounds
  56410. * default is (1,1,1)
  56411. * @param extent x,y,z value that define the extent around the queries point of reference
  56412. */
  56413. setDefaultQueryExtent(extent: Vector3): void;
  56414. /**
  56415. * Get the Bounding box extent specified by setDefaultQueryExtent
  56416. * @returns the box extent values
  56417. */
  56418. getDefaultQueryExtent(): Vector3;
  56419. /**
  56420. * Release all resources
  56421. */
  56422. dispose(): void;
  56423. }
  56424. /**
  56425. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  56426. */
  56427. export interface ICrowd {
  56428. /**
  56429. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56430. * You can attach anything to that node. The node position is updated in the scene update tick.
  56431. * @param pos world position that will be constrained by the navigation mesh
  56432. * @param parameters agent parameters
  56433. * @param transform hooked to the agent that will be update by the scene
  56434. * @returns agent index
  56435. */
  56436. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56437. /**
  56438. * Returns the agent position in world space
  56439. * @param index agent index returned by addAgent
  56440. * @returns world space position
  56441. */
  56442. getAgentPosition(index: number): Vector3;
  56443. /**
  56444. * Gets the agent velocity in world space
  56445. * @param index agent index returned by addAgent
  56446. * @returns world space velocity
  56447. */
  56448. getAgentVelocity(index: number): Vector3;
  56449. /**
  56450. * remove a particular agent previously created
  56451. * @param index agent index returned by addAgent
  56452. */
  56453. removeAgent(index: number): void;
  56454. /**
  56455. * get the list of all agents attached to this crowd
  56456. * @returns list of agent indices
  56457. */
  56458. getAgents(): number[];
  56459. /**
  56460. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56461. * @param deltaTime in seconds
  56462. */
  56463. update(deltaTime: number): void;
  56464. /**
  56465. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56466. * @param index agent index returned by addAgent
  56467. * @param destination targeted world position
  56468. */
  56469. agentGoto(index: number, destination: Vector3): void;
  56470. /**
  56471. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56472. * The queries will try to find a solution within those bounds
  56473. * default is (1,1,1)
  56474. * @param extent x,y,z value that define the extent around the queries point of reference
  56475. */
  56476. setDefaultQueryExtent(extent: Vector3): void;
  56477. /**
  56478. * Get the Bounding box extent specified by setDefaultQueryExtent
  56479. * @returns the box extent values
  56480. */
  56481. getDefaultQueryExtent(): Vector3;
  56482. /**
  56483. * Release all resources
  56484. */
  56485. dispose(): void;
  56486. }
  56487. /**
  56488. * Configures an agent
  56489. */
  56490. export interface IAgentParameters {
  56491. /**
  56492. * Agent radius. [Limit: >= 0]
  56493. */
  56494. radius: number;
  56495. /**
  56496. * Agent height. [Limit: > 0]
  56497. */
  56498. height: number;
  56499. /**
  56500. * Maximum allowed acceleration. [Limit: >= 0]
  56501. */
  56502. maxAcceleration: number;
  56503. /**
  56504. * Maximum allowed speed. [Limit: >= 0]
  56505. */
  56506. maxSpeed: number;
  56507. /**
  56508. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  56509. */
  56510. collisionQueryRange: number;
  56511. /**
  56512. * The path visibility optimization range. [Limit: > 0]
  56513. */
  56514. pathOptimizationRange: number;
  56515. /**
  56516. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  56517. */
  56518. separationWeight: number;
  56519. }
  56520. /**
  56521. * Configures the navigation mesh creation
  56522. */
  56523. export interface INavMeshParameters {
  56524. /**
  56525. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  56526. */
  56527. cs: number;
  56528. /**
  56529. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  56530. */
  56531. ch: number;
  56532. /**
  56533. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  56534. */
  56535. walkableSlopeAngle: number;
  56536. /**
  56537. * Minimum floor to 'ceiling' height that will still allow the floor area to
  56538. * be considered walkable. [Limit: >= 3] [Units: vx]
  56539. */
  56540. walkableHeight: number;
  56541. /**
  56542. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  56543. */
  56544. walkableClimb: number;
  56545. /**
  56546. * The distance to erode/shrink the walkable area of the heightfield away from
  56547. * obstructions. [Limit: >=0] [Units: vx]
  56548. */
  56549. walkableRadius: number;
  56550. /**
  56551. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  56552. */
  56553. maxEdgeLen: number;
  56554. /**
  56555. * The maximum distance a simplfied contour's border edges should deviate
  56556. * the original raw contour. [Limit: >=0] [Units: vx]
  56557. */
  56558. maxSimplificationError: number;
  56559. /**
  56560. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  56561. */
  56562. minRegionArea: number;
  56563. /**
  56564. * Any regions with a span count smaller than this value will, if possible,
  56565. * be merged with larger regions. [Limit: >=0] [Units: vx]
  56566. */
  56567. mergeRegionArea: number;
  56568. /**
  56569. * The maximum number of vertices allowed for polygons generated during the
  56570. * contour to polygon conversion process. [Limit: >= 3]
  56571. */
  56572. maxVertsPerPoly: number;
  56573. /**
  56574. * Sets the sampling distance to use when generating the detail mesh.
  56575. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  56576. */
  56577. detailSampleDist: number;
  56578. /**
  56579. * The maximum distance the detail mesh surface should deviate from heightfield
  56580. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  56581. */
  56582. detailSampleMaxError: number;
  56583. }
  56584. }
  56585. declare module BABYLON {
  56586. /**
  56587. * RecastJS navigation plugin
  56588. */
  56589. export class RecastJSPlugin implements INavigationEnginePlugin {
  56590. /**
  56591. * Reference to the Recast library
  56592. */
  56593. bjsRECAST: any;
  56594. /**
  56595. * plugin name
  56596. */
  56597. name: string;
  56598. /**
  56599. * the first navmesh created. We might extend this to support multiple navmeshes
  56600. */
  56601. navMesh: any;
  56602. /**
  56603. * Initializes the recastJS plugin
  56604. * @param recastInjection can be used to inject your own recast reference
  56605. */
  56606. constructor(recastInjection?: any);
  56607. /**
  56608. * Creates a navigation mesh
  56609. * @param meshes array of all the geometry used to compute the navigatio mesh
  56610. * @param parameters bunch of parameters used to filter geometry
  56611. */
  56612. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56613. /**
  56614. * Create a navigation mesh debug mesh
  56615. * @param scene is where the mesh will be added
  56616. * @returns debug display mesh
  56617. */
  56618. createDebugNavMesh(scene: Scene): Mesh;
  56619. /**
  56620. * Get a navigation mesh constrained position, closest to the parameter position
  56621. * @param position world position
  56622. * @returns the closest point to position constrained by the navigation mesh
  56623. */
  56624. getClosestPoint(position: Vector3): Vector3;
  56625. /**
  56626. * Get a navigation mesh constrained position, within a particular radius
  56627. * @param position world position
  56628. * @param maxRadius the maximum distance to the constrained world position
  56629. * @returns the closest point to position constrained by the navigation mesh
  56630. */
  56631. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56632. /**
  56633. * Compute the final position from a segment made of destination-position
  56634. * @param position world position
  56635. * @param destination world position
  56636. * @returns the resulting point along the navmesh
  56637. */
  56638. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56639. /**
  56640. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56641. * @param start world position
  56642. * @param end world position
  56643. * @returns array containing world position composing the path
  56644. */
  56645. computePath(start: Vector3, end: Vector3): Vector3[];
  56646. /**
  56647. * Create a new Crowd so you can add agents
  56648. * @param maxAgents the maximum agent count in the crowd
  56649. * @param maxAgentRadius the maximum radius an agent can have
  56650. * @param scene to attach the crowd to
  56651. * @returns the crowd you can add agents to
  56652. */
  56653. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56654. /**
  56655. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56656. * The queries will try to find a solution within those bounds
  56657. * default is (1,1,1)
  56658. * @param extent x,y,z value that define the extent around the queries point of reference
  56659. */
  56660. setDefaultQueryExtent(extent: Vector3): void;
  56661. /**
  56662. * Get the Bounding box extent specified by setDefaultQueryExtent
  56663. * @returns the box extent values
  56664. */
  56665. getDefaultQueryExtent(): Vector3;
  56666. /**
  56667. * Disposes
  56668. */
  56669. dispose(): void;
  56670. /**
  56671. * If this plugin is supported
  56672. * @returns true if plugin is supported
  56673. */
  56674. isSupported(): boolean;
  56675. }
  56676. /**
  56677. * Recast detour crowd implementation
  56678. */
  56679. export class RecastJSCrowd implements ICrowd {
  56680. /**
  56681. * Recast/detour plugin
  56682. */
  56683. bjsRECASTPlugin: RecastJSPlugin;
  56684. /**
  56685. * Link to the detour crowd
  56686. */
  56687. recastCrowd: any;
  56688. /**
  56689. * One transform per agent
  56690. */
  56691. transforms: TransformNode[];
  56692. /**
  56693. * All agents created
  56694. */
  56695. agents: number[];
  56696. /**
  56697. * Link to the scene is kept to unregister the crowd from the scene
  56698. */
  56699. private _scene;
  56700. /**
  56701. * Observer for crowd updates
  56702. */
  56703. private _onBeforeAnimationsObserver;
  56704. /**
  56705. * Constructor
  56706. * @param plugin recastJS plugin
  56707. * @param maxAgents the maximum agent count in the crowd
  56708. * @param maxAgentRadius the maximum radius an agent can have
  56709. * @param scene to attach the crowd to
  56710. * @returns the crowd you can add agents to
  56711. */
  56712. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  56713. /**
  56714. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56715. * You can attach anything to that node. The node position is updated in the scene update tick.
  56716. * @param pos world position that will be constrained by the navigation mesh
  56717. * @param parameters agent parameters
  56718. * @param transform hooked to the agent that will be update by the scene
  56719. * @returns agent index
  56720. */
  56721. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56722. /**
  56723. * Returns the agent position in world space
  56724. * @param index agent index returned by addAgent
  56725. * @returns world space position
  56726. */
  56727. getAgentPosition(index: number): Vector3;
  56728. /**
  56729. * Returns the agent velocity in world space
  56730. * @param index agent index returned by addAgent
  56731. * @returns world space velocity
  56732. */
  56733. getAgentVelocity(index: number): Vector3;
  56734. /**
  56735. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56736. * @param index agent index returned by addAgent
  56737. * @param destination targeted world position
  56738. */
  56739. agentGoto(index: number, destination: Vector3): void;
  56740. /**
  56741. * remove a particular agent previously created
  56742. * @param index agent index returned by addAgent
  56743. */
  56744. removeAgent(index: number): void;
  56745. /**
  56746. * get the list of all agents attached to this crowd
  56747. * @returns list of agent indices
  56748. */
  56749. getAgents(): number[];
  56750. /**
  56751. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56752. * @param deltaTime in seconds
  56753. */
  56754. update(deltaTime: number): void;
  56755. /**
  56756. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56757. * The queries will try to find a solution within those bounds
  56758. * default is (1,1,1)
  56759. * @param extent x,y,z value that define the extent around the queries point of reference
  56760. */
  56761. setDefaultQueryExtent(extent: Vector3): void;
  56762. /**
  56763. * Get the Bounding box extent specified by setDefaultQueryExtent
  56764. * @returns the box extent values
  56765. */
  56766. getDefaultQueryExtent(): Vector3;
  56767. /**
  56768. * Release all resources
  56769. */
  56770. dispose(): void;
  56771. }
  56772. }
  56773. declare module BABYLON {
  56774. /**
  56775. * Class used to enable access to IndexedDB
  56776. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56777. */
  56778. export class Database implements IOfflineProvider {
  56779. private _callbackManifestChecked;
  56780. private _currentSceneUrl;
  56781. private _db;
  56782. private _enableSceneOffline;
  56783. private _enableTexturesOffline;
  56784. private _manifestVersionFound;
  56785. private _mustUpdateRessources;
  56786. private _hasReachedQuota;
  56787. private _isSupported;
  56788. private _idbFactory;
  56789. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56790. private static IsUASupportingBlobStorage;
  56791. /**
  56792. * Gets a boolean indicating if Database storate is enabled (off by default)
  56793. */
  56794. static IDBStorageEnabled: boolean;
  56795. /**
  56796. * Gets a boolean indicating if scene must be saved in the database
  56797. */
  56798. readonly enableSceneOffline: boolean;
  56799. /**
  56800. * Gets a boolean indicating if textures must be saved in the database
  56801. */
  56802. readonly enableTexturesOffline: boolean;
  56803. /**
  56804. * Creates a new Database
  56805. * @param urlToScene defines the url to load the scene
  56806. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56807. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56808. */
  56809. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56810. private static _ParseURL;
  56811. private static _ReturnFullUrlLocation;
  56812. private _checkManifestFile;
  56813. /**
  56814. * Open the database and make it available
  56815. * @param successCallback defines the callback to call on success
  56816. * @param errorCallback defines the callback to call on error
  56817. */
  56818. open(successCallback: () => void, errorCallback: () => void): void;
  56819. /**
  56820. * Loads an image from the database
  56821. * @param url defines the url to load from
  56822. * @param image defines the target DOM image
  56823. */
  56824. loadImage(url: string, image: HTMLImageElement): void;
  56825. private _loadImageFromDBAsync;
  56826. private _saveImageIntoDBAsync;
  56827. private _checkVersionFromDB;
  56828. private _loadVersionFromDBAsync;
  56829. private _saveVersionIntoDBAsync;
  56830. /**
  56831. * Loads a file from database
  56832. * @param url defines the URL to load from
  56833. * @param sceneLoaded defines a callback to call on success
  56834. * @param progressCallBack defines a callback to call when progress changed
  56835. * @param errorCallback defines a callback to call on error
  56836. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56837. */
  56838. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56839. private _loadFileAsync;
  56840. private _saveFileAsync;
  56841. /**
  56842. * Validates if xhr data is correct
  56843. * @param xhr defines the request to validate
  56844. * @param dataType defines the expected data type
  56845. * @returns true if data is correct
  56846. */
  56847. private static _ValidateXHRData;
  56848. }
  56849. }
  56850. declare module BABYLON {
  56851. /** @hidden */
  56852. export var gpuUpdateParticlesPixelShader: {
  56853. name: string;
  56854. shader: string;
  56855. };
  56856. }
  56857. declare module BABYLON {
  56858. /** @hidden */
  56859. export var gpuUpdateParticlesVertexShader: {
  56860. name: string;
  56861. shader: string;
  56862. };
  56863. }
  56864. declare module BABYLON {
  56865. /** @hidden */
  56866. export var clipPlaneFragmentDeclaration2: {
  56867. name: string;
  56868. shader: string;
  56869. };
  56870. }
  56871. declare module BABYLON {
  56872. /** @hidden */
  56873. export var gpuRenderParticlesPixelShader: {
  56874. name: string;
  56875. shader: string;
  56876. };
  56877. }
  56878. declare module BABYLON {
  56879. /** @hidden */
  56880. export var clipPlaneVertexDeclaration2: {
  56881. name: string;
  56882. shader: string;
  56883. };
  56884. }
  56885. declare module BABYLON {
  56886. /** @hidden */
  56887. export var gpuRenderParticlesVertexShader: {
  56888. name: string;
  56889. shader: string;
  56890. };
  56891. }
  56892. declare module BABYLON {
  56893. /**
  56894. * This represents a GPU particle system in Babylon
  56895. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56896. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56897. */
  56898. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56899. /**
  56900. * The layer mask we are rendering the particles through.
  56901. */
  56902. layerMask: number;
  56903. private _capacity;
  56904. private _activeCount;
  56905. private _currentActiveCount;
  56906. private _accumulatedCount;
  56907. private _renderEffect;
  56908. private _updateEffect;
  56909. private _buffer0;
  56910. private _buffer1;
  56911. private _spriteBuffer;
  56912. private _updateVAO;
  56913. private _renderVAO;
  56914. private _targetIndex;
  56915. private _sourceBuffer;
  56916. private _targetBuffer;
  56917. private _engine;
  56918. private _currentRenderId;
  56919. private _started;
  56920. private _stopped;
  56921. private _timeDelta;
  56922. private _randomTexture;
  56923. private _randomTexture2;
  56924. private _attributesStrideSize;
  56925. private _updateEffectOptions;
  56926. private _randomTextureSize;
  56927. private _actualFrame;
  56928. private readonly _rawTextureWidth;
  56929. /**
  56930. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56931. */
  56932. static readonly IsSupported: boolean;
  56933. /**
  56934. * An event triggered when the system is disposed.
  56935. */
  56936. onDisposeObservable: Observable<GPUParticleSystem>;
  56937. /**
  56938. * Gets the maximum number of particles active at the same time.
  56939. * @returns The max number of active particles.
  56940. */
  56941. getCapacity(): number;
  56942. /**
  56943. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56944. * to override the particles.
  56945. */
  56946. forceDepthWrite: boolean;
  56947. /**
  56948. * Gets or set the number of active particles
  56949. */
  56950. activeParticleCount: number;
  56951. private _preWarmDone;
  56952. /**
  56953. * Is this system ready to be used/rendered
  56954. * @return true if the system is ready
  56955. */
  56956. isReady(): boolean;
  56957. /**
  56958. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56959. * @returns True if it has been started, otherwise false.
  56960. */
  56961. isStarted(): boolean;
  56962. /**
  56963. * Starts the particle system and begins to emit
  56964. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56965. */
  56966. start(delay?: number): void;
  56967. /**
  56968. * Stops the particle system.
  56969. */
  56970. stop(): void;
  56971. /**
  56972. * Remove all active particles
  56973. */
  56974. reset(): void;
  56975. /**
  56976. * Returns the string "GPUParticleSystem"
  56977. * @returns a string containing the class name
  56978. */
  56979. getClassName(): string;
  56980. private _colorGradientsTexture;
  56981. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56982. /**
  56983. * Adds a new color gradient
  56984. * @param gradient defines the gradient to use (between 0 and 1)
  56985. * @param color1 defines the color to affect to the specified gradient
  56986. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56987. * @returns the current particle system
  56988. */
  56989. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56990. /**
  56991. * Remove a specific color gradient
  56992. * @param gradient defines the gradient to remove
  56993. * @returns the current particle system
  56994. */
  56995. removeColorGradient(gradient: number): GPUParticleSystem;
  56996. private _angularSpeedGradientsTexture;
  56997. private _sizeGradientsTexture;
  56998. private _velocityGradientsTexture;
  56999. private _limitVelocityGradientsTexture;
  57000. private _dragGradientsTexture;
  57001. private _addFactorGradient;
  57002. /**
  57003. * Adds a new size gradient
  57004. * @param gradient defines the gradient to use (between 0 and 1)
  57005. * @param factor defines the size factor to affect to the specified gradient
  57006. * @returns the current particle system
  57007. */
  57008. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  57009. /**
  57010. * Remove a specific size gradient
  57011. * @param gradient defines the gradient to remove
  57012. * @returns the current particle system
  57013. */
  57014. removeSizeGradient(gradient: number): GPUParticleSystem;
  57015. /**
  57016. * Adds a new angular speed gradient
  57017. * @param gradient defines the gradient to use (between 0 and 1)
  57018. * @param factor defines the angular speed to affect to the specified gradient
  57019. * @returns the current particle system
  57020. */
  57021. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  57022. /**
  57023. * Remove a specific angular speed gradient
  57024. * @param gradient defines the gradient to remove
  57025. * @returns the current particle system
  57026. */
  57027. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  57028. /**
  57029. * Adds a new velocity gradient
  57030. * @param gradient defines the gradient to use (between 0 and 1)
  57031. * @param factor defines the velocity to affect to the specified gradient
  57032. * @returns the current particle system
  57033. */
  57034. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57035. /**
  57036. * Remove a specific velocity gradient
  57037. * @param gradient defines the gradient to remove
  57038. * @returns the current particle system
  57039. */
  57040. removeVelocityGradient(gradient: number): GPUParticleSystem;
  57041. /**
  57042. * Adds a new limit velocity gradient
  57043. * @param gradient defines the gradient to use (between 0 and 1)
  57044. * @param factor defines the limit velocity value to affect to the specified gradient
  57045. * @returns the current particle system
  57046. */
  57047. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57048. /**
  57049. * Remove a specific limit velocity gradient
  57050. * @param gradient defines the gradient to remove
  57051. * @returns the current particle system
  57052. */
  57053. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57054. /**
  57055. * Adds a new drag gradient
  57056. * @param gradient defines the gradient to use (between 0 and 1)
  57057. * @param factor defines the drag value to affect to the specified gradient
  57058. * @returns the current particle system
  57059. */
  57060. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  57061. /**
  57062. * Remove a specific drag gradient
  57063. * @param gradient defines the gradient to remove
  57064. * @returns the current particle system
  57065. */
  57066. removeDragGradient(gradient: number): GPUParticleSystem;
  57067. /**
  57068. * Not supported by GPUParticleSystem
  57069. * @param gradient defines the gradient to use (between 0 and 1)
  57070. * @param factor defines the emit rate value to affect to the specified gradient
  57071. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57072. * @returns the current particle system
  57073. */
  57074. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57075. /**
  57076. * Not supported by GPUParticleSystem
  57077. * @param gradient defines the gradient to remove
  57078. * @returns the current particle system
  57079. */
  57080. removeEmitRateGradient(gradient: number): IParticleSystem;
  57081. /**
  57082. * Not supported by GPUParticleSystem
  57083. * @param gradient defines the gradient to use (between 0 and 1)
  57084. * @param factor defines the start size value to affect to the specified gradient
  57085. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57086. * @returns the current particle system
  57087. */
  57088. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57089. /**
  57090. * Not supported by GPUParticleSystem
  57091. * @param gradient defines the gradient to remove
  57092. * @returns the current particle system
  57093. */
  57094. removeStartSizeGradient(gradient: number): IParticleSystem;
  57095. /**
  57096. * Not supported by GPUParticleSystem
  57097. * @param gradient defines the gradient to use (between 0 and 1)
  57098. * @param min defines the color remap minimal range
  57099. * @param max defines the color remap maximal range
  57100. * @returns the current particle system
  57101. */
  57102. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57103. /**
  57104. * Not supported by GPUParticleSystem
  57105. * @param gradient defines the gradient to remove
  57106. * @returns the current particle system
  57107. */
  57108. removeColorRemapGradient(): IParticleSystem;
  57109. /**
  57110. * Not supported by GPUParticleSystem
  57111. * @param gradient defines the gradient to use (between 0 and 1)
  57112. * @param min defines the alpha remap minimal range
  57113. * @param max defines the alpha remap maximal range
  57114. * @returns the current particle system
  57115. */
  57116. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57117. /**
  57118. * Not supported by GPUParticleSystem
  57119. * @param gradient defines the gradient to remove
  57120. * @returns the current particle system
  57121. */
  57122. removeAlphaRemapGradient(): IParticleSystem;
  57123. /**
  57124. * Not supported by GPUParticleSystem
  57125. * @param gradient defines the gradient to use (between 0 and 1)
  57126. * @param color defines the color to affect to the specified gradient
  57127. * @returns the current particle system
  57128. */
  57129. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  57130. /**
  57131. * Not supported by GPUParticleSystem
  57132. * @param gradient defines the gradient to remove
  57133. * @returns the current particle system
  57134. */
  57135. removeRampGradient(): IParticleSystem;
  57136. /**
  57137. * Not supported by GPUParticleSystem
  57138. * @returns the list of ramp gradients
  57139. */
  57140. getRampGradients(): Nullable<Array<Color3Gradient>>;
  57141. /**
  57142. * Not supported by GPUParticleSystem
  57143. * Gets or sets a boolean indicating that ramp gradients must be used
  57144. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  57145. */
  57146. useRampGradients: boolean;
  57147. /**
  57148. * Not supported by GPUParticleSystem
  57149. * @param gradient defines the gradient to use (between 0 and 1)
  57150. * @param factor defines the life time factor to affect to the specified gradient
  57151. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57152. * @returns the current particle system
  57153. */
  57154. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57155. /**
  57156. * Not supported by GPUParticleSystem
  57157. * @param gradient defines the gradient to remove
  57158. * @returns the current particle system
  57159. */
  57160. removeLifeTimeGradient(gradient: number): IParticleSystem;
  57161. /**
  57162. * Instantiates a GPU particle system.
  57163. * 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.
  57164. * @param name The name of the particle system
  57165. * @param options The options used to create the system
  57166. * @param scene The scene the particle system belongs to
  57167. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  57168. */
  57169. constructor(name: string, options: Partial<{
  57170. capacity: number;
  57171. randomTextureSize: number;
  57172. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  57173. protected _reset(): void;
  57174. private _createUpdateVAO;
  57175. private _createRenderVAO;
  57176. private _initialize;
  57177. /** @hidden */
  57178. _recreateUpdateEffect(): void;
  57179. /** @hidden */
  57180. _recreateRenderEffect(): void;
  57181. /**
  57182. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  57183. * @param preWarm defines if we are in the pre-warmimg phase
  57184. */
  57185. animate(preWarm?: boolean): void;
  57186. private _createFactorGradientTexture;
  57187. private _createSizeGradientTexture;
  57188. private _createAngularSpeedGradientTexture;
  57189. private _createVelocityGradientTexture;
  57190. private _createLimitVelocityGradientTexture;
  57191. private _createDragGradientTexture;
  57192. private _createColorGradientTexture;
  57193. /**
  57194. * Renders the particle system in its current state
  57195. * @param preWarm defines if the system should only update the particles but not render them
  57196. * @returns the current number of particles
  57197. */
  57198. render(preWarm?: boolean): number;
  57199. /**
  57200. * Rebuilds the particle system
  57201. */
  57202. rebuild(): void;
  57203. private _releaseBuffers;
  57204. private _releaseVAOs;
  57205. /**
  57206. * Disposes the particle system and free the associated resources
  57207. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  57208. */
  57209. dispose(disposeTexture?: boolean): void;
  57210. /**
  57211. * Clones the particle system.
  57212. * @param name The name of the cloned object
  57213. * @param newEmitter The new emitter to use
  57214. * @returns the cloned particle system
  57215. */
  57216. clone(name: string, newEmitter: any): GPUParticleSystem;
  57217. /**
  57218. * Serializes the particle system to a JSON object.
  57219. * @returns the JSON object
  57220. */
  57221. serialize(): any;
  57222. /**
  57223. * Parses a JSON object to create a GPU particle system.
  57224. * @param parsedParticleSystem The JSON object to parse
  57225. * @param scene The scene to create the particle system in
  57226. * @param rootUrl The root url to use to load external dependencies like texture
  57227. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  57228. * @returns the parsed GPU particle system
  57229. */
  57230. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  57231. }
  57232. }
  57233. declare module BABYLON {
  57234. /**
  57235. * Represents a set of particle systems working together to create a specific effect
  57236. */
  57237. export class ParticleSystemSet implements IDisposable {
  57238. private _emitterCreationOptions;
  57239. private _emitterNode;
  57240. /**
  57241. * Gets the particle system list
  57242. */
  57243. systems: IParticleSystem[];
  57244. /**
  57245. * Gets the emitter node used with this set
  57246. */
  57247. readonly emitterNode: Nullable<TransformNode>;
  57248. /**
  57249. * Creates a new emitter mesh as a sphere
  57250. * @param options defines the options used to create the sphere
  57251. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  57252. * @param scene defines the hosting scene
  57253. */
  57254. setEmitterAsSphere(options: {
  57255. diameter: number;
  57256. segments: number;
  57257. color: Color3;
  57258. }, renderingGroupId: number, scene: Scene): void;
  57259. /**
  57260. * Starts all particle systems of the set
  57261. * @param emitter defines an optional mesh to use as emitter for the particle systems
  57262. */
  57263. start(emitter?: AbstractMesh): void;
  57264. /**
  57265. * Release all associated resources
  57266. */
  57267. dispose(): void;
  57268. /**
  57269. * Serialize the set into a JSON compatible object
  57270. * @returns a JSON compatible representation of the set
  57271. */
  57272. serialize(): any;
  57273. /**
  57274. * Parse a new ParticleSystemSet from a serialized source
  57275. * @param data defines a JSON compatible representation of the set
  57276. * @param scene defines the hosting scene
  57277. * @param gpu defines if we want GPU particles or CPU particles
  57278. * @returns a new ParticleSystemSet
  57279. */
  57280. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57281. }
  57282. }
  57283. declare module BABYLON {
  57284. /**
  57285. * This class is made for on one-liner static method to help creating particle system set.
  57286. */
  57287. export class ParticleHelper {
  57288. /**
  57289. * Gets or sets base Assets URL
  57290. */
  57291. static BaseAssetsUrl: string;
  57292. /**
  57293. * Create a default particle system that you can tweak
  57294. * @param emitter defines the emitter to use
  57295. * @param capacity defines the system capacity (default is 500 particles)
  57296. * @param scene defines the hosting scene
  57297. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57298. * @returns the new Particle system
  57299. */
  57300. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57301. /**
  57302. * This is the main static method (one-liner) of this helper to create different particle systems
  57303. * @param type This string represents the type to the particle system to create
  57304. * @param scene The scene where the particle system should live
  57305. * @param gpu If the system will use gpu
  57306. * @returns the ParticleSystemSet created
  57307. */
  57308. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57309. /**
  57310. * Static function used to export a particle system to a ParticleSystemSet variable.
  57311. * Please note that the emitter shape is not exported
  57312. * @param systems defines the particle systems to export
  57313. * @returns the created particle system set
  57314. */
  57315. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57316. }
  57317. }
  57318. declare module BABYLON {
  57319. interface Engine {
  57320. /**
  57321. * Create an effect to use with particle systems.
  57322. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57323. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57324. * @param uniformsNames defines a list of attribute names
  57325. * @param samplers defines an array of string used to represent textures
  57326. * @param defines defines the string containing the defines to use to compile the shaders
  57327. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57328. * @param onCompiled defines a function to call when the effect creation is successful
  57329. * @param onError defines a function to call when the effect creation has failed
  57330. * @returns the new Effect
  57331. */
  57332. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57333. }
  57334. interface Mesh {
  57335. /**
  57336. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57337. * @returns an array of IParticleSystem
  57338. */
  57339. getEmittedParticleSystems(): IParticleSystem[];
  57340. /**
  57341. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57342. * @returns an array of IParticleSystem
  57343. */
  57344. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57345. }
  57346. /**
  57347. * @hidden
  57348. */
  57349. export var _IDoNeedToBeInTheBuild: number;
  57350. }
  57351. declare module BABYLON {
  57352. interface Scene {
  57353. /** @hidden (Backing field) */
  57354. _physicsEngine: Nullable<IPhysicsEngine>;
  57355. /**
  57356. * Gets the current physics engine
  57357. * @returns a IPhysicsEngine or null if none attached
  57358. */
  57359. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57360. /**
  57361. * Enables physics to the current scene
  57362. * @param gravity defines the scene's gravity for the physics engine
  57363. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57364. * @return a boolean indicating if the physics engine was initialized
  57365. */
  57366. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57367. /**
  57368. * Disables and disposes the physics engine associated with the scene
  57369. */
  57370. disablePhysicsEngine(): void;
  57371. /**
  57372. * Gets a boolean indicating if there is an active physics engine
  57373. * @returns a boolean indicating if there is an active physics engine
  57374. */
  57375. isPhysicsEnabled(): boolean;
  57376. /**
  57377. * Deletes a physics compound impostor
  57378. * @param compound defines the compound to delete
  57379. */
  57380. deleteCompoundImpostor(compound: any): void;
  57381. /**
  57382. * An event triggered when physic simulation is about to be run
  57383. */
  57384. onBeforePhysicsObservable: Observable<Scene>;
  57385. /**
  57386. * An event triggered when physic simulation has been done
  57387. */
  57388. onAfterPhysicsObservable: Observable<Scene>;
  57389. }
  57390. interface AbstractMesh {
  57391. /** @hidden */
  57392. _physicsImpostor: Nullable<PhysicsImpostor>;
  57393. /**
  57394. * Gets or sets impostor used for physic simulation
  57395. * @see http://doc.babylonjs.com/features/physics_engine
  57396. */
  57397. physicsImpostor: Nullable<PhysicsImpostor>;
  57398. /**
  57399. * Gets the current physics impostor
  57400. * @see http://doc.babylonjs.com/features/physics_engine
  57401. * @returns a physics impostor or null
  57402. */
  57403. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57404. /** Apply a physic impulse to the mesh
  57405. * @param force defines the force to apply
  57406. * @param contactPoint defines where to apply the force
  57407. * @returns the current mesh
  57408. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57409. */
  57410. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57411. /**
  57412. * Creates a physic joint between two meshes
  57413. * @param otherMesh defines the other mesh to use
  57414. * @param pivot1 defines the pivot to use on this mesh
  57415. * @param pivot2 defines the pivot to use on the other mesh
  57416. * @param options defines additional options (can be plugin dependent)
  57417. * @returns the current mesh
  57418. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57419. */
  57420. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57421. /** @hidden */
  57422. _disposePhysicsObserver: Nullable<Observer<Node>>;
  57423. }
  57424. /**
  57425. * Defines the physics engine scene component responsible to manage a physics engine
  57426. */
  57427. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57428. /**
  57429. * The component name helpful to identify the component in the list of scene components.
  57430. */
  57431. readonly name: string;
  57432. /**
  57433. * The scene the component belongs to.
  57434. */
  57435. scene: Scene;
  57436. /**
  57437. * Creates a new instance of the component for the given scene
  57438. * @param scene Defines the scene to register the component in
  57439. */
  57440. constructor(scene: Scene);
  57441. /**
  57442. * Registers the component in a given scene
  57443. */
  57444. register(): void;
  57445. /**
  57446. * Rebuilds the elements related to this component in case of
  57447. * context lost for instance.
  57448. */
  57449. rebuild(): void;
  57450. /**
  57451. * Disposes the component and the associated ressources
  57452. */
  57453. dispose(): void;
  57454. }
  57455. }
  57456. declare module BABYLON {
  57457. /**
  57458. * A helper for physics simulations
  57459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57460. */
  57461. export class PhysicsHelper {
  57462. private _scene;
  57463. private _physicsEngine;
  57464. /**
  57465. * Initializes the Physics helper
  57466. * @param scene Babylon.js scene
  57467. */
  57468. constructor(scene: Scene);
  57469. /**
  57470. * Applies a radial explosion impulse
  57471. * @param origin the origin of the explosion
  57472. * @param radiusOrEventOptions the radius or the options of radial explosion
  57473. * @param strength the explosion strength
  57474. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57475. * @returns A physics radial explosion event, or null
  57476. */
  57477. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57478. /**
  57479. * Applies a radial explosion force
  57480. * @param origin the origin of the explosion
  57481. * @param radiusOrEventOptions the radius or the options of radial explosion
  57482. * @param strength the explosion strength
  57483. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57484. * @returns A physics radial explosion event, or null
  57485. */
  57486. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57487. /**
  57488. * Creates a gravitational field
  57489. * @param origin the origin of the explosion
  57490. * @param radiusOrEventOptions the radius or the options of radial explosion
  57491. * @param strength the explosion strength
  57492. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57493. * @returns A physics gravitational field event, or null
  57494. */
  57495. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57496. /**
  57497. * Creates a physics updraft event
  57498. * @param origin the origin of the updraft
  57499. * @param radiusOrEventOptions the radius or the options of the updraft
  57500. * @param strength the strength of the updraft
  57501. * @param height the height of the updraft
  57502. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57503. * @returns A physics updraft event, or null
  57504. */
  57505. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57506. /**
  57507. * Creates a physics vortex event
  57508. * @param origin the of the vortex
  57509. * @param radiusOrEventOptions the radius or the options of the vortex
  57510. * @param strength the strength of the vortex
  57511. * @param height the height of the vortex
  57512. * @returns a Physics vortex event, or null
  57513. * A physics vortex event or null
  57514. */
  57515. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57516. }
  57517. /**
  57518. * Represents a physics radial explosion event
  57519. */
  57520. class PhysicsRadialExplosionEvent {
  57521. private _scene;
  57522. private _options;
  57523. private _sphere;
  57524. private _dataFetched;
  57525. /**
  57526. * Initializes a radial explosioin event
  57527. * @param _scene BabylonJS scene
  57528. * @param _options The options for the vortex event
  57529. */
  57530. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  57531. /**
  57532. * Returns the data related to the radial explosion event (sphere).
  57533. * @returns The radial explosion event data
  57534. */
  57535. getData(): PhysicsRadialExplosionEventData;
  57536. /**
  57537. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  57538. * @param impostor A physics imposter
  57539. * @param origin the origin of the explosion
  57540. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  57541. */
  57542. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  57543. /**
  57544. * Triggers affecterd impostors callbacks
  57545. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  57546. */
  57547. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  57548. /**
  57549. * Disposes the sphere.
  57550. * @param force Specifies if the sphere should be disposed by force
  57551. */
  57552. dispose(force?: boolean): void;
  57553. /*** Helpers ***/
  57554. private _prepareSphere;
  57555. private _intersectsWithSphere;
  57556. }
  57557. /**
  57558. * Represents a gravitational field event
  57559. */
  57560. class PhysicsGravitationalFieldEvent {
  57561. private _physicsHelper;
  57562. private _scene;
  57563. private _origin;
  57564. private _options;
  57565. private _tickCallback;
  57566. private _sphere;
  57567. private _dataFetched;
  57568. /**
  57569. * Initializes the physics gravitational field event
  57570. * @param _physicsHelper A physics helper
  57571. * @param _scene BabylonJS scene
  57572. * @param _origin The origin position of the gravitational field event
  57573. * @param _options The options for the vortex event
  57574. */
  57575. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  57576. /**
  57577. * Returns the data related to the gravitational field event (sphere).
  57578. * @returns A gravitational field event
  57579. */
  57580. getData(): PhysicsGravitationalFieldEventData;
  57581. /**
  57582. * Enables the gravitational field.
  57583. */
  57584. enable(): void;
  57585. /**
  57586. * Disables the gravitational field.
  57587. */
  57588. disable(): void;
  57589. /**
  57590. * Disposes the sphere.
  57591. * @param force The force to dispose from the gravitational field event
  57592. */
  57593. dispose(force?: boolean): void;
  57594. private _tick;
  57595. }
  57596. /**
  57597. * Represents a physics updraft event
  57598. */
  57599. class PhysicsUpdraftEvent {
  57600. private _scene;
  57601. private _origin;
  57602. private _options;
  57603. private _physicsEngine;
  57604. private _originTop;
  57605. private _originDirection;
  57606. private _tickCallback;
  57607. private _cylinder;
  57608. private _cylinderPosition;
  57609. private _dataFetched;
  57610. /**
  57611. * Initializes the physics updraft event
  57612. * @param _scene BabylonJS scene
  57613. * @param _origin The origin position of the updraft
  57614. * @param _options The options for the updraft event
  57615. */
  57616. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57617. /**
  57618. * Returns the data related to the updraft event (cylinder).
  57619. * @returns A physics updraft event
  57620. */
  57621. getData(): PhysicsUpdraftEventData;
  57622. /**
  57623. * Enables the updraft.
  57624. */
  57625. enable(): void;
  57626. /**
  57627. * Disables the updraft.
  57628. */
  57629. disable(): void;
  57630. /**
  57631. * Disposes the cylinder.
  57632. * @param force Specifies if the updraft should be disposed by force
  57633. */
  57634. dispose(force?: boolean): void;
  57635. private getImpostorHitData;
  57636. private _tick;
  57637. /*** Helpers ***/
  57638. private _prepareCylinder;
  57639. private _intersectsWithCylinder;
  57640. }
  57641. /**
  57642. * Represents a physics vortex event
  57643. */
  57644. class PhysicsVortexEvent {
  57645. private _scene;
  57646. private _origin;
  57647. private _options;
  57648. private _physicsEngine;
  57649. private _originTop;
  57650. private _tickCallback;
  57651. private _cylinder;
  57652. private _cylinderPosition;
  57653. private _dataFetched;
  57654. /**
  57655. * Initializes the physics vortex event
  57656. * @param _scene The BabylonJS scene
  57657. * @param _origin The origin position of the vortex
  57658. * @param _options The options for the vortex event
  57659. */
  57660. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57661. /**
  57662. * Returns the data related to the vortex event (cylinder).
  57663. * @returns The physics vortex event data
  57664. */
  57665. getData(): PhysicsVortexEventData;
  57666. /**
  57667. * Enables the vortex.
  57668. */
  57669. enable(): void;
  57670. /**
  57671. * Disables the cortex.
  57672. */
  57673. disable(): void;
  57674. /**
  57675. * Disposes the sphere.
  57676. * @param force
  57677. */
  57678. dispose(force?: boolean): void;
  57679. private getImpostorHitData;
  57680. private _tick;
  57681. /*** Helpers ***/
  57682. private _prepareCylinder;
  57683. private _intersectsWithCylinder;
  57684. }
  57685. /**
  57686. * Options fot the radial explosion event
  57687. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57688. */
  57689. export class PhysicsRadialExplosionEventOptions {
  57690. /**
  57691. * The radius of the sphere for the radial explosion.
  57692. */
  57693. radius: number;
  57694. /**
  57695. * The strenth of the explosion.
  57696. */
  57697. strength: number;
  57698. /**
  57699. * The strenght of the force in correspondence to the distance of the affected object
  57700. */
  57701. falloff: PhysicsRadialImpulseFalloff;
  57702. /**
  57703. * Sphere options for the radial explosion.
  57704. */
  57705. sphere: {
  57706. segments: number;
  57707. diameter: number;
  57708. };
  57709. /**
  57710. * Sphere options for the radial explosion.
  57711. */
  57712. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57713. }
  57714. /**
  57715. * Options fot the updraft event
  57716. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57717. */
  57718. export class PhysicsUpdraftEventOptions {
  57719. /**
  57720. * The radius of the cylinder for the vortex
  57721. */
  57722. radius: number;
  57723. /**
  57724. * The strenth of the updraft.
  57725. */
  57726. strength: number;
  57727. /**
  57728. * The height of the cylinder for the updraft.
  57729. */
  57730. height: number;
  57731. /**
  57732. * The mode for the the updraft.
  57733. */
  57734. updraftMode: PhysicsUpdraftMode;
  57735. }
  57736. /**
  57737. * Options fot the vortex event
  57738. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57739. */
  57740. export class PhysicsVortexEventOptions {
  57741. /**
  57742. * The radius of the cylinder for the vortex
  57743. */
  57744. radius: number;
  57745. /**
  57746. * The strenth of the vortex.
  57747. */
  57748. strength: number;
  57749. /**
  57750. * The height of the cylinder for the vortex.
  57751. */
  57752. height: number;
  57753. /**
  57754. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57755. */
  57756. centripetalForceThreshold: number;
  57757. /**
  57758. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57759. */
  57760. centripetalForceMultiplier: number;
  57761. /**
  57762. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57763. */
  57764. centrifugalForceMultiplier: number;
  57765. /**
  57766. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57767. */
  57768. updraftForceMultiplier: number;
  57769. }
  57770. /**
  57771. * The strenght of the force in correspondence to the distance of the affected object
  57772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57773. */
  57774. export enum PhysicsRadialImpulseFalloff {
  57775. /** Defines that impulse is constant in strength across it's whole radius */
  57776. Constant = 0,
  57777. /** Defines that impulse gets weaker if it's further from the origin */
  57778. Linear = 1
  57779. }
  57780. /**
  57781. * The strength of the force in correspondence to the distance of the affected object
  57782. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57783. */
  57784. export enum PhysicsUpdraftMode {
  57785. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57786. Center = 0,
  57787. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57788. Perpendicular = 1
  57789. }
  57790. /**
  57791. * Interface for a physics hit data
  57792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57793. */
  57794. export interface PhysicsHitData {
  57795. /**
  57796. * The force applied at the contact point
  57797. */
  57798. force: Vector3;
  57799. /**
  57800. * The contact point
  57801. */
  57802. contactPoint: Vector3;
  57803. /**
  57804. * The distance from the origin to the contact point
  57805. */
  57806. distanceFromOrigin: number;
  57807. }
  57808. /**
  57809. * Interface for radial explosion event data
  57810. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57811. */
  57812. export interface PhysicsRadialExplosionEventData {
  57813. /**
  57814. * A sphere used for the radial explosion event
  57815. */
  57816. sphere: Mesh;
  57817. }
  57818. /**
  57819. * Interface for gravitational field event data
  57820. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57821. */
  57822. export interface PhysicsGravitationalFieldEventData {
  57823. /**
  57824. * A sphere mesh used for the gravitational field event
  57825. */
  57826. sphere: Mesh;
  57827. }
  57828. /**
  57829. * Interface for updraft event data
  57830. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57831. */
  57832. export interface PhysicsUpdraftEventData {
  57833. /**
  57834. * A cylinder used for the updraft event
  57835. */
  57836. cylinder: Mesh;
  57837. }
  57838. /**
  57839. * Interface for vortex event data
  57840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57841. */
  57842. export interface PhysicsVortexEventData {
  57843. /**
  57844. * A cylinder used for the vortex event
  57845. */
  57846. cylinder: Mesh;
  57847. }
  57848. /**
  57849. * Interface for an affected physics impostor
  57850. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57851. */
  57852. export interface PhysicsAffectedImpostorWithData {
  57853. /**
  57854. * The impostor affected by the effect
  57855. */
  57856. impostor: PhysicsImpostor;
  57857. /**
  57858. * The data about the hit/horce from the explosion
  57859. */
  57860. hitData: PhysicsHitData;
  57861. }
  57862. }
  57863. declare module BABYLON {
  57864. /** @hidden */
  57865. export var blackAndWhitePixelShader: {
  57866. name: string;
  57867. shader: string;
  57868. };
  57869. }
  57870. declare module BABYLON {
  57871. /**
  57872. * Post process used to render in black and white
  57873. */
  57874. export class BlackAndWhitePostProcess extends PostProcess {
  57875. /**
  57876. * Linear about to convert he result to black and white (default: 1)
  57877. */
  57878. degree: number;
  57879. /**
  57880. * Creates a black and white post process
  57881. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57882. * @param name The name of the effect.
  57883. * @param options The required width/height ratio to downsize to before computing the render pass.
  57884. * @param camera The camera to apply the render pass to.
  57885. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57886. * @param engine The engine which the post process will be applied. (default: current engine)
  57887. * @param reusable If the post process can be reused on the same frame. (default: false)
  57888. */
  57889. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57890. }
  57891. }
  57892. declare module BABYLON {
  57893. /**
  57894. * This represents a set of one or more post processes in Babylon.
  57895. * A post process can be used to apply a shader to a texture after it is rendered.
  57896. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57897. */
  57898. export class PostProcessRenderEffect {
  57899. private _postProcesses;
  57900. private _getPostProcesses;
  57901. private _singleInstance;
  57902. private _cameras;
  57903. private _indicesForCamera;
  57904. /**
  57905. * Name of the effect
  57906. * @hidden
  57907. */
  57908. _name: string;
  57909. /**
  57910. * Instantiates a post process render effect.
  57911. * A post process can be used to apply a shader to a texture after it is rendered.
  57912. * @param engine The engine the effect is tied to
  57913. * @param name The name of the effect
  57914. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57915. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57916. */
  57917. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57918. /**
  57919. * Checks if all the post processes in the effect are supported.
  57920. */
  57921. readonly isSupported: boolean;
  57922. /**
  57923. * Updates the current state of the effect
  57924. * @hidden
  57925. */
  57926. _update(): void;
  57927. /**
  57928. * Attaches the effect on cameras
  57929. * @param cameras The camera to attach to.
  57930. * @hidden
  57931. */
  57932. _attachCameras(cameras: Camera): void;
  57933. /**
  57934. * Attaches the effect on cameras
  57935. * @param cameras The camera to attach to.
  57936. * @hidden
  57937. */
  57938. _attachCameras(cameras: Camera[]): void;
  57939. /**
  57940. * Detaches the effect on cameras
  57941. * @param cameras The camera to detatch from.
  57942. * @hidden
  57943. */
  57944. _detachCameras(cameras: Camera): void;
  57945. /**
  57946. * Detatches the effect on cameras
  57947. * @param cameras The camera to detatch from.
  57948. * @hidden
  57949. */
  57950. _detachCameras(cameras: Camera[]): void;
  57951. /**
  57952. * Enables the effect on given cameras
  57953. * @param cameras The camera to enable.
  57954. * @hidden
  57955. */
  57956. _enable(cameras: Camera): void;
  57957. /**
  57958. * Enables the effect on given cameras
  57959. * @param cameras The camera to enable.
  57960. * @hidden
  57961. */
  57962. _enable(cameras: Nullable<Camera[]>): void;
  57963. /**
  57964. * Disables the effect on the given cameras
  57965. * @param cameras The camera to disable.
  57966. * @hidden
  57967. */
  57968. _disable(cameras: Camera): void;
  57969. /**
  57970. * Disables the effect on the given cameras
  57971. * @param cameras The camera to disable.
  57972. * @hidden
  57973. */
  57974. _disable(cameras: Nullable<Camera[]>): void;
  57975. /**
  57976. * Gets a list of the post processes contained in the effect.
  57977. * @param camera The camera to get the post processes on.
  57978. * @returns The list of the post processes in the effect.
  57979. */
  57980. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57981. }
  57982. }
  57983. declare module BABYLON {
  57984. /** @hidden */
  57985. export var extractHighlightsPixelShader: {
  57986. name: string;
  57987. shader: string;
  57988. };
  57989. }
  57990. declare module BABYLON {
  57991. /**
  57992. * 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.
  57993. */
  57994. export class ExtractHighlightsPostProcess extends PostProcess {
  57995. /**
  57996. * The luminance threshold, pixels below this value will be set to black.
  57997. */
  57998. threshold: number;
  57999. /** @hidden */
  58000. _exposure: number;
  58001. /**
  58002. * Post process which has the input texture to be used when performing highlight extraction
  58003. * @hidden
  58004. */
  58005. _inputPostProcess: Nullable<PostProcess>;
  58006. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58007. }
  58008. }
  58009. declare module BABYLON {
  58010. /** @hidden */
  58011. export var bloomMergePixelShader: {
  58012. name: string;
  58013. shader: string;
  58014. };
  58015. }
  58016. declare module BABYLON {
  58017. /**
  58018. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58019. */
  58020. export class BloomMergePostProcess extends PostProcess {
  58021. /** Weight of the bloom to be added to the original input. */
  58022. weight: number;
  58023. /**
  58024. * Creates a new instance of @see BloomMergePostProcess
  58025. * @param name The name of the effect.
  58026. * @param originalFromInput Post process which's input will be used for the merge.
  58027. * @param blurred Blurred highlights post process which's output will be used.
  58028. * @param weight Weight of the bloom to be added to the original input.
  58029. * @param options The required width/height ratio to downsize to before computing the render pass.
  58030. * @param camera The camera to apply the render pass to.
  58031. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58032. * @param engine The engine which the post process will be applied. (default: current engine)
  58033. * @param reusable If the post process can be reused on the same frame. (default: false)
  58034. * @param textureType Type of textures used when performing the post process. (default: 0)
  58035. * @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)
  58036. */
  58037. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  58038. /** Weight of the bloom to be added to the original input. */
  58039. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58040. }
  58041. }
  58042. declare module BABYLON {
  58043. /**
  58044. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  58045. */
  58046. export class BloomEffect extends PostProcessRenderEffect {
  58047. private bloomScale;
  58048. /**
  58049. * @hidden Internal
  58050. */
  58051. _effects: Array<PostProcess>;
  58052. /**
  58053. * @hidden Internal
  58054. */
  58055. _downscale: ExtractHighlightsPostProcess;
  58056. private _blurX;
  58057. private _blurY;
  58058. private _merge;
  58059. /**
  58060. * The luminance threshold to find bright areas of the image to bloom.
  58061. */
  58062. threshold: number;
  58063. /**
  58064. * The strength of the bloom.
  58065. */
  58066. weight: number;
  58067. /**
  58068. * Specifies the size of the bloom blur kernel, relative to the final output size
  58069. */
  58070. kernel: number;
  58071. /**
  58072. * Creates a new instance of @see BloomEffect
  58073. * @param scene The scene the effect belongs to.
  58074. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  58075. * @param bloomKernel The size of the kernel to be used when applying the blur.
  58076. * @param bloomWeight The the strength of bloom.
  58077. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58078. * @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)
  58079. */
  58080. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  58081. /**
  58082. * Disposes each of the internal effects for a given camera.
  58083. * @param camera The camera to dispose the effect on.
  58084. */
  58085. disposeEffects(camera: Camera): void;
  58086. /**
  58087. * @hidden Internal
  58088. */
  58089. _updateEffects(): void;
  58090. /**
  58091. * Internal
  58092. * @returns if all the contained post processes are ready.
  58093. * @hidden
  58094. */
  58095. _isReady(): boolean;
  58096. }
  58097. }
  58098. declare module BABYLON {
  58099. /** @hidden */
  58100. export var chromaticAberrationPixelShader: {
  58101. name: string;
  58102. shader: string;
  58103. };
  58104. }
  58105. declare module BABYLON {
  58106. /**
  58107. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  58108. */
  58109. export class ChromaticAberrationPostProcess extends PostProcess {
  58110. /**
  58111. * The amount of seperation of rgb channels (default: 30)
  58112. */
  58113. aberrationAmount: number;
  58114. /**
  58115. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  58116. */
  58117. radialIntensity: number;
  58118. /**
  58119. * 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))
  58120. */
  58121. direction: Vector2;
  58122. /**
  58123. * 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))
  58124. */
  58125. centerPosition: Vector2;
  58126. /**
  58127. * Creates a new instance ChromaticAberrationPostProcess
  58128. * @param name The name of the effect.
  58129. * @param screenWidth The width of the screen to apply the effect on.
  58130. * @param screenHeight The height of the screen to apply the effect on.
  58131. * @param options The required width/height ratio to downsize to before computing the render pass.
  58132. * @param camera The camera to apply the render pass to.
  58133. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58134. * @param engine The engine which the post process will be applied. (default: current engine)
  58135. * @param reusable If the post process can be reused on the same frame. (default: false)
  58136. * @param textureType Type of textures used when performing the post process. (default: 0)
  58137. * @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)
  58138. */
  58139. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58140. }
  58141. }
  58142. declare module BABYLON {
  58143. /** @hidden */
  58144. export var circleOfConfusionPixelShader: {
  58145. name: string;
  58146. shader: string;
  58147. };
  58148. }
  58149. declare module BABYLON {
  58150. /**
  58151. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  58152. */
  58153. export class CircleOfConfusionPostProcess extends PostProcess {
  58154. /**
  58155. * 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.
  58156. */
  58157. lensSize: number;
  58158. /**
  58159. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58160. */
  58161. fStop: number;
  58162. /**
  58163. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58164. */
  58165. focusDistance: number;
  58166. /**
  58167. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  58168. */
  58169. focalLength: number;
  58170. private _depthTexture;
  58171. /**
  58172. * Creates a new instance CircleOfConfusionPostProcess
  58173. * @param name The name of the effect.
  58174. * @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.
  58175. * @param options The required width/height ratio to downsize to before computing the render pass.
  58176. * @param camera The camera to apply the render pass to.
  58177. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58178. * @param engine The engine which the post process will be applied. (default: current engine)
  58179. * @param reusable If the post process can be reused on the same frame. (default: false)
  58180. * @param textureType Type of textures used when performing the post process. (default: 0)
  58181. * @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)
  58182. */
  58183. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58184. /**
  58185. * 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.
  58186. */
  58187. depthTexture: RenderTargetTexture;
  58188. }
  58189. }
  58190. declare module BABYLON {
  58191. /** @hidden */
  58192. export var colorCorrectionPixelShader: {
  58193. name: string;
  58194. shader: string;
  58195. };
  58196. }
  58197. declare module BABYLON {
  58198. /**
  58199. *
  58200. * This post-process allows the modification of rendered colors by using
  58201. * a 'look-up table' (LUT). This effect is also called Color Grading.
  58202. *
  58203. * The object needs to be provided an url to a texture containing the color
  58204. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  58205. * Use an image editing software to tweak the LUT to match your needs.
  58206. *
  58207. * For an example of a color LUT, see here:
  58208. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  58209. * For explanations on color grading, see here:
  58210. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58211. *
  58212. */
  58213. export class ColorCorrectionPostProcess extends PostProcess {
  58214. private _colorTableTexture;
  58215. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58216. }
  58217. }
  58218. declare module BABYLON {
  58219. /** @hidden */
  58220. export var convolutionPixelShader: {
  58221. name: string;
  58222. shader: string;
  58223. };
  58224. }
  58225. declare module BABYLON {
  58226. /**
  58227. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58228. * input texture to perform effects such as edge detection or sharpening
  58229. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58230. */
  58231. export class ConvolutionPostProcess extends PostProcess {
  58232. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58233. kernel: number[];
  58234. /**
  58235. * Creates a new instance ConvolutionPostProcess
  58236. * @param name The name of the effect.
  58237. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58238. * @param options The required width/height ratio to downsize to before computing the render pass.
  58239. * @param camera The camera to apply the render pass to.
  58240. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58241. * @param engine The engine which the post process will be applied. (default: current engine)
  58242. * @param reusable If the post process can be reused on the same frame. (default: false)
  58243. * @param textureType Type of textures used when performing the post process. (default: 0)
  58244. */
  58245. constructor(name: string,
  58246. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58247. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58248. /**
  58249. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58250. */
  58251. static EdgeDetect0Kernel: number[];
  58252. /**
  58253. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58254. */
  58255. static EdgeDetect1Kernel: number[];
  58256. /**
  58257. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58258. */
  58259. static EdgeDetect2Kernel: number[];
  58260. /**
  58261. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58262. */
  58263. static SharpenKernel: number[];
  58264. /**
  58265. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58266. */
  58267. static EmbossKernel: number[];
  58268. /**
  58269. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58270. */
  58271. static GaussianKernel: number[];
  58272. }
  58273. }
  58274. declare module BABYLON {
  58275. /**
  58276. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58277. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58278. * based on samples that have a large difference in distance than the center pixel.
  58279. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58280. */
  58281. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58282. direction: Vector2;
  58283. /**
  58284. * Creates a new instance CircleOfConfusionPostProcess
  58285. * @param name The name of the effect.
  58286. * @param scene The scene the effect belongs to.
  58287. * @param direction The direction the blur should be applied.
  58288. * @param kernel The size of the kernel used to blur.
  58289. * @param options The required width/height ratio to downsize to before computing the render pass.
  58290. * @param camera The camera to apply the render pass to.
  58291. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58292. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58294. * @param engine The engine which the post process will be applied. (default: current engine)
  58295. * @param reusable If the post process can be reused on the same frame. (default: false)
  58296. * @param textureType Type of textures used when performing the post process. (default: 0)
  58297. * @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)
  58298. */
  58299. 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);
  58300. }
  58301. }
  58302. declare module BABYLON {
  58303. /** @hidden */
  58304. export var depthOfFieldMergePixelShader: {
  58305. name: string;
  58306. shader: string;
  58307. };
  58308. }
  58309. declare module BABYLON {
  58310. /**
  58311. * Options to be set when merging outputs from the default pipeline.
  58312. */
  58313. export class DepthOfFieldMergePostProcessOptions {
  58314. /**
  58315. * The original image to merge on top of
  58316. */
  58317. originalFromInput: PostProcess;
  58318. /**
  58319. * Parameters to perform the merge of the depth of field effect
  58320. */
  58321. depthOfField?: {
  58322. circleOfConfusion: PostProcess;
  58323. blurSteps: Array<PostProcess>;
  58324. };
  58325. /**
  58326. * Parameters to perform the merge of bloom effect
  58327. */
  58328. bloom?: {
  58329. blurred: PostProcess;
  58330. weight: number;
  58331. };
  58332. }
  58333. /**
  58334. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58335. */
  58336. export class DepthOfFieldMergePostProcess extends PostProcess {
  58337. private blurSteps;
  58338. /**
  58339. * Creates a new instance of DepthOfFieldMergePostProcess
  58340. * @param name The name of the effect.
  58341. * @param originalFromInput Post process which's input will be used for the merge.
  58342. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58343. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58344. * @param options The required width/height ratio to downsize to before computing the render pass.
  58345. * @param camera The camera to apply the render pass to.
  58346. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58347. * @param engine The engine which the post process will be applied. (default: current engine)
  58348. * @param reusable If the post process can be reused on the same frame. (default: false)
  58349. * @param textureType Type of textures used when performing the post process. (default: 0)
  58350. * @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)
  58351. */
  58352. 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);
  58353. /**
  58354. * Updates the effect with the current post process compile time values and recompiles the shader.
  58355. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58356. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58357. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58358. * @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
  58359. * @param onCompiled Called when the shader has been compiled.
  58360. * @param onError Called if there is an error when compiling a shader.
  58361. */
  58362. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58363. }
  58364. }
  58365. declare module BABYLON {
  58366. /**
  58367. * Specifies the level of max blur that should be applied when using the depth of field effect
  58368. */
  58369. export enum DepthOfFieldEffectBlurLevel {
  58370. /**
  58371. * Subtle blur
  58372. */
  58373. Low = 0,
  58374. /**
  58375. * Medium blur
  58376. */
  58377. Medium = 1,
  58378. /**
  58379. * Large blur
  58380. */
  58381. High = 2
  58382. }
  58383. /**
  58384. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58385. */
  58386. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58387. private _circleOfConfusion;
  58388. /**
  58389. * @hidden Internal, blurs from high to low
  58390. */
  58391. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58392. private _depthOfFieldBlurY;
  58393. private _dofMerge;
  58394. /**
  58395. * @hidden Internal post processes in depth of field effect
  58396. */
  58397. _effects: Array<PostProcess>;
  58398. /**
  58399. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58400. */
  58401. focalLength: number;
  58402. /**
  58403. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58404. */
  58405. fStop: number;
  58406. /**
  58407. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58408. */
  58409. focusDistance: number;
  58410. /**
  58411. * 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.
  58412. */
  58413. lensSize: number;
  58414. /**
  58415. * Creates a new instance DepthOfFieldEffect
  58416. * @param scene The scene the effect belongs to.
  58417. * @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.
  58418. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58419. * @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)
  58420. */
  58421. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58422. /**
  58423. * Get the current class name of the current effet
  58424. * @returns "DepthOfFieldEffect"
  58425. */
  58426. getClassName(): string;
  58427. /**
  58428. * 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.
  58429. */
  58430. depthTexture: RenderTargetTexture;
  58431. /**
  58432. * Disposes each of the internal effects for a given camera.
  58433. * @param camera The camera to dispose the effect on.
  58434. */
  58435. disposeEffects(camera: Camera): void;
  58436. /**
  58437. * @hidden Internal
  58438. */
  58439. _updateEffects(): void;
  58440. /**
  58441. * Internal
  58442. * @returns if all the contained post processes are ready.
  58443. * @hidden
  58444. */
  58445. _isReady(): boolean;
  58446. }
  58447. }
  58448. declare module BABYLON {
  58449. /** @hidden */
  58450. export var displayPassPixelShader: {
  58451. name: string;
  58452. shader: string;
  58453. };
  58454. }
  58455. declare module BABYLON {
  58456. /**
  58457. * DisplayPassPostProcess which produces an output the same as it's input
  58458. */
  58459. export class DisplayPassPostProcess extends PostProcess {
  58460. /**
  58461. * Creates the DisplayPassPostProcess
  58462. * @param name The name of the effect.
  58463. * @param options The required width/height ratio to downsize to before computing the render pass.
  58464. * @param camera The camera to apply the render pass to.
  58465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58466. * @param engine The engine which the post process will be applied. (default: current engine)
  58467. * @param reusable If the post process can be reused on the same frame. (default: false)
  58468. */
  58469. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58470. }
  58471. }
  58472. declare module BABYLON {
  58473. /** @hidden */
  58474. export var filterPixelShader: {
  58475. name: string;
  58476. shader: string;
  58477. };
  58478. }
  58479. declare module BABYLON {
  58480. /**
  58481. * Applies a kernel filter to the image
  58482. */
  58483. export class FilterPostProcess extends PostProcess {
  58484. /** The matrix to be applied to the image */
  58485. kernelMatrix: Matrix;
  58486. /**
  58487. *
  58488. * @param name The name of the effect.
  58489. * @param kernelMatrix The matrix to be applied to the image
  58490. * @param options The required width/height ratio to downsize to before computing the render pass.
  58491. * @param camera The camera to apply the render pass to.
  58492. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58493. * @param engine The engine which the post process will be applied. (default: current engine)
  58494. * @param reusable If the post process can be reused on the same frame. (default: false)
  58495. */
  58496. constructor(name: string,
  58497. /** The matrix to be applied to the image */
  58498. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58499. }
  58500. }
  58501. declare module BABYLON {
  58502. /** @hidden */
  58503. export var fxaaPixelShader: {
  58504. name: string;
  58505. shader: string;
  58506. };
  58507. }
  58508. declare module BABYLON {
  58509. /** @hidden */
  58510. export var fxaaVertexShader: {
  58511. name: string;
  58512. shader: string;
  58513. };
  58514. }
  58515. declare module BABYLON {
  58516. /**
  58517. * Fxaa post process
  58518. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58519. */
  58520. export class FxaaPostProcess extends PostProcess {
  58521. /** @hidden */
  58522. texelWidth: number;
  58523. /** @hidden */
  58524. texelHeight: number;
  58525. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58526. private _getDefines;
  58527. }
  58528. }
  58529. declare module BABYLON {
  58530. /** @hidden */
  58531. export var grainPixelShader: {
  58532. name: string;
  58533. shader: string;
  58534. };
  58535. }
  58536. declare module BABYLON {
  58537. /**
  58538. * The GrainPostProcess adds noise to the image at mid luminance levels
  58539. */
  58540. export class GrainPostProcess extends PostProcess {
  58541. /**
  58542. * The intensity of the grain added (default: 30)
  58543. */
  58544. intensity: number;
  58545. /**
  58546. * If the grain should be randomized on every frame
  58547. */
  58548. animated: boolean;
  58549. /**
  58550. * Creates a new instance of @see GrainPostProcess
  58551. * @param name The name of the effect.
  58552. * @param options The required width/height ratio to downsize to before computing the render pass.
  58553. * @param camera The camera to apply the render pass to.
  58554. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58555. * @param engine The engine which the post process will be applied. (default: current engine)
  58556. * @param reusable If the post process can be reused on the same frame. (default: false)
  58557. * @param textureType Type of textures used when performing the post process. (default: 0)
  58558. * @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)
  58559. */
  58560. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58561. }
  58562. }
  58563. declare module BABYLON {
  58564. /** @hidden */
  58565. export var highlightsPixelShader: {
  58566. name: string;
  58567. shader: string;
  58568. };
  58569. }
  58570. declare module BABYLON {
  58571. /**
  58572. * Extracts highlights from the image
  58573. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58574. */
  58575. export class HighlightsPostProcess extends PostProcess {
  58576. /**
  58577. * Extracts highlights from the image
  58578. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58579. * @param name The name of the effect.
  58580. * @param options The required width/height ratio to downsize to before computing the render pass.
  58581. * @param camera The camera to apply the render pass to.
  58582. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58583. * @param engine The engine which the post process will be applied. (default: current engine)
  58584. * @param reusable If the post process can be reused on the same frame. (default: false)
  58585. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58586. */
  58587. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58588. }
  58589. }
  58590. declare module BABYLON {
  58591. /** @hidden */
  58592. export var mrtFragmentDeclaration: {
  58593. name: string;
  58594. shader: string;
  58595. };
  58596. }
  58597. declare module BABYLON {
  58598. /** @hidden */
  58599. export var geometryPixelShader: {
  58600. name: string;
  58601. shader: string;
  58602. };
  58603. }
  58604. declare module BABYLON {
  58605. /** @hidden */
  58606. export var geometryVertexShader: {
  58607. name: string;
  58608. shader: string;
  58609. };
  58610. }
  58611. declare module BABYLON {
  58612. /** @hidden */
  58613. interface ISavedTransformationMatrix {
  58614. world: Matrix;
  58615. viewProjection: Matrix;
  58616. }
  58617. /**
  58618. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58619. */
  58620. export class GeometryBufferRenderer {
  58621. /**
  58622. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58623. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58624. */
  58625. static readonly POSITION_TEXTURE_TYPE: number;
  58626. /**
  58627. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58628. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58629. */
  58630. static readonly VELOCITY_TEXTURE_TYPE: number;
  58631. /**
  58632. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58633. * in order to compute objects velocities when enableVelocity is set to "true"
  58634. * @hidden
  58635. */
  58636. _previousTransformationMatrices: {
  58637. [index: number]: ISavedTransformationMatrix;
  58638. };
  58639. /**
  58640. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58641. * in order to compute objects velocities when enableVelocity is set to "true"
  58642. * @hidden
  58643. */
  58644. _previousBonesTransformationMatrices: {
  58645. [index: number]: Float32Array;
  58646. };
  58647. /**
  58648. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58649. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58650. */
  58651. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58652. private _scene;
  58653. private _multiRenderTarget;
  58654. private _ratio;
  58655. private _enablePosition;
  58656. private _enableVelocity;
  58657. private _positionIndex;
  58658. private _velocityIndex;
  58659. protected _effect: Effect;
  58660. protected _cachedDefines: string;
  58661. /**
  58662. * Set the render list (meshes to be rendered) used in the G buffer.
  58663. */
  58664. renderList: Mesh[];
  58665. /**
  58666. * Gets wether or not G buffer are supported by the running hardware.
  58667. * This requires draw buffer supports
  58668. */
  58669. readonly isSupported: boolean;
  58670. /**
  58671. * Returns the index of the given texture type in the G-Buffer textures array
  58672. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58673. * @returns the index of the given texture type in the G-Buffer textures array
  58674. */
  58675. getTextureIndex(textureType: number): number;
  58676. /**
  58677. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58678. */
  58679. /**
  58680. * Sets whether or not objects positions are enabled for the G buffer.
  58681. */
  58682. enablePosition: boolean;
  58683. /**
  58684. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58685. */
  58686. /**
  58687. * Sets wether or not objects velocities are enabled for the G buffer.
  58688. */
  58689. enableVelocity: boolean;
  58690. /**
  58691. * Gets the scene associated with the buffer.
  58692. */
  58693. readonly scene: Scene;
  58694. /**
  58695. * Gets the ratio used by the buffer during its creation.
  58696. * How big is the buffer related to the main canvas.
  58697. */
  58698. readonly ratio: number;
  58699. /** @hidden */
  58700. static _SceneComponentInitialization: (scene: Scene) => void;
  58701. /**
  58702. * Creates a new G Buffer for the scene
  58703. * @param scene The scene the buffer belongs to
  58704. * @param ratio How big is the buffer related to the main canvas.
  58705. */
  58706. constructor(scene: Scene, ratio?: number);
  58707. /**
  58708. * Checks wether everything is ready to render a submesh to the G buffer.
  58709. * @param subMesh the submesh to check readiness for
  58710. * @param useInstances is the mesh drawn using instance or not
  58711. * @returns true if ready otherwise false
  58712. */
  58713. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58714. /**
  58715. * Gets the current underlying G Buffer.
  58716. * @returns the buffer
  58717. */
  58718. getGBuffer(): MultiRenderTarget;
  58719. /**
  58720. * Gets the number of samples used to render the buffer (anti aliasing).
  58721. */
  58722. /**
  58723. * Sets the number of samples used to render the buffer (anti aliasing).
  58724. */
  58725. samples: number;
  58726. /**
  58727. * Disposes the renderer and frees up associated resources.
  58728. */
  58729. dispose(): void;
  58730. protected _createRenderTargets(): void;
  58731. private _copyBonesTransformationMatrices;
  58732. }
  58733. }
  58734. declare module BABYLON {
  58735. interface Scene {
  58736. /** @hidden (Backing field) */
  58737. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58738. /**
  58739. * Gets or Sets the current geometry buffer associated to the scene.
  58740. */
  58741. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58742. /**
  58743. * Enables a GeometryBufferRender and associates it with the scene
  58744. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58745. * @returns the GeometryBufferRenderer
  58746. */
  58747. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58748. /**
  58749. * Disables the GeometryBufferRender associated with the scene
  58750. */
  58751. disableGeometryBufferRenderer(): void;
  58752. }
  58753. /**
  58754. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58755. * in several rendering techniques.
  58756. */
  58757. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58758. /**
  58759. * The component name helpful to identify the component in the list of scene components.
  58760. */
  58761. readonly name: string;
  58762. /**
  58763. * The scene the component belongs to.
  58764. */
  58765. scene: Scene;
  58766. /**
  58767. * Creates a new instance of the component for the given scene
  58768. * @param scene Defines the scene to register the component in
  58769. */
  58770. constructor(scene: Scene);
  58771. /**
  58772. * Registers the component in a given scene
  58773. */
  58774. register(): void;
  58775. /**
  58776. * Rebuilds the elements related to this component in case of
  58777. * context lost for instance.
  58778. */
  58779. rebuild(): void;
  58780. /**
  58781. * Disposes the component and the associated ressources
  58782. */
  58783. dispose(): void;
  58784. private _gatherRenderTargets;
  58785. }
  58786. }
  58787. declare module BABYLON {
  58788. /** @hidden */
  58789. export var motionBlurPixelShader: {
  58790. name: string;
  58791. shader: string;
  58792. };
  58793. }
  58794. declare module BABYLON {
  58795. /**
  58796. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58797. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58798. * As an example, all you have to do is to create the post-process:
  58799. * var mb = new BABYLON.MotionBlurPostProcess(
  58800. * 'mb', // The name of the effect.
  58801. * scene, // The scene containing the objects to blur according to their velocity.
  58802. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58803. * camera // The camera to apply the render pass to.
  58804. * );
  58805. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58806. */
  58807. export class MotionBlurPostProcess extends PostProcess {
  58808. /**
  58809. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58810. */
  58811. motionStrength: number;
  58812. /**
  58813. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58814. */
  58815. /**
  58816. * Sets the number of iterations to be used for motion blur quality
  58817. */
  58818. motionBlurSamples: number;
  58819. private _motionBlurSamples;
  58820. private _geometryBufferRenderer;
  58821. /**
  58822. * Creates a new instance MotionBlurPostProcess
  58823. * @param name The name of the effect.
  58824. * @param scene The scene containing the objects to blur according to their velocity.
  58825. * @param options The required width/height ratio to downsize to before computing the render pass.
  58826. * @param camera The camera to apply the render pass to.
  58827. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58828. * @param engine The engine which the post process will be applied. (default: current engine)
  58829. * @param reusable If the post process can be reused on the same frame. (default: false)
  58830. * @param textureType Type of textures used when performing the post process. (default: 0)
  58831. * @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)
  58832. */
  58833. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58834. /**
  58835. * Excludes the given skinned mesh from computing bones velocities.
  58836. * 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.
  58837. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58838. */
  58839. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58840. /**
  58841. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58842. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58843. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58844. */
  58845. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58846. /**
  58847. * Disposes the post process.
  58848. * @param camera The camera to dispose the post process on.
  58849. */
  58850. dispose(camera?: Camera): void;
  58851. }
  58852. }
  58853. declare module BABYLON {
  58854. /** @hidden */
  58855. export var refractionPixelShader: {
  58856. name: string;
  58857. shader: string;
  58858. };
  58859. }
  58860. declare module BABYLON {
  58861. /**
  58862. * Post process which applies a refractin texture
  58863. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58864. */
  58865. export class RefractionPostProcess extends PostProcess {
  58866. /** the base color of the refraction (used to taint the rendering) */
  58867. color: Color3;
  58868. /** simulated refraction depth */
  58869. depth: number;
  58870. /** the coefficient of the base color (0 to remove base color tainting) */
  58871. colorLevel: number;
  58872. private _refTexture;
  58873. private _ownRefractionTexture;
  58874. /**
  58875. * Gets or sets the refraction texture
  58876. * Please note that you are responsible for disposing the texture if you set it manually
  58877. */
  58878. refractionTexture: Texture;
  58879. /**
  58880. * Initializes the RefractionPostProcess
  58881. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58882. * @param name The name of the effect.
  58883. * @param refractionTextureUrl Url of the refraction texture to use
  58884. * @param color the base color of the refraction (used to taint the rendering)
  58885. * @param depth simulated refraction depth
  58886. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58887. * @param camera The camera to apply the render pass to.
  58888. * @param options The required width/height ratio to downsize to before computing the render pass.
  58889. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58890. * @param engine The engine which the post process will be applied. (default: current engine)
  58891. * @param reusable If the post process can be reused on the same frame. (default: false)
  58892. */
  58893. constructor(name: string, refractionTextureUrl: string,
  58894. /** the base color of the refraction (used to taint the rendering) */
  58895. color: Color3,
  58896. /** simulated refraction depth */
  58897. depth: number,
  58898. /** the coefficient of the base color (0 to remove base color tainting) */
  58899. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58900. /**
  58901. * Disposes of the post process
  58902. * @param camera Camera to dispose post process on
  58903. */
  58904. dispose(camera: Camera): void;
  58905. }
  58906. }
  58907. declare module BABYLON {
  58908. /** @hidden */
  58909. export var sharpenPixelShader: {
  58910. name: string;
  58911. shader: string;
  58912. };
  58913. }
  58914. declare module BABYLON {
  58915. /**
  58916. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58917. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58918. */
  58919. export class SharpenPostProcess extends PostProcess {
  58920. /**
  58921. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58922. */
  58923. colorAmount: number;
  58924. /**
  58925. * How much sharpness should be applied (default: 0.3)
  58926. */
  58927. edgeAmount: number;
  58928. /**
  58929. * Creates a new instance ConvolutionPostProcess
  58930. * @param name The name of the effect.
  58931. * @param options The required width/height ratio to downsize to before computing the render pass.
  58932. * @param camera The camera to apply the render pass to.
  58933. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58934. * @param engine The engine which the post process will be applied. (default: current engine)
  58935. * @param reusable If the post process can be reused on the same frame. (default: false)
  58936. * @param textureType Type of textures used when performing the post process. (default: 0)
  58937. * @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)
  58938. */
  58939. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58940. }
  58941. }
  58942. declare module BABYLON {
  58943. /**
  58944. * PostProcessRenderPipeline
  58945. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58946. */
  58947. export class PostProcessRenderPipeline {
  58948. private engine;
  58949. private _renderEffects;
  58950. private _renderEffectsForIsolatedPass;
  58951. /**
  58952. * List of inspectable custom properties (used by the Inspector)
  58953. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58954. */
  58955. inspectableCustomProperties: IInspectable[];
  58956. /**
  58957. * @hidden
  58958. */
  58959. protected _cameras: Camera[];
  58960. /** @hidden */
  58961. _name: string;
  58962. /**
  58963. * Gets pipeline name
  58964. */
  58965. readonly name: string;
  58966. /**
  58967. * Initializes a PostProcessRenderPipeline
  58968. * @param engine engine to add the pipeline to
  58969. * @param name name of the pipeline
  58970. */
  58971. constructor(engine: Engine, name: string);
  58972. /**
  58973. * Gets the class name
  58974. * @returns "PostProcessRenderPipeline"
  58975. */
  58976. getClassName(): string;
  58977. /**
  58978. * If all the render effects in the pipeline are supported
  58979. */
  58980. readonly isSupported: boolean;
  58981. /**
  58982. * Adds an effect to the pipeline
  58983. * @param renderEffect the effect to add
  58984. */
  58985. addEffect(renderEffect: PostProcessRenderEffect): void;
  58986. /** @hidden */
  58987. _rebuild(): void;
  58988. /** @hidden */
  58989. _enableEffect(renderEffectName: string, cameras: Camera): void;
  58990. /** @hidden */
  58991. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58992. /** @hidden */
  58993. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58994. /** @hidden */
  58995. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58996. /** @hidden */
  58997. _attachCameras(cameras: Camera, unique: boolean): void;
  58998. /** @hidden */
  58999. _attachCameras(cameras: Camera[], unique: boolean): void;
  59000. /** @hidden */
  59001. _detachCameras(cameras: Camera): void;
  59002. /** @hidden */
  59003. _detachCameras(cameras: Nullable<Camera[]>): void;
  59004. /** @hidden */
  59005. _update(): void;
  59006. /** @hidden */
  59007. _reset(): void;
  59008. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  59009. /**
  59010. * Disposes of the pipeline
  59011. */
  59012. dispose(): void;
  59013. }
  59014. }
  59015. declare module BABYLON {
  59016. /**
  59017. * PostProcessRenderPipelineManager class
  59018. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59019. */
  59020. export class PostProcessRenderPipelineManager {
  59021. private _renderPipelines;
  59022. /**
  59023. * Initializes a PostProcessRenderPipelineManager
  59024. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59025. */
  59026. constructor();
  59027. /**
  59028. * Gets the list of supported render pipelines
  59029. */
  59030. readonly supportedPipelines: PostProcessRenderPipeline[];
  59031. /**
  59032. * Adds a pipeline to the manager
  59033. * @param renderPipeline The pipeline to add
  59034. */
  59035. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  59036. /**
  59037. * Attaches a camera to the pipeline
  59038. * @param renderPipelineName The name of the pipeline to attach to
  59039. * @param cameras the camera to attach
  59040. * @param unique if the camera can be attached multiple times to the pipeline
  59041. */
  59042. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  59043. /**
  59044. * Detaches a camera from the pipeline
  59045. * @param renderPipelineName The name of the pipeline to detach from
  59046. * @param cameras the camera to detach
  59047. */
  59048. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59049. /**
  59050. * Enables an effect by name on a pipeline
  59051. * @param renderPipelineName the name of the pipeline to enable the effect in
  59052. * @param renderEffectName the name of the effect to enable
  59053. * @param cameras the cameras that the effect should be enabled on
  59054. */
  59055. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59056. /**
  59057. * Disables an effect by name on a pipeline
  59058. * @param renderPipelineName the name of the pipeline to disable the effect in
  59059. * @param renderEffectName the name of the effect to disable
  59060. * @param cameras the cameras that the effect should be disabled on
  59061. */
  59062. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59063. /**
  59064. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59065. */
  59066. update(): void;
  59067. /** @hidden */
  59068. _rebuild(): void;
  59069. /**
  59070. * Disposes of the manager and pipelines
  59071. */
  59072. dispose(): void;
  59073. }
  59074. }
  59075. declare module BABYLON {
  59076. interface Scene {
  59077. /** @hidden (Backing field) */
  59078. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59079. /**
  59080. * Gets the postprocess render pipeline manager
  59081. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59082. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59083. */
  59084. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59085. }
  59086. /**
  59087. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59088. */
  59089. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59090. /**
  59091. * The component name helpfull to identify the component in the list of scene components.
  59092. */
  59093. readonly name: string;
  59094. /**
  59095. * The scene the component belongs to.
  59096. */
  59097. scene: Scene;
  59098. /**
  59099. * Creates a new instance of the component for the given scene
  59100. * @param scene Defines the scene to register the component in
  59101. */
  59102. constructor(scene: Scene);
  59103. /**
  59104. * Registers the component in a given scene
  59105. */
  59106. register(): void;
  59107. /**
  59108. * Rebuilds the elements related to this component in case of
  59109. * context lost for instance.
  59110. */
  59111. rebuild(): void;
  59112. /**
  59113. * Disposes the component and the associated ressources
  59114. */
  59115. dispose(): void;
  59116. private _gatherRenderTargets;
  59117. }
  59118. }
  59119. declare module BABYLON {
  59120. /**
  59121. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59122. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59123. */
  59124. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59125. private _scene;
  59126. private _camerasToBeAttached;
  59127. /**
  59128. * ID of the sharpen post process,
  59129. */
  59130. private readonly SharpenPostProcessId;
  59131. /**
  59132. * @ignore
  59133. * ID of the image processing post process;
  59134. */
  59135. readonly ImageProcessingPostProcessId: string;
  59136. /**
  59137. * @ignore
  59138. * ID of the Fast Approximate Anti-Aliasing post process;
  59139. */
  59140. readonly FxaaPostProcessId: string;
  59141. /**
  59142. * ID of the chromatic aberration post process,
  59143. */
  59144. private readonly ChromaticAberrationPostProcessId;
  59145. /**
  59146. * ID of the grain post process
  59147. */
  59148. private readonly GrainPostProcessId;
  59149. /**
  59150. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59151. */
  59152. sharpen: SharpenPostProcess;
  59153. private _sharpenEffect;
  59154. private bloom;
  59155. /**
  59156. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59157. */
  59158. depthOfField: DepthOfFieldEffect;
  59159. /**
  59160. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59161. */
  59162. fxaa: FxaaPostProcess;
  59163. /**
  59164. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59165. */
  59166. imageProcessing: ImageProcessingPostProcess;
  59167. /**
  59168. * Chromatic aberration post process which will shift rgb colors in the image
  59169. */
  59170. chromaticAberration: ChromaticAberrationPostProcess;
  59171. private _chromaticAberrationEffect;
  59172. /**
  59173. * Grain post process which add noise to the image
  59174. */
  59175. grain: GrainPostProcess;
  59176. private _grainEffect;
  59177. /**
  59178. * Glow post process which adds a glow to emissive areas of the image
  59179. */
  59180. private _glowLayer;
  59181. /**
  59182. * Animations which can be used to tweak settings over a period of time
  59183. */
  59184. animations: Animation[];
  59185. private _imageProcessingConfigurationObserver;
  59186. private _sharpenEnabled;
  59187. private _bloomEnabled;
  59188. private _depthOfFieldEnabled;
  59189. private _depthOfFieldBlurLevel;
  59190. private _fxaaEnabled;
  59191. private _imageProcessingEnabled;
  59192. private _defaultPipelineTextureType;
  59193. private _bloomScale;
  59194. private _chromaticAberrationEnabled;
  59195. private _grainEnabled;
  59196. private _buildAllowed;
  59197. /**
  59198. * Gets active scene
  59199. */
  59200. readonly scene: Scene;
  59201. /**
  59202. * Enable or disable the sharpen process from the pipeline
  59203. */
  59204. sharpenEnabled: boolean;
  59205. private _resizeObserver;
  59206. private _hardwareScaleLevel;
  59207. private _bloomKernel;
  59208. /**
  59209. * Specifies the size of the bloom blur kernel, relative to the final output size
  59210. */
  59211. bloomKernel: number;
  59212. /**
  59213. * Specifies the weight of the bloom in the final rendering
  59214. */
  59215. private _bloomWeight;
  59216. /**
  59217. * Specifies the luma threshold for the area that will be blurred by the bloom
  59218. */
  59219. private _bloomThreshold;
  59220. private _hdr;
  59221. /**
  59222. * The strength of the bloom.
  59223. */
  59224. bloomWeight: number;
  59225. /**
  59226. * The strength of the bloom.
  59227. */
  59228. bloomThreshold: number;
  59229. /**
  59230. * The scale of the bloom, lower value will provide better performance.
  59231. */
  59232. bloomScale: number;
  59233. /**
  59234. * Enable or disable the bloom from the pipeline
  59235. */
  59236. bloomEnabled: boolean;
  59237. private _rebuildBloom;
  59238. /**
  59239. * If the depth of field is enabled.
  59240. */
  59241. depthOfFieldEnabled: boolean;
  59242. /**
  59243. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59244. */
  59245. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59246. /**
  59247. * If the anti aliasing is enabled.
  59248. */
  59249. fxaaEnabled: boolean;
  59250. private _samples;
  59251. /**
  59252. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59253. */
  59254. samples: number;
  59255. /**
  59256. * If image processing is enabled.
  59257. */
  59258. imageProcessingEnabled: boolean;
  59259. /**
  59260. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59261. */
  59262. glowLayerEnabled: boolean;
  59263. /**
  59264. * Gets the glow layer (or null if not defined)
  59265. */
  59266. readonly glowLayer: Nullable<GlowLayer>;
  59267. /**
  59268. * Enable or disable the chromaticAberration process from the pipeline
  59269. */
  59270. chromaticAberrationEnabled: boolean;
  59271. /**
  59272. * Enable or disable the grain process from the pipeline
  59273. */
  59274. grainEnabled: boolean;
  59275. /**
  59276. * @constructor
  59277. * @param name - The rendering pipeline name (default: "")
  59278. * @param hdr - If high dynamic range textures should be used (default: true)
  59279. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59280. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59281. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59282. */
  59283. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59284. /**
  59285. * Get the class name
  59286. * @returns "DefaultRenderingPipeline"
  59287. */
  59288. getClassName(): string;
  59289. /**
  59290. * Force the compilation of the entire pipeline.
  59291. */
  59292. prepare(): void;
  59293. private _hasCleared;
  59294. private _prevPostProcess;
  59295. private _prevPrevPostProcess;
  59296. private _setAutoClearAndTextureSharing;
  59297. private _depthOfFieldSceneObserver;
  59298. private _buildPipeline;
  59299. private _disposePostProcesses;
  59300. /**
  59301. * Adds a camera to the pipeline
  59302. * @param camera the camera to be added
  59303. */
  59304. addCamera(camera: Camera): void;
  59305. /**
  59306. * Removes a camera from the pipeline
  59307. * @param camera the camera to remove
  59308. */
  59309. removeCamera(camera: Camera): void;
  59310. /**
  59311. * Dispose of the pipeline and stop all post processes
  59312. */
  59313. dispose(): void;
  59314. /**
  59315. * Serialize the rendering pipeline (Used when exporting)
  59316. * @returns the serialized object
  59317. */
  59318. serialize(): any;
  59319. /**
  59320. * Parse the serialized pipeline
  59321. * @param source Source pipeline.
  59322. * @param scene The scene to load the pipeline to.
  59323. * @param rootUrl The URL of the serialized pipeline.
  59324. * @returns An instantiated pipeline from the serialized object.
  59325. */
  59326. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59327. }
  59328. }
  59329. declare module BABYLON {
  59330. /** @hidden */
  59331. export var lensHighlightsPixelShader: {
  59332. name: string;
  59333. shader: string;
  59334. };
  59335. }
  59336. declare module BABYLON {
  59337. /** @hidden */
  59338. export var depthOfFieldPixelShader: {
  59339. name: string;
  59340. shader: string;
  59341. };
  59342. }
  59343. declare module BABYLON {
  59344. /**
  59345. * BABYLON.JS Chromatic Aberration GLSL Shader
  59346. * Author: Olivier Guyot
  59347. * Separates very slightly R, G and B colors on the edges of the screen
  59348. * Inspired by Francois Tarlier & Martins Upitis
  59349. */
  59350. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59351. /**
  59352. * @ignore
  59353. * The chromatic aberration PostProcess id in the pipeline
  59354. */
  59355. LensChromaticAberrationEffect: string;
  59356. /**
  59357. * @ignore
  59358. * The highlights enhancing PostProcess id in the pipeline
  59359. */
  59360. HighlightsEnhancingEffect: string;
  59361. /**
  59362. * @ignore
  59363. * The depth-of-field PostProcess id in the pipeline
  59364. */
  59365. LensDepthOfFieldEffect: string;
  59366. private _scene;
  59367. private _depthTexture;
  59368. private _grainTexture;
  59369. private _chromaticAberrationPostProcess;
  59370. private _highlightsPostProcess;
  59371. private _depthOfFieldPostProcess;
  59372. private _edgeBlur;
  59373. private _grainAmount;
  59374. private _chromaticAberration;
  59375. private _distortion;
  59376. private _highlightsGain;
  59377. private _highlightsThreshold;
  59378. private _dofDistance;
  59379. private _dofAperture;
  59380. private _dofDarken;
  59381. private _dofPentagon;
  59382. private _blurNoise;
  59383. /**
  59384. * @constructor
  59385. *
  59386. * Effect parameters are as follow:
  59387. * {
  59388. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59389. * edge_blur: number; // from 0 to x (1 for realism)
  59390. * distortion: number; // from 0 to x (1 for realism)
  59391. * grain_amount: number; // from 0 to 1
  59392. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59393. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59394. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59395. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59396. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59397. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59398. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59399. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59400. * }
  59401. * Note: if an effect parameter is unset, effect is disabled
  59402. *
  59403. * @param name The rendering pipeline name
  59404. * @param parameters - An object containing all parameters (see above)
  59405. * @param scene The scene linked to this pipeline
  59406. * @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)
  59407. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59408. */
  59409. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59410. /**
  59411. * Get the class name
  59412. * @returns "LensRenderingPipeline"
  59413. */
  59414. getClassName(): string;
  59415. /**
  59416. * Gets associated scene
  59417. */
  59418. readonly scene: Scene;
  59419. /**
  59420. * Gets or sets the edge blur
  59421. */
  59422. edgeBlur: number;
  59423. /**
  59424. * Gets or sets the grain amount
  59425. */
  59426. grainAmount: number;
  59427. /**
  59428. * Gets or sets the chromatic aberration amount
  59429. */
  59430. chromaticAberration: number;
  59431. /**
  59432. * Gets or sets the depth of field aperture
  59433. */
  59434. dofAperture: number;
  59435. /**
  59436. * Gets or sets the edge distortion
  59437. */
  59438. edgeDistortion: number;
  59439. /**
  59440. * Gets or sets the depth of field distortion
  59441. */
  59442. dofDistortion: number;
  59443. /**
  59444. * Gets or sets the darken out of focus amount
  59445. */
  59446. darkenOutOfFocus: number;
  59447. /**
  59448. * Gets or sets a boolean indicating if blur noise is enabled
  59449. */
  59450. blurNoise: boolean;
  59451. /**
  59452. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59453. */
  59454. pentagonBokeh: boolean;
  59455. /**
  59456. * Gets or sets the highlight grain amount
  59457. */
  59458. highlightsGain: number;
  59459. /**
  59460. * Gets or sets the highlight threshold
  59461. */
  59462. highlightsThreshold: number;
  59463. /**
  59464. * Sets the amount of blur at the edges
  59465. * @param amount blur amount
  59466. */
  59467. setEdgeBlur(amount: number): void;
  59468. /**
  59469. * Sets edge blur to 0
  59470. */
  59471. disableEdgeBlur(): void;
  59472. /**
  59473. * Sets the amout of grain
  59474. * @param amount Amount of grain
  59475. */
  59476. setGrainAmount(amount: number): void;
  59477. /**
  59478. * Set grain amount to 0
  59479. */
  59480. disableGrain(): void;
  59481. /**
  59482. * Sets the chromatic aberration amount
  59483. * @param amount amount of chromatic aberration
  59484. */
  59485. setChromaticAberration(amount: number): void;
  59486. /**
  59487. * Sets chromatic aberration amount to 0
  59488. */
  59489. disableChromaticAberration(): void;
  59490. /**
  59491. * Sets the EdgeDistortion amount
  59492. * @param amount amount of EdgeDistortion
  59493. */
  59494. setEdgeDistortion(amount: number): void;
  59495. /**
  59496. * Sets edge distortion to 0
  59497. */
  59498. disableEdgeDistortion(): void;
  59499. /**
  59500. * Sets the FocusDistance amount
  59501. * @param amount amount of FocusDistance
  59502. */
  59503. setFocusDistance(amount: number): void;
  59504. /**
  59505. * Disables depth of field
  59506. */
  59507. disableDepthOfField(): void;
  59508. /**
  59509. * Sets the Aperture amount
  59510. * @param amount amount of Aperture
  59511. */
  59512. setAperture(amount: number): void;
  59513. /**
  59514. * Sets the DarkenOutOfFocus amount
  59515. * @param amount amount of DarkenOutOfFocus
  59516. */
  59517. setDarkenOutOfFocus(amount: number): void;
  59518. private _pentagonBokehIsEnabled;
  59519. /**
  59520. * Creates a pentagon bokeh effect
  59521. */
  59522. enablePentagonBokeh(): void;
  59523. /**
  59524. * Disables the pentagon bokeh effect
  59525. */
  59526. disablePentagonBokeh(): void;
  59527. /**
  59528. * Enables noise blur
  59529. */
  59530. enableNoiseBlur(): void;
  59531. /**
  59532. * Disables noise blur
  59533. */
  59534. disableNoiseBlur(): void;
  59535. /**
  59536. * Sets the HighlightsGain amount
  59537. * @param amount amount of HighlightsGain
  59538. */
  59539. setHighlightsGain(amount: number): void;
  59540. /**
  59541. * Sets the HighlightsThreshold amount
  59542. * @param amount amount of HighlightsThreshold
  59543. */
  59544. setHighlightsThreshold(amount: number): void;
  59545. /**
  59546. * Disables highlights
  59547. */
  59548. disableHighlights(): void;
  59549. /**
  59550. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59551. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59552. */
  59553. dispose(disableDepthRender?: boolean): void;
  59554. private _createChromaticAberrationPostProcess;
  59555. private _createHighlightsPostProcess;
  59556. private _createDepthOfFieldPostProcess;
  59557. private _createGrainTexture;
  59558. }
  59559. }
  59560. declare module BABYLON {
  59561. /** @hidden */
  59562. export var ssao2PixelShader: {
  59563. name: string;
  59564. shader: string;
  59565. };
  59566. }
  59567. declare module BABYLON {
  59568. /** @hidden */
  59569. export var ssaoCombinePixelShader: {
  59570. name: string;
  59571. shader: string;
  59572. };
  59573. }
  59574. declare module BABYLON {
  59575. /**
  59576. * Render pipeline to produce ssao effect
  59577. */
  59578. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59579. /**
  59580. * @ignore
  59581. * The PassPostProcess id in the pipeline that contains the original scene color
  59582. */
  59583. SSAOOriginalSceneColorEffect: string;
  59584. /**
  59585. * @ignore
  59586. * The SSAO PostProcess id in the pipeline
  59587. */
  59588. SSAORenderEffect: string;
  59589. /**
  59590. * @ignore
  59591. * The horizontal blur PostProcess id in the pipeline
  59592. */
  59593. SSAOBlurHRenderEffect: string;
  59594. /**
  59595. * @ignore
  59596. * The vertical blur PostProcess id in the pipeline
  59597. */
  59598. SSAOBlurVRenderEffect: string;
  59599. /**
  59600. * @ignore
  59601. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59602. */
  59603. SSAOCombineRenderEffect: string;
  59604. /**
  59605. * The output strength of the SSAO post-process. Default value is 1.0.
  59606. */
  59607. totalStrength: number;
  59608. /**
  59609. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59610. */
  59611. maxZ: number;
  59612. /**
  59613. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59614. */
  59615. minZAspect: number;
  59616. private _samples;
  59617. /**
  59618. * Number of samples used for the SSAO calculations. Default value is 8
  59619. */
  59620. samples: number;
  59621. private _textureSamples;
  59622. /**
  59623. * Number of samples to use for antialiasing
  59624. */
  59625. textureSamples: number;
  59626. /**
  59627. * Ratio object used for SSAO ratio and blur ratio
  59628. */
  59629. private _ratio;
  59630. /**
  59631. * Dynamically generated sphere sampler.
  59632. */
  59633. private _sampleSphere;
  59634. /**
  59635. * Blur filter offsets
  59636. */
  59637. private _samplerOffsets;
  59638. private _expensiveBlur;
  59639. /**
  59640. * If bilateral blur should be used
  59641. */
  59642. expensiveBlur: boolean;
  59643. /**
  59644. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59645. */
  59646. radius: number;
  59647. /**
  59648. * The base color of the SSAO post-process
  59649. * The final result is "base + ssao" between [0, 1]
  59650. */
  59651. base: number;
  59652. /**
  59653. * Support test.
  59654. */
  59655. static readonly IsSupported: boolean;
  59656. private _scene;
  59657. private _depthTexture;
  59658. private _normalTexture;
  59659. private _randomTexture;
  59660. private _originalColorPostProcess;
  59661. private _ssaoPostProcess;
  59662. private _blurHPostProcess;
  59663. private _blurVPostProcess;
  59664. private _ssaoCombinePostProcess;
  59665. private _firstUpdate;
  59666. /**
  59667. * Gets active scene
  59668. */
  59669. readonly scene: Scene;
  59670. /**
  59671. * @constructor
  59672. * @param name The rendering pipeline name
  59673. * @param scene The scene linked to this pipeline
  59674. * @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 }
  59675. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59676. */
  59677. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59678. /**
  59679. * Get the class name
  59680. * @returns "SSAO2RenderingPipeline"
  59681. */
  59682. getClassName(): string;
  59683. /**
  59684. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59685. */
  59686. dispose(disableGeometryBufferRenderer?: boolean): void;
  59687. private _createBlurPostProcess;
  59688. /** @hidden */
  59689. _rebuild(): void;
  59690. private _bits;
  59691. private _radicalInverse_VdC;
  59692. private _hammersley;
  59693. private _hemisphereSample_uniform;
  59694. private _generateHemisphere;
  59695. private _createSSAOPostProcess;
  59696. private _createSSAOCombinePostProcess;
  59697. private _createRandomTexture;
  59698. /**
  59699. * Serialize the rendering pipeline (Used when exporting)
  59700. * @returns the serialized object
  59701. */
  59702. serialize(): any;
  59703. /**
  59704. * Parse the serialized pipeline
  59705. * @param source Source pipeline.
  59706. * @param scene The scene to load the pipeline to.
  59707. * @param rootUrl The URL of the serialized pipeline.
  59708. * @returns An instantiated pipeline from the serialized object.
  59709. */
  59710. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59711. }
  59712. }
  59713. declare module BABYLON {
  59714. /** @hidden */
  59715. export var ssaoPixelShader: {
  59716. name: string;
  59717. shader: string;
  59718. };
  59719. }
  59720. declare module BABYLON {
  59721. /**
  59722. * Render pipeline to produce ssao effect
  59723. */
  59724. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59725. /**
  59726. * @ignore
  59727. * The PassPostProcess id in the pipeline that contains the original scene color
  59728. */
  59729. SSAOOriginalSceneColorEffect: string;
  59730. /**
  59731. * @ignore
  59732. * The SSAO PostProcess id in the pipeline
  59733. */
  59734. SSAORenderEffect: string;
  59735. /**
  59736. * @ignore
  59737. * The horizontal blur PostProcess id in the pipeline
  59738. */
  59739. SSAOBlurHRenderEffect: string;
  59740. /**
  59741. * @ignore
  59742. * The vertical blur PostProcess id in the pipeline
  59743. */
  59744. SSAOBlurVRenderEffect: string;
  59745. /**
  59746. * @ignore
  59747. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59748. */
  59749. SSAOCombineRenderEffect: string;
  59750. /**
  59751. * The output strength of the SSAO post-process. Default value is 1.0.
  59752. */
  59753. totalStrength: number;
  59754. /**
  59755. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59756. */
  59757. radius: number;
  59758. /**
  59759. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59760. * Must not be equal to fallOff and superior to fallOff.
  59761. * Default value is 0.0075
  59762. */
  59763. area: number;
  59764. /**
  59765. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59766. * Must not be equal to area and inferior to area.
  59767. * Default value is 0.000001
  59768. */
  59769. fallOff: number;
  59770. /**
  59771. * The base color of the SSAO post-process
  59772. * The final result is "base + ssao" between [0, 1]
  59773. */
  59774. base: number;
  59775. private _scene;
  59776. private _depthTexture;
  59777. private _randomTexture;
  59778. private _originalColorPostProcess;
  59779. private _ssaoPostProcess;
  59780. private _blurHPostProcess;
  59781. private _blurVPostProcess;
  59782. private _ssaoCombinePostProcess;
  59783. private _firstUpdate;
  59784. /**
  59785. * Gets active scene
  59786. */
  59787. readonly scene: Scene;
  59788. /**
  59789. * @constructor
  59790. * @param name - The rendering pipeline name
  59791. * @param scene - The scene linked to this pipeline
  59792. * @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 }
  59793. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59794. */
  59795. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59796. /**
  59797. * Get the class name
  59798. * @returns "SSAORenderingPipeline"
  59799. */
  59800. getClassName(): string;
  59801. /**
  59802. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59803. */
  59804. dispose(disableDepthRender?: boolean): void;
  59805. private _createBlurPostProcess;
  59806. /** @hidden */
  59807. _rebuild(): void;
  59808. private _createSSAOPostProcess;
  59809. private _createSSAOCombinePostProcess;
  59810. private _createRandomTexture;
  59811. }
  59812. }
  59813. declare module BABYLON {
  59814. /** @hidden */
  59815. export var standardPixelShader: {
  59816. name: string;
  59817. shader: string;
  59818. };
  59819. }
  59820. declare module BABYLON {
  59821. /**
  59822. * Standard rendering pipeline
  59823. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59824. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59825. */
  59826. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59827. /**
  59828. * Public members
  59829. */
  59830. /**
  59831. * Post-process which contains the original scene color before the pipeline applies all the effects
  59832. */
  59833. originalPostProcess: Nullable<PostProcess>;
  59834. /**
  59835. * Post-process used to down scale an image x4
  59836. */
  59837. downSampleX4PostProcess: Nullable<PostProcess>;
  59838. /**
  59839. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59840. */
  59841. brightPassPostProcess: Nullable<PostProcess>;
  59842. /**
  59843. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59844. */
  59845. blurHPostProcesses: PostProcess[];
  59846. /**
  59847. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59848. */
  59849. blurVPostProcesses: PostProcess[];
  59850. /**
  59851. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59852. */
  59853. textureAdderPostProcess: Nullable<PostProcess>;
  59854. /**
  59855. * Post-process used to create volumetric lighting effect
  59856. */
  59857. volumetricLightPostProcess: Nullable<PostProcess>;
  59858. /**
  59859. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59860. */
  59861. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59862. /**
  59863. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59864. */
  59865. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59866. /**
  59867. * Post-process used to merge the volumetric light effect and the real scene color
  59868. */
  59869. volumetricLightMergePostProces: Nullable<PostProcess>;
  59870. /**
  59871. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59872. */
  59873. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59874. /**
  59875. * Base post-process used to calculate the average luminance of the final image for HDR
  59876. */
  59877. luminancePostProcess: Nullable<PostProcess>;
  59878. /**
  59879. * Post-processes used to create down sample post-processes in order to get
  59880. * the average luminance of the final image for HDR
  59881. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59882. */
  59883. luminanceDownSamplePostProcesses: PostProcess[];
  59884. /**
  59885. * Post-process used to create a HDR effect (light adaptation)
  59886. */
  59887. hdrPostProcess: Nullable<PostProcess>;
  59888. /**
  59889. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59890. */
  59891. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59892. /**
  59893. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59894. */
  59895. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59896. /**
  59897. * Post-process used to merge the final HDR post-process and the real scene color
  59898. */
  59899. hdrFinalPostProcess: Nullable<PostProcess>;
  59900. /**
  59901. * Post-process used to create a lens flare effect
  59902. */
  59903. lensFlarePostProcess: Nullable<PostProcess>;
  59904. /**
  59905. * Post-process that merges the result of the lens flare post-process and the real scene color
  59906. */
  59907. lensFlareComposePostProcess: Nullable<PostProcess>;
  59908. /**
  59909. * Post-process used to create a motion blur effect
  59910. */
  59911. motionBlurPostProcess: Nullable<PostProcess>;
  59912. /**
  59913. * Post-process used to create a depth of field effect
  59914. */
  59915. depthOfFieldPostProcess: Nullable<PostProcess>;
  59916. /**
  59917. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59918. */
  59919. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59920. /**
  59921. * Represents the brightness threshold in order to configure the illuminated surfaces
  59922. */
  59923. brightThreshold: number;
  59924. /**
  59925. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59926. */
  59927. blurWidth: number;
  59928. /**
  59929. * Sets if the blur for highlighted surfaces must be only horizontal
  59930. */
  59931. horizontalBlur: boolean;
  59932. /**
  59933. * Gets the overall exposure used by the pipeline
  59934. */
  59935. /**
  59936. * Sets the overall exposure used by the pipeline
  59937. */
  59938. exposure: number;
  59939. /**
  59940. * Texture used typically to simulate "dirty" on camera lens
  59941. */
  59942. lensTexture: Nullable<Texture>;
  59943. /**
  59944. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59945. */
  59946. volumetricLightCoefficient: number;
  59947. /**
  59948. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59949. */
  59950. volumetricLightPower: number;
  59951. /**
  59952. * Used the set the blur intensity to smooth the volumetric lights
  59953. */
  59954. volumetricLightBlurScale: number;
  59955. /**
  59956. * Light (spot or directional) used to generate the volumetric lights rays
  59957. * The source light must have a shadow generate so the pipeline can get its
  59958. * depth map
  59959. */
  59960. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59961. /**
  59962. * For eye adaptation, represents the minimum luminance the eye can see
  59963. */
  59964. hdrMinimumLuminance: number;
  59965. /**
  59966. * For eye adaptation, represents the decrease luminance speed
  59967. */
  59968. hdrDecreaseRate: number;
  59969. /**
  59970. * For eye adaptation, represents the increase luminance speed
  59971. */
  59972. hdrIncreaseRate: number;
  59973. /**
  59974. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59975. */
  59976. /**
  59977. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59978. */
  59979. hdrAutoExposure: boolean;
  59980. /**
  59981. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59982. */
  59983. lensColorTexture: Nullable<Texture>;
  59984. /**
  59985. * The overall strengh for the lens flare effect
  59986. */
  59987. lensFlareStrength: number;
  59988. /**
  59989. * Dispersion coefficient for lens flare ghosts
  59990. */
  59991. lensFlareGhostDispersal: number;
  59992. /**
  59993. * Main lens flare halo width
  59994. */
  59995. lensFlareHaloWidth: number;
  59996. /**
  59997. * Based on the lens distortion effect, defines how much the lens flare result
  59998. * is distorted
  59999. */
  60000. lensFlareDistortionStrength: number;
  60001. /**
  60002. * Configures the blur intensity used for for lens flare (halo)
  60003. */
  60004. lensFlareBlurWidth: number;
  60005. /**
  60006. * Lens star texture must be used to simulate rays on the flares and is available
  60007. * in the documentation
  60008. */
  60009. lensStarTexture: Nullable<Texture>;
  60010. /**
  60011. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  60012. * flare effect by taking account of the dirt texture
  60013. */
  60014. lensFlareDirtTexture: Nullable<Texture>;
  60015. /**
  60016. * Represents the focal length for the depth of field effect
  60017. */
  60018. depthOfFieldDistance: number;
  60019. /**
  60020. * Represents the blur intensity for the blurred part of the depth of field effect
  60021. */
  60022. depthOfFieldBlurWidth: number;
  60023. /**
  60024. * Gets how much the image is blurred by the movement while using the motion blur post-process
  60025. */
  60026. /**
  60027. * Sets how much the image is blurred by the movement while using the motion blur post-process
  60028. */
  60029. motionStrength: number;
  60030. /**
  60031. * Gets wether or not the motion blur post-process is object based or screen based.
  60032. */
  60033. /**
  60034. * Sets wether or not the motion blur post-process should be object based or screen based
  60035. */
  60036. objectBasedMotionBlur: boolean;
  60037. /**
  60038. * List of animations for the pipeline (IAnimatable implementation)
  60039. */
  60040. animations: Animation[];
  60041. /**
  60042. * Private members
  60043. */
  60044. private _scene;
  60045. private _currentDepthOfFieldSource;
  60046. private _basePostProcess;
  60047. private _fixedExposure;
  60048. private _currentExposure;
  60049. private _hdrAutoExposure;
  60050. private _hdrCurrentLuminance;
  60051. private _motionStrength;
  60052. private _isObjectBasedMotionBlur;
  60053. private _floatTextureType;
  60054. private _camerasToBeAttached;
  60055. private _ratio;
  60056. private _bloomEnabled;
  60057. private _depthOfFieldEnabled;
  60058. private _vlsEnabled;
  60059. private _lensFlareEnabled;
  60060. private _hdrEnabled;
  60061. private _motionBlurEnabled;
  60062. private _fxaaEnabled;
  60063. private _motionBlurSamples;
  60064. private _volumetricLightStepsCount;
  60065. private _samples;
  60066. /**
  60067. * @ignore
  60068. * Specifies if the bloom pipeline is enabled
  60069. */
  60070. BloomEnabled: boolean;
  60071. /**
  60072. * @ignore
  60073. * Specifies if the depth of field pipeline is enabed
  60074. */
  60075. DepthOfFieldEnabled: boolean;
  60076. /**
  60077. * @ignore
  60078. * Specifies if the lens flare pipeline is enabed
  60079. */
  60080. LensFlareEnabled: boolean;
  60081. /**
  60082. * @ignore
  60083. * Specifies if the HDR pipeline is enabled
  60084. */
  60085. HDREnabled: boolean;
  60086. /**
  60087. * @ignore
  60088. * Specifies if the volumetric lights scattering effect is enabled
  60089. */
  60090. VLSEnabled: boolean;
  60091. /**
  60092. * @ignore
  60093. * Specifies if the motion blur effect is enabled
  60094. */
  60095. MotionBlurEnabled: boolean;
  60096. /**
  60097. * Specifies if anti-aliasing is enabled
  60098. */
  60099. fxaaEnabled: boolean;
  60100. /**
  60101. * Specifies the number of steps used to calculate the volumetric lights
  60102. * Typically in interval [50, 200]
  60103. */
  60104. volumetricLightStepsCount: number;
  60105. /**
  60106. * Specifies the number of samples used for the motion blur effect
  60107. * Typically in interval [16, 64]
  60108. */
  60109. motionBlurSamples: number;
  60110. /**
  60111. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60112. */
  60113. samples: number;
  60114. /**
  60115. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60116. * @constructor
  60117. * @param name The rendering pipeline name
  60118. * @param scene The scene linked to this pipeline
  60119. * @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)
  60120. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60121. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60122. */
  60123. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60124. private _buildPipeline;
  60125. private _createDownSampleX4PostProcess;
  60126. private _createBrightPassPostProcess;
  60127. private _createBlurPostProcesses;
  60128. private _createTextureAdderPostProcess;
  60129. private _createVolumetricLightPostProcess;
  60130. private _createLuminancePostProcesses;
  60131. private _createHdrPostProcess;
  60132. private _createLensFlarePostProcess;
  60133. private _createDepthOfFieldPostProcess;
  60134. private _createMotionBlurPostProcess;
  60135. private _getDepthTexture;
  60136. private _disposePostProcesses;
  60137. /**
  60138. * Dispose of the pipeline and stop all post processes
  60139. */
  60140. dispose(): void;
  60141. /**
  60142. * Serialize the rendering pipeline (Used when exporting)
  60143. * @returns the serialized object
  60144. */
  60145. serialize(): any;
  60146. /**
  60147. * Parse the serialized pipeline
  60148. * @param source Source pipeline.
  60149. * @param scene The scene to load the pipeline to.
  60150. * @param rootUrl The URL of the serialized pipeline.
  60151. * @returns An instantiated pipeline from the serialized object.
  60152. */
  60153. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60154. /**
  60155. * Luminance steps
  60156. */
  60157. static LuminanceSteps: number;
  60158. }
  60159. }
  60160. declare module BABYLON {
  60161. /** @hidden */
  60162. export var tonemapPixelShader: {
  60163. name: string;
  60164. shader: string;
  60165. };
  60166. }
  60167. declare module BABYLON {
  60168. /** Defines operator used for tonemapping */
  60169. export enum TonemappingOperator {
  60170. /** Hable */
  60171. Hable = 0,
  60172. /** Reinhard */
  60173. Reinhard = 1,
  60174. /** HejiDawson */
  60175. HejiDawson = 2,
  60176. /** Photographic */
  60177. Photographic = 3
  60178. }
  60179. /**
  60180. * Defines a post process to apply tone mapping
  60181. */
  60182. export class TonemapPostProcess extends PostProcess {
  60183. private _operator;
  60184. /** Defines the required exposure adjustement */
  60185. exposureAdjustment: number;
  60186. /**
  60187. * Creates a new TonemapPostProcess
  60188. * @param name defines the name of the postprocess
  60189. * @param _operator defines the operator to use
  60190. * @param exposureAdjustment defines the required exposure adjustement
  60191. * @param camera defines the camera to use (can be null)
  60192. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60193. * @param engine defines the hosting engine (can be ignore if camera is set)
  60194. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60195. */
  60196. constructor(name: string, _operator: TonemappingOperator,
  60197. /** Defines the required exposure adjustement */
  60198. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60199. }
  60200. }
  60201. declare module BABYLON {
  60202. /** @hidden */
  60203. export var depthVertexShader: {
  60204. name: string;
  60205. shader: string;
  60206. };
  60207. }
  60208. declare module BABYLON {
  60209. /** @hidden */
  60210. export var volumetricLightScatteringPixelShader: {
  60211. name: string;
  60212. shader: string;
  60213. };
  60214. }
  60215. declare module BABYLON {
  60216. /** @hidden */
  60217. export var volumetricLightScatteringPassVertexShader: {
  60218. name: string;
  60219. shader: string;
  60220. };
  60221. }
  60222. declare module BABYLON {
  60223. /** @hidden */
  60224. export var volumetricLightScatteringPassPixelShader: {
  60225. name: string;
  60226. shader: string;
  60227. };
  60228. }
  60229. declare module BABYLON {
  60230. /**
  60231. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60232. */
  60233. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60234. private _volumetricLightScatteringPass;
  60235. private _volumetricLightScatteringRTT;
  60236. private _viewPort;
  60237. private _screenCoordinates;
  60238. private _cachedDefines;
  60239. /**
  60240. * If not undefined, the mesh position is computed from the attached node position
  60241. */
  60242. attachedNode: {
  60243. position: Vector3;
  60244. };
  60245. /**
  60246. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60247. */
  60248. customMeshPosition: Vector3;
  60249. /**
  60250. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60251. */
  60252. useCustomMeshPosition: boolean;
  60253. /**
  60254. * If the post-process should inverse the light scattering direction
  60255. */
  60256. invert: boolean;
  60257. /**
  60258. * The internal mesh used by the post-process
  60259. */
  60260. mesh: Mesh;
  60261. /**
  60262. * @hidden
  60263. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60264. */
  60265. useDiffuseColor: boolean;
  60266. /**
  60267. * Array containing the excluded meshes not rendered in the internal pass
  60268. */
  60269. excludedMeshes: AbstractMesh[];
  60270. /**
  60271. * Controls the overall intensity of the post-process
  60272. */
  60273. exposure: number;
  60274. /**
  60275. * Dissipates each sample's contribution in range [0, 1]
  60276. */
  60277. decay: number;
  60278. /**
  60279. * Controls the overall intensity of each sample
  60280. */
  60281. weight: number;
  60282. /**
  60283. * Controls the density of each sample
  60284. */
  60285. density: number;
  60286. /**
  60287. * @constructor
  60288. * @param name The post-process name
  60289. * @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)
  60290. * @param camera The camera that the post-process will be attached to
  60291. * @param mesh The mesh used to create the light scattering
  60292. * @param samples The post-process quality, default 100
  60293. * @param samplingModeThe post-process filtering mode
  60294. * @param engine The babylon engine
  60295. * @param reusable If the post-process is reusable
  60296. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60297. */
  60298. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60299. /**
  60300. * Returns the string "VolumetricLightScatteringPostProcess"
  60301. * @returns "VolumetricLightScatteringPostProcess"
  60302. */
  60303. getClassName(): string;
  60304. private _isReady;
  60305. /**
  60306. * Sets the new light position for light scattering effect
  60307. * @param position The new custom light position
  60308. */
  60309. setCustomMeshPosition(position: Vector3): void;
  60310. /**
  60311. * Returns the light position for light scattering effect
  60312. * @return Vector3 The custom light position
  60313. */
  60314. getCustomMeshPosition(): Vector3;
  60315. /**
  60316. * Disposes the internal assets and detaches the post-process from the camera
  60317. */
  60318. dispose(camera: Camera): void;
  60319. /**
  60320. * Returns the render target texture used by the post-process
  60321. * @return the render target texture used by the post-process
  60322. */
  60323. getPass(): RenderTargetTexture;
  60324. private _meshExcluded;
  60325. private _createPass;
  60326. private _updateMeshScreenCoordinates;
  60327. /**
  60328. * Creates a default mesh for the Volumeric Light Scattering post-process
  60329. * @param name The mesh name
  60330. * @param scene The scene where to create the mesh
  60331. * @return the default mesh
  60332. */
  60333. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60334. }
  60335. }
  60336. declare module BABYLON {
  60337. interface Scene {
  60338. /** @hidden (Backing field) */
  60339. _boundingBoxRenderer: BoundingBoxRenderer;
  60340. /** @hidden (Backing field) */
  60341. _forceShowBoundingBoxes: boolean;
  60342. /**
  60343. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60344. */
  60345. forceShowBoundingBoxes: boolean;
  60346. /**
  60347. * Gets the bounding box renderer associated with the scene
  60348. * @returns a BoundingBoxRenderer
  60349. */
  60350. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60351. }
  60352. interface AbstractMesh {
  60353. /** @hidden (Backing field) */
  60354. _showBoundingBox: boolean;
  60355. /**
  60356. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60357. */
  60358. showBoundingBox: boolean;
  60359. }
  60360. /**
  60361. * Component responsible of rendering the bounding box of the meshes in a scene.
  60362. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60363. */
  60364. export class BoundingBoxRenderer implements ISceneComponent {
  60365. /**
  60366. * The component name helpfull to identify the component in the list of scene components.
  60367. */
  60368. readonly name: string;
  60369. /**
  60370. * The scene the component belongs to.
  60371. */
  60372. scene: Scene;
  60373. /**
  60374. * Color of the bounding box lines placed in front of an object
  60375. */
  60376. frontColor: Color3;
  60377. /**
  60378. * Color of the bounding box lines placed behind an object
  60379. */
  60380. backColor: Color3;
  60381. /**
  60382. * Defines if the renderer should show the back lines or not
  60383. */
  60384. showBackLines: boolean;
  60385. /**
  60386. * @hidden
  60387. */
  60388. renderList: SmartArray<BoundingBox>;
  60389. private _colorShader;
  60390. private _vertexBuffers;
  60391. private _indexBuffer;
  60392. private _fillIndexBuffer;
  60393. private _fillIndexData;
  60394. /**
  60395. * Instantiates a new bounding box renderer in a scene.
  60396. * @param scene the scene the renderer renders in
  60397. */
  60398. constructor(scene: Scene);
  60399. /**
  60400. * Registers the component in a given scene
  60401. */
  60402. register(): void;
  60403. private _evaluateSubMesh;
  60404. private _activeMesh;
  60405. private _prepareRessources;
  60406. private _createIndexBuffer;
  60407. /**
  60408. * Rebuilds the elements related to this component in case of
  60409. * context lost for instance.
  60410. */
  60411. rebuild(): void;
  60412. /**
  60413. * @hidden
  60414. */
  60415. reset(): void;
  60416. /**
  60417. * Render the bounding boxes of a specific rendering group
  60418. * @param renderingGroupId defines the rendering group to render
  60419. */
  60420. render(renderingGroupId: number): void;
  60421. /**
  60422. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60423. * @param mesh Define the mesh to render the occlusion bounding box for
  60424. */
  60425. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60426. /**
  60427. * Dispose and release the resources attached to this renderer.
  60428. */
  60429. dispose(): void;
  60430. }
  60431. }
  60432. declare module BABYLON {
  60433. /** @hidden */
  60434. export var depthPixelShader: {
  60435. name: string;
  60436. shader: string;
  60437. };
  60438. }
  60439. declare module BABYLON {
  60440. /**
  60441. * This represents a depth renderer in Babylon.
  60442. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60443. */
  60444. export class DepthRenderer {
  60445. private _scene;
  60446. private _depthMap;
  60447. private _effect;
  60448. private readonly _storeNonLinearDepth;
  60449. private readonly _clearColor;
  60450. /** Get if the depth renderer is using packed depth or not */
  60451. readonly isPacked: boolean;
  60452. private _cachedDefines;
  60453. private _camera;
  60454. /**
  60455. * Specifiess that the depth renderer will only be used within
  60456. * the camera it is created for.
  60457. * This can help forcing its rendering during the camera processing.
  60458. */
  60459. useOnlyInActiveCamera: boolean;
  60460. /** @hidden */
  60461. static _SceneComponentInitialization: (scene: Scene) => void;
  60462. /**
  60463. * Instantiates a depth renderer
  60464. * @param scene The scene the renderer belongs to
  60465. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60466. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60467. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60468. */
  60469. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60470. /**
  60471. * Creates the depth rendering effect and checks if the effect is ready.
  60472. * @param subMesh The submesh to be used to render the depth map of
  60473. * @param useInstances If multiple world instances should be used
  60474. * @returns if the depth renderer is ready to render the depth map
  60475. */
  60476. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60477. /**
  60478. * Gets the texture which the depth map will be written to.
  60479. * @returns The depth map texture
  60480. */
  60481. getDepthMap(): RenderTargetTexture;
  60482. /**
  60483. * Disposes of the depth renderer.
  60484. */
  60485. dispose(): void;
  60486. }
  60487. }
  60488. declare module BABYLON {
  60489. interface Scene {
  60490. /** @hidden (Backing field) */
  60491. _depthRenderer: {
  60492. [id: string]: DepthRenderer;
  60493. };
  60494. /**
  60495. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60496. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60497. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60498. * @returns the created depth renderer
  60499. */
  60500. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  60501. /**
  60502. * Disables a depth renderer for a given camera
  60503. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60504. */
  60505. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60506. }
  60507. /**
  60508. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60509. * in several rendering techniques.
  60510. */
  60511. export class DepthRendererSceneComponent implements ISceneComponent {
  60512. /**
  60513. * The component name helpfull to identify the component in the list of scene components.
  60514. */
  60515. readonly name: string;
  60516. /**
  60517. * The scene the component belongs to.
  60518. */
  60519. scene: Scene;
  60520. /**
  60521. * Creates a new instance of the component for the given scene
  60522. * @param scene Defines the scene to register the component in
  60523. */
  60524. constructor(scene: Scene);
  60525. /**
  60526. * Registers the component in a given scene
  60527. */
  60528. register(): void;
  60529. /**
  60530. * Rebuilds the elements related to this component in case of
  60531. * context lost for instance.
  60532. */
  60533. rebuild(): void;
  60534. /**
  60535. * Disposes the component and the associated ressources
  60536. */
  60537. dispose(): void;
  60538. private _gatherRenderTargets;
  60539. private _gatherActiveCameraRenderTargets;
  60540. }
  60541. }
  60542. declare module BABYLON {
  60543. /** @hidden */
  60544. export var outlinePixelShader: {
  60545. name: string;
  60546. shader: string;
  60547. };
  60548. }
  60549. declare module BABYLON {
  60550. /** @hidden */
  60551. export var outlineVertexShader: {
  60552. name: string;
  60553. shader: string;
  60554. };
  60555. }
  60556. declare module BABYLON {
  60557. interface Scene {
  60558. /** @hidden */
  60559. _outlineRenderer: OutlineRenderer;
  60560. /**
  60561. * Gets the outline renderer associated with the scene
  60562. * @returns a OutlineRenderer
  60563. */
  60564. getOutlineRenderer(): OutlineRenderer;
  60565. }
  60566. interface AbstractMesh {
  60567. /** @hidden (Backing field) */
  60568. _renderOutline: boolean;
  60569. /**
  60570. * Gets or sets a boolean indicating if the outline must be rendered as well
  60571. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60572. */
  60573. renderOutline: boolean;
  60574. /** @hidden (Backing field) */
  60575. _renderOverlay: boolean;
  60576. /**
  60577. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60578. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60579. */
  60580. renderOverlay: boolean;
  60581. }
  60582. /**
  60583. * This class is responsible to draw bothe outline/overlay of meshes.
  60584. * It should not be used directly but through the available method on mesh.
  60585. */
  60586. export class OutlineRenderer implements ISceneComponent {
  60587. /**
  60588. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60589. */
  60590. private static _StencilReference;
  60591. /**
  60592. * The name of the component. Each component must have a unique name.
  60593. */
  60594. name: string;
  60595. /**
  60596. * The scene the component belongs to.
  60597. */
  60598. scene: Scene;
  60599. /**
  60600. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60601. */
  60602. zOffset: number;
  60603. private _engine;
  60604. private _effect;
  60605. private _cachedDefines;
  60606. private _savedDepthWrite;
  60607. /**
  60608. * Instantiates a new outline renderer. (There could be only one per scene).
  60609. * @param scene Defines the scene it belongs to
  60610. */
  60611. constructor(scene: Scene);
  60612. /**
  60613. * Register the component to one instance of a scene.
  60614. */
  60615. register(): void;
  60616. /**
  60617. * Rebuilds the elements related to this component in case of
  60618. * context lost for instance.
  60619. */
  60620. rebuild(): void;
  60621. /**
  60622. * Disposes the component and the associated ressources.
  60623. */
  60624. dispose(): void;
  60625. /**
  60626. * Renders the outline in the canvas.
  60627. * @param subMesh Defines the sumesh to render
  60628. * @param batch Defines the batch of meshes in case of instances
  60629. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60630. */
  60631. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60632. /**
  60633. * Returns whether or not the outline renderer is ready for a given submesh.
  60634. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60635. * @param subMesh Defines the submesh to check readyness for
  60636. * @param useInstances Defines wheter wee are trying to render instances or not
  60637. * @returns true if ready otherwise false
  60638. */
  60639. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60640. private _beforeRenderingMesh;
  60641. private _afterRenderingMesh;
  60642. }
  60643. }
  60644. declare module BABYLON {
  60645. /**
  60646. * Class used to manage multiple sprites of different sizes on the same spritesheet
  60647. * @see http://doc.babylonjs.com/babylon101/sprites
  60648. */
  60649. export class SpritePackedManager extends SpriteManager {
  60650. /** defines the packed manager's name */
  60651. name: string;
  60652. /**
  60653. * Creates a new sprite manager from a packed sprite sheet
  60654. * @param name defines the manager's name
  60655. * @param imgUrl defines the sprite sheet url
  60656. * @param capacity defines the maximum allowed number of sprites
  60657. * @param scene defines the hosting scene
  60658. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  60659. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  60660. * @param samplingMode defines the smapling mode to use with spritesheet
  60661. * @param fromPacked set to true; do not alter
  60662. */
  60663. constructor(
  60664. /** defines the packed manager's name */
  60665. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  60666. }
  60667. }
  60668. declare module BABYLON {
  60669. /**
  60670. * Defines the list of states available for a task inside a AssetsManager
  60671. */
  60672. export enum AssetTaskState {
  60673. /**
  60674. * Initialization
  60675. */
  60676. INIT = 0,
  60677. /**
  60678. * Running
  60679. */
  60680. RUNNING = 1,
  60681. /**
  60682. * Done
  60683. */
  60684. DONE = 2,
  60685. /**
  60686. * Error
  60687. */
  60688. ERROR = 3
  60689. }
  60690. /**
  60691. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60692. */
  60693. export abstract class AbstractAssetTask {
  60694. /**
  60695. * Task name
  60696. */ name: string;
  60697. /**
  60698. * Callback called when the task is successful
  60699. */
  60700. onSuccess: (task: any) => void;
  60701. /**
  60702. * Callback called when the task is not successful
  60703. */
  60704. onError: (task: any, message?: string, exception?: any) => void;
  60705. /**
  60706. * Creates a new AssetsManager
  60707. * @param name defines the name of the task
  60708. */
  60709. constructor(
  60710. /**
  60711. * Task name
  60712. */ name: string);
  60713. private _isCompleted;
  60714. private _taskState;
  60715. private _errorObject;
  60716. /**
  60717. * Get if the task is completed
  60718. */
  60719. readonly isCompleted: boolean;
  60720. /**
  60721. * Gets the current state of the task
  60722. */
  60723. readonly taskState: AssetTaskState;
  60724. /**
  60725. * Gets the current error object (if task is in error)
  60726. */
  60727. readonly errorObject: {
  60728. message?: string;
  60729. exception?: any;
  60730. };
  60731. /**
  60732. * Internal only
  60733. * @hidden
  60734. */
  60735. _setErrorObject(message?: string, exception?: any): void;
  60736. /**
  60737. * Execute the current task
  60738. * @param scene defines the scene where you want your assets to be loaded
  60739. * @param onSuccess is a callback called when the task is successfully executed
  60740. * @param onError is a callback called if an error occurs
  60741. */
  60742. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60743. /**
  60744. * Execute the current task
  60745. * @param scene defines the scene where you want your assets to be loaded
  60746. * @param onSuccess is a callback called when the task is successfully executed
  60747. * @param onError is a callback called if an error occurs
  60748. */
  60749. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60750. /**
  60751. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60752. * This can be used with failed tasks that have the reason for failure fixed.
  60753. */
  60754. reset(): void;
  60755. private onErrorCallback;
  60756. private onDoneCallback;
  60757. }
  60758. /**
  60759. * Define the interface used by progress events raised during assets loading
  60760. */
  60761. export interface IAssetsProgressEvent {
  60762. /**
  60763. * Defines the number of remaining tasks to process
  60764. */
  60765. remainingCount: number;
  60766. /**
  60767. * Defines the total number of tasks
  60768. */
  60769. totalCount: number;
  60770. /**
  60771. * Defines the task that was just processed
  60772. */
  60773. task: AbstractAssetTask;
  60774. }
  60775. /**
  60776. * Class used to share progress information about assets loading
  60777. */
  60778. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60779. /**
  60780. * Defines the number of remaining tasks to process
  60781. */
  60782. remainingCount: number;
  60783. /**
  60784. * Defines the total number of tasks
  60785. */
  60786. totalCount: number;
  60787. /**
  60788. * Defines the task that was just processed
  60789. */
  60790. task: AbstractAssetTask;
  60791. /**
  60792. * Creates a AssetsProgressEvent
  60793. * @param remainingCount defines the number of remaining tasks to process
  60794. * @param totalCount defines the total number of tasks
  60795. * @param task defines the task that was just processed
  60796. */
  60797. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60798. }
  60799. /**
  60800. * Define a task used by AssetsManager to load meshes
  60801. */
  60802. export class MeshAssetTask extends AbstractAssetTask {
  60803. /**
  60804. * Defines the name of the task
  60805. */
  60806. name: string;
  60807. /**
  60808. * Defines the list of mesh's names you want to load
  60809. */
  60810. meshesNames: any;
  60811. /**
  60812. * Defines the root url to use as a base to load your meshes and associated resources
  60813. */
  60814. rootUrl: string;
  60815. /**
  60816. * Defines the filename of the scene to load from
  60817. */
  60818. sceneFilename: string;
  60819. /**
  60820. * Gets the list of loaded meshes
  60821. */
  60822. loadedMeshes: Array<AbstractMesh>;
  60823. /**
  60824. * Gets the list of loaded particle systems
  60825. */
  60826. loadedParticleSystems: Array<IParticleSystem>;
  60827. /**
  60828. * Gets the list of loaded skeletons
  60829. */
  60830. loadedSkeletons: Array<Skeleton>;
  60831. /**
  60832. * Gets the list of loaded animation groups
  60833. */
  60834. loadedAnimationGroups: Array<AnimationGroup>;
  60835. /**
  60836. * Callback called when the task is successful
  60837. */
  60838. onSuccess: (task: MeshAssetTask) => void;
  60839. /**
  60840. * Callback called when the task is successful
  60841. */
  60842. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60843. /**
  60844. * Creates a new MeshAssetTask
  60845. * @param name defines the name of the task
  60846. * @param meshesNames defines the list of mesh's names you want to load
  60847. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60848. * @param sceneFilename defines the filename of the scene to load from
  60849. */
  60850. constructor(
  60851. /**
  60852. * Defines the name of the task
  60853. */
  60854. name: string,
  60855. /**
  60856. * Defines the list of mesh's names you want to load
  60857. */
  60858. meshesNames: any,
  60859. /**
  60860. * Defines the root url to use as a base to load your meshes and associated resources
  60861. */
  60862. rootUrl: string,
  60863. /**
  60864. * Defines the filename of the scene to load from
  60865. */
  60866. sceneFilename: string);
  60867. /**
  60868. * Execute the current task
  60869. * @param scene defines the scene where you want your assets to be loaded
  60870. * @param onSuccess is a callback called when the task is successfully executed
  60871. * @param onError is a callback called if an error occurs
  60872. */
  60873. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60874. }
  60875. /**
  60876. * Define a task used by AssetsManager to load text content
  60877. */
  60878. export class TextFileAssetTask extends AbstractAssetTask {
  60879. /**
  60880. * Defines the name of the task
  60881. */
  60882. name: string;
  60883. /**
  60884. * Defines the location of the file to load
  60885. */
  60886. url: string;
  60887. /**
  60888. * Gets the loaded text string
  60889. */
  60890. text: string;
  60891. /**
  60892. * Callback called when the task is successful
  60893. */
  60894. onSuccess: (task: TextFileAssetTask) => void;
  60895. /**
  60896. * Callback called when the task is successful
  60897. */
  60898. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60899. /**
  60900. * Creates a new TextFileAssetTask object
  60901. * @param name defines the name of the task
  60902. * @param url defines the location of the file to load
  60903. */
  60904. constructor(
  60905. /**
  60906. * Defines the name of the task
  60907. */
  60908. name: string,
  60909. /**
  60910. * Defines the location of the file to load
  60911. */
  60912. url: string);
  60913. /**
  60914. * Execute the current task
  60915. * @param scene defines the scene where you want your assets to be loaded
  60916. * @param onSuccess is a callback called when the task is successfully executed
  60917. * @param onError is a callback called if an error occurs
  60918. */
  60919. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60920. }
  60921. /**
  60922. * Define a task used by AssetsManager to load binary data
  60923. */
  60924. export class BinaryFileAssetTask extends AbstractAssetTask {
  60925. /**
  60926. * Defines the name of the task
  60927. */
  60928. name: string;
  60929. /**
  60930. * Defines the location of the file to load
  60931. */
  60932. url: string;
  60933. /**
  60934. * Gets the lodaded data (as an array buffer)
  60935. */
  60936. data: ArrayBuffer;
  60937. /**
  60938. * Callback called when the task is successful
  60939. */
  60940. onSuccess: (task: BinaryFileAssetTask) => void;
  60941. /**
  60942. * Callback called when the task is successful
  60943. */
  60944. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60945. /**
  60946. * Creates a new BinaryFileAssetTask object
  60947. * @param name defines the name of the new task
  60948. * @param url defines the location of the file to load
  60949. */
  60950. constructor(
  60951. /**
  60952. * Defines the name of the task
  60953. */
  60954. name: string,
  60955. /**
  60956. * Defines the location of the file to load
  60957. */
  60958. url: string);
  60959. /**
  60960. * Execute the current task
  60961. * @param scene defines the scene where you want your assets to be loaded
  60962. * @param onSuccess is a callback called when the task is successfully executed
  60963. * @param onError is a callback called if an error occurs
  60964. */
  60965. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60966. }
  60967. /**
  60968. * Define a task used by AssetsManager to load images
  60969. */
  60970. export class ImageAssetTask extends AbstractAssetTask {
  60971. /**
  60972. * Defines the name of the task
  60973. */
  60974. name: string;
  60975. /**
  60976. * Defines the location of the image to load
  60977. */
  60978. url: string;
  60979. /**
  60980. * Gets the loaded images
  60981. */
  60982. image: HTMLImageElement;
  60983. /**
  60984. * Callback called when the task is successful
  60985. */
  60986. onSuccess: (task: ImageAssetTask) => void;
  60987. /**
  60988. * Callback called when the task is successful
  60989. */
  60990. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  60991. /**
  60992. * Creates a new ImageAssetTask
  60993. * @param name defines the name of the task
  60994. * @param url defines the location of the image to load
  60995. */
  60996. constructor(
  60997. /**
  60998. * Defines the name of the task
  60999. */
  61000. name: string,
  61001. /**
  61002. * Defines the location of the image to load
  61003. */
  61004. url: string);
  61005. /**
  61006. * Execute the current task
  61007. * @param scene defines the scene where you want your assets to be loaded
  61008. * @param onSuccess is a callback called when the task is successfully executed
  61009. * @param onError is a callback called if an error occurs
  61010. */
  61011. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61012. }
  61013. /**
  61014. * Defines the interface used by texture loading tasks
  61015. */
  61016. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61017. /**
  61018. * Gets the loaded texture
  61019. */
  61020. texture: TEX;
  61021. }
  61022. /**
  61023. * Define a task used by AssetsManager to load 2D textures
  61024. */
  61025. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61026. /**
  61027. * Defines the name of the task
  61028. */
  61029. name: string;
  61030. /**
  61031. * Defines the location of the file to load
  61032. */
  61033. url: string;
  61034. /**
  61035. * Defines if mipmap should not be generated (default is false)
  61036. */
  61037. noMipmap?: boolean | undefined;
  61038. /**
  61039. * Defines if texture must be inverted on Y axis (default is false)
  61040. */
  61041. invertY?: boolean | undefined;
  61042. /**
  61043. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61044. */
  61045. samplingMode: number;
  61046. /**
  61047. * Gets the loaded texture
  61048. */
  61049. texture: Texture;
  61050. /**
  61051. * Callback called when the task is successful
  61052. */
  61053. onSuccess: (task: TextureAssetTask) => void;
  61054. /**
  61055. * Callback called when the task is successful
  61056. */
  61057. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61058. /**
  61059. * Creates a new TextureAssetTask object
  61060. * @param name defines the name of the task
  61061. * @param url defines the location of the file to load
  61062. * @param noMipmap defines if mipmap should not be generated (default is false)
  61063. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61064. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61065. */
  61066. constructor(
  61067. /**
  61068. * Defines the name of the task
  61069. */
  61070. name: string,
  61071. /**
  61072. * Defines the location of the file to load
  61073. */
  61074. url: string,
  61075. /**
  61076. * Defines if mipmap should not be generated (default is false)
  61077. */
  61078. noMipmap?: boolean | undefined,
  61079. /**
  61080. * Defines if texture must be inverted on Y axis (default is false)
  61081. */
  61082. invertY?: boolean | undefined,
  61083. /**
  61084. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61085. */
  61086. samplingMode?: number);
  61087. /**
  61088. * Execute the current task
  61089. * @param scene defines the scene where you want your assets to be loaded
  61090. * @param onSuccess is a callback called when the task is successfully executed
  61091. * @param onError is a callback called if an error occurs
  61092. */
  61093. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61094. }
  61095. /**
  61096. * Define a task used by AssetsManager to load cube textures
  61097. */
  61098. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61099. /**
  61100. * Defines the name of the task
  61101. */
  61102. name: string;
  61103. /**
  61104. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61105. */
  61106. url: string;
  61107. /**
  61108. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61109. */
  61110. extensions?: string[] | undefined;
  61111. /**
  61112. * Defines if mipmaps should not be generated (default is false)
  61113. */
  61114. noMipmap?: boolean | undefined;
  61115. /**
  61116. * Defines the explicit list of files (undefined by default)
  61117. */
  61118. files?: string[] | undefined;
  61119. /**
  61120. * Gets the loaded texture
  61121. */
  61122. texture: CubeTexture;
  61123. /**
  61124. * Callback called when the task is successful
  61125. */
  61126. onSuccess: (task: CubeTextureAssetTask) => void;
  61127. /**
  61128. * Callback called when the task is successful
  61129. */
  61130. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61131. /**
  61132. * Creates a new CubeTextureAssetTask
  61133. * @param name defines the name of the task
  61134. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61135. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61136. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61137. * @param files defines the explicit list of files (undefined by default)
  61138. */
  61139. constructor(
  61140. /**
  61141. * Defines the name of the task
  61142. */
  61143. name: string,
  61144. /**
  61145. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61146. */
  61147. url: string,
  61148. /**
  61149. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61150. */
  61151. extensions?: string[] | undefined,
  61152. /**
  61153. * Defines if mipmaps should not be generated (default is false)
  61154. */
  61155. noMipmap?: boolean | undefined,
  61156. /**
  61157. * Defines the explicit list of files (undefined by default)
  61158. */
  61159. files?: string[] | undefined);
  61160. /**
  61161. * Execute the current task
  61162. * @param scene defines the scene where you want your assets to be loaded
  61163. * @param onSuccess is a callback called when the task is successfully executed
  61164. * @param onError is a callback called if an error occurs
  61165. */
  61166. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61167. }
  61168. /**
  61169. * Define a task used by AssetsManager to load HDR cube textures
  61170. */
  61171. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61172. /**
  61173. * Defines the name of the task
  61174. */
  61175. name: string;
  61176. /**
  61177. * Defines the location of the file to load
  61178. */
  61179. url: string;
  61180. /**
  61181. * Defines the desired size (the more it increases the longer the generation will be)
  61182. */
  61183. size: number;
  61184. /**
  61185. * Defines if mipmaps should not be generated (default is false)
  61186. */
  61187. noMipmap: boolean;
  61188. /**
  61189. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61190. */
  61191. generateHarmonics: boolean;
  61192. /**
  61193. * 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)
  61194. */
  61195. gammaSpace: boolean;
  61196. /**
  61197. * Internal Use Only
  61198. */
  61199. reserved: boolean;
  61200. /**
  61201. * Gets the loaded texture
  61202. */
  61203. texture: HDRCubeTexture;
  61204. /**
  61205. * Callback called when the task is successful
  61206. */
  61207. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61208. /**
  61209. * Callback called when the task is successful
  61210. */
  61211. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61212. /**
  61213. * Creates a new HDRCubeTextureAssetTask object
  61214. * @param name defines the name of the task
  61215. * @param url defines the location of the file to load
  61216. * @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.
  61217. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61218. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61219. * @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)
  61220. * @param reserved Internal use only
  61221. */
  61222. constructor(
  61223. /**
  61224. * Defines the name of the task
  61225. */
  61226. name: string,
  61227. /**
  61228. * Defines the location of the file to load
  61229. */
  61230. url: string,
  61231. /**
  61232. * Defines the desired size (the more it increases the longer the generation will be)
  61233. */
  61234. size: number,
  61235. /**
  61236. * Defines if mipmaps should not be generated (default is false)
  61237. */
  61238. noMipmap?: boolean,
  61239. /**
  61240. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61241. */
  61242. generateHarmonics?: boolean,
  61243. /**
  61244. * 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)
  61245. */
  61246. gammaSpace?: boolean,
  61247. /**
  61248. * Internal Use Only
  61249. */
  61250. reserved?: boolean);
  61251. /**
  61252. * Execute the current task
  61253. * @param scene defines the scene where you want your assets to be loaded
  61254. * @param onSuccess is a callback called when the task is successfully executed
  61255. * @param onError is a callback called if an error occurs
  61256. */
  61257. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61258. }
  61259. /**
  61260. * Define a task used by AssetsManager to load Equirectangular cube textures
  61261. */
  61262. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61263. /**
  61264. * Defines the name of the task
  61265. */
  61266. name: string;
  61267. /**
  61268. * Defines the location of the file to load
  61269. */
  61270. url: string;
  61271. /**
  61272. * Defines the desired size (the more it increases the longer the generation will be)
  61273. */
  61274. size: number;
  61275. /**
  61276. * Defines if mipmaps should not be generated (default is false)
  61277. */
  61278. noMipmap: boolean;
  61279. /**
  61280. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61281. * but the standard material would require them in Gamma space) (default is true)
  61282. */
  61283. gammaSpace: boolean;
  61284. /**
  61285. * Gets the loaded texture
  61286. */
  61287. texture: EquiRectangularCubeTexture;
  61288. /**
  61289. * Callback called when the task is successful
  61290. */
  61291. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61292. /**
  61293. * Callback called when the task is successful
  61294. */
  61295. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61296. /**
  61297. * Creates a new EquiRectangularCubeTextureAssetTask object
  61298. * @param name defines the name of the task
  61299. * @param url defines the location of the file to load
  61300. * @param size defines the desired size (the more it increases the longer the generation will be)
  61301. * If the size is omitted this implies you are using a preprocessed cubemap.
  61302. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61303. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61304. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61305. * (default is true)
  61306. */
  61307. constructor(
  61308. /**
  61309. * Defines the name of the task
  61310. */
  61311. name: string,
  61312. /**
  61313. * Defines the location of the file to load
  61314. */
  61315. url: string,
  61316. /**
  61317. * Defines the desired size (the more it increases the longer the generation will be)
  61318. */
  61319. size: number,
  61320. /**
  61321. * Defines if mipmaps should not be generated (default is false)
  61322. */
  61323. noMipmap?: boolean,
  61324. /**
  61325. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61326. * but the standard material would require them in Gamma space) (default is true)
  61327. */
  61328. gammaSpace?: boolean);
  61329. /**
  61330. * Execute the current task
  61331. * @param scene defines the scene where you want your assets to be loaded
  61332. * @param onSuccess is a callback called when the task is successfully executed
  61333. * @param onError is a callback called if an error occurs
  61334. */
  61335. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61336. }
  61337. /**
  61338. * This class can be used to easily import assets into a scene
  61339. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61340. */
  61341. export class AssetsManager {
  61342. private _scene;
  61343. private _isLoading;
  61344. protected _tasks: AbstractAssetTask[];
  61345. protected _waitingTasksCount: number;
  61346. protected _totalTasksCount: number;
  61347. /**
  61348. * Callback called when all tasks are processed
  61349. */
  61350. onFinish: (tasks: AbstractAssetTask[]) => void;
  61351. /**
  61352. * Callback called when a task is successful
  61353. */
  61354. onTaskSuccess: (task: AbstractAssetTask) => void;
  61355. /**
  61356. * Callback called when a task had an error
  61357. */
  61358. onTaskError: (task: AbstractAssetTask) => void;
  61359. /**
  61360. * Callback called when a task is done (whatever the result is)
  61361. */
  61362. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61363. /**
  61364. * Observable called when all tasks are processed
  61365. */
  61366. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61367. /**
  61368. * Observable called when a task had an error
  61369. */
  61370. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61371. /**
  61372. * Observable called when all tasks were executed
  61373. */
  61374. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61375. /**
  61376. * Observable called when a task is done (whatever the result is)
  61377. */
  61378. onProgressObservable: Observable<IAssetsProgressEvent>;
  61379. /**
  61380. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61381. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61382. */
  61383. useDefaultLoadingScreen: boolean;
  61384. /**
  61385. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  61386. * when all assets have been downloaded.
  61387. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  61388. */
  61389. autoHideLoadingUI: boolean;
  61390. /**
  61391. * Creates a new AssetsManager
  61392. * @param scene defines the scene to work on
  61393. */
  61394. constructor(scene: Scene);
  61395. /**
  61396. * Add a MeshAssetTask to the list of active tasks
  61397. * @param taskName defines the name of the new task
  61398. * @param meshesNames defines the name of meshes to load
  61399. * @param rootUrl defines the root url to use to locate files
  61400. * @param sceneFilename defines the filename of the scene file
  61401. * @returns a new MeshAssetTask object
  61402. */
  61403. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61404. /**
  61405. * Add a TextFileAssetTask to the list of active tasks
  61406. * @param taskName defines the name of the new task
  61407. * @param url defines the url of the file to load
  61408. * @returns a new TextFileAssetTask object
  61409. */
  61410. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61411. /**
  61412. * Add a BinaryFileAssetTask to the list of active tasks
  61413. * @param taskName defines the name of the new task
  61414. * @param url defines the url of the file to load
  61415. * @returns a new BinaryFileAssetTask object
  61416. */
  61417. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61418. /**
  61419. * Add a ImageAssetTask to the list of active tasks
  61420. * @param taskName defines the name of the new task
  61421. * @param url defines the url of the file to load
  61422. * @returns a new ImageAssetTask object
  61423. */
  61424. addImageTask(taskName: string, url: string): ImageAssetTask;
  61425. /**
  61426. * Add a TextureAssetTask to the list of active tasks
  61427. * @param taskName defines the name of the new task
  61428. * @param url defines the url of the file to load
  61429. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61430. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61431. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61432. * @returns a new TextureAssetTask object
  61433. */
  61434. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61435. /**
  61436. * Add a CubeTextureAssetTask to the list of active tasks
  61437. * @param taskName defines the name of the new task
  61438. * @param url defines the url of the file to load
  61439. * @param extensions defines the extension to use to load the cube map (can be null)
  61440. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61441. * @param files defines the list of files to load (can be null)
  61442. * @returns a new CubeTextureAssetTask object
  61443. */
  61444. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61445. /**
  61446. *
  61447. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61448. * @param taskName defines the name of the new task
  61449. * @param url defines the url of the file to load
  61450. * @param size defines the size you want for the cubemap (can be null)
  61451. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61452. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61453. * @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)
  61454. * @param reserved Internal use only
  61455. * @returns a new HDRCubeTextureAssetTask object
  61456. */
  61457. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61458. /**
  61459. *
  61460. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61461. * @param taskName defines the name of the new task
  61462. * @param url defines the url of the file to load
  61463. * @param size defines the size you want for the cubemap (can be null)
  61464. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61465. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61466. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61467. * @returns a new EquiRectangularCubeTextureAssetTask object
  61468. */
  61469. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61470. /**
  61471. * Remove a task from the assets manager.
  61472. * @param task the task to remove
  61473. */
  61474. removeTask(task: AbstractAssetTask): void;
  61475. private _decreaseWaitingTasksCount;
  61476. private _runTask;
  61477. /**
  61478. * Reset the AssetsManager and remove all tasks
  61479. * @return the current instance of the AssetsManager
  61480. */
  61481. reset(): AssetsManager;
  61482. /**
  61483. * Start the loading process
  61484. * @return the current instance of the AssetsManager
  61485. */
  61486. load(): AssetsManager;
  61487. /**
  61488. * Start the loading process as an async operation
  61489. * @return a promise returning the list of failed tasks
  61490. */
  61491. loadAsync(): Promise<void>;
  61492. }
  61493. }
  61494. declare module BABYLON {
  61495. /**
  61496. * Wrapper class for promise with external resolve and reject.
  61497. */
  61498. export class Deferred<T> {
  61499. /**
  61500. * The promise associated with this deferred object.
  61501. */
  61502. readonly promise: Promise<T>;
  61503. private _resolve;
  61504. private _reject;
  61505. /**
  61506. * The resolve method of the promise associated with this deferred object.
  61507. */
  61508. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61509. /**
  61510. * The reject method of the promise associated with this deferred object.
  61511. */
  61512. readonly reject: (reason?: any) => void;
  61513. /**
  61514. * Constructor for this deferred object.
  61515. */
  61516. constructor();
  61517. }
  61518. }
  61519. declare module BABYLON {
  61520. /**
  61521. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61522. */
  61523. export class MeshExploder {
  61524. private _centerMesh;
  61525. private _meshes;
  61526. private _meshesOrigins;
  61527. private _toCenterVectors;
  61528. private _scaledDirection;
  61529. private _newPosition;
  61530. private _centerPosition;
  61531. /**
  61532. * Explodes meshes from a center mesh.
  61533. * @param meshes The meshes to explode.
  61534. * @param centerMesh The mesh to be center of explosion.
  61535. */
  61536. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61537. private _setCenterMesh;
  61538. /**
  61539. * Get class name
  61540. * @returns "MeshExploder"
  61541. */
  61542. getClassName(): string;
  61543. /**
  61544. * "Exploded meshes"
  61545. * @returns Array of meshes with the centerMesh at index 0.
  61546. */
  61547. getMeshes(): Array<Mesh>;
  61548. /**
  61549. * Explodes meshes giving a specific direction
  61550. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61551. */
  61552. explode(direction?: number): void;
  61553. }
  61554. }
  61555. declare module BABYLON {
  61556. /**
  61557. * Class used to help managing file picking and drag'n'drop
  61558. */
  61559. export class FilesInput {
  61560. /**
  61561. * List of files ready to be loaded
  61562. */
  61563. static readonly FilesToLoad: {
  61564. [key: string]: File;
  61565. };
  61566. /**
  61567. * Callback called when a file is processed
  61568. */
  61569. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61570. private _engine;
  61571. private _currentScene;
  61572. private _sceneLoadedCallback;
  61573. private _progressCallback;
  61574. private _additionalRenderLoopLogicCallback;
  61575. private _textureLoadingCallback;
  61576. private _startingProcessingFilesCallback;
  61577. private _onReloadCallback;
  61578. private _errorCallback;
  61579. private _elementToMonitor;
  61580. private _sceneFileToLoad;
  61581. private _filesToLoad;
  61582. /**
  61583. * Creates a new FilesInput
  61584. * @param engine defines the rendering engine
  61585. * @param scene defines the hosting scene
  61586. * @param sceneLoadedCallback callback called when scene is loaded
  61587. * @param progressCallback callback called to track progress
  61588. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61589. * @param textureLoadingCallback callback called when a texture is loading
  61590. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61591. * @param onReloadCallback callback called when a reload is requested
  61592. * @param errorCallback callback call if an error occurs
  61593. */
  61594. 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);
  61595. private _dragEnterHandler;
  61596. private _dragOverHandler;
  61597. private _dropHandler;
  61598. /**
  61599. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61600. * @param elementToMonitor defines the DOM element to track
  61601. */
  61602. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61603. /**
  61604. * Release all associated resources
  61605. */
  61606. dispose(): void;
  61607. private renderFunction;
  61608. private drag;
  61609. private drop;
  61610. private _traverseFolder;
  61611. private _processFiles;
  61612. /**
  61613. * Load files from a drop event
  61614. * @param event defines the drop event to use as source
  61615. */
  61616. loadFiles(event: any): void;
  61617. private _processReload;
  61618. /**
  61619. * Reload the current scene from the loaded files
  61620. */
  61621. reload(): void;
  61622. }
  61623. }
  61624. declare module BABYLON {
  61625. /**
  61626. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61627. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61628. */
  61629. export class SceneOptimization {
  61630. /**
  61631. * Defines the priority of this optimization (0 by default which means first in the list)
  61632. */
  61633. priority: number;
  61634. /**
  61635. * Gets a string describing the action executed by the current optimization
  61636. * @returns description string
  61637. */
  61638. getDescription(): string;
  61639. /**
  61640. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61641. * @param scene defines the current scene where to apply this optimization
  61642. * @param optimizer defines the current optimizer
  61643. * @returns true if everything that can be done was applied
  61644. */
  61645. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61646. /**
  61647. * Creates the SceneOptimization object
  61648. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61649. * @param desc defines the description associated with the optimization
  61650. */
  61651. constructor(
  61652. /**
  61653. * Defines the priority of this optimization (0 by default which means first in the list)
  61654. */
  61655. priority?: number);
  61656. }
  61657. /**
  61658. * Defines an optimization used to reduce the size of render target textures
  61659. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61660. */
  61661. export class TextureOptimization extends SceneOptimization {
  61662. /**
  61663. * Defines the priority of this optimization (0 by default which means first in the list)
  61664. */
  61665. priority: number;
  61666. /**
  61667. * 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
  61668. */
  61669. maximumSize: number;
  61670. /**
  61671. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61672. */
  61673. step: number;
  61674. /**
  61675. * Gets a string describing the action executed by the current optimization
  61676. * @returns description string
  61677. */
  61678. getDescription(): string;
  61679. /**
  61680. * Creates the TextureOptimization object
  61681. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61682. * @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
  61683. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61684. */
  61685. constructor(
  61686. /**
  61687. * Defines the priority of this optimization (0 by default which means first in the list)
  61688. */
  61689. priority?: number,
  61690. /**
  61691. * 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
  61692. */
  61693. maximumSize?: number,
  61694. /**
  61695. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61696. */
  61697. step?: number);
  61698. /**
  61699. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61700. * @param scene defines the current scene where to apply this optimization
  61701. * @param optimizer defines the current optimizer
  61702. * @returns true if everything that can be done was applied
  61703. */
  61704. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61705. }
  61706. /**
  61707. * Defines an optimization used to increase or decrease the rendering resolution
  61708. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61709. */
  61710. export class HardwareScalingOptimization extends SceneOptimization {
  61711. /**
  61712. * Defines the priority of this optimization (0 by default which means first in the list)
  61713. */
  61714. priority: number;
  61715. /**
  61716. * Defines the maximum scale to use (2 by default)
  61717. */
  61718. maximumScale: number;
  61719. /**
  61720. * Defines the step to use between two passes (0.5 by default)
  61721. */
  61722. step: number;
  61723. private _currentScale;
  61724. private _directionOffset;
  61725. /**
  61726. * Gets a string describing the action executed by the current optimization
  61727. * @return description string
  61728. */
  61729. getDescription(): string;
  61730. /**
  61731. * Creates the HardwareScalingOptimization object
  61732. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61733. * @param maximumScale defines the maximum scale to use (2 by default)
  61734. * @param step defines the step to use between two passes (0.5 by default)
  61735. */
  61736. constructor(
  61737. /**
  61738. * Defines the priority of this optimization (0 by default which means first in the list)
  61739. */
  61740. priority?: number,
  61741. /**
  61742. * Defines the maximum scale to use (2 by default)
  61743. */
  61744. maximumScale?: number,
  61745. /**
  61746. * Defines the step to use between two passes (0.5 by default)
  61747. */
  61748. step?: number);
  61749. /**
  61750. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61751. * @param scene defines the current scene where to apply this optimization
  61752. * @param optimizer defines the current optimizer
  61753. * @returns true if everything that can be done was applied
  61754. */
  61755. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61756. }
  61757. /**
  61758. * Defines an optimization used to remove shadows
  61759. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61760. */
  61761. export class ShadowsOptimization extends SceneOptimization {
  61762. /**
  61763. * Gets a string describing the action executed by the current optimization
  61764. * @return description string
  61765. */
  61766. getDescription(): string;
  61767. /**
  61768. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61769. * @param scene defines the current scene where to apply this optimization
  61770. * @param optimizer defines the current optimizer
  61771. * @returns true if everything that can be done was applied
  61772. */
  61773. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61774. }
  61775. /**
  61776. * Defines an optimization used to turn post-processes off
  61777. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61778. */
  61779. export class PostProcessesOptimization extends SceneOptimization {
  61780. /**
  61781. * Gets a string describing the action executed by the current optimization
  61782. * @return description string
  61783. */
  61784. getDescription(): string;
  61785. /**
  61786. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61787. * @param scene defines the current scene where to apply this optimization
  61788. * @param optimizer defines the current optimizer
  61789. * @returns true if everything that can be done was applied
  61790. */
  61791. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61792. }
  61793. /**
  61794. * Defines an optimization used to turn lens flares off
  61795. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61796. */
  61797. export class LensFlaresOptimization extends SceneOptimization {
  61798. /**
  61799. * Gets a string describing the action executed by the current optimization
  61800. * @return description string
  61801. */
  61802. getDescription(): string;
  61803. /**
  61804. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61805. * @param scene defines the current scene where to apply this optimization
  61806. * @param optimizer defines the current optimizer
  61807. * @returns true if everything that can be done was applied
  61808. */
  61809. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61810. }
  61811. /**
  61812. * Defines an optimization based on user defined callback.
  61813. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61814. */
  61815. export class CustomOptimization extends SceneOptimization {
  61816. /**
  61817. * Callback called to apply the custom optimization.
  61818. */
  61819. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61820. /**
  61821. * Callback called to get custom description
  61822. */
  61823. onGetDescription: () => string;
  61824. /**
  61825. * Gets a string describing the action executed by the current optimization
  61826. * @returns description string
  61827. */
  61828. getDescription(): string;
  61829. /**
  61830. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61831. * @param scene defines the current scene where to apply this optimization
  61832. * @param optimizer defines the current optimizer
  61833. * @returns true if everything that can be done was applied
  61834. */
  61835. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61836. }
  61837. /**
  61838. * Defines an optimization used to turn particles off
  61839. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61840. */
  61841. export class ParticlesOptimization extends SceneOptimization {
  61842. /**
  61843. * Gets a string describing the action executed by the current optimization
  61844. * @return description string
  61845. */
  61846. getDescription(): string;
  61847. /**
  61848. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61849. * @param scene defines the current scene where to apply this optimization
  61850. * @param optimizer defines the current optimizer
  61851. * @returns true if everything that can be done was applied
  61852. */
  61853. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61854. }
  61855. /**
  61856. * Defines an optimization used to turn render targets off
  61857. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61858. */
  61859. export class RenderTargetsOptimization extends SceneOptimization {
  61860. /**
  61861. * Gets a string describing the action executed by the current optimization
  61862. * @return description string
  61863. */
  61864. getDescription(): string;
  61865. /**
  61866. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61867. * @param scene defines the current scene where to apply this optimization
  61868. * @param optimizer defines the current optimizer
  61869. * @returns true if everything that can be done was applied
  61870. */
  61871. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61872. }
  61873. /**
  61874. * Defines an optimization used to merge meshes with compatible materials
  61875. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61876. */
  61877. export class MergeMeshesOptimization extends SceneOptimization {
  61878. private static _UpdateSelectionTree;
  61879. /**
  61880. * Gets or sets a boolean which defines if optimization octree has to be updated
  61881. */
  61882. /**
  61883. * Gets or sets a boolean which defines if optimization octree has to be updated
  61884. */
  61885. static UpdateSelectionTree: boolean;
  61886. /**
  61887. * Gets a string describing the action executed by the current optimization
  61888. * @return description string
  61889. */
  61890. getDescription(): string;
  61891. private _canBeMerged;
  61892. /**
  61893. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61894. * @param scene defines the current scene where to apply this optimization
  61895. * @param optimizer defines the current optimizer
  61896. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61897. * @returns true if everything that can be done was applied
  61898. */
  61899. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61900. }
  61901. /**
  61902. * Defines a list of options used by SceneOptimizer
  61903. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61904. */
  61905. export class SceneOptimizerOptions {
  61906. /**
  61907. * Defines the target frame rate to reach (60 by default)
  61908. */
  61909. targetFrameRate: number;
  61910. /**
  61911. * Defines the interval between two checkes (2000ms by default)
  61912. */
  61913. trackerDuration: number;
  61914. /**
  61915. * Gets the list of optimizations to apply
  61916. */
  61917. optimizations: SceneOptimization[];
  61918. /**
  61919. * Creates a new list of options used by SceneOptimizer
  61920. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61921. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61922. */
  61923. constructor(
  61924. /**
  61925. * Defines the target frame rate to reach (60 by default)
  61926. */
  61927. targetFrameRate?: number,
  61928. /**
  61929. * Defines the interval between two checkes (2000ms by default)
  61930. */
  61931. trackerDuration?: number);
  61932. /**
  61933. * Add a new optimization
  61934. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61935. * @returns the current SceneOptimizerOptions
  61936. */
  61937. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61938. /**
  61939. * Add a new custom optimization
  61940. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61941. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61942. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61943. * @returns the current SceneOptimizerOptions
  61944. */
  61945. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  61946. /**
  61947. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  61948. * @param targetFrameRate defines the target frame rate (60 by default)
  61949. * @returns a SceneOptimizerOptions object
  61950. */
  61951. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61952. /**
  61953. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  61954. * @param targetFrameRate defines the target frame rate (60 by default)
  61955. * @returns a SceneOptimizerOptions object
  61956. */
  61957. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61958. /**
  61959. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  61960. * @param targetFrameRate defines the target frame rate (60 by default)
  61961. * @returns a SceneOptimizerOptions object
  61962. */
  61963. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61964. }
  61965. /**
  61966. * Class used to run optimizations in order to reach a target frame rate
  61967. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61968. */
  61969. export class SceneOptimizer implements IDisposable {
  61970. private _isRunning;
  61971. private _options;
  61972. private _scene;
  61973. private _currentPriorityLevel;
  61974. private _targetFrameRate;
  61975. private _trackerDuration;
  61976. private _currentFrameRate;
  61977. private _sceneDisposeObserver;
  61978. private _improvementMode;
  61979. /**
  61980. * Defines an observable called when the optimizer reaches the target frame rate
  61981. */
  61982. onSuccessObservable: Observable<SceneOptimizer>;
  61983. /**
  61984. * Defines an observable called when the optimizer enables an optimization
  61985. */
  61986. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  61987. /**
  61988. * Defines an observable called when the optimizer is not able to reach the target frame rate
  61989. */
  61990. onFailureObservable: Observable<SceneOptimizer>;
  61991. /**
  61992. * Gets a boolean indicating if the optimizer is in improvement mode
  61993. */
  61994. readonly isInImprovementMode: boolean;
  61995. /**
  61996. * Gets the current priority level (0 at start)
  61997. */
  61998. readonly currentPriorityLevel: number;
  61999. /**
  62000. * Gets the current frame rate checked by the SceneOptimizer
  62001. */
  62002. readonly currentFrameRate: number;
  62003. /**
  62004. * Gets or sets the current target frame rate (60 by default)
  62005. */
  62006. /**
  62007. * Gets or sets the current target frame rate (60 by default)
  62008. */
  62009. targetFrameRate: number;
  62010. /**
  62011. * Gets or sets the current interval between two checks (every 2000ms by default)
  62012. */
  62013. /**
  62014. * Gets or sets the current interval between two checks (every 2000ms by default)
  62015. */
  62016. trackerDuration: number;
  62017. /**
  62018. * Gets the list of active optimizations
  62019. */
  62020. readonly optimizations: SceneOptimization[];
  62021. /**
  62022. * Creates a new SceneOptimizer
  62023. * @param scene defines the scene to work on
  62024. * @param options defines the options to use with the SceneOptimizer
  62025. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62026. * @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)
  62027. */
  62028. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62029. /**
  62030. * Stops the current optimizer
  62031. */
  62032. stop(): void;
  62033. /**
  62034. * Reset the optimizer to initial step (current priority level = 0)
  62035. */
  62036. reset(): void;
  62037. /**
  62038. * Start the optimizer. By default it will try to reach a specific framerate
  62039. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62040. */
  62041. start(): void;
  62042. private _checkCurrentState;
  62043. /**
  62044. * Release all resources
  62045. */
  62046. dispose(): void;
  62047. /**
  62048. * Helper function to create a SceneOptimizer with one single line of code
  62049. * @param scene defines the scene to work on
  62050. * @param options defines the options to use with the SceneOptimizer
  62051. * @param onSuccess defines a callback to call on success
  62052. * @param onFailure defines a callback to call on failure
  62053. * @returns the new SceneOptimizer object
  62054. */
  62055. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62056. }
  62057. }
  62058. declare module BABYLON {
  62059. /**
  62060. * Class used to serialize a scene into a string
  62061. */
  62062. export class SceneSerializer {
  62063. /**
  62064. * Clear cache used by a previous serialization
  62065. */
  62066. static ClearCache(): void;
  62067. /**
  62068. * Serialize a scene into a JSON compatible object
  62069. * @param scene defines the scene to serialize
  62070. * @returns a JSON compatible object
  62071. */
  62072. static Serialize(scene: Scene): any;
  62073. /**
  62074. * Serialize a mesh into a JSON compatible object
  62075. * @param toSerialize defines the mesh to serialize
  62076. * @param withParents defines if parents must be serialized as well
  62077. * @param withChildren defines if children must be serialized as well
  62078. * @returns a JSON compatible object
  62079. */
  62080. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62081. }
  62082. }
  62083. declare module BABYLON {
  62084. /**
  62085. * Class used to host texture specific utilities
  62086. */
  62087. export class TextureTools {
  62088. /**
  62089. * Uses the GPU to create a copy texture rescaled at a given size
  62090. * @param texture Texture to copy from
  62091. * @param width defines the desired width
  62092. * @param height defines the desired height
  62093. * @param useBilinearMode defines if bilinear mode has to be used
  62094. * @return the generated texture
  62095. */
  62096. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62097. }
  62098. }
  62099. declare module BABYLON {
  62100. /**
  62101. * This represents the different options available for the video capture.
  62102. */
  62103. export interface VideoRecorderOptions {
  62104. /** Defines the mime type of the video. */
  62105. mimeType: string;
  62106. /** Defines the FPS the video should be recorded at. */
  62107. fps: number;
  62108. /** Defines the chunk size for the recording data. */
  62109. recordChunckSize: number;
  62110. /** The audio tracks to attach to the recording. */
  62111. audioTracks?: MediaStreamTrack[];
  62112. }
  62113. /**
  62114. * This can help with recording videos from BabylonJS.
  62115. * This is based on the available WebRTC functionalities of the browser.
  62116. *
  62117. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62118. */
  62119. export class VideoRecorder {
  62120. private static readonly _defaultOptions;
  62121. /**
  62122. * Returns whether or not the VideoRecorder is available in your browser.
  62123. * @param engine Defines the Babylon Engine.
  62124. * @returns true if supported otherwise false.
  62125. */
  62126. static IsSupported(engine: Engine): boolean;
  62127. private readonly _options;
  62128. private _canvas;
  62129. private _mediaRecorder;
  62130. private _recordedChunks;
  62131. private _fileName;
  62132. private _resolve;
  62133. private _reject;
  62134. /**
  62135. * True when a recording is already in progress.
  62136. */
  62137. readonly isRecording: boolean;
  62138. /**
  62139. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62140. * @param engine Defines the BabylonJS Engine you wish to record.
  62141. * @param options Defines options that can be used to customize the capture.
  62142. */
  62143. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62144. /**
  62145. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62146. */
  62147. stopRecording(): void;
  62148. /**
  62149. * Starts recording the canvas for a max duration specified in parameters.
  62150. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62151. * If null no automatic download will start and you can rely on the promise to get the data back.
  62152. * @param maxDuration Defines the maximum recording time in seconds.
  62153. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62154. * @return A promise callback at the end of the recording with the video data in Blob.
  62155. */
  62156. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62157. /**
  62158. * Releases internal resources used during the recording.
  62159. */
  62160. dispose(): void;
  62161. private _handleDataAvailable;
  62162. private _handleError;
  62163. private _handleStop;
  62164. }
  62165. }
  62166. declare module BABYLON {
  62167. /**
  62168. * Class containing a set of static utilities functions for screenshots
  62169. */
  62170. export class ScreenshotTools {
  62171. /**
  62172. * Captures a screenshot of the current rendering
  62173. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62174. * @param engine defines the rendering engine
  62175. * @param camera defines the source camera
  62176. * @param size This parameter can be set to a single number or to an object with the
  62177. * following (optional) properties: precision, width, height. If a single number is passed,
  62178. * it will be used for both width and height. If an object is passed, the screenshot size
  62179. * will be derived from the parameters. The precision property is a multiplier allowing
  62180. * rendering at a higher or lower resolution
  62181. * @param successCallback defines the callback receives a single parameter which contains the
  62182. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62183. * src parameter of an <img> to display it
  62184. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62185. * Check your browser for supported MIME types
  62186. */
  62187. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  62188. /**
  62189. * Captures a screenshot of the current rendering
  62190. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62191. * @param engine defines the rendering engine
  62192. * @param camera defines the source camera
  62193. * @param size This parameter can be set to a single number or to an object with the
  62194. * following (optional) properties: precision, width, height. If a single number is passed,
  62195. * it will be used for both width and height. If an object is passed, the screenshot size
  62196. * will be derived from the parameters. The precision property is a multiplier allowing
  62197. * rendering at a higher or lower resolution
  62198. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62199. * Check your browser for supported MIME types
  62200. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62201. * to the src parameter of an <img> to display it
  62202. */
  62203. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  62204. /**
  62205. * Generates an image screenshot from the specified camera.
  62206. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62207. * @param engine The engine to use for rendering
  62208. * @param camera The camera to use for rendering
  62209. * @param size This parameter can be set to a single number or to an object with the
  62210. * following (optional) properties: precision, width, height. If a single number is passed,
  62211. * it will be used for both width and height. If an object is passed, the screenshot size
  62212. * will be derived from the parameters. The precision property is a multiplier allowing
  62213. * rendering at a higher or lower resolution
  62214. * @param successCallback The callback receives a single parameter which contains the
  62215. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62216. * src parameter of an <img> to display it
  62217. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62218. * Check your browser for supported MIME types
  62219. * @param samples Texture samples (default: 1)
  62220. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62221. * @param fileName A name for for the downloaded file.
  62222. */
  62223. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62224. /**
  62225. * Generates an image screenshot from the specified camera.
  62226. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62227. * @param engine The engine to use for rendering
  62228. * @param camera The camera to use for rendering
  62229. * @param size This parameter can be set to a single number or to an object with the
  62230. * following (optional) properties: precision, width, height. If a single number is passed,
  62231. * it will be used for both width and height. If an object is passed, the screenshot size
  62232. * will be derived from the parameters. The precision property is a multiplier allowing
  62233. * rendering at a higher or lower resolution
  62234. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62235. * Check your browser for supported MIME types
  62236. * @param samples Texture samples (default: 1)
  62237. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62238. * @param fileName A name for for the downloaded file.
  62239. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62240. * to the src parameter of an <img> to display it
  62241. */
  62242. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  62243. /**
  62244. * Gets height and width for screenshot size
  62245. * @private
  62246. */
  62247. private static _getScreenshotSize;
  62248. }
  62249. }
  62250. declare module BABYLON {
  62251. /**
  62252. * A cursor which tracks a point on a path
  62253. */
  62254. export class PathCursor {
  62255. private path;
  62256. /**
  62257. * Stores path cursor callbacks for when an onchange event is triggered
  62258. */
  62259. private _onchange;
  62260. /**
  62261. * The value of the path cursor
  62262. */
  62263. value: number;
  62264. /**
  62265. * The animation array of the path cursor
  62266. */
  62267. animations: Animation[];
  62268. /**
  62269. * Initializes the path cursor
  62270. * @param path The path to track
  62271. */
  62272. constructor(path: Path2);
  62273. /**
  62274. * Gets the cursor point on the path
  62275. * @returns A point on the path cursor at the cursor location
  62276. */
  62277. getPoint(): Vector3;
  62278. /**
  62279. * Moves the cursor ahead by the step amount
  62280. * @param step The amount to move the cursor forward
  62281. * @returns This path cursor
  62282. */
  62283. moveAhead(step?: number): PathCursor;
  62284. /**
  62285. * Moves the cursor behind by the step amount
  62286. * @param step The amount to move the cursor back
  62287. * @returns This path cursor
  62288. */
  62289. moveBack(step?: number): PathCursor;
  62290. /**
  62291. * Moves the cursor by the step amount
  62292. * If the step amount is greater than one, an exception is thrown
  62293. * @param step The amount to move the cursor
  62294. * @returns This path cursor
  62295. */
  62296. move(step: number): PathCursor;
  62297. /**
  62298. * Ensures that the value is limited between zero and one
  62299. * @returns This path cursor
  62300. */
  62301. private ensureLimits;
  62302. /**
  62303. * Runs onchange callbacks on change (used by the animation engine)
  62304. * @returns This path cursor
  62305. */
  62306. private raiseOnChange;
  62307. /**
  62308. * Executes a function on change
  62309. * @param f A path cursor onchange callback
  62310. * @returns This path cursor
  62311. */
  62312. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62313. }
  62314. }
  62315. declare module BABYLON {
  62316. /** @hidden */
  62317. export var blurPixelShader: {
  62318. name: string;
  62319. shader: string;
  62320. };
  62321. }
  62322. declare module BABYLON {
  62323. /** @hidden */
  62324. export var pointCloudVertexDeclaration: {
  62325. name: string;
  62326. shader: string;
  62327. };
  62328. }
  62329. // Mixins
  62330. interface Window {
  62331. mozIndexedDB: IDBFactory;
  62332. webkitIndexedDB: IDBFactory;
  62333. msIndexedDB: IDBFactory;
  62334. webkitURL: typeof URL;
  62335. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62336. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62337. WebGLRenderingContext: WebGLRenderingContext;
  62338. MSGesture: MSGesture;
  62339. CANNON: any;
  62340. AudioContext: AudioContext;
  62341. webkitAudioContext: AudioContext;
  62342. PointerEvent: any;
  62343. Math: Math;
  62344. Uint8Array: Uint8ArrayConstructor;
  62345. Float32Array: Float32ArrayConstructor;
  62346. mozURL: typeof URL;
  62347. msURL: typeof URL;
  62348. VRFrameData: any; // WebVR, from specs 1.1
  62349. DracoDecoderModule: any;
  62350. setImmediate(handler: (...args: any[]) => void): number;
  62351. }
  62352. interface HTMLCanvasElement {
  62353. requestPointerLock(): void;
  62354. msRequestPointerLock?(): void;
  62355. mozRequestPointerLock?(): void;
  62356. webkitRequestPointerLock?(): void;
  62357. /** Track wether a record is in progress */
  62358. isRecording: boolean;
  62359. /** Capture Stream method defined by some browsers */
  62360. captureStream(fps?: number): MediaStream;
  62361. }
  62362. interface CanvasRenderingContext2D {
  62363. msImageSmoothingEnabled: boolean;
  62364. }
  62365. interface MouseEvent {
  62366. mozMovementX: number;
  62367. mozMovementY: number;
  62368. webkitMovementX: number;
  62369. webkitMovementY: number;
  62370. msMovementX: number;
  62371. msMovementY: number;
  62372. }
  62373. interface Navigator {
  62374. mozGetVRDevices: (any: any) => any;
  62375. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62376. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62377. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62378. webkitGetGamepads(): Gamepad[];
  62379. msGetGamepads(): Gamepad[];
  62380. webkitGamepads(): Gamepad[];
  62381. }
  62382. interface HTMLVideoElement {
  62383. mozSrcObject: any;
  62384. }
  62385. interface Math {
  62386. fround(x: number): number;
  62387. imul(a: number, b: number): number;
  62388. }
  62389. interface WebGLRenderingContext {
  62390. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62391. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62392. vertexAttribDivisor(index: number, divisor: number): void;
  62393. createVertexArray(): any;
  62394. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62395. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62396. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62397. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62398. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62399. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62400. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62401. // Queries
  62402. createQuery(): WebGLQuery;
  62403. deleteQuery(query: WebGLQuery): void;
  62404. beginQuery(target: number, query: WebGLQuery): void;
  62405. endQuery(target: number): void;
  62406. getQueryParameter(query: WebGLQuery, pname: number): any;
  62407. getQuery(target: number, pname: number): any;
  62408. MAX_SAMPLES: number;
  62409. RGBA8: number;
  62410. READ_FRAMEBUFFER: number;
  62411. DRAW_FRAMEBUFFER: number;
  62412. UNIFORM_BUFFER: number;
  62413. HALF_FLOAT_OES: number;
  62414. RGBA16F: number;
  62415. RGBA32F: number;
  62416. R32F: number;
  62417. RG32F: number;
  62418. RGB32F: number;
  62419. R16F: number;
  62420. RG16F: number;
  62421. RGB16F: number;
  62422. RED: number;
  62423. RG: number;
  62424. R8: number;
  62425. RG8: number;
  62426. UNSIGNED_INT_24_8: number;
  62427. DEPTH24_STENCIL8: number;
  62428. /* Multiple Render Targets */
  62429. drawBuffers(buffers: number[]): void;
  62430. readBuffer(src: number): void;
  62431. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62432. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62433. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62434. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62435. // Occlusion Query
  62436. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62437. ANY_SAMPLES_PASSED: number;
  62438. QUERY_RESULT_AVAILABLE: number;
  62439. QUERY_RESULT: number;
  62440. }
  62441. interface WebGLProgram {
  62442. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62443. }
  62444. interface EXT_disjoint_timer_query {
  62445. QUERY_COUNTER_BITS_EXT: number;
  62446. TIME_ELAPSED_EXT: number;
  62447. TIMESTAMP_EXT: number;
  62448. GPU_DISJOINT_EXT: number;
  62449. QUERY_RESULT_EXT: number;
  62450. QUERY_RESULT_AVAILABLE_EXT: number;
  62451. queryCounterEXT(query: WebGLQuery, target: number): void;
  62452. createQueryEXT(): WebGLQuery;
  62453. beginQueryEXT(target: number, query: WebGLQuery): void;
  62454. endQueryEXT(target: number): void;
  62455. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62456. deleteQueryEXT(query: WebGLQuery): void;
  62457. }
  62458. interface WebGLUniformLocation {
  62459. _currentState: any;
  62460. }
  62461. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62462. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62463. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62464. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62465. interface WebGLRenderingContext {
  62466. readonly RASTERIZER_DISCARD: number;
  62467. readonly DEPTH_COMPONENT24: number;
  62468. readonly TEXTURE_3D: number;
  62469. readonly TEXTURE_2D_ARRAY: number;
  62470. readonly TEXTURE_COMPARE_FUNC: number;
  62471. readonly TEXTURE_COMPARE_MODE: number;
  62472. readonly COMPARE_REF_TO_TEXTURE: number;
  62473. readonly TEXTURE_WRAP_R: number;
  62474. readonly HALF_FLOAT: number;
  62475. readonly RGB8: number;
  62476. readonly RED_INTEGER: number;
  62477. readonly RG_INTEGER: number;
  62478. readonly RGB_INTEGER: number;
  62479. readonly RGBA_INTEGER: number;
  62480. readonly R8_SNORM: number;
  62481. readonly RG8_SNORM: number;
  62482. readonly RGB8_SNORM: number;
  62483. readonly RGBA8_SNORM: number;
  62484. readonly R8I: number;
  62485. readonly RG8I: number;
  62486. readonly RGB8I: number;
  62487. readonly RGBA8I: number;
  62488. readonly R8UI: number;
  62489. readonly RG8UI: number;
  62490. readonly RGB8UI: number;
  62491. readonly RGBA8UI: number;
  62492. readonly R16I: number;
  62493. readonly RG16I: number;
  62494. readonly RGB16I: number;
  62495. readonly RGBA16I: number;
  62496. readonly R16UI: number;
  62497. readonly RG16UI: number;
  62498. readonly RGB16UI: number;
  62499. readonly RGBA16UI: number;
  62500. readonly R32I: number;
  62501. readonly RG32I: number;
  62502. readonly RGB32I: number;
  62503. readonly RGBA32I: number;
  62504. readonly R32UI: number;
  62505. readonly RG32UI: number;
  62506. readonly RGB32UI: number;
  62507. readonly RGBA32UI: number;
  62508. readonly RGB10_A2UI: number;
  62509. readonly R11F_G11F_B10F: number;
  62510. readonly RGB9_E5: number;
  62511. readonly RGB10_A2: number;
  62512. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62513. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62514. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62515. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62516. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62517. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62518. 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;
  62519. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62520. readonly TRANSFORM_FEEDBACK: number;
  62521. readonly INTERLEAVED_ATTRIBS: number;
  62522. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62523. createTransformFeedback(): WebGLTransformFeedback;
  62524. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62525. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62526. beginTransformFeedback(primitiveMode: number): void;
  62527. endTransformFeedback(): void;
  62528. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62529. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62530. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62531. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62532. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62533. }
  62534. interface ImageBitmap {
  62535. readonly width: number;
  62536. readonly height: number;
  62537. close(): void;
  62538. }
  62539. interface WebGLQuery extends WebGLObject {
  62540. }
  62541. declare var WebGLQuery: {
  62542. prototype: WebGLQuery;
  62543. new(): WebGLQuery;
  62544. };
  62545. interface WebGLSampler extends WebGLObject {
  62546. }
  62547. declare var WebGLSampler: {
  62548. prototype: WebGLSampler;
  62549. new(): WebGLSampler;
  62550. };
  62551. interface WebGLSync extends WebGLObject {
  62552. }
  62553. declare var WebGLSync: {
  62554. prototype: WebGLSync;
  62555. new(): WebGLSync;
  62556. };
  62557. interface WebGLTransformFeedback extends WebGLObject {
  62558. }
  62559. declare var WebGLTransformFeedback: {
  62560. prototype: WebGLTransformFeedback;
  62561. new(): WebGLTransformFeedback;
  62562. };
  62563. interface WebGLVertexArrayObject extends WebGLObject {
  62564. }
  62565. declare var WebGLVertexArrayObject: {
  62566. prototype: WebGLVertexArrayObject;
  62567. new(): WebGLVertexArrayObject;
  62568. };
  62569. // Type definitions for WebVR API
  62570. // Project: https://w3c.github.io/webvr/
  62571. // Definitions by: six a <https://github.com/lostfictions>
  62572. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62573. interface VRDisplay extends EventTarget {
  62574. /**
  62575. * Dictionary of capabilities describing the VRDisplay.
  62576. */
  62577. readonly capabilities: VRDisplayCapabilities;
  62578. /**
  62579. * z-depth defining the far plane of the eye view frustum
  62580. * enables mapping of values in the render target depth
  62581. * attachment to scene coordinates. Initially set to 10000.0.
  62582. */
  62583. depthFar: number;
  62584. /**
  62585. * z-depth defining the near plane of the eye view frustum
  62586. * enables mapping of values in the render target depth
  62587. * attachment to scene coordinates. Initially set to 0.01.
  62588. */
  62589. depthNear: number;
  62590. /**
  62591. * An identifier for this distinct VRDisplay. Used as an
  62592. * association point in the Gamepad API.
  62593. */
  62594. readonly displayId: number;
  62595. /**
  62596. * A display name, a user-readable name identifying it.
  62597. */
  62598. readonly displayName: string;
  62599. readonly isConnected: boolean;
  62600. readonly isPresenting: boolean;
  62601. /**
  62602. * If this VRDisplay supports room-scale experiences, the optional
  62603. * stage attribute contains details on the room-scale parameters.
  62604. */
  62605. readonly stageParameters: VRStageParameters | null;
  62606. /**
  62607. * Passing the value returned by `requestAnimationFrame` to
  62608. * `cancelAnimationFrame` will unregister the callback.
  62609. * @param handle Define the hanle of the request to cancel
  62610. */
  62611. cancelAnimationFrame(handle: number): void;
  62612. /**
  62613. * Stops presenting to the VRDisplay.
  62614. * @returns a promise to know when it stopped
  62615. */
  62616. exitPresent(): Promise<void>;
  62617. /**
  62618. * Return the current VREyeParameters for the given eye.
  62619. * @param whichEye Define the eye we want the parameter for
  62620. * @returns the eye parameters
  62621. */
  62622. getEyeParameters(whichEye: string): VREyeParameters;
  62623. /**
  62624. * Populates the passed VRFrameData with the information required to render
  62625. * the current frame.
  62626. * @param frameData Define the data structure to populate
  62627. * @returns true if ok otherwise false
  62628. */
  62629. getFrameData(frameData: VRFrameData): boolean;
  62630. /**
  62631. * Get the layers currently being presented.
  62632. * @returns the list of VR layers
  62633. */
  62634. getLayers(): VRLayer[];
  62635. /**
  62636. * Return a VRPose containing the future predicted pose of the VRDisplay
  62637. * when the current frame will be presented. The value returned will not
  62638. * change until JavaScript has returned control to the browser.
  62639. *
  62640. * The VRPose will contain the position, orientation, velocity,
  62641. * and acceleration of each of these properties.
  62642. * @returns the pose object
  62643. */
  62644. getPose(): VRPose;
  62645. /**
  62646. * Return the current instantaneous pose of the VRDisplay, with no
  62647. * prediction applied.
  62648. * @returns the current instantaneous pose
  62649. */
  62650. getImmediatePose(): VRPose;
  62651. /**
  62652. * The callback passed to `requestAnimationFrame` will be called
  62653. * any time a new frame should be rendered. When the VRDisplay is
  62654. * presenting the callback will be called at the native refresh
  62655. * rate of the HMD. When not presenting this function acts
  62656. * identically to how window.requestAnimationFrame acts. Content should
  62657. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62658. * asynchronously from other displays and at differing refresh rates.
  62659. * @param callback Define the eaction to run next frame
  62660. * @returns the request handle it
  62661. */
  62662. requestAnimationFrame(callback: FrameRequestCallback): number;
  62663. /**
  62664. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62665. * Repeat calls while already presenting will update the VRLayers being displayed.
  62666. * @param layers Define the list of layer to present
  62667. * @returns a promise to know when the request has been fulfilled
  62668. */
  62669. requestPresent(layers: VRLayer[]): Promise<void>;
  62670. /**
  62671. * Reset the pose for this display, treating its current position and
  62672. * orientation as the "origin/zero" values. VRPose.position,
  62673. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62674. * updated when calling resetPose(). This should be called in only
  62675. * sitting-space experiences.
  62676. */
  62677. resetPose(): void;
  62678. /**
  62679. * The VRLayer provided to the VRDisplay will be captured and presented
  62680. * in the HMD. Calling this function has the same effect on the source
  62681. * canvas as any other operation that uses its source image, and canvases
  62682. * created without preserveDrawingBuffer set to true will be cleared.
  62683. * @param pose Define the pose to submit
  62684. */
  62685. submitFrame(pose?: VRPose): void;
  62686. }
  62687. declare var VRDisplay: {
  62688. prototype: VRDisplay;
  62689. new(): VRDisplay;
  62690. };
  62691. interface VRLayer {
  62692. leftBounds?: number[] | Float32Array | null;
  62693. rightBounds?: number[] | Float32Array | null;
  62694. source?: HTMLCanvasElement | null;
  62695. }
  62696. interface VRDisplayCapabilities {
  62697. readonly canPresent: boolean;
  62698. readonly hasExternalDisplay: boolean;
  62699. readonly hasOrientation: boolean;
  62700. readonly hasPosition: boolean;
  62701. readonly maxLayers: number;
  62702. }
  62703. interface VREyeParameters {
  62704. /** @deprecated */
  62705. readonly fieldOfView: VRFieldOfView;
  62706. readonly offset: Float32Array;
  62707. readonly renderHeight: number;
  62708. readonly renderWidth: number;
  62709. }
  62710. interface VRFieldOfView {
  62711. readonly downDegrees: number;
  62712. readonly leftDegrees: number;
  62713. readonly rightDegrees: number;
  62714. readonly upDegrees: number;
  62715. }
  62716. interface VRFrameData {
  62717. readonly leftProjectionMatrix: Float32Array;
  62718. readonly leftViewMatrix: Float32Array;
  62719. readonly pose: VRPose;
  62720. readonly rightProjectionMatrix: Float32Array;
  62721. readonly rightViewMatrix: Float32Array;
  62722. readonly timestamp: number;
  62723. }
  62724. interface VRPose {
  62725. readonly angularAcceleration: Float32Array | null;
  62726. readonly angularVelocity: Float32Array | null;
  62727. readonly linearAcceleration: Float32Array | null;
  62728. readonly linearVelocity: Float32Array | null;
  62729. readonly orientation: Float32Array | null;
  62730. readonly position: Float32Array | null;
  62731. readonly timestamp: number;
  62732. }
  62733. interface VRStageParameters {
  62734. sittingToStandingTransform?: Float32Array;
  62735. sizeX?: number;
  62736. sizeY?: number;
  62737. }
  62738. interface Navigator {
  62739. getVRDisplays(): Promise<VRDisplay[]>;
  62740. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62741. }
  62742. interface Window {
  62743. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62744. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62745. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62746. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62747. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62748. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62749. }
  62750. interface Gamepad {
  62751. readonly displayId: number;
  62752. }
  62753. type XRSessionMode =
  62754. | "inline"
  62755. | "immersive-vr"
  62756. | "immersive-ar";
  62757. type XRReferenceSpaceType =
  62758. | "viewer"
  62759. | "local"
  62760. | "local-floor"
  62761. | "bounded-floor"
  62762. | "unbounded";
  62763. type XREnvironmentBlendMode =
  62764. | "opaque"
  62765. | "additive"
  62766. | "alpha-blend";
  62767. type XRVisibilityState =
  62768. | "visible"
  62769. | "visible-blurred"
  62770. | "hidden";
  62771. type XRHandedness =
  62772. | "none"
  62773. | "left"
  62774. | "right";
  62775. type XRTargetRayMode =
  62776. | "gaze"
  62777. | "tracked-pointer"
  62778. | "screen";
  62779. type XREye =
  62780. | "none"
  62781. | "left"
  62782. | "right";
  62783. interface XRSpace extends EventTarget {
  62784. }
  62785. interface XRRenderState {
  62786. depthNear?: number;
  62787. depthFar?: number;
  62788. inlineVerticalFieldOfView?: number;
  62789. baseLayer?: XRWebGLLayer;
  62790. }
  62791. interface XRInputSource {
  62792. handedness: XRHandedness;
  62793. targetRayMode: XRTargetRayMode;
  62794. targetRaySpace: XRSpace;
  62795. gripSpace: XRSpace | undefined;
  62796. gamepad: Gamepad | undefined;
  62797. profiles: Array<string>;
  62798. }
  62799. interface XRSession {
  62800. addEventListener: Function;
  62801. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  62802. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  62803. requestAnimationFrame: Function;
  62804. end(): Promise<void>;
  62805. renderState: XRRenderState;
  62806. inputSources: Array<XRInputSource>;
  62807. }
  62808. interface XRReferenceSpace extends XRSpace {
  62809. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  62810. onreset: any;
  62811. }
  62812. interface XRFrame {
  62813. session: XRSession;
  62814. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  62815. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  62816. }
  62817. interface XRViewerPose extends XRPose {
  62818. views: Array<XRView>;
  62819. }
  62820. interface XRPose {
  62821. transform: XRRigidTransform;
  62822. emulatedPosition: boolean;
  62823. }
  62824. declare var XRWebGLLayer: {
  62825. prototype: XRWebGLLayer;
  62826. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  62827. };
  62828. interface XRWebGLLayer {
  62829. framebuffer: WebGLFramebuffer;
  62830. framebufferWidth: number;
  62831. framebufferHeight: number;
  62832. getViewport: Function;
  62833. }
  62834. interface XRRigidTransform {
  62835. position: DOMPointReadOnly;
  62836. orientation: DOMPointReadOnly;
  62837. matrix: Float32Array;
  62838. inverse: XRRigidTransform;
  62839. }
  62840. interface XRView {
  62841. eye: XREye;
  62842. projectionMatrix: Float32Array;
  62843. transform: XRRigidTransform;
  62844. }
  62845. interface XRInputSourceChangeEvent {
  62846. session: XRSession;
  62847. removed: Array<XRInputSource>;
  62848. added: Array<XRInputSource>;
  62849. }
  62850. /**
  62851. * @ignore
  62852. */
  62853. declare module BABYLON.GLTF2.Exporter {
  62854. }
  62855. /**
  62856. * @ignore
  62857. */
  62858. declare module BABYLON.GLTF1 {
  62859. }
  62860. declare module BABYLON.GUI {
  62861. /**
  62862. * Class used to specific a value and its associated unit
  62863. */
  62864. export class ValueAndUnit {
  62865. /** defines the unit to store */
  62866. unit: number;
  62867. /** defines a boolean indicating if the value can be negative */
  62868. negativeValueAllowed: boolean;
  62869. private _value;
  62870. private _originalUnit;
  62871. /**
  62872. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  62873. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62874. */
  62875. ignoreAdaptiveScaling: boolean;
  62876. /**
  62877. * Creates a new ValueAndUnit
  62878. * @param value defines the value to store
  62879. * @param unit defines the unit to store
  62880. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  62881. */
  62882. constructor(value: number,
  62883. /** defines the unit to store */
  62884. unit?: number,
  62885. /** defines a boolean indicating if the value can be negative */
  62886. negativeValueAllowed?: boolean);
  62887. /** Gets a boolean indicating if the value is a percentage */
  62888. readonly isPercentage: boolean;
  62889. /** Gets a boolean indicating if the value is store as pixel */
  62890. readonly isPixel: boolean;
  62891. /** Gets direct internal value */
  62892. readonly internalValue: number;
  62893. /**
  62894. * Gets value as pixel
  62895. * @param host defines the root host
  62896. * @param refValue defines the reference value for percentages
  62897. * @returns the value as pixel
  62898. */
  62899. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  62900. /**
  62901. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  62902. * @param value defines the value to store
  62903. * @param unit defines the unit to store
  62904. * @returns the current ValueAndUnit
  62905. */
  62906. updateInPlace(value: number, unit?: number): ValueAndUnit;
  62907. /**
  62908. * Gets the value accordingly to its unit
  62909. * @param host defines the root host
  62910. * @returns the value
  62911. */
  62912. getValue(host: AdvancedDynamicTexture): number;
  62913. /**
  62914. * Gets a string representation of the value
  62915. * @param host defines the root host
  62916. * @param decimals defines an optional number of decimals to display
  62917. * @returns a string
  62918. */
  62919. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  62920. /**
  62921. * Store a value parsed from a string
  62922. * @param source defines the source string
  62923. * @returns true if the value was successfully parsed
  62924. */
  62925. fromString(source: string | number): boolean;
  62926. private static _Regex;
  62927. private static _UNITMODE_PERCENTAGE;
  62928. private static _UNITMODE_PIXEL;
  62929. /** UNITMODE_PERCENTAGE */
  62930. static readonly UNITMODE_PERCENTAGE: number;
  62931. /** UNITMODE_PIXEL */
  62932. static readonly UNITMODE_PIXEL: number;
  62933. }
  62934. }
  62935. declare module BABYLON.GUI {
  62936. /**
  62937. * Define a style used by control to automatically setup properties based on a template.
  62938. * Only support font related properties so far
  62939. */
  62940. export class Style implements BABYLON.IDisposable {
  62941. private _fontFamily;
  62942. private _fontStyle;
  62943. private _fontWeight;
  62944. /** @hidden */
  62945. _host: AdvancedDynamicTexture;
  62946. /** @hidden */
  62947. _fontSize: ValueAndUnit;
  62948. /**
  62949. * BABYLON.Observable raised when the style values are changed
  62950. */
  62951. onChangedObservable: BABYLON.Observable<Style>;
  62952. /**
  62953. * Creates a new style object
  62954. * @param host defines the AdvancedDynamicTexture which hosts this style
  62955. */
  62956. constructor(host: AdvancedDynamicTexture);
  62957. /**
  62958. * Gets or sets the font size
  62959. */
  62960. fontSize: string | number;
  62961. /**
  62962. * Gets or sets the font family
  62963. */
  62964. fontFamily: string;
  62965. /**
  62966. * Gets or sets the font style
  62967. */
  62968. fontStyle: string;
  62969. /** Gets or sets font weight */
  62970. fontWeight: string;
  62971. /** Dispose all associated resources */
  62972. dispose(): void;
  62973. }
  62974. }
  62975. declare module BABYLON.GUI {
  62976. /**
  62977. * Class used to transport BABYLON.Vector2 information for pointer events
  62978. */
  62979. export class Vector2WithInfo extends BABYLON.Vector2 {
  62980. /** defines the current mouse button index */
  62981. buttonIndex: number;
  62982. /**
  62983. * Creates a new Vector2WithInfo
  62984. * @param source defines the vector2 data to transport
  62985. * @param buttonIndex defines the current mouse button index
  62986. */
  62987. constructor(source: BABYLON.Vector2,
  62988. /** defines the current mouse button index */
  62989. buttonIndex?: number);
  62990. }
  62991. /** Class used to provide 2D matrix features */
  62992. export class Matrix2D {
  62993. /** Gets the internal array of 6 floats used to store matrix data */
  62994. m: Float32Array;
  62995. /**
  62996. * Creates a new matrix
  62997. * @param m00 defines value for (0, 0)
  62998. * @param m01 defines value for (0, 1)
  62999. * @param m10 defines value for (1, 0)
  63000. * @param m11 defines value for (1, 1)
  63001. * @param m20 defines value for (2, 0)
  63002. * @param m21 defines value for (2, 1)
  63003. */
  63004. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  63005. /**
  63006. * Fills the matrix from direct values
  63007. * @param m00 defines value for (0, 0)
  63008. * @param m01 defines value for (0, 1)
  63009. * @param m10 defines value for (1, 0)
  63010. * @param m11 defines value for (1, 1)
  63011. * @param m20 defines value for (2, 0)
  63012. * @param m21 defines value for (2, 1)
  63013. * @returns the current modified matrix
  63014. */
  63015. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  63016. /**
  63017. * Gets matrix determinant
  63018. * @returns the determinant
  63019. */
  63020. determinant(): number;
  63021. /**
  63022. * Inverses the matrix and stores it in a target matrix
  63023. * @param result defines the target matrix
  63024. * @returns the current matrix
  63025. */
  63026. invertToRef(result: Matrix2D): Matrix2D;
  63027. /**
  63028. * Multiplies the current matrix with another one
  63029. * @param other defines the second operand
  63030. * @param result defines the target matrix
  63031. * @returns the current matrix
  63032. */
  63033. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  63034. /**
  63035. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  63036. * @param x defines the x coordinate to transform
  63037. * @param y defines the x coordinate to transform
  63038. * @param result defines the target vector2
  63039. * @returns the current matrix
  63040. */
  63041. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  63042. /**
  63043. * Creates an identity matrix
  63044. * @returns a new matrix
  63045. */
  63046. static Identity(): Matrix2D;
  63047. /**
  63048. * Creates a translation matrix and stores it in a target matrix
  63049. * @param x defines the x coordinate of the translation
  63050. * @param y defines the y coordinate of the translation
  63051. * @param result defines the target matrix
  63052. */
  63053. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  63054. /**
  63055. * Creates a scaling matrix and stores it in a target matrix
  63056. * @param x defines the x coordinate of the scaling
  63057. * @param y defines the y coordinate of the scaling
  63058. * @param result defines the target matrix
  63059. */
  63060. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  63061. /**
  63062. * Creates a rotation matrix and stores it in a target matrix
  63063. * @param angle defines the rotation angle
  63064. * @param result defines the target matrix
  63065. */
  63066. static RotationToRef(angle: number, result: Matrix2D): void;
  63067. private static _TempPreTranslationMatrix;
  63068. private static _TempPostTranslationMatrix;
  63069. private static _TempRotationMatrix;
  63070. private static _TempScalingMatrix;
  63071. private static _TempCompose0;
  63072. private static _TempCompose1;
  63073. private static _TempCompose2;
  63074. /**
  63075. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  63076. * @param tx defines the x coordinate of the translation
  63077. * @param ty defines the y coordinate of the translation
  63078. * @param angle defines the rotation angle
  63079. * @param scaleX defines the x coordinate of the scaling
  63080. * @param scaleY defines the y coordinate of the scaling
  63081. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  63082. * @param result defines the target matrix
  63083. */
  63084. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  63085. }
  63086. }
  63087. declare module BABYLON.GUI {
  63088. /**
  63089. * Class used to store 2D control sizes
  63090. */
  63091. export class Measure {
  63092. /** defines left coordinate */
  63093. left: number;
  63094. /** defines top coordinate */
  63095. top: number;
  63096. /** defines width dimension */
  63097. width: number;
  63098. /** defines height dimension */
  63099. height: number;
  63100. /**
  63101. * Creates a new measure
  63102. * @param left defines left coordinate
  63103. * @param top defines top coordinate
  63104. * @param width defines width dimension
  63105. * @param height defines height dimension
  63106. */
  63107. constructor(
  63108. /** defines left coordinate */
  63109. left: number,
  63110. /** defines top coordinate */
  63111. top: number,
  63112. /** defines width dimension */
  63113. width: number,
  63114. /** defines height dimension */
  63115. height: number);
  63116. /**
  63117. * Copy from another measure
  63118. * @param other defines the other measure to copy from
  63119. */
  63120. copyFrom(other: Measure): void;
  63121. /**
  63122. * Copy from a group of 4 floats
  63123. * @param left defines left coordinate
  63124. * @param top defines top coordinate
  63125. * @param width defines width dimension
  63126. * @param height defines height dimension
  63127. */
  63128. copyFromFloats(left: number, top: number, width: number, height: number): void;
  63129. /**
  63130. * Computes the axis aligned bounding box measure for two given measures
  63131. * @param a Input measure
  63132. * @param b Input measure
  63133. * @param result the resulting bounding measure
  63134. */
  63135. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  63136. /**
  63137. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  63138. * @param transform the matrix to transform the measure before computing the AABB
  63139. * @param result the resulting AABB
  63140. */
  63141. transformToRef(transform: Matrix2D, result: Measure): void;
  63142. /**
  63143. * Check equality between this measure and another one
  63144. * @param other defines the other measures
  63145. * @returns true if both measures are equals
  63146. */
  63147. isEqualsTo(other: Measure): boolean;
  63148. /**
  63149. * Creates an empty measure
  63150. * @returns a new measure
  63151. */
  63152. static Empty(): Measure;
  63153. }
  63154. }
  63155. declare module BABYLON.GUI {
  63156. /**
  63157. * Interface used to define a control that can receive focus
  63158. */
  63159. export interface IFocusableControl {
  63160. /**
  63161. * Function called when the control receives the focus
  63162. */
  63163. onFocus(): void;
  63164. /**
  63165. * Function called when the control loses the focus
  63166. */
  63167. onBlur(): void;
  63168. /**
  63169. * Function called to let the control handle keyboard events
  63170. * @param evt defines the current keyboard event
  63171. */
  63172. processKeyboard(evt: KeyboardEvent): void;
  63173. /**
  63174. * Function called to get the list of controls that should not steal the focus from this control
  63175. * @returns an array of controls
  63176. */
  63177. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  63178. }
  63179. /**
  63180. * Class used to create texture to support 2D GUI elements
  63181. * @see http://doc.babylonjs.com/how_to/gui
  63182. */
  63183. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  63184. private _isDirty;
  63185. private _renderObserver;
  63186. private _resizeObserver;
  63187. private _preKeyboardObserver;
  63188. private _pointerMoveObserver;
  63189. private _pointerObserver;
  63190. private _canvasPointerOutObserver;
  63191. private _background;
  63192. /** @hidden */
  63193. _rootContainer: Container;
  63194. /** @hidden */
  63195. _lastPickedControl: Control;
  63196. /** @hidden */
  63197. _lastControlOver: {
  63198. [pointerId: number]: Control;
  63199. };
  63200. /** @hidden */
  63201. _lastControlDown: {
  63202. [pointerId: number]: Control;
  63203. };
  63204. /** @hidden */
  63205. _capturingControl: {
  63206. [pointerId: number]: Control;
  63207. };
  63208. /** @hidden */
  63209. _shouldBlockPointer: boolean;
  63210. /** @hidden */
  63211. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  63212. /** @hidden */
  63213. _linkedControls: Control[];
  63214. private _isFullscreen;
  63215. private _fullscreenViewport;
  63216. private _idealWidth;
  63217. private _idealHeight;
  63218. private _useSmallestIdeal;
  63219. private _renderAtIdealSize;
  63220. private _focusedControl;
  63221. private _blockNextFocusCheck;
  63222. private _renderScale;
  63223. private _rootCanvas;
  63224. private _cursorChanged;
  63225. /**
  63226. * Define type to string to ensure compatibility across browsers
  63227. * Safari doesn't support DataTransfer constructor
  63228. */
  63229. private _clipboardData;
  63230. /**
  63231. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  63232. */
  63233. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  63234. /**
  63235. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  63236. */
  63237. onControlPickedObservable: BABYLON.Observable<Control>;
  63238. /**
  63239. * BABYLON.Observable event triggered before layout is evaluated
  63240. */
  63241. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63242. /**
  63243. * BABYLON.Observable event triggered after the layout was evaluated
  63244. */
  63245. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63246. /**
  63247. * BABYLON.Observable event triggered before the texture is rendered
  63248. */
  63249. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63250. /**
  63251. * BABYLON.Observable event triggered after the texture was rendered
  63252. */
  63253. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63254. /**
  63255. * Gets or sets a boolean defining if alpha is stored as premultiplied
  63256. */
  63257. premulAlpha: boolean;
  63258. /**
  63259. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  63260. * Useful when you want more antialiasing
  63261. */
  63262. renderScale: number;
  63263. /** Gets or sets the background color */
  63264. background: string;
  63265. /**
  63266. * Gets or sets the ideal width used to design controls.
  63267. * The GUI will then rescale everything accordingly
  63268. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63269. */
  63270. idealWidth: number;
  63271. /**
  63272. * Gets or sets the ideal height used to design controls.
  63273. * The GUI will then rescale everything accordingly
  63274. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63275. */
  63276. idealHeight: number;
  63277. /**
  63278. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  63279. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63280. */
  63281. useSmallestIdeal: boolean;
  63282. /**
  63283. * Gets or sets a boolean indicating if adaptive scaling must be used
  63284. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63285. */
  63286. renderAtIdealSize: boolean;
  63287. /**
  63288. * Gets the underlying layer used to render the texture when in fullscreen mode
  63289. */
  63290. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  63291. /**
  63292. * Gets the root container control
  63293. */
  63294. readonly rootContainer: Container;
  63295. /**
  63296. * Returns an array containing the root container.
  63297. * This is mostly used to let the Inspector introspects the ADT
  63298. * @returns an array containing the rootContainer
  63299. */
  63300. getChildren(): Array<Container>;
  63301. /**
  63302. * Will return all controls that are inside this texture
  63303. * @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
  63304. * @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
  63305. * @return all child controls
  63306. */
  63307. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63308. /**
  63309. * Gets or sets the current focused control
  63310. */
  63311. focusedControl: BABYLON.Nullable<IFocusableControl>;
  63312. /**
  63313. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  63314. */
  63315. isForeground: boolean;
  63316. /**
  63317. * Gets or set information about clipboardData
  63318. */
  63319. clipboardData: string;
  63320. /**
  63321. * Creates a new AdvancedDynamicTexture
  63322. * @param name defines the name of the texture
  63323. * @param width defines the width of the texture
  63324. * @param height defines the height of the texture
  63325. * @param scene defines the hosting scene
  63326. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  63327. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  63328. */
  63329. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  63330. /**
  63331. * Get the current class name of the texture useful for serialization or dynamic coding.
  63332. * @returns "AdvancedDynamicTexture"
  63333. */
  63334. getClassName(): string;
  63335. /**
  63336. * Function used to execute a function on all controls
  63337. * @param func defines the function to execute
  63338. * @param container defines the container where controls belong. If null the root container will be used
  63339. */
  63340. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  63341. private _useInvalidateRectOptimization;
  63342. /**
  63343. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  63344. */
  63345. useInvalidateRectOptimization: boolean;
  63346. private _invalidatedRectangle;
  63347. /**
  63348. * Invalidates a rectangle area on the gui texture
  63349. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  63350. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  63351. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  63352. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  63353. */
  63354. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  63355. /**
  63356. * Marks the texture as dirty forcing a complete update
  63357. */
  63358. markAsDirty(): void;
  63359. /**
  63360. * Helper function used to create a new style
  63361. * @returns a new style
  63362. * @see http://doc.babylonjs.com/how_to/gui#styles
  63363. */
  63364. createStyle(): Style;
  63365. /**
  63366. * Adds a new control to the root container
  63367. * @param control defines the control to add
  63368. * @returns the current texture
  63369. */
  63370. addControl(control: Control): AdvancedDynamicTexture;
  63371. /**
  63372. * Removes a control from the root container
  63373. * @param control defines the control to remove
  63374. * @returns the current texture
  63375. */
  63376. removeControl(control: Control): AdvancedDynamicTexture;
  63377. /**
  63378. * Release all resources
  63379. */
  63380. dispose(): void;
  63381. private _onResize;
  63382. /** @hidden */
  63383. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  63384. /**
  63385. * Get screen coordinates for a vector3
  63386. * @param position defines the position to project
  63387. * @param worldMatrix defines the world matrix to use
  63388. * @returns the projected position
  63389. */
  63390. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  63391. private _checkUpdate;
  63392. private _clearMeasure;
  63393. private _render;
  63394. /** @hidden */
  63395. _changeCursor(cursor: string): void;
  63396. /** @hidden */
  63397. _registerLastControlDown(control: Control, pointerId: number): void;
  63398. private _doPicking;
  63399. /** @hidden */
  63400. _cleanControlAfterRemovalFromList(list: {
  63401. [pointerId: number]: Control;
  63402. }, control: Control): void;
  63403. /** @hidden */
  63404. _cleanControlAfterRemoval(control: Control): void;
  63405. /** Attach to all scene events required to support pointer events */
  63406. attach(): void;
  63407. /** @hidden */
  63408. private onClipboardCopy;
  63409. /** @hidden */
  63410. private onClipboardCut;
  63411. /** @hidden */
  63412. private onClipboardPaste;
  63413. /**
  63414. * Register the clipboard Events onto the canvas
  63415. */
  63416. registerClipboardEvents(): void;
  63417. /**
  63418. * Unregister the clipboard Events from the canvas
  63419. */
  63420. unRegisterClipboardEvents(): void;
  63421. /**
  63422. * Connect the texture to a hosting mesh to enable interactions
  63423. * @param mesh defines the mesh to attach to
  63424. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  63425. */
  63426. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  63427. /**
  63428. * Move the focus to a specific control
  63429. * @param control defines the control which will receive the focus
  63430. */
  63431. moveFocusToControl(control: IFocusableControl): void;
  63432. private _manageFocus;
  63433. private _attachToOnPointerOut;
  63434. /**
  63435. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  63436. * @param mesh defines the mesh which will receive the texture
  63437. * @param width defines the texture width (1024 by default)
  63438. * @param height defines the texture height (1024 by default)
  63439. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  63440. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  63441. * @returns a new AdvancedDynamicTexture
  63442. */
  63443. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  63444. /**
  63445. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  63446. * In this mode the texture will rely on a layer for its rendering.
  63447. * This allows it to be treated like any other layer.
  63448. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  63449. * LayerMask is set through advancedTexture.layer.layerMask
  63450. * @param name defines name for the texture
  63451. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  63452. * @param scene defines the hsoting scene
  63453. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  63454. * @returns a new AdvancedDynamicTexture
  63455. */
  63456. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  63457. }
  63458. }
  63459. declare module BABYLON.GUI {
  63460. /**
  63461. * Root class used for all 2D controls
  63462. * @see http://doc.babylonjs.com/how_to/gui#controls
  63463. */
  63464. export class Control {
  63465. /** defines the name of the control */
  63466. name?: string | undefined;
  63467. /**
  63468. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  63469. */
  63470. static AllowAlphaInheritance: boolean;
  63471. private _alpha;
  63472. private _alphaSet;
  63473. private _zIndex;
  63474. /** @hidden */
  63475. _host: AdvancedDynamicTexture;
  63476. /** Gets or sets the control parent */
  63477. parent: BABYLON.Nullable<Container>;
  63478. /** @hidden */
  63479. _currentMeasure: Measure;
  63480. private _fontFamily;
  63481. private _fontStyle;
  63482. private _fontWeight;
  63483. private _fontSize;
  63484. private _font;
  63485. /** @hidden */
  63486. _width: ValueAndUnit;
  63487. /** @hidden */
  63488. _height: ValueAndUnit;
  63489. /** @hidden */
  63490. protected _fontOffset: {
  63491. ascent: number;
  63492. height: number;
  63493. descent: number;
  63494. };
  63495. private _color;
  63496. private _style;
  63497. private _styleObserver;
  63498. /** @hidden */
  63499. protected _horizontalAlignment: number;
  63500. /** @hidden */
  63501. protected _verticalAlignment: number;
  63502. /** @hidden */
  63503. protected _isDirty: boolean;
  63504. /** @hidden */
  63505. protected _wasDirty: boolean;
  63506. /** @hidden */
  63507. _tempParentMeasure: Measure;
  63508. /** @hidden */
  63509. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  63510. /** @hidden */
  63511. protected _cachedParentMeasure: Measure;
  63512. private _paddingLeft;
  63513. private _paddingRight;
  63514. private _paddingTop;
  63515. private _paddingBottom;
  63516. /** @hidden */
  63517. _left: ValueAndUnit;
  63518. /** @hidden */
  63519. _top: ValueAndUnit;
  63520. private _scaleX;
  63521. private _scaleY;
  63522. private _rotation;
  63523. private _transformCenterX;
  63524. private _transformCenterY;
  63525. /** @hidden */
  63526. _transformMatrix: Matrix2D;
  63527. /** @hidden */
  63528. protected _invertTransformMatrix: Matrix2D;
  63529. /** @hidden */
  63530. protected _transformedPosition: BABYLON.Vector2;
  63531. private _isMatrixDirty;
  63532. private _cachedOffsetX;
  63533. private _cachedOffsetY;
  63534. private _isVisible;
  63535. private _isHighlighted;
  63536. /** @hidden */
  63537. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63538. private _fontSet;
  63539. private _dummyVector2;
  63540. private _downCount;
  63541. private _enterCount;
  63542. private _doNotRender;
  63543. private _downPointerIds;
  63544. protected _isEnabled: boolean;
  63545. protected _disabledColor: string;
  63546. /** @hidden */
  63547. protected _rebuildLayout: boolean;
  63548. /** @hidden */
  63549. _isClipped: boolean;
  63550. /** @hidden */
  63551. _tag: any;
  63552. /**
  63553. * 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
  63554. */
  63555. uniqueId: number;
  63556. /**
  63557. * Gets or sets an object used to store user defined information for the node
  63558. */
  63559. metadata: any;
  63560. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  63561. isHitTestVisible: boolean;
  63562. /** Gets or sets a boolean indicating if the control can block pointer events */
  63563. isPointerBlocker: boolean;
  63564. /** Gets or sets a boolean indicating if the control can be focusable */
  63565. isFocusInvisible: boolean;
  63566. /**
  63567. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  63568. * 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
  63569. */
  63570. clipChildren: boolean;
  63571. /**
  63572. * Gets or sets a boolean indicating that control content must be clipped
  63573. * 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
  63574. */
  63575. clipContent: boolean;
  63576. /**
  63577. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  63578. */
  63579. useBitmapCache: boolean;
  63580. private _cacheData;
  63581. private _shadowOffsetX;
  63582. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  63583. shadowOffsetX: number;
  63584. private _shadowOffsetY;
  63585. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  63586. shadowOffsetY: number;
  63587. private _shadowBlur;
  63588. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  63589. shadowBlur: number;
  63590. private _shadowColor;
  63591. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  63592. shadowColor: string;
  63593. /** Gets or sets the cursor to use when the control is hovered */
  63594. hoverCursor: string;
  63595. /** @hidden */
  63596. protected _linkOffsetX: ValueAndUnit;
  63597. /** @hidden */
  63598. protected _linkOffsetY: ValueAndUnit;
  63599. /** Gets the control type name */
  63600. readonly typeName: string;
  63601. /**
  63602. * Get the current class name of the control.
  63603. * @returns current class name
  63604. */
  63605. getClassName(): string;
  63606. /**
  63607. * An event triggered when the pointer move over the control.
  63608. */
  63609. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  63610. /**
  63611. * An event triggered when the pointer move out of the control.
  63612. */
  63613. onPointerOutObservable: BABYLON.Observable<Control>;
  63614. /**
  63615. * An event triggered when the pointer taps the control
  63616. */
  63617. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  63618. /**
  63619. * An event triggered when pointer up
  63620. */
  63621. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  63622. /**
  63623. * An event triggered when a control is clicked on
  63624. */
  63625. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  63626. /**
  63627. * An event triggered when pointer enters the control
  63628. */
  63629. onPointerEnterObservable: BABYLON.Observable<Control>;
  63630. /**
  63631. * An event triggered when the control is marked as dirty
  63632. */
  63633. onDirtyObservable: BABYLON.Observable<Control>;
  63634. /**
  63635. * An event triggered before drawing the control
  63636. */
  63637. onBeforeDrawObservable: BABYLON.Observable<Control>;
  63638. /**
  63639. * An event triggered after the control was drawn
  63640. */
  63641. onAfterDrawObservable: BABYLON.Observable<Control>;
  63642. /**
  63643. * Get the hosting AdvancedDynamicTexture
  63644. */
  63645. readonly host: AdvancedDynamicTexture;
  63646. /** Gets or set information about font offsets (used to render and align text) */
  63647. fontOffset: {
  63648. ascent: number;
  63649. height: number;
  63650. descent: number;
  63651. };
  63652. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  63653. alpha: number;
  63654. /**
  63655. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  63656. */
  63657. isHighlighted: boolean;
  63658. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  63659. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63660. */
  63661. scaleX: number;
  63662. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  63663. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63664. */
  63665. scaleY: number;
  63666. /** Gets or sets the rotation angle (0 by default)
  63667. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63668. */
  63669. rotation: number;
  63670. /** Gets or sets the transformation center on Y axis (0 by default)
  63671. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63672. */
  63673. transformCenterY: number;
  63674. /** Gets or sets the transformation center on X axis (0 by default)
  63675. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63676. */
  63677. transformCenterX: number;
  63678. /**
  63679. * Gets or sets the horizontal alignment
  63680. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63681. */
  63682. horizontalAlignment: number;
  63683. /**
  63684. * Gets or sets the vertical alignment
  63685. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63686. */
  63687. verticalAlignment: number;
  63688. /**
  63689. * Gets or sets control width
  63690. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63691. */
  63692. width: string | number;
  63693. /**
  63694. * Gets or sets the control width in pixel
  63695. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63696. */
  63697. widthInPixels: number;
  63698. /**
  63699. * Gets or sets control height
  63700. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63701. */
  63702. height: string | number;
  63703. /**
  63704. * Gets or sets control height in pixel
  63705. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63706. */
  63707. heightInPixels: number;
  63708. /** Gets or set font family */
  63709. fontFamily: string;
  63710. /** Gets or sets font style */
  63711. fontStyle: string;
  63712. /** Gets or sets font weight */
  63713. fontWeight: string;
  63714. /**
  63715. * Gets or sets style
  63716. * @see http://doc.babylonjs.com/how_to/gui#styles
  63717. */
  63718. style: BABYLON.Nullable<Style>;
  63719. /** @hidden */
  63720. readonly _isFontSizeInPercentage: boolean;
  63721. /** Gets or sets font size in pixels */
  63722. fontSizeInPixels: number;
  63723. /** Gets or sets font size */
  63724. fontSize: string | number;
  63725. /** Gets or sets foreground color */
  63726. color: string;
  63727. /** Gets or sets z index which is used to reorder controls on the z axis */
  63728. zIndex: number;
  63729. /** Gets or sets a boolean indicating if the control can be rendered */
  63730. notRenderable: boolean;
  63731. /** Gets or sets a boolean indicating if the control is visible */
  63732. isVisible: boolean;
  63733. /** Gets a boolean indicating that the control needs to update its rendering */
  63734. readonly isDirty: boolean;
  63735. /**
  63736. * Gets the current linked mesh (or null if none)
  63737. */
  63738. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63739. /**
  63740. * Gets or sets a value indicating the padding to use on the left of the control
  63741. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63742. */
  63743. paddingLeft: string | number;
  63744. /**
  63745. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  63746. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63747. */
  63748. paddingLeftInPixels: number;
  63749. /**
  63750. * Gets or sets a value indicating the padding to use on the right of the control
  63751. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63752. */
  63753. paddingRight: string | number;
  63754. /**
  63755. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  63756. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63757. */
  63758. paddingRightInPixels: number;
  63759. /**
  63760. * Gets or sets a value indicating the padding to use on the top of the control
  63761. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63762. */
  63763. paddingTop: string | number;
  63764. /**
  63765. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  63766. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63767. */
  63768. paddingTopInPixels: number;
  63769. /**
  63770. * Gets or sets a value indicating the padding to use on the bottom of the control
  63771. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63772. */
  63773. paddingBottom: string | number;
  63774. /**
  63775. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  63776. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63777. */
  63778. paddingBottomInPixels: number;
  63779. /**
  63780. * Gets or sets a value indicating the left coordinate of the control
  63781. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63782. */
  63783. left: string | number;
  63784. /**
  63785. * Gets or sets a value indicating the left coordinate in pixels of the control
  63786. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63787. */
  63788. leftInPixels: number;
  63789. /**
  63790. * Gets or sets a value indicating the top coordinate of the control
  63791. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63792. */
  63793. top: string | number;
  63794. /**
  63795. * Gets or sets a value indicating the top coordinate in pixels of the control
  63796. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63797. */
  63798. topInPixels: number;
  63799. /**
  63800. * Gets or sets a value indicating the offset on X axis to the linked mesh
  63801. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63802. */
  63803. linkOffsetX: string | number;
  63804. /**
  63805. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  63806. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63807. */
  63808. linkOffsetXInPixels: number;
  63809. /**
  63810. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  63811. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63812. */
  63813. linkOffsetY: string | number;
  63814. /**
  63815. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  63816. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63817. */
  63818. linkOffsetYInPixels: number;
  63819. /** Gets the center coordinate on X axis */
  63820. readonly centerX: number;
  63821. /** Gets the center coordinate on Y axis */
  63822. readonly centerY: number;
  63823. /** Gets or sets if control is Enabled*/
  63824. isEnabled: boolean;
  63825. /** Gets or sets background color of control if it's disabled*/
  63826. disabledColor: string;
  63827. /**
  63828. * Creates a new control
  63829. * @param name defines the name of the control
  63830. */
  63831. constructor(
  63832. /** defines the name of the control */
  63833. name?: string | undefined);
  63834. /** @hidden */
  63835. protected _getTypeName(): string;
  63836. /**
  63837. * Gets the first ascendant in the hierarchy of the given type
  63838. * @param className defines the required type
  63839. * @returns the ascendant or null if not found
  63840. */
  63841. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  63842. /** @hidden */
  63843. _resetFontCache(): void;
  63844. /**
  63845. * Determines if a container is an ascendant of the current control
  63846. * @param container defines the container to look for
  63847. * @returns true if the container is one of the ascendant of the control
  63848. */
  63849. isAscendant(container: Control): boolean;
  63850. /**
  63851. * Gets coordinates in local control space
  63852. * @param globalCoordinates defines the coordinates to transform
  63853. * @returns the new coordinates in local space
  63854. */
  63855. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63856. /**
  63857. * Gets coordinates in local control space
  63858. * @param globalCoordinates defines the coordinates to transform
  63859. * @param result defines the target vector2 where to store the result
  63860. * @returns the current control
  63861. */
  63862. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  63863. /**
  63864. * Gets coordinates in parent local control space
  63865. * @param globalCoordinates defines the coordinates to transform
  63866. * @returns the new coordinates in parent local space
  63867. */
  63868. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63869. /**
  63870. * Move the current control to a vector3 position projected onto the screen.
  63871. * @param position defines the target position
  63872. * @param scene defines the hosting scene
  63873. */
  63874. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  63875. /** @hidden */
  63876. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63877. /**
  63878. * Will return all controls that have this control as ascendant
  63879. * @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
  63880. * @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
  63881. * @return all child controls
  63882. */
  63883. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63884. /**
  63885. * Link current control with a target mesh
  63886. * @param mesh defines the mesh to link with
  63887. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63888. */
  63889. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  63890. /** @hidden */
  63891. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  63892. /** @hidden */
  63893. _offsetLeft(offset: number): void;
  63894. /** @hidden */
  63895. _offsetTop(offset: number): void;
  63896. /** @hidden */
  63897. _markMatrixAsDirty(): void;
  63898. /** @hidden */
  63899. _flagDescendantsAsMatrixDirty(): void;
  63900. /** @hidden */
  63901. _intersectsRect(rect: Measure): boolean;
  63902. /** @hidden */
  63903. protected invalidateRect(): void;
  63904. /** @hidden */
  63905. _markAsDirty(force?: boolean): void;
  63906. /** @hidden */
  63907. _markAllAsDirty(): void;
  63908. /** @hidden */
  63909. _link(host: AdvancedDynamicTexture): void;
  63910. /** @hidden */
  63911. protected _transform(context?: CanvasRenderingContext2D): void;
  63912. /** @hidden */
  63913. _renderHighlight(context: CanvasRenderingContext2D): void;
  63914. /** @hidden */
  63915. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63916. /** @hidden */
  63917. protected _applyStates(context: CanvasRenderingContext2D): void;
  63918. /** @hidden */
  63919. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63920. /** @hidden */
  63921. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63922. protected _evaluateClippingState(parentMeasure: Measure): void;
  63923. /** @hidden */
  63924. _measure(): void;
  63925. /** @hidden */
  63926. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63927. /** @hidden */
  63928. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63929. /** @hidden */
  63930. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63931. /** @hidden */
  63932. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63933. private static _ClipMeasure;
  63934. private _tmpMeasureA;
  63935. private _clip;
  63936. /** @hidden */
  63937. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  63938. /** @hidden */
  63939. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  63940. /**
  63941. * Tests if a given coordinates belong to the current control
  63942. * @param x defines x coordinate to test
  63943. * @param y defines y coordinate to test
  63944. * @returns true if the coordinates are inside the control
  63945. */
  63946. contains(x: number, y: number): boolean;
  63947. /** @hidden */
  63948. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63949. /** @hidden */
  63950. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63951. /** @hidden */
  63952. _onPointerEnter(target: Control): boolean;
  63953. /** @hidden */
  63954. _onPointerOut(target: Control, force?: boolean): void;
  63955. /** @hidden */
  63956. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63957. /** @hidden */
  63958. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63959. /** @hidden */
  63960. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  63961. /** @hidden */
  63962. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  63963. private _prepareFont;
  63964. /** Releases associated resources */
  63965. dispose(): void;
  63966. private static _HORIZONTAL_ALIGNMENT_LEFT;
  63967. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  63968. private static _HORIZONTAL_ALIGNMENT_CENTER;
  63969. private static _VERTICAL_ALIGNMENT_TOP;
  63970. private static _VERTICAL_ALIGNMENT_BOTTOM;
  63971. private static _VERTICAL_ALIGNMENT_CENTER;
  63972. /** HORIZONTAL_ALIGNMENT_LEFT */
  63973. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  63974. /** HORIZONTAL_ALIGNMENT_RIGHT */
  63975. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  63976. /** HORIZONTAL_ALIGNMENT_CENTER */
  63977. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  63978. /** VERTICAL_ALIGNMENT_TOP */
  63979. static readonly VERTICAL_ALIGNMENT_TOP: number;
  63980. /** VERTICAL_ALIGNMENT_BOTTOM */
  63981. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  63982. /** VERTICAL_ALIGNMENT_CENTER */
  63983. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  63984. private static _FontHeightSizes;
  63985. /** @hidden */
  63986. static _GetFontOffset(font: string): {
  63987. ascent: number;
  63988. height: number;
  63989. descent: number;
  63990. };
  63991. /**
  63992. * Creates a stack panel that can be used to render headers
  63993. * @param control defines the control to associate with the header
  63994. * @param text defines the text of the header
  63995. * @param size defines the size of the header
  63996. * @param options defines options used to configure the header
  63997. * @returns a new StackPanel
  63998. * @ignore
  63999. * @hidden
  64000. */
  64001. static AddHeader: (control: Control, text: string, size: string | number, options: {
  64002. isHorizontal: boolean;
  64003. controlFirst: boolean;
  64004. }) => any;
  64005. /** @hidden */
  64006. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  64007. }
  64008. }
  64009. declare module BABYLON.GUI {
  64010. /**
  64011. * Root class for 2D containers
  64012. * @see http://doc.babylonjs.com/how_to/gui#containers
  64013. */
  64014. export class Container extends Control {
  64015. name?: string | undefined;
  64016. /** @hidden */
  64017. protected _children: Control[];
  64018. /** @hidden */
  64019. protected _measureForChildren: Measure;
  64020. /** @hidden */
  64021. protected _background: string;
  64022. /** @hidden */
  64023. protected _adaptWidthToChildren: boolean;
  64024. /** @hidden */
  64025. protected _adaptHeightToChildren: boolean;
  64026. /**
  64027. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  64028. */
  64029. logLayoutCycleErrors: boolean;
  64030. /**
  64031. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  64032. */
  64033. maxLayoutCycle: number;
  64034. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  64035. adaptHeightToChildren: boolean;
  64036. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  64037. adaptWidthToChildren: boolean;
  64038. /** Gets or sets background color */
  64039. background: string;
  64040. /** Gets the list of children */
  64041. readonly children: Control[];
  64042. /**
  64043. * Creates a new Container
  64044. * @param name defines the name of the container
  64045. */
  64046. constructor(name?: string | undefined);
  64047. protected _getTypeName(): string;
  64048. _flagDescendantsAsMatrixDirty(): void;
  64049. /**
  64050. * Gets a child using its name
  64051. * @param name defines the child name to look for
  64052. * @returns the child control if found
  64053. */
  64054. getChildByName(name: string): BABYLON.Nullable<Control>;
  64055. /**
  64056. * Gets a child using its type and its name
  64057. * @param name defines the child name to look for
  64058. * @param type defines the child type to look for
  64059. * @returns the child control if found
  64060. */
  64061. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  64062. /**
  64063. * Search for a specific control in children
  64064. * @param control defines the control to look for
  64065. * @returns true if the control is in child list
  64066. */
  64067. containsControl(control: Control): boolean;
  64068. /**
  64069. * Adds a new control to the current container
  64070. * @param control defines the control to add
  64071. * @returns the current container
  64072. */
  64073. addControl(control: BABYLON.Nullable<Control>): Container;
  64074. /**
  64075. * Removes all controls from the current container
  64076. * @returns the current container
  64077. */
  64078. clearControls(): Container;
  64079. /**
  64080. * Removes a control from the current container
  64081. * @param control defines the control to remove
  64082. * @returns the current container
  64083. */
  64084. removeControl(control: Control): Container;
  64085. /** @hidden */
  64086. _reOrderControl(control: Control): void;
  64087. /** @hidden */
  64088. _offsetLeft(offset: number): void;
  64089. /** @hidden */
  64090. _offsetTop(offset: number): void;
  64091. /** @hidden */
  64092. _markAllAsDirty(): void;
  64093. /** @hidden */
  64094. protected _localDraw(context: CanvasRenderingContext2D): void;
  64095. /** @hidden */
  64096. _link(host: AdvancedDynamicTexture): void;
  64097. /** @hidden */
  64098. protected _beforeLayout(): void;
  64099. /** @hidden */
  64100. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64101. /** @hidden */
  64102. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64103. protected _postMeasure(): void;
  64104. /** @hidden */
  64105. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  64106. /** @hidden */
  64107. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64108. /** @hidden */
  64109. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64110. /** @hidden */
  64111. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64112. /** Releases associated resources */
  64113. dispose(): void;
  64114. }
  64115. }
  64116. declare module BABYLON.GUI {
  64117. /** Class used to create rectangle container */
  64118. export class Rectangle extends Container {
  64119. name?: string | undefined;
  64120. private _thickness;
  64121. private _cornerRadius;
  64122. /** Gets or sets border thickness */
  64123. thickness: number;
  64124. /** Gets or sets the corner radius angle */
  64125. cornerRadius: number;
  64126. /**
  64127. * Creates a new Rectangle
  64128. * @param name defines the control name
  64129. */
  64130. constructor(name?: string | undefined);
  64131. protected _getTypeName(): string;
  64132. protected _localDraw(context: CanvasRenderingContext2D): void;
  64133. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64134. private _drawRoundedRect;
  64135. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64136. }
  64137. }
  64138. declare module BABYLON.GUI {
  64139. /**
  64140. * Enum that determines the text-wrapping mode to use.
  64141. */
  64142. export enum TextWrapping {
  64143. /**
  64144. * Clip the text when it's larger than Control.width; this is the default mode.
  64145. */
  64146. Clip = 0,
  64147. /**
  64148. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  64149. */
  64150. WordWrap = 1,
  64151. /**
  64152. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  64153. */
  64154. Ellipsis = 2
  64155. }
  64156. /**
  64157. * Class used to create text block control
  64158. */
  64159. export class TextBlock extends Control {
  64160. /**
  64161. * Defines the name of the control
  64162. */
  64163. name?: string | undefined;
  64164. private _text;
  64165. private _textWrapping;
  64166. private _textHorizontalAlignment;
  64167. private _textVerticalAlignment;
  64168. private _lines;
  64169. private _resizeToFit;
  64170. private _lineSpacing;
  64171. private _outlineWidth;
  64172. private _outlineColor;
  64173. /**
  64174. * An event triggered after the text is changed
  64175. */
  64176. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  64177. /**
  64178. * An event triggered after the text was broken up into lines
  64179. */
  64180. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  64181. /**
  64182. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  64183. */
  64184. readonly lines: any[];
  64185. /**
  64186. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64187. */
  64188. /**
  64189. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64190. */
  64191. resizeToFit: boolean;
  64192. /**
  64193. * Gets or sets a boolean indicating if text must be wrapped
  64194. */
  64195. /**
  64196. * Gets or sets a boolean indicating if text must be wrapped
  64197. */
  64198. textWrapping: TextWrapping | boolean;
  64199. /**
  64200. * Gets or sets text to display
  64201. */
  64202. /**
  64203. * Gets or sets text to display
  64204. */
  64205. text: string;
  64206. /**
  64207. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64208. */
  64209. /**
  64210. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64211. */
  64212. textHorizontalAlignment: number;
  64213. /**
  64214. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64215. */
  64216. /**
  64217. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64218. */
  64219. textVerticalAlignment: number;
  64220. /**
  64221. * Gets or sets line spacing value
  64222. */
  64223. /**
  64224. * Gets or sets line spacing value
  64225. */
  64226. lineSpacing: string | number;
  64227. /**
  64228. * Gets or sets outlineWidth of the text to display
  64229. */
  64230. /**
  64231. * Gets or sets outlineWidth of the text to display
  64232. */
  64233. outlineWidth: number;
  64234. /**
  64235. * Gets or sets outlineColor of the text to display
  64236. */
  64237. /**
  64238. * Gets or sets outlineColor of the text to display
  64239. */
  64240. outlineColor: string;
  64241. /**
  64242. * Creates a new TextBlock object
  64243. * @param name defines the name of the control
  64244. * @param text defines the text to display (emptry string by default)
  64245. */
  64246. constructor(
  64247. /**
  64248. * Defines the name of the control
  64249. */
  64250. name?: string | undefined, text?: string);
  64251. protected _getTypeName(): string;
  64252. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64253. private _drawText;
  64254. /** @hidden */
  64255. _draw(context: CanvasRenderingContext2D): void;
  64256. protected _applyStates(context: CanvasRenderingContext2D): void;
  64257. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  64258. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  64259. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  64260. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  64261. protected _renderLines(context: CanvasRenderingContext2D): void;
  64262. /**
  64263. * Given a width constraint applied on the text block, find the expected height
  64264. * @returns expected height
  64265. */
  64266. computeExpectedHeight(): number;
  64267. dispose(): void;
  64268. }
  64269. }
  64270. declare module BABYLON.GUI {
  64271. /**
  64272. * Class used to create 2D images
  64273. */
  64274. export class Image extends Control {
  64275. name?: string | undefined;
  64276. private static _WorkingCanvas;
  64277. private _domImage;
  64278. private _imageWidth;
  64279. private _imageHeight;
  64280. private _loaded;
  64281. private _stretch;
  64282. private _source;
  64283. private _autoScale;
  64284. private _sourceLeft;
  64285. private _sourceTop;
  64286. private _sourceWidth;
  64287. private _sourceHeight;
  64288. private _cellWidth;
  64289. private _cellHeight;
  64290. private _cellId;
  64291. private _populateNinePatchSlicesFromImage;
  64292. private _sliceLeft;
  64293. private _sliceRight;
  64294. private _sliceTop;
  64295. private _sliceBottom;
  64296. private _detectPointerOnOpaqueOnly;
  64297. /**
  64298. * BABYLON.Observable notified when the content is loaded
  64299. */
  64300. onImageLoadedObservable: BABYLON.Observable<Image>;
  64301. /**
  64302. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  64303. */
  64304. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  64305. /**
  64306. * Gets a boolean indicating that the content is loaded
  64307. */
  64308. readonly isLoaded: boolean;
  64309. /**
  64310. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  64311. */
  64312. populateNinePatchSlicesFromImage: boolean;
  64313. /**
  64314. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  64315. * Beware using this as this will comsume more memory as the image has to be stored twice
  64316. */
  64317. detectPointerOnOpaqueOnly: boolean;
  64318. /**
  64319. * Gets or sets the left value for slicing (9-patch)
  64320. */
  64321. sliceLeft: number;
  64322. /**
  64323. * Gets or sets the right value for slicing (9-patch)
  64324. */
  64325. sliceRight: number;
  64326. /**
  64327. * Gets or sets the top value for slicing (9-patch)
  64328. */
  64329. sliceTop: number;
  64330. /**
  64331. * Gets or sets the bottom value for slicing (9-patch)
  64332. */
  64333. sliceBottom: number;
  64334. /**
  64335. * Gets or sets the left coordinate in the source image
  64336. */
  64337. sourceLeft: number;
  64338. /**
  64339. * Gets or sets the top coordinate in the source image
  64340. */
  64341. sourceTop: number;
  64342. /**
  64343. * Gets or sets the width to capture in the source image
  64344. */
  64345. sourceWidth: number;
  64346. /**
  64347. * Gets or sets the height to capture in the source image
  64348. */
  64349. sourceHeight: number;
  64350. /**
  64351. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  64352. * @see http://doc.babylonjs.com/how_to/gui#image
  64353. */
  64354. autoScale: boolean;
  64355. /** Gets or sets the streching mode used by the image */
  64356. stretch: number;
  64357. /**
  64358. * Gets or sets the internal DOM image used to render the control
  64359. */
  64360. domImage: HTMLImageElement;
  64361. private _onImageLoaded;
  64362. private _extractNinePatchSliceDataFromImage;
  64363. /**
  64364. * Gets or sets image source url
  64365. */
  64366. source: BABYLON.Nullable<string>;
  64367. /**
  64368. * Checks for svg document with icon id present
  64369. */
  64370. private _svgCheck;
  64371. /**
  64372. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  64373. * given external svg file and icon id
  64374. */
  64375. private _getSVGAttribs;
  64376. /**
  64377. * Gets or sets the cell width to use when animation sheet is enabled
  64378. * @see http://doc.babylonjs.com/how_to/gui#image
  64379. */
  64380. cellWidth: number;
  64381. /**
  64382. * Gets or sets the cell height to use when animation sheet is enabled
  64383. * @see http://doc.babylonjs.com/how_to/gui#image
  64384. */
  64385. cellHeight: number;
  64386. /**
  64387. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  64388. * @see http://doc.babylonjs.com/how_to/gui#image
  64389. */
  64390. cellId: number;
  64391. /**
  64392. * Creates a new Image
  64393. * @param name defines the control name
  64394. * @param url defines the image url
  64395. */
  64396. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  64397. /**
  64398. * Tests if a given coordinates belong to the current control
  64399. * @param x defines x coordinate to test
  64400. * @param y defines y coordinate to test
  64401. * @returns true if the coordinates are inside the control
  64402. */
  64403. contains(x: number, y: number): boolean;
  64404. protected _getTypeName(): string;
  64405. /** Force the control to synchronize with its content */
  64406. synchronizeSizeWithContent(): void;
  64407. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64408. private _prepareWorkingCanvasForOpaqueDetection;
  64409. private _drawImage;
  64410. _draw(context: CanvasRenderingContext2D): void;
  64411. private _renderCornerPatch;
  64412. private _renderNinePatch;
  64413. dispose(): void;
  64414. /** STRETCH_NONE */
  64415. static readonly STRETCH_NONE: number;
  64416. /** STRETCH_FILL */
  64417. static readonly STRETCH_FILL: number;
  64418. /** STRETCH_UNIFORM */
  64419. static readonly STRETCH_UNIFORM: number;
  64420. /** STRETCH_EXTEND */
  64421. static readonly STRETCH_EXTEND: number;
  64422. /** NINE_PATCH */
  64423. static readonly STRETCH_NINE_PATCH: number;
  64424. }
  64425. }
  64426. declare module BABYLON.GUI {
  64427. /**
  64428. * Class used to create 2D buttons
  64429. */
  64430. export class Button extends Rectangle {
  64431. name?: string | undefined;
  64432. /**
  64433. * Function called to generate a pointer enter animation
  64434. */
  64435. pointerEnterAnimation: () => void;
  64436. /**
  64437. * Function called to generate a pointer out animation
  64438. */
  64439. pointerOutAnimation: () => void;
  64440. /**
  64441. * Function called to generate a pointer down animation
  64442. */
  64443. pointerDownAnimation: () => void;
  64444. /**
  64445. * Function called to generate a pointer up animation
  64446. */
  64447. pointerUpAnimation: () => void;
  64448. /**
  64449. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  64450. */
  64451. delegatePickingToChildren: boolean;
  64452. private _image;
  64453. /**
  64454. * Returns the image part of the button (if any)
  64455. */
  64456. readonly image: BABYLON.Nullable<Image>;
  64457. private _textBlock;
  64458. /**
  64459. * Returns the image part of the button (if any)
  64460. */
  64461. readonly textBlock: BABYLON.Nullable<TextBlock>;
  64462. /**
  64463. * Creates a new Button
  64464. * @param name defines the name of the button
  64465. */
  64466. constructor(name?: string | undefined);
  64467. protected _getTypeName(): string;
  64468. /** @hidden */
  64469. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64470. /** @hidden */
  64471. _onPointerEnter(target: Control): boolean;
  64472. /** @hidden */
  64473. _onPointerOut(target: Control, force?: boolean): void;
  64474. /** @hidden */
  64475. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64476. /** @hidden */
  64477. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64478. /**
  64479. * Creates a new button made with an image and a text
  64480. * @param name defines the name of the button
  64481. * @param text defines the text of the button
  64482. * @param imageUrl defines the url of the image
  64483. * @returns a new Button
  64484. */
  64485. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  64486. /**
  64487. * Creates a new button made with an image
  64488. * @param name defines the name of the button
  64489. * @param imageUrl defines the url of the image
  64490. * @returns a new Button
  64491. */
  64492. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  64493. /**
  64494. * Creates a new button made with a text
  64495. * @param name defines the name of the button
  64496. * @param text defines the text of the button
  64497. * @returns a new Button
  64498. */
  64499. static CreateSimpleButton(name: string, text: string): Button;
  64500. /**
  64501. * Creates a new button made with an image and a centered text
  64502. * @param name defines the name of the button
  64503. * @param text defines the text of the button
  64504. * @param imageUrl defines the url of the image
  64505. * @returns a new Button
  64506. */
  64507. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  64508. }
  64509. }
  64510. declare module BABYLON.GUI {
  64511. /**
  64512. * Class used to create a 2D stack panel container
  64513. */
  64514. export class StackPanel extends Container {
  64515. name?: string | undefined;
  64516. private _isVertical;
  64517. private _manualWidth;
  64518. private _manualHeight;
  64519. private _doNotTrackManualChanges;
  64520. /**
  64521. * Gets or sets a boolean indicating that layou warnings should be ignored
  64522. */
  64523. ignoreLayoutWarnings: boolean;
  64524. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  64525. isVertical: boolean;
  64526. /**
  64527. * Gets or sets panel width.
  64528. * This value should not be set when in horizontal mode as it will be computed automatically
  64529. */
  64530. width: string | number;
  64531. /**
  64532. * Gets or sets panel height.
  64533. * This value should not be set when in vertical mode as it will be computed automatically
  64534. */
  64535. height: string | number;
  64536. /**
  64537. * Creates a new StackPanel
  64538. * @param name defines control name
  64539. */
  64540. constructor(name?: string | undefined);
  64541. protected _getTypeName(): string;
  64542. /** @hidden */
  64543. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64544. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64545. protected _postMeasure(): void;
  64546. }
  64547. }
  64548. declare module BABYLON.GUI {
  64549. /**
  64550. * Class used to represent a 2D checkbox
  64551. */
  64552. export class Checkbox extends Control {
  64553. name?: string | undefined;
  64554. private _isChecked;
  64555. private _background;
  64556. private _checkSizeRatio;
  64557. private _thickness;
  64558. /** Gets or sets border thickness */
  64559. thickness: number;
  64560. /**
  64561. * BABYLON.Observable raised when isChecked property changes
  64562. */
  64563. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  64564. /** Gets or sets a value indicating the ratio between overall size and check size */
  64565. checkSizeRatio: number;
  64566. /** Gets or sets background color */
  64567. background: string;
  64568. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  64569. isChecked: boolean;
  64570. /**
  64571. * Creates a new CheckBox
  64572. * @param name defines the control name
  64573. */
  64574. constructor(name?: string | undefined);
  64575. protected _getTypeName(): string;
  64576. /** @hidden */
  64577. _draw(context: CanvasRenderingContext2D): void;
  64578. /** @hidden */
  64579. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64580. /**
  64581. * Utility function to easily create a checkbox with a header
  64582. * @param title defines the label to use for the header
  64583. * @param onValueChanged defines the callback to call when value changes
  64584. * @returns a StackPanel containing the checkbox and a textBlock
  64585. */
  64586. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  64587. }
  64588. }
  64589. declare module BABYLON.GUI {
  64590. /**
  64591. * Class used to store key control properties
  64592. */
  64593. export class KeyPropertySet {
  64594. /** Width */
  64595. width?: string;
  64596. /** Height */
  64597. height?: string;
  64598. /** Left padding */
  64599. paddingLeft?: string;
  64600. /** Right padding */
  64601. paddingRight?: string;
  64602. /** Top padding */
  64603. paddingTop?: string;
  64604. /** Bottom padding */
  64605. paddingBottom?: string;
  64606. /** Foreground color */
  64607. color?: string;
  64608. /** Background color */
  64609. background?: string;
  64610. }
  64611. /**
  64612. * Class used to create virtual keyboard
  64613. */
  64614. export class VirtualKeyboard extends StackPanel {
  64615. /** BABYLON.Observable raised when a key is pressed */
  64616. onKeyPressObservable: BABYLON.Observable<string>;
  64617. /** Gets or sets default key button width */
  64618. defaultButtonWidth: string;
  64619. /** Gets or sets default key button height */
  64620. defaultButtonHeight: string;
  64621. /** Gets or sets default key button left padding */
  64622. defaultButtonPaddingLeft: string;
  64623. /** Gets or sets default key button right padding */
  64624. defaultButtonPaddingRight: string;
  64625. /** Gets or sets default key button top padding */
  64626. defaultButtonPaddingTop: string;
  64627. /** Gets or sets default key button bottom padding */
  64628. defaultButtonPaddingBottom: string;
  64629. /** Gets or sets default key button foreground color */
  64630. defaultButtonColor: string;
  64631. /** Gets or sets default key button background color */
  64632. defaultButtonBackground: string;
  64633. /** Gets or sets shift button foreground color */
  64634. shiftButtonColor: string;
  64635. /** Gets or sets shift button thickness*/
  64636. selectedShiftThickness: number;
  64637. /** Gets shift key state */
  64638. shiftState: number;
  64639. protected _getTypeName(): string;
  64640. private _createKey;
  64641. /**
  64642. * Adds a new row of keys
  64643. * @param keys defines the list of keys to add
  64644. * @param propertySets defines the associated property sets
  64645. */
  64646. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  64647. /**
  64648. * Set the shift key to a specific state
  64649. * @param shiftState defines the new shift state
  64650. */
  64651. applyShiftState(shiftState: number): void;
  64652. private _currentlyConnectedInputText;
  64653. private _connectedInputTexts;
  64654. private _onKeyPressObserver;
  64655. /** Gets the input text control currently attached to the keyboard */
  64656. readonly connectedInputText: BABYLON.Nullable<InputText>;
  64657. /**
  64658. * Connects the keyboard with an input text control
  64659. *
  64660. * @param input defines the target control
  64661. */
  64662. connect(input: InputText): void;
  64663. /**
  64664. * Disconnects the keyboard from connected InputText controls
  64665. *
  64666. * @param input optionally defines a target control, otherwise all are disconnected
  64667. */
  64668. disconnect(input?: InputText): void;
  64669. private _removeConnectedInputObservables;
  64670. /**
  64671. * Release all resources
  64672. */
  64673. dispose(): void;
  64674. /**
  64675. * Creates a new keyboard using a default layout
  64676. *
  64677. * @param name defines control name
  64678. * @returns a new VirtualKeyboard
  64679. */
  64680. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  64681. }
  64682. }
  64683. declare module BABYLON.GUI {
  64684. /**
  64685. * Class used to create input text control
  64686. */
  64687. export class InputText extends Control implements IFocusableControl {
  64688. name?: string | undefined;
  64689. private _text;
  64690. private _placeholderText;
  64691. private _background;
  64692. private _focusedBackground;
  64693. private _focusedColor;
  64694. private _placeholderColor;
  64695. private _thickness;
  64696. private _margin;
  64697. private _autoStretchWidth;
  64698. private _maxWidth;
  64699. private _isFocused;
  64700. private _blinkTimeout;
  64701. private _blinkIsEven;
  64702. private _cursorOffset;
  64703. private _scrollLeft;
  64704. private _textWidth;
  64705. private _clickedCoordinate;
  64706. private _deadKey;
  64707. private _addKey;
  64708. private _currentKey;
  64709. private _isTextHighlightOn;
  64710. private _textHighlightColor;
  64711. private _highligherOpacity;
  64712. private _highlightedText;
  64713. private _startHighlightIndex;
  64714. private _endHighlightIndex;
  64715. private _cursorIndex;
  64716. private _onFocusSelectAll;
  64717. private _isPointerDown;
  64718. private _onClipboardObserver;
  64719. private _onPointerDblTapObserver;
  64720. /** @hidden */
  64721. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  64722. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  64723. promptMessage: string;
  64724. /** Force disable prompt on mobile device */
  64725. disableMobilePrompt: boolean;
  64726. /** BABYLON.Observable raised when the text changes */
  64727. onTextChangedObservable: BABYLON.Observable<InputText>;
  64728. /** BABYLON.Observable raised just before an entered character is to be added */
  64729. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  64730. /** BABYLON.Observable raised when the control gets the focus */
  64731. onFocusObservable: BABYLON.Observable<InputText>;
  64732. /** BABYLON.Observable raised when the control loses the focus */
  64733. onBlurObservable: BABYLON.Observable<InputText>;
  64734. /**Observable raised when the text is highlighted */
  64735. onTextHighlightObservable: BABYLON.Observable<InputText>;
  64736. /**Observable raised when copy event is triggered */
  64737. onTextCopyObservable: BABYLON.Observable<InputText>;
  64738. /** BABYLON.Observable raised when cut event is triggered */
  64739. onTextCutObservable: BABYLON.Observable<InputText>;
  64740. /** BABYLON.Observable raised when paste event is triggered */
  64741. onTextPasteObservable: BABYLON.Observable<InputText>;
  64742. /** BABYLON.Observable raised when a key event was processed */
  64743. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  64744. /** Gets or sets the maximum width allowed by the control */
  64745. maxWidth: string | number;
  64746. /** Gets the maximum width allowed by the control in pixels */
  64747. readonly maxWidthInPixels: number;
  64748. /** Gets or sets the text highlighter transparency; default: 0.4 */
  64749. highligherOpacity: number;
  64750. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  64751. onFocusSelectAll: boolean;
  64752. /** Gets or sets the text hightlight color */
  64753. textHighlightColor: string;
  64754. /** Gets or sets control margin */
  64755. margin: string;
  64756. /** Gets control margin in pixels */
  64757. readonly marginInPixels: number;
  64758. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  64759. autoStretchWidth: boolean;
  64760. /** Gets or sets border thickness */
  64761. thickness: number;
  64762. /** Gets or sets the background color when focused */
  64763. focusedBackground: string;
  64764. /** Gets or sets the background color when focused */
  64765. focusedColor: string;
  64766. /** Gets or sets the background color */
  64767. background: string;
  64768. /** Gets or sets the placeholder color */
  64769. placeholderColor: string;
  64770. /** Gets or sets the text displayed when the control is empty */
  64771. placeholderText: string;
  64772. /** Gets or sets the dead key flag */
  64773. deadKey: boolean;
  64774. /** Gets or sets the highlight text */
  64775. highlightedText: string;
  64776. /** Gets or sets if the current key should be added */
  64777. addKey: boolean;
  64778. /** Gets or sets the value of the current key being entered */
  64779. currentKey: string;
  64780. /** Gets or sets the text displayed in the control */
  64781. text: string;
  64782. /** Gets or sets control width */
  64783. width: string | number;
  64784. /**
  64785. * Creates a new InputText
  64786. * @param name defines the control name
  64787. * @param text defines the text of the control
  64788. */
  64789. constructor(name?: string | undefined, text?: string);
  64790. /** @hidden */
  64791. onBlur(): void;
  64792. /** @hidden */
  64793. onFocus(): void;
  64794. protected _getTypeName(): string;
  64795. /**
  64796. * Function called to get the list of controls that should not steal the focus from this control
  64797. * @returns an array of controls
  64798. */
  64799. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  64800. /** @hidden */
  64801. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  64802. /** @hidden */
  64803. private _updateValueFromCursorIndex;
  64804. /** @hidden */
  64805. private _processDblClick;
  64806. /** @hidden */
  64807. private _selectAllText;
  64808. /**
  64809. * Handles the keyboard event
  64810. * @param evt Defines the KeyboardEvent
  64811. */
  64812. processKeyboard(evt: KeyboardEvent): void;
  64813. /** @hidden */
  64814. private _onCopyText;
  64815. /** @hidden */
  64816. private _onCutText;
  64817. /** @hidden */
  64818. private _onPasteText;
  64819. _draw(context: CanvasRenderingContext2D): void;
  64820. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64821. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64822. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64823. protected _beforeRenderText(text: string): string;
  64824. dispose(): void;
  64825. }
  64826. }
  64827. declare module BABYLON.GUI {
  64828. /**
  64829. * Class used to create a 2D grid container
  64830. */
  64831. export class Grid extends Container {
  64832. name?: string | undefined;
  64833. private _rowDefinitions;
  64834. private _columnDefinitions;
  64835. private _cells;
  64836. private _childControls;
  64837. /**
  64838. * Gets the number of columns
  64839. */
  64840. readonly columnCount: number;
  64841. /**
  64842. * Gets the number of rows
  64843. */
  64844. readonly rowCount: number;
  64845. /** Gets the list of children */
  64846. readonly children: Control[];
  64847. /** Gets the list of cells (e.g. the containers) */
  64848. readonly cells: {
  64849. [key: string]: Container;
  64850. };
  64851. /**
  64852. * Gets the definition of a specific row
  64853. * @param index defines the index of the row
  64854. * @returns the row definition
  64855. */
  64856. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64857. /**
  64858. * Gets the definition of a specific column
  64859. * @param index defines the index of the column
  64860. * @returns the column definition
  64861. */
  64862. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64863. /**
  64864. * Adds a new row to the grid
  64865. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64866. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  64867. * @returns the current grid
  64868. */
  64869. addRowDefinition(height: number, isPixel?: boolean): Grid;
  64870. /**
  64871. * Adds a new column to the grid
  64872. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64873. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64874. * @returns the current grid
  64875. */
  64876. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  64877. /**
  64878. * Update a row definition
  64879. * @param index defines the index of the row to update
  64880. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64881. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  64882. * @returns the current grid
  64883. */
  64884. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  64885. /**
  64886. * Update a column definition
  64887. * @param index defines the index of the column to update
  64888. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64889. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64890. * @returns the current grid
  64891. */
  64892. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  64893. /**
  64894. * Gets the list of children stored in a specific cell
  64895. * @param row defines the row to check
  64896. * @param column defines the column to check
  64897. * @returns the list of controls
  64898. */
  64899. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  64900. /**
  64901. * Gets a string representing the child cell info (row x column)
  64902. * @param child defines the control to get info from
  64903. * @returns a string containing the child cell info (row x column)
  64904. */
  64905. getChildCellInfo(child: Control): string;
  64906. private _removeCell;
  64907. private _offsetCell;
  64908. /**
  64909. * Remove a column definition at specified index
  64910. * @param index defines the index of the column to remove
  64911. * @returns the current grid
  64912. */
  64913. removeColumnDefinition(index: number): Grid;
  64914. /**
  64915. * Remove a row definition at specified index
  64916. * @param index defines the index of the row to remove
  64917. * @returns the current grid
  64918. */
  64919. removeRowDefinition(index: number): Grid;
  64920. /**
  64921. * Adds a new control to the current grid
  64922. * @param control defines the control to add
  64923. * @param row defines the row where to add the control (0 by default)
  64924. * @param column defines the column where to add the control (0 by default)
  64925. * @returns the current grid
  64926. */
  64927. addControl(control: Control, row?: number, column?: number): Grid;
  64928. /**
  64929. * Removes a control from the current container
  64930. * @param control defines the control to remove
  64931. * @returns the current container
  64932. */
  64933. removeControl(control: Control): Container;
  64934. /**
  64935. * Creates a new Grid
  64936. * @param name defines control name
  64937. */
  64938. constructor(name?: string | undefined);
  64939. protected _getTypeName(): string;
  64940. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  64941. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64942. _flagDescendantsAsMatrixDirty(): void;
  64943. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64944. /** Releases associated resources */
  64945. dispose(): void;
  64946. }
  64947. }
  64948. declare module BABYLON.GUI {
  64949. /** Class used to create color pickers */
  64950. export class ColorPicker extends Control {
  64951. name?: string | undefined;
  64952. private static _Epsilon;
  64953. private _colorWheelCanvas;
  64954. private _value;
  64955. private _tmpColor;
  64956. private _pointerStartedOnSquare;
  64957. private _pointerStartedOnWheel;
  64958. private _squareLeft;
  64959. private _squareTop;
  64960. private _squareSize;
  64961. private _h;
  64962. private _s;
  64963. private _v;
  64964. private _lastPointerDownID;
  64965. /**
  64966. * BABYLON.Observable raised when the value changes
  64967. */
  64968. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  64969. /** Gets or sets the color of the color picker */
  64970. value: BABYLON.Color3;
  64971. /**
  64972. * Gets or sets control width
  64973. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64974. */
  64975. width: string | number;
  64976. /**
  64977. * Gets or sets control height
  64978. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64979. */
  64980. /** Gets or sets control height */
  64981. height: string | number;
  64982. /** Gets or sets control size */
  64983. size: string | number;
  64984. /**
  64985. * Creates a new ColorPicker
  64986. * @param name defines the control name
  64987. */
  64988. constructor(name?: string | undefined);
  64989. protected _getTypeName(): string;
  64990. /** @hidden */
  64991. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64992. private _updateSquareProps;
  64993. private _drawGradientSquare;
  64994. private _drawCircle;
  64995. private _createColorWheelCanvas;
  64996. /** @hidden */
  64997. _draw(context: CanvasRenderingContext2D): void;
  64998. private _pointerIsDown;
  64999. private _updateValueFromPointer;
  65000. private _isPointOnSquare;
  65001. private _isPointOnWheel;
  65002. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65003. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65004. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65005. /**
  65006. * This function expands the color picker by creating a color picker dialog with manual
  65007. * color value input and the ability to save colors into an array to be used later in
  65008. * subsequent launches of the dialogue.
  65009. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  65010. * @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.
  65011. * @returns picked color as a hex string and the saved colors array as hex strings.
  65012. */
  65013. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  65014. pickerWidth?: string;
  65015. pickerHeight?: string;
  65016. headerHeight?: string;
  65017. lastColor?: string;
  65018. swatchLimit?: number;
  65019. numSwatchesPerLine?: number;
  65020. savedColors?: Array<string>;
  65021. }): Promise<{
  65022. savedColors?: string[];
  65023. pickedColor: string;
  65024. }>;
  65025. }
  65026. }
  65027. declare module BABYLON.GUI {
  65028. /** Class used to create 2D ellipse containers */
  65029. export class Ellipse extends Container {
  65030. name?: string | undefined;
  65031. private _thickness;
  65032. /** Gets or sets border thickness */
  65033. thickness: number;
  65034. /**
  65035. * Creates a new Ellipse
  65036. * @param name defines the control name
  65037. */
  65038. constructor(name?: string | undefined);
  65039. protected _getTypeName(): string;
  65040. protected _localDraw(context: CanvasRenderingContext2D): void;
  65041. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65042. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65043. }
  65044. }
  65045. declare module BABYLON.GUI {
  65046. /**
  65047. * Class used to create a password control
  65048. */
  65049. export class InputPassword extends InputText {
  65050. protected _beforeRenderText(text: string): string;
  65051. }
  65052. }
  65053. declare module BABYLON.GUI {
  65054. /** Class used to render 2D lines */
  65055. export class Line extends Control {
  65056. name?: string | undefined;
  65057. private _lineWidth;
  65058. private _x1;
  65059. private _y1;
  65060. private _x2;
  65061. private _y2;
  65062. private _dash;
  65063. private _connectedControl;
  65064. private _connectedControlDirtyObserver;
  65065. /** Gets or sets the dash pattern */
  65066. dash: Array<number>;
  65067. /** Gets or sets the control connected with the line end */
  65068. connectedControl: Control;
  65069. /** Gets or sets start coordinates on X axis */
  65070. x1: string | number;
  65071. /** Gets or sets start coordinates on Y axis */
  65072. y1: string | number;
  65073. /** Gets or sets end coordinates on X axis */
  65074. x2: string | number;
  65075. /** Gets or sets end coordinates on Y axis */
  65076. y2: string | number;
  65077. /** Gets or sets line width */
  65078. lineWidth: number;
  65079. /** Gets or sets horizontal alignment */
  65080. horizontalAlignment: number;
  65081. /** Gets or sets vertical alignment */
  65082. verticalAlignment: number;
  65083. private readonly _effectiveX2;
  65084. private readonly _effectiveY2;
  65085. /**
  65086. * Creates a new Line
  65087. * @param name defines the control name
  65088. */
  65089. constructor(name?: string | undefined);
  65090. protected _getTypeName(): string;
  65091. _draw(context: CanvasRenderingContext2D): void;
  65092. _measure(): void;
  65093. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65094. /**
  65095. * Move one end of the line given 3D cartesian coordinates.
  65096. * @param position Targeted world position
  65097. * @param scene BABYLON.Scene
  65098. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65099. */
  65100. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  65101. /**
  65102. * Move one end of the line to a position in screen absolute space.
  65103. * @param projectedPosition Position in screen absolute space (X, Y)
  65104. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65105. */
  65106. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  65107. }
  65108. }
  65109. declare module BABYLON.GUI {
  65110. /**
  65111. * Class used to store a point for a MultiLine object.
  65112. * The point can be pure 2D coordinates, a mesh or a control
  65113. */
  65114. export class MultiLinePoint {
  65115. private _multiLine;
  65116. private _x;
  65117. private _y;
  65118. private _control;
  65119. private _mesh;
  65120. private _controlObserver;
  65121. private _meshObserver;
  65122. /** @hidden */
  65123. _point: BABYLON.Vector2;
  65124. /**
  65125. * Creates a new MultiLinePoint
  65126. * @param multiLine defines the source MultiLine object
  65127. */
  65128. constructor(multiLine: MultiLine);
  65129. /** Gets or sets x coordinate */
  65130. x: string | number;
  65131. /** Gets or sets y coordinate */
  65132. y: string | number;
  65133. /** Gets or sets the control associated with this point */
  65134. control: BABYLON.Nullable<Control>;
  65135. /** Gets or sets the mesh associated with this point */
  65136. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65137. /** Resets links */
  65138. resetLinks(): void;
  65139. /**
  65140. * Gets a translation vector
  65141. * @returns the translation vector
  65142. */
  65143. translate(): BABYLON.Vector2;
  65144. private _translatePoint;
  65145. /** Release associated resources */
  65146. dispose(): void;
  65147. }
  65148. }
  65149. declare module BABYLON.GUI {
  65150. /**
  65151. * Class used to create multi line control
  65152. */
  65153. export class MultiLine extends Control {
  65154. name?: string | undefined;
  65155. private _lineWidth;
  65156. private _dash;
  65157. private _points;
  65158. private _minX;
  65159. private _minY;
  65160. private _maxX;
  65161. private _maxY;
  65162. /**
  65163. * Creates a new MultiLine
  65164. * @param name defines the control name
  65165. */
  65166. constructor(name?: string | undefined);
  65167. /** Gets or sets dash pattern */
  65168. dash: Array<number>;
  65169. /**
  65170. * Gets point stored at specified index
  65171. * @param index defines the index to look for
  65172. * @returns the requested point if found
  65173. */
  65174. getAt(index: number): MultiLinePoint;
  65175. /** Function called when a point is updated */
  65176. onPointUpdate: () => void;
  65177. /**
  65178. * Adds new points to the point collection
  65179. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  65180. * @returns the list of created MultiLinePoint
  65181. */
  65182. add(...items: (AbstractMesh | Control | {
  65183. x: string | number;
  65184. y: string | number;
  65185. })[]): MultiLinePoint[];
  65186. /**
  65187. * Adds a new point to the point collection
  65188. * @param item defines the item (mesh, control or 2d coordiantes) to add
  65189. * @returns the created MultiLinePoint
  65190. */
  65191. push(item?: (AbstractMesh | Control | {
  65192. x: string | number;
  65193. y: string | number;
  65194. })): MultiLinePoint;
  65195. /**
  65196. * Remove a specific value or point from the active point collection
  65197. * @param value defines the value or point to remove
  65198. */
  65199. remove(value: number | MultiLinePoint): void;
  65200. /**
  65201. * Resets this object to initial state (no point)
  65202. */
  65203. reset(): void;
  65204. /**
  65205. * Resets all links
  65206. */
  65207. resetLinks(): void;
  65208. /** Gets or sets line width */
  65209. lineWidth: number;
  65210. horizontalAlignment: number;
  65211. verticalAlignment: number;
  65212. protected _getTypeName(): string;
  65213. _draw(context: CanvasRenderingContext2D): void;
  65214. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65215. _measure(): void;
  65216. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65217. dispose(): void;
  65218. }
  65219. }
  65220. declare module BABYLON.GUI {
  65221. /**
  65222. * Class used to create radio button controls
  65223. */
  65224. export class RadioButton extends Control {
  65225. name?: string | undefined;
  65226. private _isChecked;
  65227. private _background;
  65228. private _checkSizeRatio;
  65229. private _thickness;
  65230. /** Gets or sets border thickness */
  65231. thickness: number;
  65232. /** Gets or sets group name */
  65233. group: string;
  65234. /** BABYLON.Observable raised when isChecked is changed */
  65235. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65236. /** Gets or sets a value indicating the ratio between overall size and check size */
  65237. checkSizeRatio: number;
  65238. /** Gets or sets background color */
  65239. background: string;
  65240. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65241. isChecked: boolean;
  65242. /**
  65243. * Creates a new RadioButton
  65244. * @param name defines the control name
  65245. */
  65246. constructor(name?: string | undefined);
  65247. protected _getTypeName(): string;
  65248. _draw(context: CanvasRenderingContext2D): void;
  65249. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65250. /**
  65251. * Utility function to easily create a radio button with a header
  65252. * @param title defines the label to use for the header
  65253. * @param group defines the group to use for the radio button
  65254. * @param isChecked defines the initial state of the radio button
  65255. * @param onValueChanged defines the callback to call when value changes
  65256. * @returns a StackPanel containing the radio button and a textBlock
  65257. */
  65258. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  65259. }
  65260. }
  65261. declare module BABYLON.GUI {
  65262. /**
  65263. * Class used to create slider controls
  65264. */
  65265. export class BaseSlider extends Control {
  65266. name?: string | undefined;
  65267. protected _thumbWidth: ValueAndUnit;
  65268. private _minimum;
  65269. private _maximum;
  65270. private _value;
  65271. private _isVertical;
  65272. protected _barOffset: ValueAndUnit;
  65273. private _isThumbClamped;
  65274. protected _displayThumb: boolean;
  65275. private _step;
  65276. private _lastPointerDownID;
  65277. protected _effectiveBarOffset: number;
  65278. protected _renderLeft: number;
  65279. protected _renderTop: number;
  65280. protected _renderWidth: number;
  65281. protected _renderHeight: number;
  65282. protected _backgroundBoxLength: number;
  65283. protected _backgroundBoxThickness: number;
  65284. protected _effectiveThumbThickness: number;
  65285. /** BABYLON.Observable raised when the sldier value changes */
  65286. onValueChangedObservable: BABYLON.Observable<number>;
  65287. /** Gets or sets a boolean indicating if the thumb must be rendered */
  65288. displayThumb: boolean;
  65289. /** Gets or sets a step to apply to values (0 by default) */
  65290. step: number;
  65291. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  65292. barOffset: string | number;
  65293. /** Gets main bar offset in pixels*/
  65294. readonly barOffsetInPixels: number;
  65295. /** Gets or sets thumb width */
  65296. thumbWidth: string | number;
  65297. /** Gets thumb width in pixels */
  65298. readonly thumbWidthInPixels: number;
  65299. /** Gets or sets minimum value */
  65300. minimum: number;
  65301. /** Gets or sets maximum value */
  65302. maximum: number;
  65303. /** Gets or sets current value */
  65304. value: number;
  65305. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  65306. isVertical: boolean;
  65307. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  65308. isThumbClamped: boolean;
  65309. /**
  65310. * Creates a new BaseSlider
  65311. * @param name defines the control name
  65312. */
  65313. constructor(name?: string | undefined);
  65314. protected _getTypeName(): string;
  65315. protected _getThumbPosition(): number;
  65316. protected _getThumbThickness(type: string): number;
  65317. protected _prepareRenderingData(type: string): void;
  65318. private _pointerIsDown;
  65319. /** @hidden */
  65320. protected _updateValueFromPointer(x: number, y: number): void;
  65321. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65322. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65323. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65324. }
  65325. }
  65326. declare module BABYLON.GUI {
  65327. /**
  65328. * Class used to create slider controls
  65329. */
  65330. export class Slider extends BaseSlider {
  65331. name?: string | undefined;
  65332. private _background;
  65333. private _borderColor;
  65334. private _isThumbCircle;
  65335. protected _displayValueBar: boolean;
  65336. /** Gets or sets a boolean indicating if the value bar must be rendered */
  65337. displayValueBar: boolean;
  65338. /** Gets or sets border color */
  65339. borderColor: string;
  65340. /** Gets or sets background color */
  65341. background: string;
  65342. /** Gets or sets a boolean indicating if the thumb should be round or square */
  65343. isThumbCircle: boolean;
  65344. /**
  65345. * Creates a new Slider
  65346. * @param name defines the control name
  65347. */
  65348. constructor(name?: string | undefined);
  65349. protected _getTypeName(): string;
  65350. _draw(context: CanvasRenderingContext2D): void;
  65351. }
  65352. }
  65353. declare module BABYLON.GUI {
  65354. /** Class used to create a RadioGroup
  65355. * which contains groups of radio buttons
  65356. */
  65357. export class SelectorGroup {
  65358. /** name of SelectorGroup */
  65359. name: string;
  65360. private _groupPanel;
  65361. private _selectors;
  65362. private _groupHeader;
  65363. /**
  65364. * Creates a new SelectorGroup
  65365. * @param name of group, used as a group heading
  65366. */
  65367. constructor(
  65368. /** name of SelectorGroup */
  65369. name: string);
  65370. /** Gets the groupPanel of the SelectorGroup */
  65371. readonly groupPanel: StackPanel;
  65372. /** Gets the selectors array */
  65373. readonly selectors: StackPanel[];
  65374. /** Gets and sets the group header */
  65375. header: string;
  65376. /** @hidden */
  65377. private _addGroupHeader;
  65378. /** @hidden*/
  65379. _getSelector(selectorNb: number): StackPanel | undefined;
  65380. /** Removes the selector at the given position
  65381. * @param selectorNb the position of the selector within the group
  65382. */
  65383. removeSelector(selectorNb: number): void;
  65384. }
  65385. /** Class used to create a CheckboxGroup
  65386. * which contains groups of checkbox buttons
  65387. */
  65388. export class CheckboxGroup extends SelectorGroup {
  65389. /** Adds a checkbox as a control
  65390. * @param text is the label for the selector
  65391. * @param func is the function called when the Selector is checked
  65392. * @param checked is true when Selector is checked
  65393. */
  65394. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  65395. /** @hidden */
  65396. _setSelectorLabel(selectorNb: number, label: string): void;
  65397. /** @hidden */
  65398. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65399. /** @hidden */
  65400. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65401. /** @hidden */
  65402. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65403. }
  65404. /** Class used to create a RadioGroup
  65405. * which contains groups of radio buttons
  65406. */
  65407. export class RadioGroup extends SelectorGroup {
  65408. private _selectNb;
  65409. /** Adds a radio button as a control
  65410. * @param label is the label for the selector
  65411. * @param func is the function called when the Selector is checked
  65412. * @param checked is true when Selector is checked
  65413. */
  65414. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  65415. /** @hidden */
  65416. _setSelectorLabel(selectorNb: number, label: string): void;
  65417. /** @hidden */
  65418. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65419. /** @hidden */
  65420. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65421. /** @hidden */
  65422. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65423. }
  65424. /** Class used to create a SliderGroup
  65425. * which contains groups of slider buttons
  65426. */
  65427. export class SliderGroup extends SelectorGroup {
  65428. /**
  65429. * Adds a slider to the SelectorGroup
  65430. * @param label is the label for the SliderBar
  65431. * @param func is the function called when the Slider moves
  65432. * @param unit is a string describing the units used, eg degrees or metres
  65433. * @param min is the minimum value for the Slider
  65434. * @param max is the maximum value for the Slider
  65435. * @param value is the start value for the Slider between min and max
  65436. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  65437. */
  65438. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  65439. /** @hidden */
  65440. _setSelectorLabel(selectorNb: number, label: string): void;
  65441. /** @hidden */
  65442. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65443. /** @hidden */
  65444. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65445. /** @hidden */
  65446. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65447. }
  65448. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  65449. * @see http://doc.babylonjs.com/how_to/selector
  65450. */
  65451. export class SelectionPanel extends Rectangle {
  65452. /** name of SelectionPanel */
  65453. name: string;
  65454. /** an array of SelectionGroups */
  65455. groups: SelectorGroup[];
  65456. private _panel;
  65457. private _buttonColor;
  65458. private _buttonBackground;
  65459. private _headerColor;
  65460. private _barColor;
  65461. private _barHeight;
  65462. private _spacerHeight;
  65463. private _labelColor;
  65464. private _groups;
  65465. private _bars;
  65466. /**
  65467. * Creates a new SelectionPanel
  65468. * @param name of SelectionPanel
  65469. * @param groups is an array of SelectionGroups
  65470. */
  65471. constructor(
  65472. /** name of SelectionPanel */
  65473. name: string,
  65474. /** an array of SelectionGroups */
  65475. groups?: SelectorGroup[]);
  65476. protected _getTypeName(): string;
  65477. /** Gets or sets the headerColor */
  65478. headerColor: string;
  65479. private _setHeaderColor;
  65480. /** Gets or sets the button color */
  65481. buttonColor: string;
  65482. private _setbuttonColor;
  65483. /** Gets or sets the label color */
  65484. labelColor: string;
  65485. private _setLabelColor;
  65486. /** Gets or sets the button background */
  65487. buttonBackground: string;
  65488. private _setButtonBackground;
  65489. /** Gets or sets the color of separator bar */
  65490. barColor: string;
  65491. private _setBarColor;
  65492. /** Gets or sets the height of separator bar */
  65493. barHeight: string;
  65494. private _setBarHeight;
  65495. /** Gets or sets the height of spacers*/
  65496. spacerHeight: string;
  65497. private _setSpacerHeight;
  65498. /** Adds a bar between groups */
  65499. private _addSpacer;
  65500. /** Add a group to the selection panel
  65501. * @param group is the selector group to add
  65502. */
  65503. addGroup(group: SelectorGroup): void;
  65504. /** Remove the group from the given position
  65505. * @param groupNb is the position of the group in the list
  65506. */
  65507. removeGroup(groupNb: number): void;
  65508. /** Change a group header label
  65509. * @param label is the new group header label
  65510. * @param groupNb is the number of the group to relabel
  65511. * */
  65512. setHeaderName(label: string, groupNb: number): void;
  65513. /** Change selector label to the one given
  65514. * @param label is the new selector label
  65515. * @param groupNb is the number of the groupcontaining the selector
  65516. * @param selectorNb is the number of the selector within a group to relabel
  65517. * */
  65518. relabel(label: string, groupNb: number, selectorNb: number): void;
  65519. /** For a given group position remove the selector at the given position
  65520. * @param groupNb is the number of the group to remove the selector from
  65521. * @param selectorNb is the number of the selector within the group
  65522. */
  65523. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  65524. /** For a given group position of correct type add a checkbox button
  65525. * @param groupNb is the number of the group to remove the selector from
  65526. * @param label is the label for the selector
  65527. * @param func is the function called when the Selector is checked
  65528. * @param checked is true when Selector is checked
  65529. */
  65530. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  65531. /** For a given group position of correct type add a radio button
  65532. * @param groupNb is the number of the group to remove the selector from
  65533. * @param label is the label for the selector
  65534. * @param func is the function called when the Selector is checked
  65535. * @param checked is true when Selector is checked
  65536. */
  65537. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  65538. /**
  65539. * For a given slider group add a slider
  65540. * @param groupNb is the number of the group to add the slider to
  65541. * @param label is the label for the Slider
  65542. * @param func is the function called when the Slider moves
  65543. * @param unit is a string describing the units used, eg degrees or metres
  65544. * @param min is the minimum value for the Slider
  65545. * @param max is the maximum value for the Slider
  65546. * @param value is the start value for the Slider between min and max
  65547. * @param onVal is the function used to format the value displayed, eg radians to degrees
  65548. */
  65549. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  65550. }
  65551. }
  65552. declare module BABYLON.GUI {
  65553. /**
  65554. * Class used to hold a the container for ScrollViewer
  65555. * @hidden
  65556. */
  65557. export class _ScrollViewerWindow extends Container {
  65558. parentClientWidth: number;
  65559. parentClientHeight: number;
  65560. /**
  65561. * Creates a new ScrollViewerWindow
  65562. * @param name of ScrollViewerWindow
  65563. */
  65564. constructor(name?: string);
  65565. protected _getTypeName(): string;
  65566. /** @hidden */
  65567. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65568. protected _postMeasure(): void;
  65569. }
  65570. }
  65571. declare module BABYLON.GUI {
  65572. /**
  65573. * Class used to create slider controls
  65574. */
  65575. export class ScrollBar extends BaseSlider {
  65576. name?: string | undefined;
  65577. private _background;
  65578. private _borderColor;
  65579. private _thumbMeasure;
  65580. /** Gets or sets border color */
  65581. borderColor: string;
  65582. /** Gets or sets background color */
  65583. background: string;
  65584. /**
  65585. * Creates a new Slider
  65586. * @param name defines the control name
  65587. */
  65588. constructor(name?: string | undefined);
  65589. protected _getTypeName(): string;
  65590. protected _getThumbThickness(): number;
  65591. _draw(context: CanvasRenderingContext2D): void;
  65592. private _first;
  65593. private _originX;
  65594. private _originY;
  65595. /** @hidden */
  65596. protected _updateValueFromPointer(x: number, y: number): void;
  65597. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65598. }
  65599. }
  65600. declare module BABYLON.GUI {
  65601. /**
  65602. * Class used to hold a viewer window and sliders in a grid
  65603. */
  65604. export class ScrollViewer extends Rectangle {
  65605. private _grid;
  65606. private _horizontalBarSpace;
  65607. private _verticalBarSpace;
  65608. private _dragSpace;
  65609. private _horizontalBar;
  65610. private _verticalBar;
  65611. private _barColor;
  65612. private _barBackground;
  65613. private _barSize;
  65614. private _endLeft;
  65615. private _endTop;
  65616. private _window;
  65617. private _pointerIsOver;
  65618. private _wheelPrecision;
  65619. private _onPointerObserver;
  65620. private _clientWidth;
  65621. private _clientHeight;
  65622. /**
  65623. * Gets the horizontal scrollbar
  65624. */
  65625. readonly horizontalBar: ScrollBar;
  65626. /**
  65627. * Gets the vertical scrollbar
  65628. */
  65629. readonly verticalBar: ScrollBar;
  65630. /**
  65631. * Adds a new control to the current container
  65632. * @param control defines the control to add
  65633. * @returns the current container
  65634. */
  65635. addControl(control: BABYLON.Nullable<Control>): Container;
  65636. /**
  65637. * Removes a control from the current container
  65638. * @param control defines the control to remove
  65639. * @returns the current container
  65640. */
  65641. removeControl(control: Control): Container;
  65642. /** Gets the list of children */
  65643. readonly children: Control[];
  65644. _flagDescendantsAsMatrixDirty(): void;
  65645. /**
  65646. * Creates a new ScrollViewer
  65647. * @param name of ScrollViewer
  65648. */
  65649. constructor(name?: string);
  65650. /** Reset the scroll viewer window to initial size */
  65651. resetWindow(): void;
  65652. protected _getTypeName(): string;
  65653. private _buildClientSizes;
  65654. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65655. protected _postMeasure(): void;
  65656. /**
  65657. * Gets or sets the mouse wheel precision
  65658. * from 0 to 1 with a default value of 0.05
  65659. * */
  65660. wheelPrecision: number;
  65661. /** Gets or sets the bar color */
  65662. barColor: string;
  65663. /** Gets or sets the size of the bar */
  65664. barSize: number;
  65665. /** Gets or sets the bar background */
  65666. barBackground: string;
  65667. /** @hidden */
  65668. private _updateScroller;
  65669. _link(host: AdvancedDynamicTexture): void;
  65670. /** @hidden */
  65671. private _attachWheel;
  65672. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65673. /** Releases associated resources */
  65674. dispose(): void;
  65675. }
  65676. }
  65677. declare module BABYLON.GUI {
  65678. /** Class used to render a grid */
  65679. export class DisplayGrid extends Control {
  65680. name?: string | undefined;
  65681. private _cellWidth;
  65682. private _cellHeight;
  65683. private _minorLineTickness;
  65684. private _minorLineColor;
  65685. private _majorLineTickness;
  65686. private _majorLineColor;
  65687. private _majorLineFrequency;
  65688. private _background;
  65689. private _displayMajorLines;
  65690. private _displayMinorLines;
  65691. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  65692. displayMinorLines: boolean;
  65693. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  65694. displayMajorLines: boolean;
  65695. /** Gets or sets background color (Black by default) */
  65696. background: string;
  65697. /** Gets or sets the width of each cell (20 by default) */
  65698. cellWidth: number;
  65699. /** Gets or sets the height of each cell (20 by default) */
  65700. cellHeight: number;
  65701. /** Gets or sets the tickness of minor lines (1 by default) */
  65702. minorLineTickness: number;
  65703. /** Gets or sets the color of minor lines (DarkGray by default) */
  65704. minorLineColor: string;
  65705. /** Gets or sets the tickness of major lines (2 by default) */
  65706. majorLineTickness: number;
  65707. /** Gets or sets the color of major lines (White by default) */
  65708. majorLineColor: string;
  65709. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  65710. majorLineFrequency: number;
  65711. /**
  65712. * Creates a new GridDisplayRectangle
  65713. * @param name defines the control name
  65714. */
  65715. constructor(name?: string | undefined);
  65716. _draw(context: CanvasRenderingContext2D): void;
  65717. protected _getTypeName(): string;
  65718. }
  65719. }
  65720. declare module BABYLON.GUI {
  65721. /**
  65722. * Class used to create slider controls based on images
  65723. */
  65724. export class ImageBasedSlider extends BaseSlider {
  65725. name?: string | undefined;
  65726. private _backgroundImage;
  65727. private _thumbImage;
  65728. private _valueBarImage;
  65729. private _tempMeasure;
  65730. displayThumb: boolean;
  65731. /**
  65732. * Gets or sets the image used to render the background
  65733. */
  65734. backgroundImage: Image;
  65735. /**
  65736. * Gets or sets the image used to render the value bar
  65737. */
  65738. valueBarImage: Image;
  65739. /**
  65740. * Gets or sets the image used to render the thumb
  65741. */
  65742. thumbImage: Image;
  65743. /**
  65744. * Creates a new ImageBasedSlider
  65745. * @param name defines the control name
  65746. */
  65747. constructor(name?: string | undefined);
  65748. protected _getTypeName(): string;
  65749. _draw(context: CanvasRenderingContext2D): void;
  65750. }
  65751. }
  65752. declare module BABYLON.GUI {
  65753. /**
  65754. * Forcing an export so that this code will execute
  65755. * @hidden
  65756. */
  65757. const name = "Statics";
  65758. }
  65759. declare module BABYLON.GUI {
  65760. /**
  65761. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  65762. */
  65763. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  65764. /**
  65765. * Define the instrumented AdvancedDynamicTexture.
  65766. */
  65767. texture: AdvancedDynamicTexture;
  65768. private _captureRenderTime;
  65769. private _renderTime;
  65770. private _captureLayoutTime;
  65771. private _layoutTime;
  65772. private _onBeginRenderObserver;
  65773. private _onEndRenderObserver;
  65774. private _onBeginLayoutObserver;
  65775. private _onEndLayoutObserver;
  65776. /**
  65777. * Gets the perf counter used to capture render time
  65778. */
  65779. readonly renderTimeCounter: BABYLON.PerfCounter;
  65780. /**
  65781. * Gets the perf counter used to capture layout time
  65782. */
  65783. readonly layoutTimeCounter: BABYLON.PerfCounter;
  65784. /**
  65785. * Enable or disable the render time capture
  65786. */
  65787. captureRenderTime: boolean;
  65788. /**
  65789. * Enable or disable the layout time capture
  65790. */
  65791. captureLayoutTime: boolean;
  65792. /**
  65793. * Instantiates a new advanced dynamic texture instrumentation.
  65794. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  65795. * @param texture Defines the AdvancedDynamicTexture to instrument
  65796. */
  65797. constructor(
  65798. /**
  65799. * Define the instrumented AdvancedDynamicTexture.
  65800. */
  65801. texture: AdvancedDynamicTexture);
  65802. /**
  65803. * Dispose and release associated resources.
  65804. */
  65805. dispose(): void;
  65806. }
  65807. }
  65808. declare module BABYLON.GUI {
  65809. /**
  65810. * Class used to create containers for controls
  65811. */
  65812. export class Container3D extends Control3D {
  65813. private _blockLayout;
  65814. /**
  65815. * Gets the list of child controls
  65816. */
  65817. protected _children: Control3D[];
  65818. /**
  65819. * Gets the list of child controls
  65820. */
  65821. readonly children: Array<Control3D>;
  65822. /**
  65823. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  65824. * This is helpful to optimize layout operation when adding multiple children in a row
  65825. */
  65826. blockLayout: boolean;
  65827. /**
  65828. * Creates a new container
  65829. * @param name defines the container name
  65830. */
  65831. constructor(name?: string);
  65832. /**
  65833. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  65834. * @returns the current container
  65835. */
  65836. updateLayout(): Container3D;
  65837. /**
  65838. * Gets a boolean indicating if the given control is in the children of this control
  65839. * @param control defines the control to check
  65840. * @returns true if the control is in the child list
  65841. */
  65842. containsControl(control: Control3D): boolean;
  65843. /**
  65844. * Adds a control to the children of this control
  65845. * @param control defines the control to add
  65846. * @returns the current container
  65847. */
  65848. addControl(control: Control3D): Container3D;
  65849. /**
  65850. * This function will be called everytime a new control is added
  65851. */
  65852. protected _arrangeChildren(): void;
  65853. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65854. /**
  65855. * Removes a control from the children of this control
  65856. * @param control defines the control to remove
  65857. * @returns the current container
  65858. */
  65859. removeControl(control: Control3D): Container3D;
  65860. protected _getTypeName(): string;
  65861. /**
  65862. * Releases all associated resources
  65863. */
  65864. dispose(): void;
  65865. /** Control rotation will remain unchanged */
  65866. static readonly UNSET_ORIENTATION: number;
  65867. /** Control will rotate to make it look at sphere central axis */
  65868. static readonly FACEORIGIN_ORIENTATION: number;
  65869. /** Control will rotate to make it look back at sphere central axis */
  65870. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  65871. /** Control will rotate to look at z axis (0, 0, 1) */
  65872. static readonly FACEFORWARD_ORIENTATION: number;
  65873. /** Control will rotate to look at negative z axis (0, 0, -1) */
  65874. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  65875. }
  65876. }
  65877. declare module BABYLON.GUI {
  65878. /**
  65879. * Class used to manage 3D user interface
  65880. * @see http://doc.babylonjs.com/how_to/gui3d
  65881. */
  65882. export class GUI3DManager implements BABYLON.IDisposable {
  65883. private _scene;
  65884. private _sceneDisposeObserver;
  65885. private _utilityLayer;
  65886. private _rootContainer;
  65887. private _pointerObserver;
  65888. private _pointerOutObserver;
  65889. /** @hidden */
  65890. _lastPickedControl: Control3D;
  65891. /** @hidden */
  65892. _lastControlOver: {
  65893. [pointerId: number]: Control3D;
  65894. };
  65895. /** @hidden */
  65896. _lastControlDown: {
  65897. [pointerId: number]: Control3D;
  65898. };
  65899. /**
  65900. * BABYLON.Observable raised when the point picked by the pointer events changed
  65901. */
  65902. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  65903. /** @hidden */
  65904. _sharedMaterials: {
  65905. [key: string]: BABYLON.Material;
  65906. };
  65907. /** Gets the hosting scene */
  65908. readonly scene: BABYLON.Scene;
  65909. /** Gets associated utility layer */
  65910. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  65911. /**
  65912. * Creates a new GUI3DManager
  65913. * @param scene
  65914. */
  65915. constructor(scene?: BABYLON.Scene);
  65916. private _handlePointerOut;
  65917. private _doPicking;
  65918. /**
  65919. * Gets the root container
  65920. */
  65921. readonly rootContainer: Container3D;
  65922. /**
  65923. * Gets a boolean indicating if the given control is in the root child list
  65924. * @param control defines the control to check
  65925. * @returns true if the control is in the root child list
  65926. */
  65927. containsControl(control: Control3D): boolean;
  65928. /**
  65929. * Adds a control to the root child list
  65930. * @param control defines the control to add
  65931. * @returns the current manager
  65932. */
  65933. addControl(control: Control3D): GUI3DManager;
  65934. /**
  65935. * Removes a control from the root child list
  65936. * @param control defines the control to remove
  65937. * @returns the current container
  65938. */
  65939. removeControl(control: Control3D): GUI3DManager;
  65940. /**
  65941. * Releases all associated resources
  65942. */
  65943. dispose(): void;
  65944. }
  65945. }
  65946. declare module BABYLON.GUI {
  65947. /**
  65948. * Class used to transport BABYLON.Vector3 information for pointer events
  65949. */
  65950. export class Vector3WithInfo extends BABYLON.Vector3 {
  65951. /** defines the current mouse button index */
  65952. buttonIndex: number;
  65953. /**
  65954. * Creates a new Vector3WithInfo
  65955. * @param source defines the vector3 data to transport
  65956. * @param buttonIndex defines the current mouse button index
  65957. */
  65958. constructor(source: BABYLON.Vector3,
  65959. /** defines the current mouse button index */
  65960. buttonIndex?: number);
  65961. }
  65962. }
  65963. declare module BABYLON.GUI {
  65964. /**
  65965. * Class used as base class for controls
  65966. */
  65967. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  65968. /** Defines the control name */
  65969. name?: string | undefined;
  65970. /** @hidden */
  65971. _host: GUI3DManager;
  65972. private _node;
  65973. private _downCount;
  65974. private _enterCount;
  65975. private _downPointerIds;
  65976. private _isVisible;
  65977. /** Gets or sets the control position in world space */
  65978. position: BABYLON.Vector3;
  65979. /** Gets or sets the control scaling in world space */
  65980. scaling: BABYLON.Vector3;
  65981. /** Callback used to start pointer enter animation */
  65982. pointerEnterAnimation: () => void;
  65983. /** Callback used to start pointer out animation */
  65984. pointerOutAnimation: () => void;
  65985. /** Callback used to start pointer down animation */
  65986. pointerDownAnimation: () => void;
  65987. /** Callback used to start pointer up animation */
  65988. pointerUpAnimation: () => void;
  65989. /**
  65990. * An event triggered when the pointer move over the control
  65991. */
  65992. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  65993. /**
  65994. * An event triggered when the pointer move out of the control
  65995. */
  65996. onPointerOutObservable: BABYLON.Observable<Control3D>;
  65997. /**
  65998. * An event triggered when the pointer taps the control
  65999. */
  66000. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  66001. /**
  66002. * An event triggered when pointer is up
  66003. */
  66004. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  66005. /**
  66006. * An event triggered when a control is clicked on (with a mouse)
  66007. */
  66008. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  66009. /**
  66010. * An event triggered when pointer enters the control
  66011. */
  66012. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  66013. /**
  66014. * Gets or sets the parent container
  66015. */
  66016. parent: BABYLON.Nullable<Container3D>;
  66017. private _behaviors;
  66018. /**
  66019. * Gets the list of attached behaviors
  66020. * @see http://doc.babylonjs.com/features/behaviour
  66021. */
  66022. readonly behaviors: BABYLON.Behavior<Control3D>[];
  66023. /**
  66024. * Attach a behavior to the control
  66025. * @see http://doc.babylonjs.com/features/behaviour
  66026. * @param behavior defines the behavior to attach
  66027. * @returns the current control
  66028. */
  66029. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66030. /**
  66031. * Remove an attached behavior
  66032. * @see http://doc.babylonjs.com/features/behaviour
  66033. * @param behavior defines the behavior to attach
  66034. * @returns the current control
  66035. */
  66036. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66037. /**
  66038. * Gets an attached behavior by name
  66039. * @param name defines the name of the behavior to look for
  66040. * @see http://doc.babylonjs.com/features/behaviour
  66041. * @returns null if behavior was not found else the requested behavior
  66042. */
  66043. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  66044. /** Gets or sets a boolean indicating if the control is visible */
  66045. isVisible: boolean;
  66046. /**
  66047. * Creates a new control
  66048. * @param name defines the control name
  66049. */
  66050. constructor(
  66051. /** Defines the control name */
  66052. name?: string | undefined);
  66053. /**
  66054. * Gets a string representing the class name
  66055. */
  66056. readonly typeName: string;
  66057. /**
  66058. * Get the current class name of the control.
  66059. * @returns current class name
  66060. */
  66061. getClassName(): string;
  66062. protected _getTypeName(): string;
  66063. /**
  66064. * Gets the transform node used by this control
  66065. */
  66066. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  66067. /**
  66068. * Gets the mesh used to render this control
  66069. */
  66070. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66071. /**
  66072. * Link the control as child of the given node
  66073. * @param node defines the node to link to. Use null to unlink the control
  66074. * @returns the current control
  66075. */
  66076. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  66077. /** @hidden **/
  66078. _prepareNode(scene: BABYLON.Scene): void;
  66079. /**
  66080. * Node creation.
  66081. * Can be overriden by children
  66082. * @param scene defines the scene where the node must be attached
  66083. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  66084. */
  66085. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66086. /**
  66087. * Affect a material to the given mesh
  66088. * @param mesh defines the mesh which will represent the control
  66089. */
  66090. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66091. /** @hidden */
  66092. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  66093. /** @hidden */
  66094. _onPointerEnter(target: Control3D): boolean;
  66095. /** @hidden */
  66096. _onPointerOut(target: Control3D): void;
  66097. /** @hidden */
  66098. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66099. /** @hidden */
  66100. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66101. /** @hidden */
  66102. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  66103. /** @hidden */
  66104. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66105. /** @hidden */
  66106. _disposeNode(): void;
  66107. /**
  66108. * Releases all associated resources
  66109. */
  66110. dispose(): void;
  66111. }
  66112. }
  66113. declare module BABYLON.GUI {
  66114. /**
  66115. * Class used as a root to all buttons
  66116. */
  66117. export class AbstractButton3D extends Control3D {
  66118. /**
  66119. * Creates a new button
  66120. * @param name defines the control name
  66121. */
  66122. constructor(name?: string);
  66123. protected _getTypeName(): string;
  66124. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66125. }
  66126. }
  66127. declare module BABYLON.GUI {
  66128. /**
  66129. * Class used to create a button in 3D
  66130. */
  66131. export class Button3D extends AbstractButton3D {
  66132. /** @hidden */
  66133. protected _currentMaterial: BABYLON.Material;
  66134. private _facadeTexture;
  66135. private _content;
  66136. private _contentResolution;
  66137. private _contentScaleRatio;
  66138. /**
  66139. * Gets or sets the texture resolution used to render content (512 by default)
  66140. */
  66141. contentResolution: BABYLON.int;
  66142. /**
  66143. * Gets or sets the texture scale ratio used to render content (2 by default)
  66144. */
  66145. contentScaleRatio: number;
  66146. protected _disposeFacadeTexture(): void;
  66147. protected _resetContent(): void;
  66148. /**
  66149. * Creates a new button
  66150. * @param name defines the control name
  66151. */
  66152. constructor(name?: string);
  66153. /**
  66154. * Gets or sets the GUI 2D content used to display the button's facade
  66155. */
  66156. content: Control;
  66157. /**
  66158. * Apply the facade texture (created from the content property).
  66159. * This function can be overloaded by child classes
  66160. * @param facadeTexture defines the AdvancedDynamicTexture to use
  66161. */
  66162. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66163. protected _getTypeName(): string;
  66164. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66165. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66166. /**
  66167. * Releases all associated resources
  66168. */
  66169. dispose(): void;
  66170. }
  66171. }
  66172. declare module BABYLON.GUI {
  66173. /**
  66174. * Abstract class used to create a container panel deployed on the surface of a volume
  66175. */
  66176. export abstract class VolumeBasedPanel extends Container3D {
  66177. private _columns;
  66178. private _rows;
  66179. private _rowThenColum;
  66180. private _orientation;
  66181. protected _cellWidth: number;
  66182. protected _cellHeight: number;
  66183. /**
  66184. * Gets or sets the distance between elements
  66185. */
  66186. margin: number;
  66187. /**
  66188. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  66189. * | Value | Type | Description |
  66190. * | ----- | ----------------------------------- | ----------- |
  66191. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  66192. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  66193. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  66194. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  66195. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  66196. */
  66197. orientation: number;
  66198. /**
  66199. * Gets or sets the number of columns requested (10 by default).
  66200. * The panel will automatically compute the number of rows based on number of child controls.
  66201. */
  66202. columns: BABYLON.int;
  66203. /**
  66204. * Gets or sets a the number of rows requested.
  66205. * The panel will automatically compute the number of columns based on number of child controls.
  66206. */
  66207. rows: BABYLON.int;
  66208. /**
  66209. * Creates new VolumeBasedPanel
  66210. */
  66211. constructor();
  66212. protected _arrangeChildren(): void;
  66213. /** Child classes must implement this function to provide correct control positioning */
  66214. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66215. /** Child classes can implement this function to provide additional processing */
  66216. protected _finalProcessing(): void;
  66217. }
  66218. }
  66219. declare module BABYLON.GUI {
  66220. /**
  66221. * Class used to create a container panel deployed on the surface of a cylinder
  66222. */
  66223. export class CylinderPanel extends VolumeBasedPanel {
  66224. private _radius;
  66225. /**
  66226. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  66227. */
  66228. radius: BABYLON.float;
  66229. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66230. private _cylindricalMapping;
  66231. }
  66232. }
  66233. declare module BABYLON.GUI {
  66234. /** @hidden */
  66235. export var fluentVertexShader: {
  66236. name: string;
  66237. shader: string;
  66238. };
  66239. }
  66240. declare module BABYLON.GUI {
  66241. /** @hidden */
  66242. export var fluentPixelShader: {
  66243. name: string;
  66244. shader: string;
  66245. };
  66246. }
  66247. declare module BABYLON.GUI {
  66248. /** @hidden */
  66249. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  66250. INNERGLOW: boolean;
  66251. BORDER: boolean;
  66252. HOVERLIGHT: boolean;
  66253. TEXTURE: boolean;
  66254. constructor();
  66255. }
  66256. /**
  66257. * Class used to render controls with fluent desgin
  66258. */
  66259. export class FluentMaterial extends BABYLON.PushMaterial {
  66260. /**
  66261. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  66262. */
  66263. innerGlowColorIntensity: number;
  66264. /**
  66265. * Gets or sets the inner glow color (white by default)
  66266. */
  66267. innerGlowColor: BABYLON.Color3;
  66268. /**
  66269. * Gets or sets alpha value (default is 1.0)
  66270. */
  66271. alpha: number;
  66272. /**
  66273. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  66274. */
  66275. albedoColor: BABYLON.Color3;
  66276. /**
  66277. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  66278. */
  66279. renderBorders: boolean;
  66280. /**
  66281. * Gets or sets border width (default is 0.5)
  66282. */
  66283. borderWidth: number;
  66284. /**
  66285. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  66286. */
  66287. edgeSmoothingValue: number;
  66288. /**
  66289. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  66290. */
  66291. borderMinValue: number;
  66292. /**
  66293. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  66294. */
  66295. renderHoverLight: boolean;
  66296. /**
  66297. * Gets or sets the radius used to render the hover light (default is 1.0)
  66298. */
  66299. hoverRadius: number;
  66300. /**
  66301. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  66302. */
  66303. hoverColor: BABYLON.Color4;
  66304. /**
  66305. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  66306. */
  66307. hoverPosition: BABYLON.Vector3;
  66308. private _albedoTexture;
  66309. /** Gets or sets the texture to use for albedo color */
  66310. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66311. /**
  66312. * Creates a new Fluent material
  66313. * @param name defines the name of the material
  66314. * @param scene defines the hosting scene
  66315. */
  66316. constructor(name: string, scene: BABYLON.Scene);
  66317. needAlphaBlending(): boolean;
  66318. needAlphaTesting(): boolean;
  66319. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66320. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66321. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66322. getActiveTextures(): BABYLON.BaseTexture[];
  66323. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66324. dispose(forceDisposeEffect?: boolean): void;
  66325. clone(name: string): FluentMaterial;
  66326. serialize(): any;
  66327. getClassName(): string;
  66328. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  66329. }
  66330. }
  66331. declare module BABYLON.GUI {
  66332. /**
  66333. * Class used to create a holographic button in 3D
  66334. */
  66335. export class HolographicButton extends Button3D {
  66336. private _backPlate;
  66337. private _textPlate;
  66338. private _frontPlate;
  66339. private _text;
  66340. private _imageUrl;
  66341. private _shareMaterials;
  66342. private _frontMaterial;
  66343. private _backMaterial;
  66344. private _plateMaterial;
  66345. private _pickedPointObserver;
  66346. private _tooltipFade;
  66347. private _tooltipTextBlock;
  66348. private _tooltipTexture;
  66349. private _tooltipMesh;
  66350. private _tooltipHoverObserver;
  66351. private _tooltipOutObserver;
  66352. private _disposeTooltip;
  66353. /**
  66354. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  66355. */
  66356. tooltipText: BABYLON.Nullable<string>;
  66357. /**
  66358. * Gets or sets text for the button
  66359. */
  66360. text: string;
  66361. /**
  66362. * Gets or sets the image url for the button
  66363. */
  66364. imageUrl: string;
  66365. /**
  66366. * Gets the back material used by this button
  66367. */
  66368. readonly backMaterial: FluentMaterial;
  66369. /**
  66370. * Gets the front material used by this button
  66371. */
  66372. readonly frontMaterial: FluentMaterial;
  66373. /**
  66374. * Gets the plate material used by this button
  66375. */
  66376. readonly plateMaterial: BABYLON.StandardMaterial;
  66377. /**
  66378. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  66379. */
  66380. readonly shareMaterials: boolean;
  66381. /**
  66382. * Creates a new button
  66383. * @param name defines the control name
  66384. */
  66385. constructor(name?: string, shareMaterials?: boolean);
  66386. protected _getTypeName(): string;
  66387. private _rebuildContent;
  66388. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66389. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66390. private _createBackMaterial;
  66391. private _createFrontMaterial;
  66392. private _createPlateMaterial;
  66393. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  66394. /**
  66395. * Releases all associated resources
  66396. */
  66397. dispose(): void;
  66398. }
  66399. }
  66400. declare module BABYLON.GUI {
  66401. /**
  66402. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  66403. */
  66404. export class MeshButton3D extends Button3D {
  66405. /** @hidden */
  66406. protected _currentMesh: BABYLON.Mesh;
  66407. /**
  66408. * Creates a new 3D button based on a mesh
  66409. * @param mesh mesh to become a 3D button
  66410. * @param name defines the control name
  66411. */
  66412. constructor(mesh: BABYLON.Mesh, name?: string);
  66413. protected _getTypeName(): string;
  66414. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66415. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66416. }
  66417. }
  66418. declare module BABYLON.GUI {
  66419. /**
  66420. * Class used to create a container panel deployed on the surface of a plane
  66421. */
  66422. export class PlanePanel extends VolumeBasedPanel {
  66423. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66424. }
  66425. }
  66426. declare module BABYLON.GUI {
  66427. /**
  66428. * Class used to create a container panel where items get randomized planar mapping
  66429. */
  66430. export class ScatterPanel extends VolumeBasedPanel {
  66431. private _iteration;
  66432. /**
  66433. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  66434. */
  66435. iteration: BABYLON.float;
  66436. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66437. private _scatterMapping;
  66438. protected _finalProcessing(): void;
  66439. }
  66440. }
  66441. declare module BABYLON.GUI {
  66442. /**
  66443. * Class used to create a container panel deployed on the surface of a sphere
  66444. */
  66445. export class SpherePanel extends VolumeBasedPanel {
  66446. private _radius;
  66447. /**
  66448. * Gets or sets the radius of the sphere where to project controls (5 by default)
  66449. */
  66450. radius: BABYLON.float;
  66451. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66452. private _sphericalMapping;
  66453. }
  66454. }
  66455. declare module BABYLON.GUI {
  66456. /**
  66457. * Class used to create a stack panel in 3D on XY plane
  66458. */
  66459. export class StackPanel3D extends Container3D {
  66460. private _isVertical;
  66461. /**
  66462. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  66463. */
  66464. isVertical: boolean;
  66465. /**
  66466. * Gets or sets the distance between elements
  66467. */
  66468. margin: number;
  66469. /**
  66470. * Creates new StackPanel
  66471. * @param isVertical
  66472. */
  66473. constructor(isVertical?: boolean);
  66474. protected _arrangeChildren(): void;
  66475. }
  66476. }
  66477. declare module BABYLON {
  66478. /**
  66479. * Mode that determines the coordinate system to use.
  66480. */
  66481. export enum GLTFLoaderCoordinateSystemMode {
  66482. /**
  66483. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  66484. */
  66485. AUTO = 0,
  66486. /**
  66487. * Sets the useRightHandedSystem flag on the scene.
  66488. */
  66489. FORCE_RIGHT_HANDED = 1
  66490. }
  66491. /**
  66492. * Mode that determines what animations will start.
  66493. */
  66494. export enum GLTFLoaderAnimationStartMode {
  66495. /**
  66496. * No animation will start.
  66497. */
  66498. NONE = 0,
  66499. /**
  66500. * The first animation will start.
  66501. */
  66502. FIRST = 1,
  66503. /**
  66504. * All animations will start.
  66505. */
  66506. ALL = 2
  66507. }
  66508. /**
  66509. * Interface that contains the data for the glTF asset.
  66510. */
  66511. export interface IGLTFLoaderData {
  66512. /**
  66513. * Object that represents the glTF JSON.
  66514. */
  66515. json: Object;
  66516. /**
  66517. * The BIN chunk of a binary glTF.
  66518. */
  66519. bin: Nullable<ArrayBufferView>;
  66520. }
  66521. /**
  66522. * Interface for extending the loader.
  66523. */
  66524. export interface IGLTFLoaderExtension {
  66525. /**
  66526. * The name of this extension.
  66527. */
  66528. readonly name: string;
  66529. /**
  66530. * Defines whether this extension is enabled.
  66531. */
  66532. enabled: boolean;
  66533. }
  66534. /**
  66535. * Loader state.
  66536. */
  66537. export enum GLTFLoaderState {
  66538. /**
  66539. * The asset is loading.
  66540. */
  66541. LOADING = 0,
  66542. /**
  66543. * The asset is ready for rendering.
  66544. */
  66545. READY = 1,
  66546. /**
  66547. * The asset is completely loaded.
  66548. */
  66549. COMPLETE = 2
  66550. }
  66551. /** @hidden */
  66552. export interface IGLTFLoader extends IDisposable {
  66553. readonly state: Nullable<GLTFLoaderState>;
  66554. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  66555. meshes: AbstractMesh[];
  66556. particleSystems: IParticleSystem[];
  66557. skeletons: Skeleton[];
  66558. animationGroups: AnimationGroup[];
  66559. }>;
  66560. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  66561. }
  66562. /**
  66563. * File loader for loading glTF files into a scene.
  66564. */
  66565. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  66566. /** @hidden */
  66567. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  66568. /** @hidden */
  66569. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  66570. /**
  66571. * Raised when the asset has been parsed
  66572. */
  66573. onParsedObservable: Observable<IGLTFLoaderData>;
  66574. private _onParsedObserver;
  66575. /**
  66576. * Raised when the asset has been parsed
  66577. */
  66578. onParsed: (loaderData: IGLTFLoaderData) => void;
  66579. /**
  66580. * 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.
  66581. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  66582. * Defaults to true.
  66583. * @hidden
  66584. */
  66585. static IncrementalLoading: boolean;
  66586. /**
  66587. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  66588. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  66589. * @hidden
  66590. */
  66591. static HomogeneousCoordinates: boolean;
  66592. /**
  66593. * The coordinate system mode. Defaults to AUTO.
  66594. */
  66595. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  66596. /**
  66597. * The animation start mode. Defaults to FIRST.
  66598. */
  66599. animationStartMode: GLTFLoaderAnimationStartMode;
  66600. /**
  66601. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  66602. */
  66603. compileMaterials: boolean;
  66604. /**
  66605. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  66606. */
  66607. useClipPlane: boolean;
  66608. /**
  66609. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  66610. */
  66611. compileShadowGenerators: boolean;
  66612. /**
  66613. * Defines if the Alpha blended materials are only applied as coverage.
  66614. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  66615. * If true, no extra effects are applied to transparent pixels.
  66616. */
  66617. transparencyAsCoverage: boolean;
  66618. /**
  66619. * Function called before loading a url referenced by the asset.
  66620. */
  66621. preprocessUrlAsync: (url: string) => Promise<string>;
  66622. /**
  66623. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  66624. */
  66625. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  66626. private _onMeshLoadedObserver;
  66627. /**
  66628. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  66629. */
  66630. onMeshLoaded: (mesh: AbstractMesh) => void;
  66631. /**
  66632. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  66633. */
  66634. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  66635. private _onTextureLoadedObserver;
  66636. /**
  66637. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  66638. */
  66639. onTextureLoaded: (texture: BaseTexture) => void;
  66640. /**
  66641. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  66642. */
  66643. readonly onMaterialLoadedObservable: Observable<Material>;
  66644. private _onMaterialLoadedObserver;
  66645. /**
  66646. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  66647. */
  66648. onMaterialLoaded: (material: Material) => void;
  66649. /**
  66650. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  66651. */
  66652. readonly onCameraLoadedObservable: Observable<Camera>;
  66653. private _onCameraLoadedObserver;
  66654. /**
  66655. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  66656. */
  66657. onCameraLoaded: (camera: Camera) => void;
  66658. /**
  66659. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  66660. * For assets with LODs, raised when all of the LODs are complete.
  66661. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  66662. */
  66663. readonly onCompleteObservable: Observable<void>;
  66664. private _onCompleteObserver;
  66665. /**
  66666. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  66667. * For assets with LODs, raised when all of the LODs are complete.
  66668. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  66669. */
  66670. onComplete: () => void;
  66671. /**
  66672. * Observable raised when an error occurs.
  66673. */
  66674. readonly onErrorObservable: Observable<any>;
  66675. private _onErrorObserver;
  66676. /**
  66677. * Callback raised when an error occurs.
  66678. */
  66679. onError: (reason: any) => void;
  66680. /**
  66681. * Observable raised after the loader is disposed.
  66682. */
  66683. readonly onDisposeObservable: Observable<void>;
  66684. private _onDisposeObserver;
  66685. /**
  66686. * Callback raised after the loader is disposed.
  66687. */
  66688. onDispose: () => void;
  66689. /**
  66690. * Observable raised after a loader extension is created.
  66691. * Set additional options for a loader extension in this event.
  66692. */
  66693. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  66694. private _onExtensionLoadedObserver;
  66695. /**
  66696. * Callback raised after a loader extension is created.
  66697. */
  66698. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  66699. /**
  66700. * Defines if the loader logging is enabled.
  66701. */
  66702. loggingEnabled: boolean;
  66703. /**
  66704. * Defines if the loader should capture performance counters.
  66705. */
  66706. capturePerformanceCounters: boolean;
  66707. /**
  66708. * Defines if the loader should validate the asset.
  66709. */
  66710. validate: boolean;
  66711. /**
  66712. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  66713. */
  66714. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  66715. private _onValidatedObserver;
  66716. /**
  66717. * Callback raised after a loader extension is created.
  66718. */
  66719. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  66720. private _loader;
  66721. /**
  66722. * Name of the loader ("gltf")
  66723. */
  66724. name: string;
  66725. /**
  66726. * Supported file extensions of the loader (.gltf, .glb)
  66727. */
  66728. extensions: ISceneLoaderPluginExtensions;
  66729. /**
  66730. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  66731. */
  66732. dispose(): void;
  66733. /** @hidden */
  66734. _clear(): void;
  66735. /**
  66736. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  66737. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66738. * @param scene the scene the meshes should be added to
  66739. * @param data the glTF data to load
  66740. * @param rootUrl root url to load from
  66741. * @param onProgress event that fires when loading progress has occured
  66742. * @param fileName Defines the name of the file to load
  66743. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66744. */
  66745. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66746. meshes: AbstractMesh[];
  66747. particleSystems: IParticleSystem[];
  66748. skeletons: Skeleton[];
  66749. animationGroups: AnimationGroup[];
  66750. }>;
  66751. /**
  66752. * Imports all objects from the loaded glTF data and adds them to the scene
  66753. * @param scene the scene the objects should be added to
  66754. * @param data the glTF data to load
  66755. * @param rootUrl root url to load from
  66756. * @param onProgress event that fires when loading progress has occured
  66757. * @param fileName Defines the name of the file to load
  66758. * @returns a promise which completes when objects have been loaded to the scene
  66759. */
  66760. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66761. /**
  66762. * Load into an asset container.
  66763. * @param scene The scene to load into
  66764. * @param data The data to import
  66765. * @param rootUrl The root url for scene and resources
  66766. * @param onProgress The callback when the load progresses
  66767. * @param fileName Defines the name of the file to load
  66768. * @returns The loaded asset container
  66769. */
  66770. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  66771. /**
  66772. * If the data string can be loaded directly.
  66773. * @param data string contianing the file data
  66774. * @returns if the data can be loaded directly
  66775. */
  66776. canDirectLoad(data: string): boolean;
  66777. /**
  66778. * Rewrites a url by combining a root url and response url.
  66779. */
  66780. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  66781. /**
  66782. * Instantiates a glTF file loader plugin.
  66783. * @returns the created plugin
  66784. */
  66785. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  66786. /**
  66787. * The loader state or null if the loader is not active.
  66788. */
  66789. readonly loaderState: Nullable<GLTFLoaderState>;
  66790. /**
  66791. * Returns a promise that resolves when the asset is completely loaded.
  66792. * @returns a promise that resolves when the asset is completely loaded.
  66793. */
  66794. whenCompleteAsync(): Promise<void>;
  66795. private _parseAsync;
  66796. private _validateAsync;
  66797. private _getLoader;
  66798. private _unpackBinary;
  66799. private _unpackBinaryV1;
  66800. private _unpackBinaryV2;
  66801. private static _parseVersion;
  66802. private static _compareVersion;
  66803. private static _decodeBufferToText;
  66804. private static readonly _logSpaces;
  66805. private _logIndentLevel;
  66806. private _loggingEnabled;
  66807. /** @hidden */
  66808. _log: (message: string) => void;
  66809. /** @hidden */
  66810. _logOpen(message: string): void;
  66811. /** @hidden */
  66812. _logClose(): void;
  66813. private _logEnabled;
  66814. private _logDisabled;
  66815. private _capturePerformanceCounters;
  66816. /** @hidden */
  66817. _startPerformanceCounter: (counterName: string) => void;
  66818. /** @hidden */
  66819. _endPerformanceCounter: (counterName: string) => void;
  66820. private _startPerformanceCounterEnabled;
  66821. private _startPerformanceCounterDisabled;
  66822. private _endPerformanceCounterEnabled;
  66823. private _endPerformanceCounterDisabled;
  66824. }
  66825. }
  66826. declare module BABYLON.GLTF1 {
  66827. /**
  66828. * Enums
  66829. * @hidden
  66830. */
  66831. export enum EComponentType {
  66832. BYTE = 5120,
  66833. UNSIGNED_BYTE = 5121,
  66834. SHORT = 5122,
  66835. UNSIGNED_SHORT = 5123,
  66836. FLOAT = 5126
  66837. }
  66838. /** @hidden */
  66839. export enum EShaderType {
  66840. FRAGMENT = 35632,
  66841. VERTEX = 35633
  66842. }
  66843. /** @hidden */
  66844. export enum EParameterType {
  66845. BYTE = 5120,
  66846. UNSIGNED_BYTE = 5121,
  66847. SHORT = 5122,
  66848. UNSIGNED_SHORT = 5123,
  66849. INT = 5124,
  66850. UNSIGNED_INT = 5125,
  66851. FLOAT = 5126,
  66852. FLOAT_VEC2 = 35664,
  66853. FLOAT_VEC3 = 35665,
  66854. FLOAT_VEC4 = 35666,
  66855. INT_VEC2 = 35667,
  66856. INT_VEC3 = 35668,
  66857. INT_VEC4 = 35669,
  66858. BOOL = 35670,
  66859. BOOL_VEC2 = 35671,
  66860. BOOL_VEC3 = 35672,
  66861. BOOL_VEC4 = 35673,
  66862. FLOAT_MAT2 = 35674,
  66863. FLOAT_MAT3 = 35675,
  66864. FLOAT_MAT4 = 35676,
  66865. SAMPLER_2D = 35678
  66866. }
  66867. /** @hidden */
  66868. export enum ETextureWrapMode {
  66869. CLAMP_TO_EDGE = 33071,
  66870. MIRRORED_REPEAT = 33648,
  66871. REPEAT = 10497
  66872. }
  66873. /** @hidden */
  66874. export enum ETextureFilterType {
  66875. NEAREST = 9728,
  66876. LINEAR = 9728,
  66877. NEAREST_MIPMAP_NEAREST = 9984,
  66878. LINEAR_MIPMAP_NEAREST = 9985,
  66879. NEAREST_MIPMAP_LINEAR = 9986,
  66880. LINEAR_MIPMAP_LINEAR = 9987
  66881. }
  66882. /** @hidden */
  66883. export enum ETextureFormat {
  66884. ALPHA = 6406,
  66885. RGB = 6407,
  66886. RGBA = 6408,
  66887. LUMINANCE = 6409,
  66888. LUMINANCE_ALPHA = 6410
  66889. }
  66890. /** @hidden */
  66891. export enum ECullingType {
  66892. FRONT = 1028,
  66893. BACK = 1029,
  66894. FRONT_AND_BACK = 1032
  66895. }
  66896. /** @hidden */
  66897. export enum EBlendingFunction {
  66898. ZERO = 0,
  66899. ONE = 1,
  66900. SRC_COLOR = 768,
  66901. ONE_MINUS_SRC_COLOR = 769,
  66902. DST_COLOR = 774,
  66903. ONE_MINUS_DST_COLOR = 775,
  66904. SRC_ALPHA = 770,
  66905. ONE_MINUS_SRC_ALPHA = 771,
  66906. DST_ALPHA = 772,
  66907. ONE_MINUS_DST_ALPHA = 773,
  66908. CONSTANT_COLOR = 32769,
  66909. ONE_MINUS_CONSTANT_COLOR = 32770,
  66910. CONSTANT_ALPHA = 32771,
  66911. ONE_MINUS_CONSTANT_ALPHA = 32772,
  66912. SRC_ALPHA_SATURATE = 776
  66913. }
  66914. /** @hidden */
  66915. export interface IGLTFProperty {
  66916. extensions?: {
  66917. [key: string]: any;
  66918. };
  66919. extras?: Object;
  66920. }
  66921. /** @hidden */
  66922. export interface IGLTFChildRootProperty extends IGLTFProperty {
  66923. name?: string;
  66924. }
  66925. /** @hidden */
  66926. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  66927. bufferView: string;
  66928. byteOffset: number;
  66929. byteStride: number;
  66930. count: number;
  66931. type: string;
  66932. componentType: EComponentType;
  66933. max?: number[];
  66934. min?: number[];
  66935. name?: string;
  66936. }
  66937. /** @hidden */
  66938. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  66939. buffer: string;
  66940. byteOffset: number;
  66941. byteLength: number;
  66942. byteStride: number;
  66943. target?: number;
  66944. }
  66945. /** @hidden */
  66946. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  66947. uri: string;
  66948. byteLength?: number;
  66949. type?: string;
  66950. }
  66951. /** @hidden */
  66952. export interface IGLTFShader extends IGLTFChildRootProperty {
  66953. uri: string;
  66954. type: EShaderType;
  66955. }
  66956. /** @hidden */
  66957. export interface IGLTFProgram extends IGLTFChildRootProperty {
  66958. attributes: string[];
  66959. fragmentShader: string;
  66960. vertexShader: string;
  66961. }
  66962. /** @hidden */
  66963. export interface IGLTFTechniqueParameter {
  66964. type: number;
  66965. count?: number;
  66966. semantic?: string;
  66967. node?: string;
  66968. value?: number | boolean | string | Array<any>;
  66969. source?: string;
  66970. babylonValue?: any;
  66971. }
  66972. /** @hidden */
  66973. export interface IGLTFTechniqueCommonProfile {
  66974. lightingModel: string;
  66975. texcoordBindings: Object;
  66976. parameters?: Array<any>;
  66977. }
  66978. /** @hidden */
  66979. export interface IGLTFTechniqueStatesFunctions {
  66980. blendColor?: number[];
  66981. blendEquationSeparate?: number[];
  66982. blendFuncSeparate?: number[];
  66983. colorMask: boolean[];
  66984. cullFace: number[];
  66985. }
  66986. /** @hidden */
  66987. export interface IGLTFTechniqueStates {
  66988. enable: number[];
  66989. functions: IGLTFTechniqueStatesFunctions;
  66990. }
  66991. /** @hidden */
  66992. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  66993. parameters: {
  66994. [key: string]: IGLTFTechniqueParameter;
  66995. };
  66996. program: string;
  66997. attributes: {
  66998. [key: string]: string;
  66999. };
  67000. uniforms: {
  67001. [key: string]: string;
  67002. };
  67003. states: IGLTFTechniqueStates;
  67004. }
  67005. /** @hidden */
  67006. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  67007. technique?: string;
  67008. values: string[];
  67009. }
  67010. /** @hidden */
  67011. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  67012. attributes: {
  67013. [key: string]: string;
  67014. };
  67015. indices: string;
  67016. material: string;
  67017. mode?: number;
  67018. }
  67019. /** @hidden */
  67020. export interface IGLTFMesh extends IGLTFChildRootProperty {
  67021. primitives: IGLTFMeshPrimitive[];
  67022. }
  67023. /** @hidden */
  67024. export interface IGLTFImage extends IGLTFChildRootProperty {
  67025. uri: string;
  67026. }
  67027. /** @hidden */
  67028. export interface IGLTFSampler extends IGLTFChildRootProperty {
  67029. magFilter?: number;
  67030. minFilter?: number;
  67031. wrapS?: number;
  67032. wrapT?: number;
  67033. }
  67034. /** @hidden */
  67035. export interface IGLTFTexture extends IGLTFChildRootProperty {
  67036. sampler: string;
  67037. source: string;
  67038. format?: ETextureFormat;
  67039. internalFormat?: ETextureFormat;
  67040. target?: number;
  67041. type?: number;
  67042. babylonTexture?: Texture;
  67043. }
  67044. /** @hidden */
  67045. export interface IGLTFAmbienLight {
  67046. color?: number[];
  67047. }
  67048. /** @hidden */
  67049. export interface IGLTFDirectionalLight {
  67050. color?: number[];
  67051. }
  67052. /** @hidden */
  67053. export interface IGLTFPointLight {
  67054. color?: number[];
  67055. constantAttenuation?: number;
  67056. linearAttenuation?: number;
  67057. quadraticAttenuation?: number;
  67058. }
  67059. /** @hidden */
  67060. export interface IGLTFSpotLight {
  67061. color?: number[];
  67062. constantAttenuation?: number;
  67063. fallOfAngle?: number;
  67064. fallOffExponent?: number;
  67065. linearAttenuation?: number;
  67066. quadraticAttenuation?: number;
  67067. }
  67068. /** @hidden */
  67069. export interface IGLTFLight extends IGLTFChildRootProperty {
  67070. type: string;
  67071. }
  67072. /** @hidden */
  67073. export interface IGLTFCameraOrthographic {
  67074. xmag: number;
  67075. ymag: number;
  67076. zfar: number;
  67077. znear: number;
  67078. }
  67079. /** @hidden */
  67080. export interface IGLTFCameraPerspective {
  67081. aspectRatio: number;
  67082. yfov: number;
  67083. zfar: number;
  67084. znear: number;
  67085. }
  67086. /** @hidden */
  67087. export interface IGLTFCamera extends IGLTFChildRootProperty {
  67088. type: string;
  67089. }
  67090. /** @hidden */
  67091. export interface IGLTFAnimationChannelTarget {
  67092. id: string;
  67093. path: string;
  67094. }
  67095. /** @hidden */
  67096. export interface IGLTFAnimationChannel {
  67097. sampler: string;
  67098. target: IGLTFAnimationChannelTarget;
  67099. }
  67100. /** @hidden */
  67101. export interface IGLTFAnimationSampler {
  67102. input: string;
  67103. output: string;
  67104. interpolation?: string;
  67105. }
  67106. /** @hidden */
  67107. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  67108. channels?: IGLTFAnimationChannel[];
  67109. parameters?: {
  67110. [key: string]: string;
  67111. };
  67112. samplers?: {
  67113. [key: string]: IGLTFAnimationSampler;
  67114. };
  67115. }
  67116. /** @hidden */
  67117. export interface IGLTFNodeInstanceSkin {
  67118. skeletons: string[];
  67119. skin: string;
  67120. meshes: string[];
  67121. }
  67122. /** @hidden */
  67123. export interface IGLTFSkins extends IGLTFChildRootProperty {
  67124. bindShapeMatrix: number[];
  67125. inverseBindMatrices: string;
  67126. jointNames: string[];
  67127. babylonSkeleton?: Skeleton;
  67128. }
  67129. /** @hidden */
  67130. export interface IGLTFNode extends IGLTFChildRootProperty {
  67131. camera?: string;
  67132. children: string[];
  67133. skin?: string;
  67134. jointName?: string;
  67135. light?: string;
  67136. matrix: number[];
  67137. mesh?: string;
  67138. meshes?: string[];
  67139. rotation?: number[];
  67140. scale?: number[];
  67141. translation?: number[];
  67142. babylonNode?: Node;
  67143. }
  67144. /** @hidden */
  67145. export interface IGLTFScene extends IGLTFChildRootProperty {
  67146. nodes: string[];
  67147. }
  67148. /** @hidden */
  67149. export interface IGLTFRuntime {
  67150. extensions: {
  67151. [key: string]: any;
  67152. };
  67153. accessors: {
  67154. [key: string]: IGLTFAccessor;
  67155. };
  67156. buffers: {
  67157. [key: string]: IGLTFBuffer;
  67158. };
  67159. bufferViews: {
  67160. [key: string]: IGLTFBufferView;
  67161. };
  67162. meshes: {
  67163. [key: string]: IGLTFMesh;
  67164. };
  67165. lights: {
  67166. [key: string]: IGLTFLight;
  67167. };
  67168. cameras: {
  67169. [key: string]: IGLTFCamera;
  67170. };
  67171. nodes: {
  67172. [key: string]: IGLTFNode;
  67173. };
  67174. images: {
  67175. [key: string]: IGLTFImage;
  67176. };
  67177. textures: {
  67178. [key: string]: IGLTFTexture;
  67179. };
  67180. shaders: {
  67181. [key: string]: IGLTFShader;
  67182. };
  67183. programs: {
  67184. [key: string]: IGLTFProgram;
  67185. };
  67186. samplers: {
  67187. [key: string]: IGLTFSampler;
  67188. };
  67189. techniques: {
  67190. [key: string]: IGLTFTechnique;
  67191. };
  67192. materials: {
  67193. [key: string]: IGLTFMaterial;
  67194. };
  67195. animations: {
  67196. [key: string]: IGLTFAnimation;
  67197. };
  67198. skins: {
  67199. [key: string]: IGLTFSkins;
  67200. };
  67201. currentScene?: Object;
  67202. scenes: {
  67203. [key: string]: IGLTFScene;
  67204. };
  67205. extensionsUsed: string[];
  67206. extensionsRequired?: string[];
  67207. buffersCount: number;
  67208. shaderscount: number;
  67209. scene: Scene;
  67210. rootUrl: string;
  67211. loadedBufferCount: number;
  67212. loadedBufferViews: {
  67213. [name: string]: ArrayBufferView;
  67214. };
  67215. loadedShaderCount: number;
  67216. importOnlyMeshes: boolean;
  67217. importMeshesNames?: string[];
  67218. dummyNodes: Node[];
  67219. }
  67220. /** @hidden */
  67221. export interface INodeToRoot {
  67222. bone: Bone;
  67223. node: IGLTFNode;
  67224. id: string;
  67225. }
  67226. /** @hidden */
  67227. export interface IJointNode {
  67228. node: IGLTFNode;
  67229. id: string;
  67230. }
  67231. }
  67232. declare module BABYLON.GLTF1 {
  67233. /**
  67234. * Utils functions for GLTF
  67235. * @hidden
  67236. */
  67237. export class GLTFUtils {
  67238. /**
  67239. * Sets the given "parameter" matrix
  67240. * @param scene: the Scene object
  67241. * @param source: the source node where to pick the matrix
  67242. * @param parameter: the GLTF technique parameter
  67243. * @param uniformName: the name of the shader's uniform
  67244. * @param shaderMaterial: the shader material
  67245. */
  67246. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  67247. /**
  67248. * Sets the given "parameter" matrix
  67249. * @param shaderMaterial: the shader material
  67250. * @param uniform: the name of the shader's uniform
  67251. * @param value: the value of the uniform
  67252. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  67253. */
  67254. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  67255. /**
  67256. * Returns the wrap mode of the texture
  67257. * @param mode: the mode value
  67258. */
  67259. static GetWrapMode(mode: number): number;
  67260. /**
  67261. * Returns the byte stride giving an accessor
  67262. * @param accessor: the GLTF accessor objet
  67263. */
  67264. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  67265. /**
  67266. * Returns the texture filter mode giving a mode value
  67267. * @param mode: the filter mode value
  67268. */
  67269. static GetTextureFilterMode(mode: number): ETextureFilterType;
  67270. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  67271. /**
  67272. * Returns a buffer from its accessor
  67273. * @param gltfRuntime: the GLTF runtime
  67274. * @param accessor: the GLTF accessor
  67275. */
  67276. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  67277. /**
  67278. * Decodes a buffer view into a string
  67279. * @param view: the buffer view
  67280. */
  67281. static DecodeBufferToText(view: ArrayBufferView): string;
  67282. /**
  67283. * Returns the default material of gltf. Related to
  67284. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  67285. * @param scene: the Babylon.js scene
  67286. */
  67287. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  67288. private static _DefaultMaterial;
  67289. }
  67290. }
  67291. declare module BABYLON.GLTF1 {
  67292. /**
  67293. * Implementation of the base glTF spec
  67294. * @hidden
  67295. */
  67296. export class GLTFLoaderBase {
  67297. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  67298. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67299. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  67300. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67301. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  67302. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67303. }
  67304. /**
  67305. * glTF V1 Loader
  67306. * @hidden
  67307. */
  67308. export class GLTFLoader implements IGLTFLoader {
  67309. static Extensions: {
  67310. [name: string]: GLTFLoaderExtension;
  67311. };
  67312. static RegisterExtension(extension: GLTFLoaderExtension): void;
  67313. state: Nullable<GLTFLoaderState>;
  67314. dispose(): void;
  67315. private _importMeshAsync;
  67316. /**
  67317. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  67318. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67319. * @param scene the scene the meshes should be added to
  67320. * @param data gltf data containing information of the meshes in a loaded file
  67321. * @param rootUrl root url to load from
  67322. * @param onProgress event that fires when loading progress has occured
  67323. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67324. */
  67325. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  67326. meshes: AbstractMesh[];
  67327. particleSystems: IParticleSystem[];
  67328. skeletons: Skeleton[];
  67329. animationGroups: AnimationGroup[];
  67330. }>;
  67331. private _loadAsync;
  67332. /**
  67333. * Imports all objects from a loaded gltf file and adds them to the scene
  67334. * @param scene the scene the objects should be added to
  67335. * @param data gltf data containing information of the meshes in a loaded file
  67336. * @param rootUrl root url to load from
  67337. * @param onProgress event that fires when loading progress has occured
  67338. * @returns a promise which completes when objects have been loaded to the scene
  67339. */
  67340. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  67341. private _loadShadersAsync;
  67342. private _loadBuffersAsync;
  67343. private _createNodes;
  67344. }
  67345. /** @hidden */
  67346. export abstract class GLTFLoaderExtension {
  67347. private _name;
  67348. constructor(name: string);
  67349. readonly name: string;
  67350. /**
  67351. * Defines an override for loading the runtime
  67352. * Return true to stop further extensions from loading the runtime
  67353. */
  67354. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  67355. /**
  67356. * Defines an onverride for creating gltf runtime
  67357. * Return true to stop further extensions from creating the runtime
  67358. */
  67359. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  67360. /**
  67361. * Defines an override for loading buffers
  67362. * Return true to stop further extensions from loading this buffer
  67363. */
  67364. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  67365. /**
  67366. * Defines an override for loading texture buffers
  67367. * Return true to stop further extensions from loading this texture data
  67368. */
  67369. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67370. /**
  67371. * Defines an override for creating textures
  67372. * Return true to stop further extensions from loading this texture
  67373. */
  67374. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  67375. /**
  67376. * Defines an override for loading shader strings
  67377. * Return true to stop further extensions from loading this shader data
  67378. */
  67379. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67380. /**
  67381. * Defines an override for loading materials
  67382. * Return true to stop further extensions from loading this material
  67383. */
  67384. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67385. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  67386. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  67387. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67388. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67389. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  67390. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67391. private static LoadTextureBufferAsync;
  67392. private static CreateTextureAsync;
  67393. private static ApplyExtensions;
  67394. }
  67395. }
  67396. declare module BABYLON.GLTF1 {
  67397. /** @hidden */
  67398. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  67399. private _bin;
  67400. constructor();
  67401. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  67402. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67403. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67404. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67405. }
  67406. }
  67407. declare module BABYLON.GLTF1 {
  67408. /** @hidden */
  67409. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  67410. constructor();
  67411. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  67412. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67413. private _loadTexture;
  67414. }
  67415. }
  67416. declare module BABYLON.GLTF2.Loader {
  67417. /**
  67418. * Loader interface with an index field.
  67419. */
  67420. export interface IArrayItem {
  67421. /**
  67422. * The index of this item in the array.
  67423. */
  67424. index: number;
  67425. }
  67426. /**
  67427. * Loader interface with additional members.
  67428. */
  67429. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  67430. /** @hidden */
  67431. _data?: Promise<ArrayBufferView>;
  67432. /** @hidden */
  67433. _babylonVertexBuffer?: Promise<VertexBuffer>;
  67434. }
  67435. /**
  67436. * Loader interface with additional members.
  67437. */
  67438. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  67439. }
  67440. /** @hidden */
  67441. export interface _IAnimationSamplerData {
  67442. input: Float32Array;
  67443. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  67444. output: Float32Array;
  67445. }
  67446. /**
  67447. * Loader interface with additional members.
  67448. */
  67449. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  67450. /** @hidden */
  67451. _data?: Promise<_IAnimationSamplerData>;
  67452. }
  67453. /**
  67454. * Loader interface with additional members.
  67455. */
  67456. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  67457. channels: IAnimationChannel[];
  67458. samplers: IAnimationSampler[];
  67459. /** @hidden */
  67460. _babylonAnimationGroup?: AnimationGroup;
  67461. }
  67462. /**
  67463. * Loader interface with additional members.
  67464. */
  67465. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  67466. /** @hidden */
  67467. _data?: Promise<ArrayBufferView>;
  67468. }
  67469. /**
  67470. * Loader interface with additional members.
  67471. */
  67472. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  67473. /** @hidden */
  67474. _data?: Promise<ArrayBufferView>;
  67475. /** @hidden */
  67476. _babylonBuffer?: Promise<Buffer>;
  67477. }
  67478. /**
  67479. * Loader interface with additional members.
  67480. */
  67481. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  67482. }
  67483. /**
  67484. * Loader interface with additional members.
  67485. */
  67486. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  67487. /** @hidden */
  67488. _data?: Promise<ArrayBufferView>;
  67489. }
  67490. /**
  67491. * Loader interface with additional members.
  67492. */
  67493. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  67494. }
  67495. /**
  67496. * Loader interface with additional members.
  67497. */
  67498. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  67499. }
  67500. /**
  67501. * Loader interface with additional members.
  67502. */
  67503. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  67504. baseColorTexture?: ITextureInfo;
  67505. metallicRoughnessTexture?: ITextureInfo;
  67506. }
  67507. /**
  67508. * Loader interface with additional members.
  67509. */
  67510. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  67511. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  67512. normalTexture?: IMaterialNormalTextureInfo;
  67513. occlusionTexture?: IMaterialOcclusionTextureInfo;
  67514. emissiveTexture?: ITextureInfo;
  67515. /** @hidden */
  67516. _data?: {
  67517. [babylonDrawMode: number]: {
  67518. babylonMaterial: Material;
  67519. babylonMeshes: AbstractMesh[];
  67520. promise: Promise<void>;
  67521. };
  67522. };
  67523. }
  67524. /**
  67525. * Loader interface with additional members.
  67526. */
  67527. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  67528. primitives: IMeshPrimitive[];
  67529. }
  67530. /**
  67531. * Loader interface with additional members.
  67532. */
  67533. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  67534. /** @hidden */
  67535. _instanceData?: {
  67536. babylonSourceMesh: Mesh;
  67537. promise: Promise<any>;
  67538. };
  67539. }
  67540. /**
  67541. * Loader interface with additional members.
  67542. */
  67543. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  67544. /**
  67545. * The parent glTF node.
  67546. */
  67547. parent?: INode;
  67548. /** @hidden */
  67549. _babylonTransformNode?: TransformNode;
  67550. /** @hidden */
  67551. _primitiveBabylonMeshes?: AbstractMesh[];
  67552. /** @hidden */
  67553. _babylonBones?: Bone[];
  67554. /** @hidden */
  67555. _numMorphTargets?: number;
  67556. }
  67557. /** @hidden */
  67558. export interface _ISamplerData {
  67559. noMipMaps: boolean;
  67560. samplingMode: number;
  67561. wrapU: number;
  67562. wrapV: number;
  67563. }
  67564. /**
  67565. * Loader interface with additional members.
  67566. */
  67567. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  67568. /** @hidden */
  67569. _data?: _ISamplerData;
  67570. }
  67571. /**
  67572. * Loader interface with additional members.
  67573. */
  67574. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  67575. }
  67576. /**
  67577. * Loader interface with additional members.
  67578. */
  67579. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  67580. /** @hidden */
  67581. _data?: {
  67582. babylonSkeleton: Skeleton;
  67583. promise: Promise<void>;
  67584. };
  67585. }
  67586. /**
  67587. * Loader interface with additional members.
  67588. */
  67589. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  67590. }
  67591. /**
  67592. * Loader interface with additional members.
  67593. */
  67594. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  67595. }
  67596. /**
  67597. * Loader interface with additional members.
  67598. */
  67599. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  67600. accessors?: IAccessor[];
  67601. animations?: IAnimation[];
  67602. buffers?: IBuffer[];
  67603. bufferViews?: IBufferView[];
  67604. cameras?: ICamera[];
  67605. images?: IImage[];
  67606. materials?: IMaterial[];
  67607. meshes?: IMesh[];
  67608. nodes?: INode[];
  67609. samplers?: ISampler[];
  67610. scenes?: IScene[];
  67611. skins?: ISkin[];
  67612. textures?: ITexture[];
  67613. }
  67614. }
  67615. declare module BABYLON.GLTF2 {
  67616. /**
  67617. * Interface for a glTF loader extension.
  67618. */
  67619. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  67620. /**
  67621. * Called after the loader state changes to LOADING.
  67622. */
  67623. onLoading?(): void;
  67624. /**
  67625. * Called after the loader state changes to READY.
  67626. */
  67627. onReady?(): void;
  67628. /**
  67629. * Define this method to modify the default behavior when loading scenes.
  67630. * @param context The context when loading the asset
  67631. * @param scene The glTF scene property
  67632. * @returns A promise that resolves when the load is complete or null if not handled
  67633. */
  67634. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  67635. /**
  67636. * Define this method to modify the default behavior when loading nodes.
  67637. * @param context The context when loading the asset
  67638. * @param node The glTF node property
  67639. * @param assign A function called synchronously after parsing the glTF properties
  67640. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  67641. */
  67642. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67643. /**
  67644. * Define this method to modify the default behavior when loading cameras.
  67645. * @param context The context when loading the asset
  67646. * @param camera The glTF camera property
  67647. * @param assign A function called synchronously after parsing the glTF properties
  67648. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  67649. */
  67650. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  67651. /**
  67652. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  67653. * @param context The context when loading the asset
  67654. * @param primitive The glTF mesh primitive property
  67655. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  67656. */
  67657. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  67658. /**
  67659. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67660. * @param context The context when loading the asset
  67661. * @param name The mesh name when loading the asset
  67662. * @param node The glTF node when loading the asset
  67663. * @param mesh The glTF mesh when loading the asset
  67664. * @param primitive The glTF mesh primitive property
  67665. * @param assign A function called synchronously after parsing the glTF properties
  67666. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67667. */
  67668. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67669. /**
  67670. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  67671. * @param context The context when loading the asset
  67672. * @param material The glTF material property
  67673. * @param assign A function called synchronously after parsing the glTF properties
  67674. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  67675. */
  67676. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  67677. /**
  67678. * Define this method to modify the default behavior when creating materials.
  67679. * @param context The context when loading the asset
  67680. * @param material The glTF material property
  67681. * @param babylonDrawMode The draw mode for the Babylon material
  67682. * @returns The Babylon material or null if not handled
  67683. */
  67684. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  67685. /**
  67686. * Define this method to modify the default behavior when loading material properties.
  67687. * @param context The context when loading the asset
  67688. * @param material The glTF material property
  67689. * @param babylonMaterial The Babylon material
  67690. * @returns A promise that resolves when the load is complete or null if not handled
  67691. */
  67692. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67693. /**
  67694. * Define this method to modify the default behavior when loading texture infos.
  67695. * @param context The context when loading the asset
  67696. * @param textureInfo The glTF texture info property
  67697. * @param assign A function called synchronously after parsing the glTF properties
  67698. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  67699. */
  67700. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  67701. /**
  67702. * Define this method to modify the default behavior when loading animations.
  67703. * @param context The context when loading the asset
  67704. * @param animation The glTF animation property
  67705. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  67706. */
  67707. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  67708. /**
  67709. * @hidden Define this method to modify the default behavior when loading skins.
  67710. * @param context The context when loading the asset
  67711. * @param node The glTF node property
  67712. * @param skin The glTF skin property
  67713. * @returns A promise that resolves when the load is complete or null if not handled
  67714. */
  67715. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  67716. /**
  67717. * @hidden Define this method to modify the default behavior when loading uris.
  67718. * @param context The context when loading the asset
  67719. * @param property The glTF property associated with the uri
  67720. * @param uri The uri to load
  67721. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  67722. */
  67723. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  67724. }
  67725. }
  67726. declare module BABYLON.GLTF2 {
  67727. /**
  67728. * Helper class for working with arrays when loading the glTF asset
  67729. */
  67730. export class ArrayItem {
  67731. /**
  67732. * Gets an item from the given array.
  67733. * @param context The context when loading the asset
  67734. * @param array The array to get the item from
  67735. * @param index The index to the array
  67736. * @returns The array item
  67737. */
  67738. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  67739. /**
  67740. * Assign an `index` field to each item of the given array.
  67741. * @param array The array of items
  67742. */
  67743. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  67744. }
  67745. /**
  67746. * The glTF 2.0 loader
  67747. */
  67748. export class GLTFLoader implements IGLTFLoader {
  67749. /** @hidden */
  67750. _completePromises: Promise<any>[];
  67751. private _disposed;
  67752. private _parent;
  67753. private _state;
  67754. private _extensions;
  67755. private _rootUrl;
  67756. private _fileName;
  67757. private _uniqueRootUrl;
  67758. private _gltf;
  67759. private _babylonScene;
  67760. private _rootBabylonMesh;
  67761. private _defaultBabylonMaterialData;
  67762. private _progressCallback?;
  67763. private _requests;
  67764. private static readonly _DefaultSampler;
  67765. private static _ExtensionNames;
  67766. private static _ExtensionFactories;
  67767. /**
  67768. * Registers a loader extension.
  67769. * @param name The name of the loader extension.
  67770. * @param factory The factory function that creates the loader extension.
  67771. */
  67772. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  67773. /**
  67774. * Unregisters a loader extension.
  67775. * @param name The name of the loader extenion.
  67776. * @returns A boolean indicating whether the extension has been unregistered
  67777. */
  67778. static UnregisterExtension(name: string): boolean;
  67779. /**
  67780. * Gets the loader state.
  67781. */
  67782. readonly state: Nullable<GLTFLoaderState>;
  67783. /**
  67784. * The glTF object parsed from the JSON.
  67785. */
  67786. readonly gltf: IGLTF;
  67787. /**
  67788. * The Babylon scene when loading the asset.
  67789. */
  67790. readonly babylonScene: Scene;
  67791. /**
  67792. * The root Babylon mesh when loading the asset.
  67793. */
  67794. readonly rootBabylonMesh: Mesh;
  67795. /** @hidden */
  67796. constructor(parent: GLTFFileLoader);
  67797. /** @hidden */
  67798. dispose(): void;
  67799. /** @hidden */
  67800. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67801. meshes: AbstractMesh[];
  67802. particleSystems: IParticleSystem[];
  67803. skeletons: Skeleton[];
  67804. animationGroups: AnimationGroup[];
  67805. }>;
  67806. /** @hidden */
  67807. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67808. private _loadAsync;
  67809. private _loadData;
  67810. private _setupData;
  67811. private _loadExtensions;
  67812. private _checkExtensions;
  67813. private _setState;
  67814. private _createRootNode;
  67815. /**
  67816. * Loads a glTF scene.
  67817. * @param context The context when loading the asset
  67818. * @param scene The glTF scene property
  67819. * @returns A promise that resolves when the load is complete
  67820. */
  67821. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  67822. private _forEachPrimitive;
  67823. private _getMeshes;
  67824. private _getSkeletons;
  67825. private _getAnimationGroups;
  67826. private _startAnimations;
  67827. /**
  67828. * Loads a glTF node.
  67829. * @param context The context when loading the asset
  67830. * @param node The glTF node property
  67831. * @param assign A function called synchronously after parsing the glTF properties
  67832. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  67833. */
  67834. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  67835. private _loadMeshAsync;
  67836. /**
  67837. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67838. * @param context The context when loading the asset
  67839. * @param name The mesh name when loading the asset
  67840. * @param node The glTF node when loading the asset
  67841. * @param mesh The glTF mesh when loading the asset
  67842. * @param primitive The glTF mesh primitive property
  67843. * @param assign A function called synchronously after parsing the glTF properties
  67844. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67845. */
  67846. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67847. private _loadVertexDataAsync;
  67848. private _createMorphTargets;
  67849. private _loadMorphTargetsAsync;
  67850. private _loadMorphTargetVertexDataAsync;
  67851. private static _LoadTransform;
  67852. private _loadSkinAsync;
  67853. private _loadBones;
  67854. private _loadBone;
  67855. private _loadSkinInverseBindMatricesDataAsync;
  67856. private _updateBoneMatrices;
  67857. private _getNodeMatrix;
  67858. /**
  67859. * Loads a glTF camera.
  67860. * @param context The context when loading the asset
  67861. * @param camera The glTF camera property
  67862. * @param assign A function called synchronously after parsing the glTF properties
  67863. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  67864. */
  67865. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  67866. private _loadAnimationsAsync;
  67867. /**
  67868. * Loads a glTF animation.
  67869. * @param context The context when loading the asset
  67870. * @param animation The glTF animation property
  67871. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  67872. */
  67873. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  67874. /**
  67875. * @hidden Loads a glTF animation channel.
  67876. * @param context The context when loading the asset
  67877. * @param animationContext The context of the animation when loading the asset
  67878. * @param animation The glTF animation property
  67879. * @param channel The glTF animation channel property
  67880. * @param babylonAnimationGroup The babylon animation group property
  67881. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  67882. * @returns A void promise when the channel load is complete
  67883. */
  67884. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  67885. private _loadAnimationSamplerAsync;
  67886. private _loadBufferAsync;
  67887. /**
  67888. * Loads a glTF buffer view.
  67889. * @param context The context when loading the asset
  67890. * @param bufferView The glTF buffer view property
  67891. * @returns A promise that resolves with the loaded data when the load is complete
  67892. */
  67893. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  67894. private _loadAccessorAsync;
  67895. private _loadFloatAccessorAsync;
  67896. private _loadIndicesAccessorAsync;
  67897. private _loadVertexBufferViewAsync;
  67898. private _loadVertexAccessorAsync;
  67899. private _loadMaterialMetallicRoughnessPropertiesAsync;
  67900. /** @hidden */
  67901. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  67902. private _createDefaultMaterial;
  67903. /**
  67904. * Creates a Babylon material from a glTF material.
  67905. * @param context The context when loading the asset
  67906. * @param material The glTF material property
  67907. * @param babylonDrawMode The draw mode for the Babylon material
  67908. * @returns The Babylon material
  67909. */
  67910. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  67911. /**
  67912. * Loads properties from a glTF material into a Babylon material.
  67913. * @param context The context when loading the asset
  67914. * @param material The glTF material property
  67915. * @param babylonMaterial The Babylon material
  67916. * @returns A promise that resolves when the load is complete
  67917. */
  67918. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67919. /**
  67920. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  67921. * @param context The context when loading the asset
  67922. * @param material The glTF material property
  67923. * @param babylonMaterial The Babylon material
  67924. * @returns A promise that resolves when the load is complete
  67925. */
  67926. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67927. /**
  67928. * Loads the alpha properties from a glTF material into a Babylon material.
  67929. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  67930. * @param context The context when loading the asset
  67931. * @param material The glTF material property
  67932. * @param babylonMaterial The Babylon material
  67933. */
  67934. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  67935. /**
  67936. * Loads a glTF texture info.
  67937. * @param context The context when loading the asset
  67938. * @param textureInfo The glTF texture info property
  67939. * @param assign A function called synchronously after parsing the glTF properties
  67940. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  67941. */
  67942. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  67943. private _loadTextureAsync;
  67944. private _loadSampler;
  67945. /**
  67946. * Loads a glTF image.
  67947. * @param context The context when loading the asset
  67948. * @param image The glTF image property
  67949. * @returns A promise that resolves with the loaded data when the load is complete
  67950. */
  67951. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  67952. /**
  67953. * Loads a glTF uri.
  67954. * @param context The context when loading the asset
  67955. * @param property The glTF property associated with the uri
  67956. * @param uri The base64 or relative uri
  67957. * @returns A promise that resolves with the loaded data when the load is complete
  67958. */
  67959. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  67960. private _onProgress;
  67961. /**
  67962. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  67963. * @param babylonObject the Babylon object with metadata
  67964. * @param pointer the JSON pointer
  67965. */
  67966. static AddPointerMetadata(babylonObject: {
  67967. metadata: any;
  67968. }, pointer: string): void;
  67969. private static _GetTextureWrapMode;
  67970. private static _GetTextureSamplingMode;
  67971. private static _GetTypedArrayConstructor;
  67972. private static _GetTypedArray;
  67973. private static _GetNumComponents;
  67974. private static _ValidateUri;
  67975. private static _GetDrawMode;
  67976. private _compileMaterialsAsync;
  67977. private _compileShadowGeneratorsAsync;
  67978. private _forEachExtensions;
  67979. private _applyExtensions;
  67980. private _extensionsOnLoading;
  67981. private _extensionsOnReady;
  67982. private _extensionsLoadSceneAsync;
  67983. private _extensionsLoadNodeAsync;
  67984. private _extensionsLoadCameraAsync;
  67985. private _extensionsLoadVertexDataAsync;
  67986. private _extensionsLoadMeshPrimitiveAsync;
  67987. private _extensionsLoadMaterialAsync;
  67988. private _extensionsCreateMaterial;
  67989. private _extensionsLoadMaterialPropertiesAsync;
  67990. private _extensionsLoadTextureInfoAsync;
  67991. private _extensionsLoadAnimationAsync;
  67992. private _extensionsLoadSkinAsync;
  67993. private _extensionsLoadUriAsync;
  67994. /**
  67995. * Helper method called by a loader extension to load an glTF extension.
  67996. * @param context The context when loading the asset
  67997. * @param property The glTF property to load the extension from
  67998. * @param extensionName The name of the extension to load
  67999. * @param actionAsync The action to run
  68000. * @returns The promise returned by actionAsync or null if the extension does not exist
  68001. */
  68002. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68003. /**
  68004. * Helper method called by a loader extension to load a glTF extra.
  68005. * @param context The context when loading the asset
  68006. * @param property The glTF property to load the extra from
  68007. * @param extensionName The name of the extension to load
  68008. * @param actionAsync The action to run
  68009. * @returns The promise returned by actionAsync or null if the extra does not exist
  68010. */
  68011. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68012. /**
  68013. * Increments the indentation level and logs a message.
  68014. * @param message The message to log
  68015. */
  68016. logOpen(message: string): void;
  68017. /**
  68018. * Decrements the indentation level.
  68019. */
  68020. logClose(): void;
  68021. /**
  68022. * Logs a message
  68023. * @param message The message to log
  68024. */
  68025. log(message: string): void;
  68026. /**
  68027. * Starts a performance counter.
  68028. * @param counterName The name of the performance counter
  68029. */
  68030. startPerformanceCounter(counterName: string): void;
  68031. /**
  68032. * Ends a performance counter.
  68033. * @param counterName The name of the performance counter
  68034. */
  68035. endPerformanceCounter(counterName: string): void;
  68036. }
  68037. }
  68038. declare module BABYLON.GLTF2.Loader.Extensions {
  68039. /**
  68040. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  68041. */
  68042. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  68043. /** The name of this extension. */
  68044. readonly name: string;
  68045. /** Defines whether this extension is enabled. */
  68046. enabled: boolean;
  68047. private _loader;
  68048. private _lights?;
  68049. /** @hidden */
  68050. constructor(loader: GLTFLoader);
  68051. /** @hidden */
  68052. dispose(): void;
  68053. /** @hidden */
  68054. onLoading(): void;
  68055. /** @hidden */
  68056. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68057. private _loadLightAsync;
  68058. }
  68059. }
  68060. declare module BABYLON.GLTF2.Loader.Extensions {
  68061. /**
  68062. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  68063. */
  68064. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  68065. /** The name of this extension. */
  68066. readonly name: string;
  68067. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  68068. dracoCompression?: DracoCompression;
  68069. /** Defines whether this extension is enabled. */
  68070. enabled: boolean;
  68071. private _loader;
  68072. /** @hidden */
  68073. constructor(loader: GLTFLoader);
  68074. /** @hidden */
  68075. dispose(): void;
  68076. /** @hidden */
  68077. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  68078. }
  68079. }
  68080. declare module BABYLON.GLTF2.Loader.Extensions {
  68081. /**
  68082. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  68083. */
  68084. export class KHR_lights implements IGLTFLoaderExtension {
  68085. /** The name of this extension. */
  68086. readonly name: string;
  68087. /** Defines whether this extension is enabled. */
  68088. enabled: boolean;
  68089. private _loader;
  68090. private _lights?;
  68091. /** @hidden */
  68092. constructor(loader: GLTFLoader);
  68093. /** @hidden */
  68094. dispose(): void;
  68095. /** @hidden */
  68096. onLoading(): void;
  68097. /** @hidden */
  68098. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68099. }
  68100. }
  68101. declare module BABYLON.GLTF2.Loader.Extensions {
  68102. /**
  68103. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  68104. */
  68105. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  68106. /** The name of this extension. */
  68107. readonly name: string;
  68108. /** Defines whether this extension is enabled. */
  68109. enabled: boolean;
  68110. private _loader;
  68111. /** @hidden */
  68112. constructor(loader: GLTFLoader);
  68113. /** @hidden */
  68114. dispose(): void;
  68115. /** @hidden */
  68116. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68117. private _loadSpecularGlossinessPropertiesAsync;
  68118. }
  68119. }
  68120. declare module BABYLON.GLTF2.Loader.Extensions {
  68121. /**
  68122. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  68123. */
  68124. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  68125. /** The name of this extension. */
  68126. readonly name: string;
  68127. /** Defines whether this extension is enabled. */
  68128. enabled: boolean;
  68129. private _loader;
  68130. /** @hidden */
  68131. constructor(loader: GLTFLoader);
  68132. /** @hidden */
  68133. dispose(): void;
  68134. /** @hidden */
  68135. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68136. private _loadUnlitPropertiesAsync;
  68137. }
  68138. }
  68139. declare module BABYLON.GLTF2.Loader.Extensions {
  68140. /**
  68141. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  68142. */
  68143. export class KHR_texture_transform implements IGLTFLoaderExtension {
  68144. /** The name of this extension. */
  68145. readonly name: string;
  68146. /** Defines whether this extension is enabled. */
  68147. enabled: boolean;
  68148. private _loader;
  68149. /** @hidden */
  68150. constructor(loader: GLTFLoader);
  68151. /** @hidden */
  68152. dispose(): void;
  68153. /** @hidden */
  68154. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  68155. }
  68156. }
  68157. declare module BABYLON.GLTF2.Loader.Extensions {
  68158. /**
  68159. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  68160. */
  68161. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  68162. /** The name of this extension. */
  68163. readonly name: string;
  68164. /** Defines whether this extension is enabled. */
  68165. enabled: boolean;
  68166. private _loader;
  68167. private _clips;
  68168. private _emitters;
  68169. /** @hidden */
  68170. constructor(loader: GLTFLoader);
  68171. /** @hidden */
  68172. dispose(): void;
  68173. /** @hidden */
  68174. onLoading(): void;
  68175. /** @hidden */
  68176. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68177. /** @hidden */
  68178. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68179. /** @hidden */
  68180. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  68181. private _loadClipAsync;
  68182. private _loadEmitterAsync;
  68183. private _getEventAction;
  68184. private _loadAnimationEventAsync;
  68185. }
  68186. }
  68187. declare module BABYLON.GLTF2.Loader.Extensions {
  68188. /**
  68189. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  68190. */
  68191. export class MSFT_lod implements IGLTFLoaderExtension {
  68192. /** The name of this extension. */
  68193. readonly name: string;
  68194. /** Defines whether this extension is enabled. */
  68195. enabled: boolean;
  68196. /**
  68197. * Maximum number of LODs to load, starting from the lowest LOD.
  68198. */
  68199. maxLODsToLoad: number;
  68200. /**
  68201. * Observable raised when all node LODs of one level are loaded.
  68202. * The event data is the index of the loaded LOD starting from zero.
  68203. * Dispose the loader to cancel the loading of the next level of LODs.
  68204. */
  68205. onNodeLODsLoadedObservable: Observable<number>;
  68206. /**
  68207. * Observable raised when all material LODs of one level are loaded.
  68208. * The event data is the index of the loaded LOD starting from zero.
  68209. * Dispose the loader to cancel the loading of the next level of LODs.
  68210. */
  68211. onMaterialLODsLoadedObservable: Observable<number>;
  68212. private _loader;
  68213. private _nodeIndexLOD;
  68214. private _nodeSignalLODs;
  68215. private _nodePromiseLODs;
  68216. private _materialIndexLOD;
  68217. private _materialSignalLODs;
  68218. private _materialPromiseLODs;
  68219. /** @hidden */
  68220. constructor(loader: GLTFLoader);
  68221. /** @hidden */
  68222. dispose(): void;
  68223. /** @hidden */
  68224. onReady(): void;
  68225. /** @hidden */
  68226. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68227. /** @hidden */
  68228. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  68229. /** @hidden */
  68230. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  68231. /**
  68232. * Gets an array of LOD properties from lowest to highest.
  68233. */
  68234. private _getLODs;
  68235. private _disposeUnusedMaterials;
  68236. }
  68237. }
  68238. declare module BABYLON.GLTF2.Loader.Extensions {
  68239. /** @hidden */
  68240. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  68241. readonly name: string;
  68242. enabled: boolean;
  68243. private _loader;
  68244. constructor(loader: GLTFLoader);
  68245. dispose(): void;
  68246. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68247. }
  68248. }
  68249. declare module BABYLON.GLTF2.Loader.Extensions {
  68250. /** @hidden */
  68251. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  68252. readonly name: string;
  68253. enabled: boolean;
  68254. private _loader;
  68255. constructor(loader: GLTFLoader);
  68256. dispose(): void;
  68257. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68258. }
  68259. }
  68260. declare module BABYLON.GLTF2.Loader.Extensions {
  68261. /**
  68262. * Store glTF extras (if present) in BJS objects' metadata
  68263. */
  68264. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  68265. /** The name of this extension. */
  68266. readonly name: string;
  68267. /** Defines whether this extension is enabled. */
  68268. enabled: boolean;
  68269. private _loader;
  68270. private _assignExtras;
  68271. /** @hidden */
  68272. constructor(loader: GLTFLoader);
  68273. /** @hidden */
  68274. dispose(): void;
  68275. /** @hidden */
  68276. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68277. /** @hidden */
  68278. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  68279. /** @hidden */
  68280. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  68281. }
  68282. }
  68283. declare module BABYLON {
  68284. /**
  68285. * Class reading and parsing the MTL file bundled with the obj file.
  68286. */
  68287. export class MTLFileLoader {
  68288. /**
  68289. * All material loaded from the mtl will be set here
  68290. */
  68291. materials: StandardMaterial[];
  68292. /**
  68293. * This function will read the mtl file and create each material described inside
  68294. * This function could be improve by adding :
  68295. * -some component missing (Ni, Tf...)
  68296. * -including the specific options available
  68297. *
  68298. * @param scene defines the scene the material will be created in
  68299. * @param data defines the mtl data to parse
  68300. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  68301. */
  68302. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  68303. /**
  68304. * Gets the texture for the material.
  68305. *
  68306. * If the material is imported from input file,
  68307. * We sanitize the url to ensure it takes the textre from aside the material.
  68308. *
  68309. * @param rootUrl The root url to load from
  68310. * @param value The value stored in the mtl
  68311. * @return The Texture
  68312. */
  68313. private static _getTexture;
  68314. }
  68315. /**
  68316. * Options for loading OBJ/MTL files
  68317. */
  68318. type MeshLoadOptions = {
  68319. /**
  68320. * Defines if UVs are optimized by default during load.
  68321. */
  68322. OptimizeWithUV: boolean;
  68323. /**
  68324. * Defines custom scaling of UV coordinates of loaded meshes.
  68325. */
  68326. UVScaling: Vector2;
  68327. /**
  68328. * Invert model on y-axis (does a model scaling inversion)
  68329. */
  68330. InvertY: boolean;
  68331. /**
  68332. * Invert Y-Axis of referenced textures on load
  68333. */
  68334. InvertTextureY: boolean;
  68335. /**
  68336. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68337. */
  68338. ImportVertexColors: boolean;
  68339. /**
  68340. * Compute the normals for the model, even if normals are present in the file.
  68341. */
  68342. ComputeNormals: boolean;
  68343. /**
  68344. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68345. */
  68346. SkipMaterials: boolean;
  68347. /**
  68348. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68349. */
  68350. MaterialLoadingFailsSilently: boolean;
  68351. };
  68352. /**
  68353. * OBJ file type loader.
  68354. * This is a babylon scene loader plugin.
  68355. */
  68356. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  68357. /**
  68358. * Defines if UVs are optimized by default during load.
  68359. */
  68360. static OPTIMIZE_WITH_UV: boolean;
  68361. /**
  68362. * Invert model on y-axis (does a model scaling inversion)
  68363. */
  68364. static INVERT_Y: boolean;
  68365. /**
  68366. * Invert Y-Axis of referenced textures on load
  68367. */
  68368. static INVERT_TEXTURE_Y: boolean;
  68369. /**
  68370. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68371. */
  68372. static IMPORT_VERTEX_COLORS: boolean;
  68373. /**
  68374. * Compute the normals for the model, even if normals are present in the file.
  68375. */
  68376. static COMPUTE_NORMALS: boolean;
  68377. /**
  68378. * Defines custom scaling of UV coordinates of loaded meshes.
  68379. */
  68380. static UV_SCALING: Vector2;
  68381. /**
  68382. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68383. */
  68384. static SKIP_MATERIALS: boolean;
  68385. /**
  68386. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68387. *
  68388. * Defaults to true for backwards compatibility.
  68389. */
  68390. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  68391. /**
  68392. * Defines the name of the plugin.
  68393. */
  68394. name: string;
  68395. /**
  68396. * Defines the extension the plugin is able to load.
  68397. */
  68398. extensions: string;
  68399. /** @hidden */
  68400. obj: RegExp;
  68401. /** @hidden */
  68402. group: RegExp;
  68403. /** @hidden */
  68404. mtllib: RegExp;
  68405. /** @hidden */
  68406. usemtl: RegExp;
  68407. /** @hidden */
  68408. smooth: RegExp;
  68409. /** @hidden */
  68410. vertexPattern: RegExp;
  68411. /** @hidden */
  68412. normalPattern: RegExp;
  68413. /** @hidden */
  68414. uvPattern: RegExp;
  68415. /** @hidden */
  68416. facePattern1: RegExp;
  68417. /** @hidden */
  68418. facePattern2: RegExp;
  68419. /** @hidden */
  68420. facePattern3: RegExp;
  68421. /** @hidden */
  68422. facePattern4: RegExp;
  68423. /** @hidden */
  68424. facePattern5: RegExp;
  68425. private _meshLoadOptions;
  68426. /**
  68427. * Creates loader for .OBJ files
  68428. *
  68429. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  68430. */
  68431. constructor(meshLoadOptions?: MeshLoadOptions);
  68432. private static readonly currentMeshLoadOptions;
  68433. /**
  68434. * Calls synchronously the MTL file attached to this obj.
  68435. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  68436. * Without this function materials are not displayed in the first frame (but displayed after).
  68437. * In consequence it is impossible to get material information in your HTML file
  68438. *
  68439. * @param url The URL of the MTL file
  68440. * @param rootUrl
  68441. * @param onSuccess Callback function to be called when the MTL file is loaded
  68442. * @private
  68443. */
  68444. private _loadMTL;
  68445. /**
  68446. * Instantiates a OBJ file loader plugin.
  68447. * @returns the created plugin
  68448. */
  68449. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  68450. /**
  68451. * If the data string can be loaded directly.
  68452. *
  68453. * @param data string containing the file data
  68454. * @returns if the data can be loaded directly
  68455. */
  68456. canDirectLoad(data: string): boolean;
  68457. /**
  68458. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  68459. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68460. * @param scene the scene the meshes should be added to
  68461. * @param data the OBJ data to load
  68462. * @param rootUrl root url to load from
  68463. * @param onProgress event that fires when loading progress has occured
  68464. * @param fileName Defines the name of the file to load
  68465. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68466. */
  68467. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68468. meshes: AbstractMesh[];
  68469. particleSystems: IParticleSystem[];
  68470. skeletons: Skeleton[];
  68471. animationGroups: AnimationGroup[];
  68472. }>;
  68473. /**
  68474. * Imports all objects from the loaded OBJ data and adds them to the scene
  68475. * @param scene the scene the objects should be added to
  68476. * @param data the OBJ data to load
  68477. * @param rootUrl root url to load from
  68478. * @param onProgress event that fires when loading progress has occured
  68479. * @param fileName Defines the name of the file to load
  68480. * @returns a promise which completes when objects have been loaded to the scene
  68481. */
  68482. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68483. /**
  68484. * Load into an asset container.
  68485. * @param scene The scene to load into
  68486. * @param data The data to import
  68487. * @param rootUrl The root url for scene and resources
  68488. * @param onProgress The callback when the load progresses
  68489. * @param fileName Defines the name of the file to load
  68490. * @returns The loaded asset container
  68491. */
  68492. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  68493. /**
  68494. * Read the OBJ file and create an Array of meshes.
  68495. * Each mesh contains all information given by the OBJ and the MTL file.
  68496. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  68497. *
  68498. * @param meshesNames
  68499. * @param scene Scene The scene where are displayed the data
  68500. * @param data String The content of the obj file
  68501. * @param rootUrl String The path to the folder
  68502. * @returns Array<AbstractMesh>
  68503. * @private
  68504. */
  68505. private _parseSolid;
  68506. }
  68507. }
  68508. declare module BABYLON {
  68509. /**
  68510. * STL file type loader.
  68511. * This is a babylon scene loader plugin.
  68512. */
  68513. export class STLFileLoader implements ISceneLoaderPlugin {
  68514. /** @hidden */
  68515. solidPattern: RegExp;
  68516. /** @hidden */
  68517. facetsPattern: RegExp;
  68518. /** @hidden */
  68519. normalPattern: RegExp;
  68520. /** @hidden */
  68521. vertexPattern: RegExp;
  68522. /**
  68523. * Defines the name of the plugin.
  68524. */
  68525. name: string;
  68526. /**
  68527. * Defines the extensions the stl loader is able to load.
  68528. * force data to come in as an ArrayBuffer
  68529. * we'll convert to string if it looks like it's an ASCII .stl
  68530. */
  68531. extensions: ISceneLoaderPluginExtensions;
  68532. /**
  68533. * Import meshes into a scene.
  68534. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  68535. * @param scene The scene to import into
  68536. * @param data The data to import
  68537. * @param rootUrl The root url for scene and resources
  68538. * @param meshes The meshes array to import into
  68539. * @param particleSystems The particle systems array to import into
  68540. * @param skeletons The skeletons array to import into
  68541. * @param onError The callback when import fails
  68542. * @returns True if successful or false otherwise
  68543. */
  68544. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  68545. /**
  68546. * Load into a scene.
  68547. * @param scene The scene to load into
  68548. * @param data The data to import
  68549. * @param rootUrl The root url for scene and resources
  68550. * @param onError The callback when import fails
  68551. * @returns true if successful or false otherwise
  68552. */
  68553. load(scene: Scene, data: any, rootUrl: string): boolean;
  68554. /**
  68555. * Load into an asset container.
  68556. * @param scene The scene to load into
  68557. * @param data The data to import
  68558. * @param rootUrl The root url for scene and resources
  68559. * @param onError The callback when import fails
  68560. * @returns The loaded asset container
  68561. */
  68562. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  68563. private _isBinary;
  68564. private _parseBinary;
  68565. private _parseASCII;
  68566. }
  68567. }
  68568. declare module BABYLON {
  68569. /**
  68570. * Class for generating OBJ data from a Babylon scene.
  68571. */
  68572. export class OBJExport {
  68573. /**
  68574. * Exports the geometry of a Mesh array in .OBJ file format (text)
  68575. * @param mesh defines the list of meshes to serialize
  68576. * @param materials defines if materials should be exported
  68577. * @param matlibname defines the name of the associated mtl file
  68578. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  68579. * @returns the OBJ content
  68580. */
  68581. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  68582. /**
  68583. * Exports the material(s) of a mesh in .MTL file format (text)
  68584. * @param mesh defines the mesh to extract the material from
  68585. * @returns the mtl content
  68586. */
  68587. static MTL(mesh: Mesh): string;
  68588. }
  68589. }
  68590. declare module BABYLON {
  68591. /** @hidden */
  68592. export var __IGLTFExporterExtension: number;
  68593. /**
  68594. * Interface for extending the exporter
  68595. * @hidden
  68596. */
  68597. export interface IGLTFExporterExtension {
  68598. /**
  68599. * The name of this extension
  68600. */
  68601. readonly name: string;
  68602. /**
  68603. * Defines whether this extension is enabled
  68604. */
  68605. enabled: boolean;
  68606. /**
  68607. * Defines whether this extension is required
  68608. */
  68609. required: boolean;
  68610. }
  68611. }
  68612. declare module BABYLON.GLTF2.Exporter {
  68613. /** @hidden */
  68614. export var __IGLTFExporterExtensionV2: number;
  68615. /**
  68616. * Interface for a glTF exporter extension
  68617. * @hidden
  68618. */
  68619. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  68620. /**
  68621. * Define this method to modify the default behavior before exporting a texture
  68622. * @param context The context when loading the asset
  68623. * @param babylonTexture The glTF texture info property
  68624. * @param mimeType The mime-type of the generated image
  68625. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  68626. */
  68627. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  68628. /**
  68629. * Define this method to modify the default behavior when exporting texture info
  68630. * @param context The context when loading the asset
  68631. * @param meshPrimitive glTF mesh primitive
  68632. * @param babylonSubMesh Babylon submesh
  68633. * @param binaryWriter glTF serializer binary writer instance
  68634. * @returns nullable IMeshPrimitive promise
  68635. */
  68636. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  68637. /**
  68638. * Define this method to modify the default behavior when exporting a node
  68639. * @param context The context when exporting the node
  68640. * @param node glTF node
  68641. * @param babylonNode BabylonJS node
  68642. * @returns nullable INode promise
  68643. */
  68644. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68645. /**
  68646. * Called after the exporter state changes to EXPORTING
  68647. */
  68648. onExporting?(): void;
  68649. }
  68650. }
  68651. declare module BABYLON.GLTF2.Exporter {
  68652. /**
  68653. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  68654. * @hidden
  68655. */
  68656. export class _GLTFMaterialExporter {
  68657. /**
  68658. * Represents the dielectric specular values for R, G and B
  68659. */
  68660. private static readonly _DielectricSpecular;
  68661. /**
  68662. * Allows the maximum specular power to be defined for material calculations
  68663. */
  68664. private static readonly _MaxSpecularPower;
  68665. /**
  68666. * Mapping to store textures
  68667. */
  68668. private _textureMap;
  68669. /**
  68670. * Numeric tolerance value
  68671. */
  68672. private static readonly _Epsilon;
  68673. /**
  68674. * Reference to the glTF Exporter
  68675. */
  68676. private _exporter;
  68677. constructor(exporter: _Exporter);
  68678. /**
  68679. * Specifies if two colors are approximately equal in value
  68680. * @param color1 first color to compare to
  68681. * @param color2 second color to compare to
  68682. * @param epsilon threshold value
  68683. */
  68684. private static FuzzyEquals;
  68685. /**
  68686. * Gets the materials from a Babylon scene and converts them to glTF materials
  68687. * @param scene babylonjs scene
  68688. * @param mimeType texture mime type
  68689. * @param images array of images
  68690. * @param textures array of textures
  68691. * @param materials array of materials
  68692. * @param imageData mapping of texture names to base64 textures
  68693. * @param hasTextureCoords specifies if texture coordinates are present on the material
  68694. */
  68695. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68696. /**
  68697. * Makes a copy of the glTF material without the texture parameters
  68698. * @param originalMaterial original glTF material
  68699. * @returns glTF material without texture parameters
  68700. */
  68701. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  68702. /**
  68703. * Specifies if the material has any texture parameters present
  68704. * @param material glTF Material
  68705. * @returns boolean specifying if texture parameters are present
  68706. */
  68707. _hasTexturesPresent(material: IMaterial): boolean;
  68708. /**
  68709. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  68710. * @param babylonStandardMaterial
  68711. * @returns glTF Metallic Roughness Material representation
  68712. */
  68713. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  68714. /**
  68715. * Computes the metallic factor
  68716. * @param diffuse diffused value
  68717. * @param specular specular value
  68718. * @param oneMinusSpecularStrength one minus the specular strength
  68719. * @returns metallic value
  68720. */
  68721. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  68722. /**
  68723. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  68724. * @param glTFMaterial glTF material
  68725. * @param babylonMaterial Babylon material
  68726. */
  68727. private static _SetAlphaMode;
  68728. /**
  68729. * Converts a Babylon Standard Material to a glTF Material
  68730. * @param babylonStandardMaterial BJS Standard Material
  68731. * @param mimeType mime type to use for the textures
  68732. * @param images array of glTF image interfaces
  68733. * @param textures array of glTF texture interfaces
  68734. * @param materials array of glTF material interfaces
  68735. * @param imageData map of image file name to data
  68736. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68737. */
  68738. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68739. /**
  68740. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68741. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  68742. * @param mimeType mime type to use for the textures
  68743. * @param images array of glTF image interfaces
  68744. * @param textures array of glTF texture interfaces
  68745. * @param materials array of glTF material interfaces
  68746. * @param imageData map of image file name to data
  68747. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68748. */
  68749. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68750. /**
  68751. * Converts an image typed array buffer to a base64 image
  68752. * @param buffer typed array buffer
  68753. * @param width width of the image
  68754. * @param height height of the image
  68755. * @param mimeType mimetype of the image
  68756. * @returns base64 image string
  68757. */
  68758. private _createBase64FromCanvasAsync;
  68759. /**
  68760. * Generates a white texture based on the specified width and height
  68761. * @param width width of the texture in pixels
  68762. * @param height height of the texture in pixels
  68763. * @param scene babylonjs scene
  68764. * @returns white texture
  68765. */
  68766. private _createWhiteTexture;
  68767. /**
  68768. * 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
  68769. * @param texture1 first texture to resize
  68770. * @param texture2 second texture to resize
  68771. * @param scene babylonjs scene
  68772. * @returns resized textures or null
  68773. */
  68774. private _resizeTexturesToSameDimensions;
  68775. /**
  68776. * Converts an array of pixels to a Float32Array
  68777. * Throws an error if the pixel format is not supported
  68778. * @param pixels - array buffer containing pixel values
  68779. * @returns Float32 of pixels
  68780. */
  68781. private _convertPixelArrayToFloat32;
  68782. /**
  68783. * Convert Specular Glossiness Textures to Metallic Roughness
  68784. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  68785. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  68786. * @param diffuseTexture texture used to store diffuse information
  68787. * @param specularGlossinessTexture texture used to store specular and glossiness information
  68788. * @param factors specular glossiness material factors
  68789. * @param mimeType the mime type to use for the texture
  68790. * @returns pbr metallic roughness interface or null
  68791. */
  68792. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  68793. /**
  68794. * Converts specular glossiness material properties to metallic roughness
  68795. * @param specularGlossiness interface with specular glossiness material properties
  68796. * @returns interface with metallic roughness material properties
  68797. */
  68798. private _convertSpecularGlossinessToMetallicRoughness;
  68799. /**
  68800. * Calculates the surface reflectance, independent of lighting conditions
  68801. * @param color Color source to calculate brightness from
  68802. * @returns number representing the perceived brightness, or zero if color is undefined
  68803. */
  68804. private _getPerceivedBrightness;
  68805. /**
  68806. * Returns the maximum color component value
  68807. * @param color
  68808. * @returns maximum color component value, or zero if color is null or undefined
  68809. */
  68810. private _getMaxComponent;
  68811. /**
  68812. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  68813. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68814. * @param mimeType mime type to use for the textures
  68815. * @param images array of glTF image interfaces
  68816. * @param textures array of glTF texture interfaces
  68817. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68818. * @param imageData map of image file name to data
  68819. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68820. * @returns glTF PBR Metallic Roughness factors
  68821. */
  68822. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  68823. private _getGLTFTextureSampler;
  68824. private _getGLTFTextureWrapMode;
  68825. private _getGLTFTextureWrapModesSampler;
  68826. /**
  68827. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  68828. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68829. * @param mimeType mime type to use for the textures
  68830. * @param images array of glTF image interfaces
  68831. * @param textures array of glTF texture interfaces
  68832. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68833. * @param imageData map of image file name to data
  68834. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68835. * @returns glTF PBR Metallic Roughness factors
  68836. */
  68837. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  68838. /**
  68839. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68840. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68841. * @param mimeType mime type to use for the textures
  68842. * @param images array of glTF image interfaces
  68843. * @param textures array of glTF texture interfaces
  68844. * @param materials array of glTF material interfaces
  68845. * @param imageData map of image file name to data
  68846. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68847. */
  68848. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68849. private setMetallicRoughnessPbrMaterial;
  68850. private getPixelsFromTexture;
  68851. /**
  68852. * Extracts a texture from a Babylon texture into file data and glTF data
  68853. * @param babylonTexture Babylon texture to extract
  68854. * @param mimeType Mime Type of the babylonTexture
  68855. * @return glTF texture info, or null if the texture format is not supported
  68856. */
  68857. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  68858. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  68859. /**
  68860. * Builds a texture from base64 string
  68861. * @param base64Texture base64 texture string
  68862. * @param baseTextureName Name to use for the texture
  68863. * @param mimeType image mime type for the texture
  68864. * @param images array of images
  68865. * @param textures array of textures
  68866. * @param imageData map of image data
  68867. * @returns glTF texture info, or null if the texture format is not supported
  68868. */
  68869. private _getTextureInfoFromBase64;
  68870. }
  68871. }
  68872. declare module BABYLON {
  68873. /**
  68874. * Class for holding and downloading glTF file data
  68875. */
  68876. export class GLTFData {
  68877. /**
  68878. * Object which contains the file name as the key and its data as the value
  68879. */
  68880. glTFFiles: {
  68881. [fileName: string]: string | Blob;
  68882. };
  68883. /**
  68884. * Initializes the glTF file object
  68885. */
  68886. constructor();
  68887. /**
  68888. * Downloads the glTF data as files based on their names and data
  68889. */
  68890. downloadFiles(): void;
  68891. }
  68892. }
  68893. declare module BABYLON {
  68894. /**
  68895. * Holds a collection of exporter options and parameters
  68896. */
  68897. export interface IExportOptions {
  68898. /**
  68899. * Function which indicates whether a babylon node should be exported or not
  68900. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  68901. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  68902. */
  68903. shouldExportNode?(node: Node): boolean;
  68904. /**
  68905. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  68906. * @param metadata source metadata to read from
  68907. * @returns the data to store to glTF node extras
  68908. */
  68909. metadataSelector?(metadata: any): any;
  68910. /**
  68911. * The sample rate to bake animation curves
  68912. */
  68913. animationSampleRate?: number;
  68914. /**
  68915. * Begin serialization without waiting for the scene to be ready
  68916. */
  68917. exportWithoutWaitingForScene?: boolean;
  68918. }
  68919. /**
  68920. * Class for generating glTF data from a Babylon scene.
  68921. */
  68922. export class GLTF2Export {
  68923. /**
  68924. * Exports the geometry of the scene to .gltf file format asynchronously
  68925. * @param scene Babylon scene with scene hierarchy information
  68926. * @param filePrefix File prefix to use when generating the glTF file
  68927. * @param options Exporter options
  68928. * @returns Returns an object with a .gltf file and associates texture names
  68929. * as keys and their data and paths as values
  68930. */
  68931. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68932. private static _PreExportAsync;
  68933. private static _PostExportAsync;
  68934. /**
  68935. * Exports the geometry of the scene to .glb file format asychronously
  68936. * @param scene Babylon scene with scene hierarchy information
  68937. * @param filePrefix File prefix to use when generating glb file
  68938. * @param options Exporter options
  68939. * @returns Returns an object with a .glb filename as key and data as value
  68940. */
  68941. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68942. }
  68943. }
  68944. declare module BABYLON.GLTF2.Exporter {
  68945. /**
  68946. * @hidden
  68947. */
  68948. export class _GLTFUtilities {
  68949. /**
  68950. * Creates a buffer view based on the supplied arguments
  68951. * @param bufferIndex index value of the specified buffer
  68952. * @param byteOffset byte offset value
  68953. * @param byteLength byte length of the bufferView
  68954. * @param byteStride byte distance between conequential elements
  68955. * @param name name of the buffer view
  68956. * @returns bufferView for glTF
  68957. */
  68958. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  68959. /**
  68960. * Creates an accessor based on the supplied arguments
  68961. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  68962. * @param name The name of the accessor
  68963. * @param type The type of the accessor
  68964. * @param componentType The datatype of components in the attribute
  68965. * @param count The number of attributes referenced by this accessor
  68966. * @param byteOffset The offset relative to the start of the bufferView in bytes
  68967. * @param min Minimum value of each component in this attribute
  68968. * @param max Maximum value of each component in this attribute
  68969. * @returns accessor for glTF
  68970. */
  68971. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  68972. /**
  68973. * Calculates the minimum and maximum values of an array of position floats
  68974. * @param positions Positions array of a mesh
  68975. * @param vertexStart Starting vertex offset to calculate min and max values
  68976. * @param vertexCount Number of vertices to check for min and max values
  68977. * @returns min number array and max number array
  68978. */
  68979. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  68980. min: number[];
  68981. max: number[];
  68982. };
  68983. /**
  68984. * Converts a new right-handed Vector3
  68985. * @param vector vector3 array
  68986. * @returns right-handed Vector3
  68987. */
  68988. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  68989. /**
  68990. * Converts a Vector3 to right-handed
  68991. * @param vector Vector3 to convert to right-handed
  68992. */
  68993. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  68994. /**
  68995. * Converts a three element number array to right-handed
  68996. * @param vector number array to convert to right-handed
  68997. */
  68998. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  68999. /**
  69000. * Converts a new right-handed Vector3
  69001. * @param vector vector3 array
  69002. * @returns right-handed Vector3
  69003. */
  69004. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  69005. /**
  69006. * Converts a Vector3 to right-handed
  69007. * @param vector Vector3 to convert to right-handed
  69008. */
  69009. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  69010. /**
  69011. * Converts a three element number array to right-handed
  69012. * @param vector number array to convert to right-handed
  69013. */
  69014. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  69015. /**
  69016. * Converts a Vector4 to right-handed
  69017. * @param vector Vector4 to convert to right-handed
  69018. */
  69019. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  69020. /**
  69021. * Converts a Vector4 to right-handed
  69022. * @param vector Vector4 to convert to right-handed
  69023. */
  69024. static _GetRightHandedArray4FromRef(vector: number[]): void;
  69025. /**
  69026. * Converts a Quaternion to right-handed
  69027. * @param quaternion Source quaternion to convert to right-handed
  69028. */
  69029. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  69030. /**
  69031. * Converts a Quaternion to right-handed
  69032. * @param quaternion Source quaternion to convert to right-handed
  69033. */
  69034. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  69035. static _NormalizeTangentFromRef(tangent: Vector4): void;
  69036. }
  69037. }
  69038. declare module BABYLON.GLTF2.Exporter {
  69039. /**
  69040. * Converts Babylon Scene into glTF 2.0.
  69041. * @hidden
  69042. */
  69043. export class _Exporter {
  69044. /**
  69045. * Stores the glTF to export
  69046. */
  69047. _glTF: IGLTF;
  69048. /**
  69049. * Stores all generated buffer views, which represents views into the main glTF buffer data
  69050. */
  69051. _bufferViews: IBufferView[];
  69052. /**
  69053. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  69054. */
  69055. _accessors: IAccessor[];
  69056. /**
  69057. * Stores all the generated nodes, which contains transform and/or mesh information per node
  69058. */
  69059. private _nodes;
  69060. /**
  69061. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  69062. */
  69063. private _scenes;
  69064. /**
  69065. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  69066. */
  69067. private _meshes;
  69068. /**
  69069. * Stores all the generated material information, which represents the appearance of each primitive
  69070. */
  69071. _materials: IMaterial[];
  69072. _materialMap: {
  69073. [materialID: number]: number;
  69074. };
  69075. /**
  69076. * Stores all the generated texture information, which is referenced by glTF materials
  69077. */
  69078. _textures: ITexture[];
  69079. /**
  69080. * Stores all the generated image information, which is referenced by glTF textures
  69081. */
  69082. _images: IImage[];
  69083. /**
  69084. * Stores all the texture samplers
  69085. */
  69086. _samplers: ISampler[];
  69087. /**
  69088. * Stores all the generated animation samplers, which is referenced by glTF animations
  69089. */
  69090. /**
  69091. * Stores the animations for glTF models
  69092. */
  69093. private _animations;
  69094. /**
  69095. * Stores the total amount of bytes stored in the glTF buffer
  69096. */
  69097. private _totalByteLength;
  69098. /**
  69099. * Stores a reference to the Babylon scene containing the source geometry and material information
  69100. */
  69101. _babylonScene: Scene;
  69102. /**
  69103. * Stores a map of the image data, where the key is the file name and the value
  69104. * is the image data
  69105. */
  69106. _imageData: {
  69107. [fileName: string]: {
  69108. data: Uint8Array;
  69109. mimeType: ImageMimeType;
  69110. };
  69111. };
  69112. /**
  69113. * Stores a map of the unique id of a node to its index in the node array
  69114. */
  69115. private _nodeMap;
  69116. /**
  69117. * Specifies if the Babylon scene should be converted to right-handed on export
  69118. */
  69119. _convertToRightHandedSystem: boolean;
  69120. /**
  69121. * Baked animation sample rate
  69122. */
  69123. private _animationSampleRate;
  69124. private _options;
  69125. private _localEngine;
  69126. _glTFMaterialExporter: _GLTFMaterialExporter;
  69127. private _extensions;
  69128. private static _ExtensionNames;
  69129. private static _ExtensionFactories;
  69130. private _applyExtensions;
  69131. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  69132. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  69133. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69134. private _forEachExtensions;
  69135. private _extensionsOnExporting;
  69136. /**
  69137. * Load glTF serializer extensions
  69138. */
  69139. private _loadExtensions;
  69140. /**
  69141. * Creates a glTF Exporter instance, which can accept optional exporter options
  69142. * @param babylonScene Babylon scene object
  69143. * @param options Options to modify the behavior of the exporter
  69144. */
  69145. constructor(babylonScene: Scene, options?: IExportOptions);
  69146. /**
  69147. * Registers a glTF exporter extension
  69148. * @param name Name of the extension to export
  69149. * @param factory The factory function that creates the exporter extension
  69150. */
  69151. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  69152. /**
  69153. * Un-registers an exporter extension
  69154. * @param name The name fo the exporter extension
  69155. * @returns A boolean indicating whether the extension has been un-registered
  69156. */
  69157. static UnregisterExtension(name: string): boolean;
  69158. /**
  69159. * Lazy load a local engine with premultiplied alpha set to false
  69160. */
  69161. _getLocalEngine(): Engine;
  69162. private reorderIndicesBasedOnPrimitiveMode;
  69163. /**
  69164. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  69165. * clock-wise during export to glTF
  69166. * @param submesh BabylonJS submesh
  69167. * @param primitiveMode Primitive mode of the mesh
  69168. * @param sideOrientation the winding order of the submesh
  69169. * @param vertexBufferKind The type of vertex attribute
  69170. * @param meshAttributeArray The vertex attribute data
  69171. * @param byteOffset The offset to the binary data
  69172. * @param binaryWriter The binary data for the glTF file
  69173. */
  69174. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  69175. /**
  69176. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  69177. * clock-wise during export to glTF
  69178. * @param submesh BabylonJS submesh
  69179. * @param primitiveMode Primitive mode of the mesh
  69180. * @param sideOrientation the winding order of the submesh
  69181. * @param vertexBufferKind The type of vertex attribute
  69182. * @param meshAttributeArray The vertex attribute data
  69183. * @param byteOffset The offset to the binary data
  69184. * @param binaryWriter The binary data for the glTF file
  69185. */
  69186. private reorderTriangleFillMode;
  69187. /**
  69188. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  69189. * clock-wise during export to glTF
  69190. * @param submesh BabylonJS submesh
  69191. * @param primitiveMode Primitive mode of the mesh
  69192. * @param sideOrientation the winding order of the submesh
  69193. * @param vertexBufferKind The type of vertex attribute
  69194. * @param meshAttributeArray The vertex attribute data
  69195. * @param byteOffset The offset to the binary data
  69196. * @param binaryWriter The binary data for the glTF file
  69197. */
  69198. private reorderTriangleStripDrawMode;
  69199. /**
  69200. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  69201. * clock-wise during export to glTF
  69202. * @param submesh BabylonJS submesh
  69203. * @param primitiveMode Primitive mode of the mesh
  69204. * @param sideOrientation the winding order of the submesh
  69205. * @param vertexBufferKind The type of vertex attribute
  69206. * @param meshAttributeArray The vertex attribute data
  69207. * @param byteOffset The offset to the binary data
  69208. * @param binaryWriter The binary data for the glTF file
  69209. */
  69210. private reorderTriangleFanMode;
  69211. /**
  69212. * Writes the vertex attribute data to binary
  69213. * @param vertices The vertices to write to the binary writer
  69214. * @param byteOffset The offset into the binary writer to overwrite binary data
  69215. * @param vertexAttributeKind The vertex attribute type
  69216. * @param meshAttributeArray The vertex attribute data
  69217. * @param binaryWriter The writer containing the binary data
  69218. */
  69219. private writeVertexAttributeData;
  69220. /**
  69221. * Writes mesh attribute data to a data buffer
  69222. * Returns the bytelength of the data
  69223. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  69224. * @param meshAttributeArray Array containing the attribute data
  69225. * @param binaryWriter The buffer to write the binary data to
  69226. * @param indices Used to specify the order of the vertex data
  69227. */
  69228. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  69229. /**
  69230. * Generates glTF json data
  69231. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  69232. * @param glTFPrefix Text to use when prefixing a glTF file
  69233. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  69234. * @returns json data as string
  69235. */
  69236. private generateJSON;
  69237. /**
  69238. * Generates data for .gltf and .bin files based on the glTF prefix string
  69239. * @param glTFPrefix Text to use when prefixing a glTF file
  69240. * @returns GLTFData with glTF file data
  69241. */
  69242. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  69243. /**
  69244. * Creates a binary buffer for glTF
  69245. * @returns array buffer for binary data
  69246. */
  69247. private _generateBinaryAsync;
  69248. /**
  69249. * Pads the number to a multiple of 4
  69250. * @param num number to pad
  69251. * @returns padded number
  69252. */
  69253. private _getPadding;
  69254. /**
  69255. * Generates a glb file from the json and binary data
  69256. * Returns an object with the glb file name as the key and data as the value
  69257. * @param glTFPrefix
  69258. * @returns object with glb filename as key and data as value
  69259. */
  69260. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  69261. /**
  69262. * Sets the TRS for each node
  69263. * @param node glTF Node for storing the transformation data
  69264. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  69265. */
  69266. private setNodeTransformation;
  69267. private getVertexBufferFromMesh;
  69268. /**
  69269. * Creates a bufferview based on the vertices type for the Babylon mesh
  69270. * @param kind Indicates the type of vertices data
  69271. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  69272. * @param binaryWriter The buffer to write the bufferview data to
  69273. */
  69274. private createBufferViewKind;
  69275. /**
  69276. * The primitive mode of the Babylon mesh
  69277. * @param babylonMesh The BabylonJS mesh
  69278. */
  69279. private getMeshPrimitiveMode;
  69280. /**
  69281. * Sets the primitive mode of the glTF mesh primitive
  69282. * @param meshPrimitive glTF mesh primitive
  69283. * @param primitiveMode The primitive mode
  69284. */
  69285. private setPrimitiveMode;
  69286. /**
  69287. * Sets the vertex attribute accessor based of the glTF mesh primitive
  69288. * @param meshPrimitive glTF mesh primitive
  69289. * @param attributeKind vertex attribute
  69290. * @returns boolean specifying if uv coordinates are present
  69291. */
  69292. private setAttributeKind;
  69293. /**
  69294. * Sets data for the primitive attributes of each submesh
  69295. * @param mesh glTF Mesh object to store the primitive attribute information
  69296. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  69297. * @param binaryWriter Buffer to write the attribute data to
  69298. */
  69299. private setPrimitiveAttributesAsync;
  69300. /**
  69301. * Creates a glTF scene based on the array of meshes
  69302. * Returns the the total byte offset
  69303. * @param babylonScene Babylon scene to get the mesh data from
  69304. * @param binaryWriter Buffer to write binary data to
  69305. */
  69306. private createSceneAsync;
  69307. /**
  69308. * Creates a mapping of Node unique id to node index and handles animations
  69309. * @param babylonScene Babylon Scene
  69310. * @param nodes Babylon transform nodes
  69311. * @param binaryWriter Buffer to write binary data to
  69312. * @returns Node mapping of unique id to index
  69313. */
  69314. private createNodeMapAndAnimationsAsync;
  69315. /**
  69316. * Creates a glTF node from a Babylon mesh
  69317. * @param babylonMesh Source Babylon mesh
  69318. * @param binaryWriter Buffer for storing geometry data
  69319. * @returns glTF node
  69320. */
  69321. private createNodeAsync;
  69322. }
  69323. /**
  69324. * @hidden
  69325. *
  69326. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  69327. */
  69328. export class _BinaryWriter {
  69329. /**
  69330. * Array buffer which stores all binary data
  69331. */
  69332. private _arrayBuffer;
  69333. /**
  69334. * View of the array buffer
  69335. */
  69336. private _dataView;
  69337. /**
  69338. * byte offset of data in array buffer
  69339. */
  69340. private _byteOffset;
  69341. /**
  69342. * Initialize binary writer with an initial byte length
  69343. * @param byteLength Initial byte length of the array buffer
  69344. */
  69345. constructor(byteLength: number);
  69346. /**
  69347. * Resize the array buffer to the specified byte length
  69348. * @param byteLength
  69349. */
  69350. private resizeBuffer;
  69351. /**
  69352. * Get an array buffer with the length of the byte offset
  69353. * @returns ArrayBuffer resized to the byte offset
  69354. */
  69355. getArrayBuffer(): ArrayBuffer;
  69356. /**
  69357. * Get the byte offset of the array buffer
  69358. * @returns byte offset
  69359. */
  69360. getByteOffset(): number;
  69361. /**
  69362. * Stores an UInt8 in the array buffer
  69363. * @param entry
  69364. * @param byteOffset If defined, specifies where to set the value as an offset.
  69365. */
  69366. setUInt8(entry: number, byteOffset?: number): void;
  69367. /**
  69368. * Gets an UInt32 in the array buffer
  69369. * @param entry
  69370. * @param byteOffset If defined, specifies where to set the value as an offset.
  69371. */
  69372. getUInt32(byteOffset: number): number;
  69373. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69374. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69375. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69376. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69377. /**
  69378. * Stores a Float32 in the array buffer
  69379. * @param entry
  69380. */
  69381. setFloat32(entry: number, byteOffset?: number): void;
  69382. /**
  69383. * Stores an UInt32 in the array buffer
  69384. * @param entry
  69385. * @param byteOffset If defined, specifies where to set the value as an offset.
  69386. */
  69387. setUInt32(entry: number, byteOffset?: number): void;
  69388. }
  69389. }
  69390. declare module BABYLON.GLTF2.Exporter {
  69391. /**
  69392. * @hidden
  69393. * Interface to store animation data.
  69394. */
  69395. export interface _IAnimationData {
  69396. /**
  69397. * Keyframe data.
  69398. */
  69399. inputs: number[];
  69400. /**
  69401. * Value data.
  69402. */
  69403. outputs: number[][];
  69404. /**
  69405. * Animation interpolation data.
  69406. */
  69407. samplerInterpolation: AnimationSamplerInterpolation;
  69408. /**
  69409. * Minimum keyframe value.
  69410. */
  69411. inputsMin: number;
  69412. /**
  69413. * Maximum keyframe value.
  69414. */
  69415. inputsMax: number;
  69416. }
  69417. /**
  69418. * @hidden
  69419. */
  69420. export interface _IAnimationInfo {
  69421. /**
  69422. * The target channel for the animation
  69423. */
  69424. animationChannelTargetPath: AnimationChannelTargetPath;
  69425. /**
  69426. * The glTF accessor type for the data.
  69427. */
  69428. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  69429. /**
  69430. * Specifies if quaternions should be used.
  69431. */
  69432. useQuaternion: boolean;
  69433. }
  69434. /**
  69435. * @hidden
  69436. * Utility class for generating glTF animation data from BabylonJS.
  69437. */
  69438. export class _GLTFAnimation {
  69439. /**
  69440. * @ignore
  69441. *
  69442. * Creates glTF channel animation from BabylonJS animation.
  69443. * @param babylonTransformNode - BabylonJS mesh.
  69444. * @param animation - animation.
  69445. * @param animationChannelTargetPath - The target animation channel.
  69446. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  69447. * @param useQuaternion - Specifies if quaternions are used.
  69448. * @returns nullable IAnimationData
  69449. */
  69450. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  69451. private static _DeduceAnimationInfo;
  69452. /**
  69453. * @ignore
  69454. * Create node animations from the transform node animations
  69455. * @param babylonNode
  69456. * @param runtimeGLTFAnimation
  69457. * @param idleGLTFAnimations
  69458. * @param nodeMap
  69459. * @param nodes
  69460. * @param binaryWriter
  69461. * @param bufferViews
  69462. * @param accessors
  69463. * @param convertToRightHandedSystem
  69464. */
  69465. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  69466. [key: number]: number;
  69467. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  69468. /**
  69469. * @ignore
  69470. * Create node animations from the animation groups
  69471. * @param babylonScene
  69472. * @param glTFAnimations
  69473. * @param nodeMap
  69474. * @param nodes
  69475. * @param binaryWriter
  69476. * @param bufferViews
  69477. * @param accessors
  69478. * @param convertToRightHandedSystem
  69479. */
  69480. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  69481. [key: number]: number;
  69482. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  69483. private static AddAnimation;
  69484. /**
  69485. * Create a baked animation
  69486. * @param babylonTransformNode BabylonJS mesh
  69487. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  69488. * @param animationChannelTargetPath animation target channel
  69489. * @param minFrame minimum animation frame
  69490. * @param maxFrame maximum animation frame
  69491. * @param fps frames per second of the animation
  69492. * @param inputs input key frames of the animation
  69493. * @param outputs output key frame data of the animation
  69494. * @param convertToRightHandedSystem converts the values to right-handed
  69495. * @param useQuaternion specifies if quaternions should be used
  69496. */
  69497. private static _CreateBakedAnimation;
  69498. private static _ConvertFactorToVector3OrQuaternion;
  69499. private static _SetInterpolatedValue;
  69500. /**
  69501. * Creates linear animation from the animation key frames
  69502. * @param babylonTransformNode BabylonJS mesh
  69503. * @param animation BabylonJS animation
  69504. * @param animationChannelTargetPath The target animation channel
  69505. * @param frameDelta The difference between the last and first frame of the animation
  69506. * @param inputs Array to store the key frame times
  69507. * @param outputs Array to store the key frame data
  69508. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  69509. * @param useQuaternion Specifies if quaternions are used in the animation
  69510. */
  69511. private static _CreateLinearOrStepAnimation;
  69512. /**
  69513. * Creates cubic spline animation from the animation key frames
  69514. * @param babylonTransformNode BabylonJS mesh
  69515. * @param animation BabylonJS animation
  69516. * @param animationChannelTargetPath The target animation channel
  69517. * @param frameDelta The difference between the last and first frame of the animation
  69518. * @param inputs Array to store the key frame times
  69519. * @param outputs Array to store the key frame data
  69520. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  69521. * @param useQuaternion Specifies if quaternions are used in the animation
  69522. */
  69523. private static _CreateCubicSplineAnimation;
  69524. private static _GetBasePositionRotationOrScale;
  69525. /**
  69526. * Adds a key frame value
  69527. * @param keyFrame
  69528. * @param animation
  69529. * @param outputs
  69530. * @param animationChannelTargetPath
  69531. * @param basePositionRotationOrScale
  69532. * @param convertToRightHandedSystem
  69533. * @param useQuaternion
  69534. */
  69535. private static _AddKeyframeValue;
  69536. /**
  69537. * Determine the interpolation based on the key frames
  69538. * @param keyFrames
  69539. * @param animationChannelTargetPath
  69540. * @param useQuaternion
  69541. */
  69542. private static _DeduceInterpolation;
  69543. /**
  69544. * Adds an input tangent or output tangent to the output data
  69545. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  69546. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  69547. * @param outputs The animation data by keyframe
  69548. * @param animationChannelTargetPath The target animation channel
  69549. * @param interpolation The interpolation type
  69550. * @param keyFrame The key frame with the animation data
  69551. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  69552. * @param useQuaternion Specifies if quaternions are used
  69553. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  69554. */
  69555. private static AddSplineTangent;
  69556. /**
  69557. * Get the minimum and maximum key frames' frame values
  69558. * @param keyFrames animation key frames
  69559. * @returns the minimum and maximum key frame value
  69560. */
  69561. private static calculateMinMaxKeyFrames;
  69562. }
  69563. }
  69564. declare module BABYLON.GLTF2.Exporter {
  69565. /** @hidden */
  69566. export var textureTransformPixelShader: {
  69567. name: string;
  69568. shader: string;
  69569. };
  69570. }
  69571. declare module BABYLON.GLTF2.Exporter.Extensions {
  69572. /**
  69573. * @hidden
  69574. */
  69575. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  69576. /** Name of this extension */
  69577. readonly name: string;
  69578. /** Defines whether this extension is enabled */
  69579. enabled: boolean;
  69580. /** Defines whether this extension is required */
  69581. required: boolean;
  69582. /** Reference to the glTF exporter */
  69583. private _exporter;
  69584. constructor(exporter: _Exporter);
  69585. dispose(): void;
  69586. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  69587. /**
  69588. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  69589. * @param babylonTexture
  69590. * @param offset
  69591. * @param rotation
  69592. * @param scale
  69593. * @param scene
  69594. */
  69595. private _textureTransformTextureAsync;
  69596. }
  69597. }
  69598. declare module BABYLON.GLTF2.Exporter.Extensions {
  69599. /**
  69600. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  69601. */
  69602. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  69603. /** The name of this extension. */
  69604. readonly name: string;
  69605. /** Defines whether this extension is enabled. */
  69606. enabled: boolean;
  69607. /** Defines whether this extension is required */
  69608. required: boolean;
  69609. /** Reference to the glTF exporter */
  69610. private _exporter;
  69611. private _lights;
  69612. /** @hidden */
  69613. constructor(exporter: _Exporter);
  69614. /** @hidden */
  69615. dispose(): void;
  69616. /** @hidden */
  69617. onExporting(): void;
  69618. /**
  69619. * Define this method to modify the default behavior when exporting a node
  69620. * @param context The context when exporting the node
  69621. * @param node glTF node
  69622. * @param babylonNode BabylonJS node
  69623. * @returns nullable INode promise
  69624. */
  69625. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69626. }
  69627. }
  69628. declare module BABYLON {
  69629. /**
  69630. * Class for generating STL data from a Babylon scene.
  69631. */
  69632. export class STLExport {
  69633. /**
  69634. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  69635. * @param meshes list defines the mesh to serialize
  69636. * @param download triggers the automatic download of the file.
  69637. * @param fileName changes the downloads fileName.
  69638. * @param binary changes the STL to a binary type.
  69639. * @param isLittleEndian toggle for binary type exporter.
  69640. * @returns the STL as UTF8 string
  69641. */
  69642. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  69643. }
  69644. }
  69645. declare module "babylonjs-gltf2interface" {
  69646. export = BABYLON.GLTF2;
  69647. }
  69648. /**
  69649. * Module for glTF 2.0 Interface
  69650. */
  69651. declare module BABYLON.GLTF2 {
  69652. /**
  69653. * The datatype of the components in the attribute
  69654. */
  69655. const enum AccessorComponentType {
  69656. /**
  69657. * Byte
  69658. */
  69659. BYTE = 5120,
  69660. /**
  69661. * Unsigned Byte
  69662. */
  69663. UNSIGNED_BYTE = 5121,
  69664. /**
  69665. * Short
  69666. */
  69667. SHORT = 5122,
  69668. /**
  69669. * Unsigned Short
  69670. */
  69671. UNSIGNED_SHORT = 5123,
  69672. /**
  69673. * Unsigned Int
  69674. */
  69675. UNSIGNED_INT = 5125,
  69676. /**
  69677. * Float
  69678. */
  69679. FLOAT = 5126,
  69680. }
  69681. /**
  69682. * Specifies if the attirbute is a scalar, vector, or matrix
  69683. */
  69684. const enum AccessorType {
  69685. /**
  69686. * Scalar
  69687. */
  69688. SCALAR = "SCALAR",
  69689. /**
  69690. * Vector2
  69691. */
  69692. VEC2 = "VEC2",
  69693. /**
  69694. * Vector3
  69695. */
  69696. VEC3 = "VEC3",
  69697. /**
  69698. * Vector4
  69699. */
  69700. VEC4 = "VEC4",
  69701. /**
  69702. * Matrix2x2
  69703. */
  69704. MAT2 = "MAT2",
  69705. /**
  69706. * Matrix3x3
  69707. */
  69708. MAT3 = "MAT3",
  69709. /**
  69710. * Matrix4x4
  69711. */
  69712. MAT4 = "MAT4",
  69713. }
  69714. /**
  69715. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  69716. */
  69717. const enum AnimationChannelTargetPath {
  69718. /**
  69719. * Translation
  69720. */
  69721. TRANSLATION = "translation",
  69722. /**
  69723. * Rotation
  69724. */
  69725. ROTATION = "rotation",
  69726. /**
  69727. * Scale
  69728. */
  69729. SCALE = "scale",
  69730. /**
  69731. * Weights
  69732. */
  69733. WEIGHTS = "weights",
  69734. }
  69735. /**
  69736. * Interpolation algorithm
  69737. */
  69738. const enum AnimationSamplerInterpolation {
  69739. /**
  69740. * The animated values are linearly interpolated between keyframes
  69741. */
  69742. LINEAR = "LINEAR",
  69743. /**
  69744. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  69745. */
  69746. STEP = "STEP",
  69747. /**
  69748. * The animation's interpolation is computed using a cubic spline with specified tangents
  69749. */
  69750. CUBICSPLINE = "CUBICSPLINE",
  69751. }
  69752. /**
  69753. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69754. */
  69755. const enum CameraType {
  69756. /**
  69757. * A perspective camera containing properties to create a perspective projection matrix
  69758. */
  69759. PERSPECTIVE = "perspective",
  69760. /**
  69761. * An orthographic camera containing properties to create an orthographic projection matrix
  69762. */
  69763. ORTHOGRAPHIC = "orthographic",
  69764. }
  69765. /**
  69766. * The mime-type of the image
  69767. */
  69768. const enum ImageMimeType {
  69769. /**
  69770. * JPEG Mime-type
  69771. */
  69772. JPEG = "image/jpeg",
  69773. /**
  69774. * PNG Mime-type
  69775. */
  69776. PNG = "image/png",
  69777. }
  69778. /**
  69779. * The alpha rendering mode of the material
  69780. */
  69781. const enum MaterialAlphaMode {
  69782. /**
  69783. * The alpha value is ignored and the rendered output is fully opaque
  69784. */
  69785. OPAQUE = "OPAQUE",
  69786. /**
  69787. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  69788. */
  69789. MASK = "MASK",
  69790. /**
  69791. * 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)
  69792. */
  69793. BLEND = "BLEND",
  69794. }
  69795. /**
  69796. * The type of the primitives to render
  69797. */
  69798. const enum MeshPrimitiveMode {
  69799. /**
  69800. * Points
  69801. */
  69802. POINTS = 0,
  69803. /**
  69804. * Lines
  69805. */
  69806. LINES = 1,
  69807. /**
  69808. * Line Loop
  69809. */
  69810. LINE_LOOP = 2,
  69811. /**
  69812. * Line Strip
  69813. */
  69814. LINE_STRIP = 3,
  69815. /**
  69816. * Triangles
  69817. */
  69818. TRIANGLES = 4,
  69819. /**
  69820. * Triangle Strip
  69821. */
  69822. TRIANGLE_STRIP = 5,
  69823. /**
  69824. * Triangle Fan
  69825. */
  69826. TRIANGLE_FAN = 6,
  69827. }
  69828. /**
  69829. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  69830. */
  69831. const enum TextureMagFilter {
  69832. /**
  69833. * Nearest
  69834. */
  69835. NEAREST = 9728,
  69836. /**
  69837. * Linear
  69838. */
  69839. LINEAR = 9729,
  69840. }
  69841. /**
  69842. * Minification filter. All valid values correspond to WebGL enums
  69843. */
  69844. const enum TextureMinFilter {
  69845. /**
  69846. * Nearest
  69847. */
  69848. NEAREST = 9728,
  69849. /**
  69850. * Linear
  69851. */
  69852. LINEAR = 9729,
  69853. /**
  69854. * Nearest Mip-Map Nearest
  69855. */
  69856. NEAREST_MIPMAP_NEAREST = 9984,
  69857. /**
  69858. * Linear Mipmap Nearest
  69859. */
  69860. LINEAR_MIPMAP_NEAREST = 9985,
  69861. /**
  69862. * Nearest Mipmap Linear
  69863. */
  69864. NEAREST_MIPMAP_LINEAR = 9986,
  69865. /**
  69866. * Linear Mipmap Linear
  69867. */
  69868. LINEAR_MIPMAP_LINEAR = 9987,
  69869. }
  69870. /**
  69871. * S (U) wrapping mode. All valid values correspond to WebGL enums
  69872. */
  69873. const enum TextureWrapMode {
  69874. /**
  69875. * Clamp to Edge
  69876. */
  69877. CLAMP_TO_EDGE = 33071,
  69878. /**
  69879. * Mirrored Repeat
  69880. */
  69881. MIRRORED_REPEAT = 33648,
  69882. /**
  69883. * Repeat
  69884. */
  69885. REPEAT = 10497,
  69886. }
  69887. /**
  69888. * glTF Property
  69889. */
  69890. interface IProperty {
  69891. /**
  69892. * Dictionary object with extension-specific objects
  69893. */
  69894. extensions?: {
  69895. [key: string]: any;
  69896. };
  69897. /**
  69898. * Application-Specific data
  69899. */
  69900. extras?: any;
  69901. }
  69902. /**
  69903. * glTF Child of Root Property
  69904. */
  69905. interface IChildRootProperty extends IProperty {
  69906. /**
  69907. * The user-defined name of this object
  69908. */
  69909. name?: string;
  69910. }
  69911. /**
  69912. * Indices of those attributes that deviate from their initialization value
  69913. */
  69914. interface IAccessorSparseIndices extends IProperty {
  69915. /**
  69916. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69917. */
  69918. bufferView: number;
  69919. /**
  69920. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69921. */
  69922. byteOffset?: number;
  69923. /**
  69924. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  69925. */
  69926. componentType: AccessorComponentType;
  69927. }
  69928. /**
  69929. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  69930. */
  69931. interface IAccessorSparseValues extends IProperty {
  69932. /**
  69933. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69934. */
  69935. bufferView: number;
  69936. /**
  69937. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69938. */
  69939. byteOffset?: number;
  69940. }
  69941. /**
  69942. * Sparse storage of attributes that deviate from their initialization value
  69943. */
  69944. interface IAccessorSparse extends IProperty {
  69945. /**
  69946. * The number of attributes encoded in this sparse accessor
  69947. */
  69948. count: number;
  69949. /**
  69950. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  69951. */
  69952. indices: IAccessorSparseIndices;
  69953. /**
  69954. * 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
  69955. */
  69956. values: IAccessorSparseValues;
  69957. }
  69958. /**
  69959. * 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
  69960. */
  69961. interface IAccessor extends IChildRootProperty {
  69962. /**
  69963. * The index of the bufferview
  69964. */
  69965. bufferView?: number;
  69966. /**
  69967. * The offset relative to the start of the bufferView in bytes
  69968. */
  69969. byteOffset?: number;
  69970. /**
  69971. * The datatype of components in the attribute
  69972. */
  69973. componentType: AccessorComponentType;
  69974. /**
  69975. * Specifies whether integer data values should be normalized
  69976. */
  69977. normalized?: boolean;
  69978. /**
  69979. * The number of attributes referenced by this accessor
  69980. */
  69981. count: number;
  69982. /**
  69983. * Specifies if the attribute is a scalar, vector, or matrix
  69984. */
  69985. type: AccessorType;
  69986. /**
  69987. * Maximum value of each component in this attribute
  69988. */
  69989. max?: number[];
  69990. /**
  69991. * Minimum value of each component in this attribute
  69992. */
  69993. min?: number[];
  69994. /**
  69995. * Sparse storage of attributes that deviate from their initialization value
  69996. */
  69997. sparse?: IAccessorSparse;
  69998. }
  69999. /**
  70000. * Targets an animation's sampler at a node's property
  70001. */
  70002. interface IAnimationChannel extends IProperty {
  70003. /**
  70004. * The index of a sampler in this animation used to compute the value for the target
  70005. */
  70006. sampler: number;
  70007. /**
  70008. * The index of the node and TRS property to target
  70009. */
  70010. target: IAnimationChannelTarget;
  70011. }
  70012. /**
  70013. * The index of the node and TRS property that an animation channel targets
  70014. */
  70015. interface IAnimationChannelTarget extends IProperty {
  70016. /**
  70017. * The index of the node to target
  70018. */
  70019. node: number;
  70020. /**
  70021. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  70022. */
  70023. path: AnimationChannelTargetPath;
  70024. }
  70025. /**
  70026. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70027. */
  70028. interface IAnimationSampler extends IProperty {
  70029. /**
  70030. * The index of an accessor containing keyframe input values, e.g., time
  70031. */
  70032. input: number;
  70033. /**
  70034. * Interpolation algorithm
  70035. */
  70036. interpolation?: AnimationSamplerInterpolation;
  70037. /**
  70038. * The index of an accessor, containing keyframe output values
  70039. */
  70040. output: number;
  70041. }
  70042. /**
  70043. * A keyframe animation
  70044. */
  70045. interface IAnimation extends IChildRootProperty {
  70046. /**
  70047. * An array of channels, each of which targets an animation's sampler at a node's property
  70048. */
  70049. channels: IAnimationChannel[];
  70050. /**
  70051. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70052. */
  70053. samplers: IAnimationSampler[];
  70054. }
  70055. /**
  70056. * Metadata about the glTF asset
  70057. */
  70058. interface IAsset extends IChildRootProperty {
  70059. /**
  70060. * A copyright message suitable for display to credit the content creator
  70061. */
  70062. copyright?: string;
  70063. /**
  70064. * Tool that generated this glTF model. Useful for debugging
  70065. */
  70066. generator?: string;
  70067. /**
  70068. * The glTF version that this asset targets
  70069. */
  70070. version: string;
  70071. /**
  70072. * The minimum glTF version that this asset targets
  70073. */
  70074. minVersion?: string;
  70075. }
  70076. /**
  70077. * A buffer points to binary geometry, animation, or skins
  70078. */
  70079. interface IBuffer extends IChildRootProperty {
  70080. /**
  70081. * 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
  70082. */
  70083. uri?: string;
  70084. /**
  70085. * The length of the buffer in bytes
  70086. */
  70087. byteLength: number;
  70088. }
  70089. /**
  70090. * A view into a buffer generally representing a subset of the buffer
  70091. */
  70092. interface IBufferView extends IChildRootProperty {
  70093. /**
  70094. * The index of the buffer
  70095. */
  70096. buffer: number;
  70097. /**
  70098. * The offset into the buffer in bytes
  70099. */
  70100. byteOffset?: number;
  70101. /**
  70102. * The lenth of the bufferView in bytes
  70103. */
  70104. byteLength: number;
  70105. /**
  70106. * The stride, in bytes
  70107. */
  70108. byteStride?: number;
  70109. }
  70110. /**
  70111. * An orthographic camera containing properties to create an orthographic projection matrix
  70112. */
  70113. interface ICameraOrthographic extends IProperty {
  70114. /**
  70115. * The floating-point horizontal magnification of the view. Must not be zero
  70116. */
  70117. xmag: number;
  70118. /**
  70119. * The floating-point vertical magnification of the view. Must not be zero
  70120. */
  70121. ymag: number;
  70122. /**
  70123. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  70124. */
  70125. zfar: number;
  70126. /**
  70127. * The floating-point distance to the near clipping plane
  70128. */
  70129. znear: number;
  70130. }
  70131. /**
  70132. * A perspective camera containing properties to create a perspective projection matrix
  70133. */
  70134. interface ICameraPerspective extends IProperty {
  70135. /**
  70136. * The floating-point aspect ratio of the field of view
  70137. */
  70138. aspectRatio?: number;
  70139. /**
  70140. * The floating-point vertical field of view in radians
  70141. */
  70142. yfov: number;
  70143. /**
  70144. * The floating-point distance to the far clipping plane
  70145. */
  70146. zfar?: number;
  70147. /**
  70148. * The floating-point distance to the near clipping plane
  70149. */
  70150. znear: number;
  70151. }
  70152. /**
  70153. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  70154. */
  70155. interface ICamera extends IChildRootProperty {
  70156. /**
  70157. * An orthographic camera containing properties to create an orthographic projection matrix
  70158. */
  70159. orthographic?: ICameraOrthographic;
  70160. /**
  70161. * A perspective camera containing properties to create a perspective projection matrix
  70162. */
  70163. perspective?: ICameraPerspective;
  70164. /**
  70165. * Specifies if the camera uses a perspective or orthographic projection
  70166. */
  70167. type: CameraType;
  70168. }
  70169. /**
  70170. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  70171. */
  70172. interface IImage extends IChildRootProperty {
  70173. /**
  70174. * 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
  70175. */
  70176. uri?: string;
  70177. /**
  70178. * The image's MIME type
  70179. */
  70180. mimeType?: ImageMimeType;
  70181. /**
  70182. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  70183. */
  70184. bufferView?: number;
  70185. }
  70186. /**
  70187. * Material Normal Texture Info
  70188. */
  70189. interface IMaterialNormalTextureInfo extends ITextureInfo {
  70190. /**
  70191. * The scalar multiplier applied to each normal vector of the normal texture
  70192. */
  70193. scale?: number;
  70194. }
  70195. /**
  70196. * Material Occlusion Texture Info
  70197. */
  70198. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  70199. /**
  70200. * A scalar multiplier controlling the amount of occlusion applied
  70201. */
  70202. strength?: number;
  70203. }
  70204. /**
  70205. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  70206. */
  70207. interface IMaterialPbrMetallicRoughness {
  70208. /**
  70209. * The material's base color factor
  70210. */
  70211. baseColorFactor?: number[];
  70212. /**
  70213. * The base color texture
  70214. */
  70215. baseColorTexture?: ITextureInfo;
  70216. /**
  70217. * The metalness of the material
  70218. */
  70219. metallicFactor?: number;
  70220. /**
  70221. * The roughness of the material
  70222. */
  70223. roughnessFactor?: number;
  70224. /**
  70225. * The metallic-roughness texture
  70226. */
  70227. metallicRoughnessTexture?: ITextureInfo;
  70228. }
  70229. /**
  70230. * The material appearance of a primitive
  70231. */
  70232. interface IMaterial extends IChildRootProperty {
  70233. /**
  70234. * 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
  70235. */
  70236. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  70237. /**
  70238. * The normal map texture
  70239. */
  70240. normalTexture?: IMaterialNormalTextureInfo;
  70241. /**
  70242. * The occlusion map texture
  70243. */
  70244. occlusionTexture?: IMaterialOcclusionTextureInfo;
  70245. /**
  70246. * The emissive map texture
  70247. */
  70248. emissiveTexture?: ITextureInfo;
  70249. /**
  70250. * 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
  70251. */
  70252. emissiveFactor?: number[];
  70253. /**
  70254. * The alpha rendering mode of the material
  70255. */
  70256. alphaMode?: MaterialAlphaMode;
  70257. /**
  70258. * The alpha cutoff value of the material
  70259. */
  70260. alphaCutoff?: number;
  70261. /**
  70262. * Specifies whether the material is double sided
  70263. */
  70264. doubleSided?: boolean;
  70265. }
  70266. /**
  70267. * Geometry to be rendered with the given material
  70268. */
  70269. interface IMeshPrimitive extends IProperty {
  70270. /**
  70271. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  70272. */
  70273. attributes: {
  70274. [name: string]: number;
  70275. };
  70276. /**
  70277. * The index of the accessor that contains the indices
  70278. */
  70279. indices?: number;
  70280. /**
  70281. * The index of the material to apply to this primitive when rendering
  70282. */
  70283. material?: number;
  70284. /**
  70285. * The type of primitives to render. All valid values correspond to WebGL enums
  70286. */
  70287. mode?: MeshPrimitiveMode;
  70288. /**
  70289. * 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
  70290. */
  70291. targets?: {
  70292. [name: string]: number;
  70293. }[];
  70294. }
  70295. /**
  70296. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  70297. */
  70298. interface IMesh extends IChildRootProperty {
  70299. /**
  70300. * An array of primitives, each defining geometry to be rendered with a material
  70301. */
  70302. primitives: IMeshPrimitive[];
  70303. /**
  70304. * Array of weights to be applied to the Morph Targets
  70305. */
  70306. weights?: number[];
  70307. }
  70308. /**
  70309. * A node in the node hierarchy
  70310. */
  70311. interface INode extends IChildRootProperty {
  70312. /**
  70313. * The index of the camera referenced by this node
  70314. */
  70315. camera?: number;
  70316. /**
  70317. * The indices of this node's children
  70318. */
  70319. children?: number[];
  70320. /**
  70321. * The index of the skin referenced by this node
  70322. */
  70323. skin?: number;
  70324. /**
  70325. * A floating-point 4x4 transformation matrix stored in column-major order
  70326. */
  70327. matrix?: number[];
  70328. /**
  70329. * The index of the mesh in this node
  70330. */
  70331. mesh?: number;
  70332. /**
  70333. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  70334. */
  70335. rotation?: number[];
  70336. /**
  70337. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  70338. */
  70339. scale?: number[];
  70340. /**
  70341. * The node's translation along the x, y, and z axes
  70342. */
  70343. translation?: number[];
  70344. /**
  70345. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  70346. */
  70347. weights?: number[];
  70348. }
  70349. /**
  70350. * Texture sampler properties for filtering and wrapping modes
  70351. */
  70352. interface ISampler extends IChildRootProperty {
  70353. /**
  70354. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70355. */
  70356. magFilter?: TextureMagFilter;
  70357. /**
  70358. * Minification filter. All valid values correspond to WebGL enums
  70359. */
  70360. minFilter?: TextureMinFilter;
  70361. /**
  70362. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70363. */
  70364. wrapS?: TextureWrapMode;
  70365. /**
  70366. * T (V) wrapping mode. All valid values correspond to WebGL enums
  70367. */
  70368. wrapT?: TextureWrapMode;
  70369. }
  70370. /**
  70371. * The root nodes of a scene
  70372. */
  70373. interface IScene extends IChildRootProperty {
  70374. /**
  70375. * The indices of each root node
  70376. */
  70377. nodes: number[];
  70378. }
  70379. /**
  70380. * Joints and matrices defining a skin
  70381. */
  70382. interface ISkin extends IChildRootProperty {
  70383. /**
  70384. * 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
  70385. */
  70386. inverseBindMatrices?: number;
  70387. /**
  70388. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  70389. */
  70390. skeleton?: number;
  70391. /**
  70392. * 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)
  70393. */
  70394. joints: number[];
  70395. }
  70396. /**
  70397. * A texture and its sampler
  70398. */
  70399. interface ITexture extends IChildRootProperty {
  70400. /**
  70401. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  70402. */
  70403. sampler?: number;
  70404. /**
  70405. * The index of the image used by this texture
  70406. */
  70407. source: number;
  70408. }
  70409. /**
  70410. * Reference to a texture
  70411. */
  70412. interface ITextureInfo extends IProperty {
  70413. /**
  70414. * The index of the texture
  70415. */
  70416. index: number;
  70417. /**
  70418. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  70419. */
  70420. texCoord?: number;
  70421. }
  70422. /**
  70423. * The root object for a glTF asset
  70424. */
  70425. interface IGLTF extends IProperty {
  70426. /**
  70427. * An array of accessors. An accessor is a typed view into a bufferView
  70428. */
  70429. accessors?: IAccessor[];
  70430. /**
  70431. * An array of keyframe animations
  70432. */
  70433. animations?: IAnimation[];
  70434. /**
  70435. * Metadata about the glTF asset
  70436. */
  70437. asset: IAsset;
  70438. /**
  70439. * An array of buffers. A buffer points to binary geometry, animation, or skins
  70440. */
  70441. buffers?: IBuffer[];
  70442. /**
  70443. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  70444. */
  70445. bufferViews?: IBufferView[];
  70446. /**
  70447. * An array of cameras
  70448. */
  70449. cameras?: ICamera[];
  70450. /**
  70451. * Names of glTF extensions used somewhere in this asset
  70452. */
  70453. extensionsUsed?: string[];
  70454. /**
  70455. * Names of glTF extensions required to properly load this asset
  70456. */
  70457. extensionsRequired?: string[];
  70458. /**
  70459. * An array of images. An image defines data used to create a texture
  70460. */
  70461. images?: IImage[];
  70462. /**
  70463. * An array of materials. A material defines the appearance of a primitive
  70464. */
  70465. materials?: IMaterial[];
  70466. /**
  70467. * An array of meshes. A mesh is a set of primitives to be rendered
  70468. */
  70469. meshes?: IMesh[];
  70470. /**
  70471. * An array of nodes
  70472. */
  70473. nodes?: INode[];
  70474. /**
  70475. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  70476. */
  70477. samplers?: ISampler[];
  70478. /**
  70479. * The index of the default scene
  70480. */
  70481. scene?: number;
  70482. /**
  70483. * An array of scenes
  70484. */
  70485. scenes?: IScene[];
  70486. /**
  70487. * An array of skins. A skin is defined by joints and matrices
  70488. */
  70489. skins?: ISkin[];
  70490. /**
  70491. * An array of textures
  70492. */
  70493. textures?: ITexture[];
  70494. }
  70495. /**
  70496. * The glTF validation results
  70497. * @ignore
  70498. */
  70499. interface IGLTFValidationResults {
  70500. info: {
  70501. generator: string;
  70502. hasAnimations: boolean;
  70503. hasDefaultScene: boolean;
  70504. hasMaterials: boolean;
  70505. hasMorphTargets: boolean;
  70506. hasSkins: boolean;
  70507. hasTextures: boolean;
  70508. maxAttributesUsed: number;
  70509. primitivesCount: number
  70510. };
  70511. issues: {
  70512. messages: Array<string>;
  70513. numErrors: number;
  70514. numHints: number;
  70515. numInfos: number;
  70516. numWarnings: number;
  70517. truncated: boolean
  70518. };
  70519. mimeType: string;
  70520. uri: string;
  70521. validatedAt: string;
  70522. validatorVersion: string;
  70523. }
  70524. /**
  70525. * The glTF validation options
  70526. */
  70527. interface IGLTFValidationOptions {
  70528. /** Uri to use */
  70529. uri?: string;
  70530. /** Function used to load external resources */
  70531. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  70532. /** Boolean indicating that we need to validate accessor data */
  70533. validateAccessorData?: boolean;
  70534. /** max number of issues allowed */
  70535. maxIssues?: number;
  70536. /** Ignored issues */
  70537. ignoredIssues?: Array<string>;
  70538. /** Value to override severy settings */
  70539. severityOverrides?: Object;
  70540. }
  70541. /**
  70542. * The glTF validator object
  70543. * @ignore
  70544. */
  70545. interface IGLTFValidator {
  70546. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  70547. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  70548. }
  70549. }
  70550. declare module BABYLON {
  70551. /** @hidden */
  70552. export var cellPixelShader: {
  70553. name: string;
  70554. shader: string;
  70555. };
  70556. }
  70557. declare module BABYLON {
  70558. /** @hidden */
  70559. export var cellVertexShader: {
  70560. name: string;
  70561. shader: string;
  70562. };
  70563. }
  70564. declare module BABYLON {
  70565. export class CellMaterial extends BABYLON.PushMaterial {
  70566. private _diffuseTexture;
  70567. diffuseTexture: BABYLON.BaseTexture;
  70568. diffuseColor: BABYLON.Color3;
  70569. _computeHighLevel: boolean;
  70570. computeHighLevel: boolean;
  70571. private _disableLighting;
  70572. disableLighting: boolean;
  70573. private _maxSimultaneousLights;
  70574. maxSimultaneousLights: number;
  70575. private _renderId;
  70576. constructor(name: string, scene: BABYLON.Scene);
  70577. needAlphaBlending(): boolean;
  70578. needAlphaTesting(): boolean;
  70579. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70580. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70581. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70582. getAnimatables(): BABYLON.IAnimatable[];
  70583. getActiveTextures(): BABYLON.BaseTexture[];
  70584. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70585. dispose(forceDisposeEffect?: boolean): void;
  70586. getClassName(): string;
  70587. clone(name: string): CellMaterial;
  70588. serialize(): any;
  70589. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  70590. }
  70591. }
  70592. declare module BABYLON {
  70593. export class CustomShaderStructure {
  70594. FragmentStore: string;
  70595. VertexStore: string;
  70596. constructor();
  70597. }
  70598. export class ShaderSpecialParts {
  70599. constructor();
  70600. Fragment_Begin: string;
  70601. Fragment_Definitions: string;
  70602. Fragment_MainBegin: string;
  70603. Fragment_Custom_Diffuse: string;
  70604. Fragment_Before_Lights: string;
  70605. Fragment_Before_Fog: string;
  70606. Fragment_Custom_Alpha: string;
  70607. Fragment_Before_FragColor: string;
  70608. Vertex_Begin: string;
  70609. Vertex_Definitions: string;
  70610. Vertex_MainBegin: string;
  70611. Vertex_Before_PositionUpdated: string;
  70612. Vertex_Before_NormalUpdated: string;
  70613. Vertex_MainEnd: string;
  70614. }
  70615. export class CustomMaterial extends BABYLON.StandardMaterial {
  70616. static ShaderIndexer: number;
  70617. CustomParts: ShaderSpecialParts;
  70618. _isCreatedShader: boolean;
  70619. _createdShaderName: string;
  70620. _customUniform: string[];
  70621. _newUniforms: string[];
  70622. _newUniformInstances: any[];
  70623. _newSamplerInstances: BABYLON.Texture[];
  70624. FragmentShader: string;
  70625. VertexShader: string;
  70626. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  70627. ReviewUniform(name: string, arr: string[]): string[];
  70628. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  70629. constructor(name: string, scene: BABYLON.Scene);
  70630. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  70631. Fragment_Begin(shaderPart: string): CustomMaterial;
  70632. Fragment_Definitions(shaderPart: string): CustomMaterial;
  70633. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  70634. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  70635. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  70636. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  70637. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  70638. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  70639. Vertex_Begin(shaderPart: string): CustomMaterial;
  70640. Vertex_Definitions(shaderPart: string): CustomMaterial;
  70641. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  70642. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  70643. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  70644. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  70645. }
  70646. }
  70647. declare module BABYLON {
  70648. export class ShaderAlebdoParts {
  70649. constructor();
  70650. Fragment_Begin: string;
  70651. Fragment_Definitions: string;
  70652. Fragment_MainBegin: string;
  70653. Fragment_Custom_Albedo: string;
  70654. Fragment_Before_Lights: string;
  70655. Fragment_Custom_MetallicRoughness: string;
  70656. Fragment_Custom_MicroSurface: string;
  70657. Fragment_Before_Fog: string;
  70658. Fragment_Custom_Alpha: string;
  70659. Fragment_Before_FragColor: string;
  70660. Vertex_Begin: string;
  70661. Vertex_Definitions: string;
  70662. Vertex_MainBegin: string;
  70663. Vertex_Before_PositionUpdated: string;
  70664. Vertex_Before_NormalUpdated: string;
  70665. Vertex_MainEnd: string;
  70666. }
  70667. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  70668. static ShaderIndexer: number;
  70669. CustomParts: ShaderAlebdoParts;
  70670. _isCreatedShader: boolean;
  70671. _createdShaderName: string;
  70672. _customUniform: string[];
  70673. _newUniforms: string[];
  70674. _newUniformInstances: any[];
  70675. _newSamplerInstances: BABYLON.Texture[];
  70676. FragmentShader: string;
  70677. VertexShader: string;
  70678. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  70679. ReviewUniform(name: string, arr: string[]): string[];
  70680. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  70681. constructor(name: string, scene: BABYLON.Scene);
  70682. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  70683. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  70684. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  70685. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  70686. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  70687. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  70688. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  70689. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  70690. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  70691. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  70692. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  70693. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  70694. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  70695. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  70696. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  70697. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  70698. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  70699. }
  70700. }
  70701. declare module BABYLON {
  70702. /** @hidden */
  70703. export var firePixelShader: {
  70704. name: string;
  70705. shader: string;
  70706. };
  70707. }
  70708. declare module BABYLON {
  70709. /** @hidden */
  70710. export var fireVertexShader: {
  70711. name: string;
  70712. shader: string;
  70713. };
  70714. }
  70715. declare module BABYLON {
  70716. export class FireMaterial extends BABYLON.PushMaterial {
  70717. private _diffuseTexture;
  70718. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70719. private _distortionTexture;
  70720. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70721. private _opacityTexture;
  70722. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70723. diffuseColor: BABYLON.Color3;
  70724. speed: number;
  70725. private _scaledDiffuse;
  70726. private _renderId;
  70727. private _lastTime;
  70728. constructor(name: string, scene: BABYLON.Scene);
  70729. needAlphaBlending(): boolean;
  70730. needAlphaTesting(): boolean;
  70731. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70732. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70733. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70734. getAnimatables(): BABYLON.IAnimatable[];
  70735. getActiveTextures(): BABYLON.BaseTexture[];
  70736. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70737. getClassName(): string;
  70738. dispose(forceDisposeEffect?: boolean): void;
  70739. clone(name: string): FireMaterial;
  70740. serialize(): any;
  70741. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  70742. }
  70743. }
  70744. declare module BABYLON {
  70745. /** @hidden */
  70746. export var furPixelShader: {
  70747. name: string;
  70748. shader: string;
  70749. };
  70750. }
  70751. declare module BABYLON {
  70752. /** @hidden */
  70753. export var furVertexShader: {
  70754. name: string;
  70755. shader: string;
  70756. };
  70757. }
  70758. declare module BABYLON {
  70759. export class FurMaterial extends BABYLON.PushMaterial {
  70760. private _diffuseTexture;
  70761. diffuseTexture: BABYLON.BaseTexture;
  70762. private _heightTexture;
  70763. heightTexture: BABYLON.BaseTexture;
  70764. diffuseColor: BABYLON.Color3;
  70765. furLength: number;
  70766. furAngle: number;
  70767. furColor: BABYLON.Color3;
  70768. furOffset: number;
  70769. furSpacing: number;
  70770. furGravity: BABYLON.Vector3;
  70771. furSpeed: number;
  70772. furDensity: number;
  70773. furOcclusion: number;
  70774. furTexture: BABYLON.DynamicTexture;
  70775. private _disableLighting;
  70776. disableLighting: boolean;
  70777. private _maxSimultaneousLights;
  70778. maxSimultaneousLights: number;
  70779. highLevelFur: boolean;
  70780. _meshes: BABYLON.AbstractMesh[];
  70781. private _renderId;
  70782. private _furTime;
  70783. constructor(name: string, scene: BABYLON.Scene);
  70784. furTime: number;
  70785. needAlphaBlending(): boolean;
  70786. needAlphaTesting(): boolean;
  70787. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70788. updateFur(): void;
  70789. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70790. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70791. getAnimatables(): BABYLON.IAnimatable[];
  70792. getActiveTextures(): BABYLON.BaseTexture[];
  70793. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70794. dispose(forceDisposeEffect?: boolean): void;
  70795. clone(name: string): FurMaterial;
  70796. serialize(): any;
  70797. getClassName(): string;
  70798. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  70799. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  70800. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  70801. }
  70802. }
  70803. declare module BABYLON {
  70804. /** @hidden */
  70805. export var gradientPixelShader: {
  70806. name: string;
  70807. shader: string;
  70808. };
  70809. }
  70810. declare module BABYLON {
  70811. /** @hidden */
  70812. export var gradientVertexShader: {
  70813. name: string;
  70814. shader: string;
  70815. };
  70816. }
  70817. declare module BABYLON {
  70818. export class GradientMaterial extends BABYLON.PushMaterial {
  70819. private _maxSimultaneousLights;
  70820. maxSimultaneousLights: number;
  70821. topColor: BABYLON.Color3;
  70822. topColorAlpha: number;
  70823. bottomColor: BABYLON.Color3;
  70824. bottomColorAlpha: number;
  70825. offset: number;
  70826. scale: number;
  70827. smoothness: number;
  70828. private _disableLighting;
  70829. disableLighting: boolean;
  70830. private _renderId;
  70831. constructor(name: string, scene: BABYLON.Scene);
  70832. needAlphaBlending(): boolean;
  70833. needAlphaTesting(): boolean;
  70834. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70835. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70836. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70837. getAnimatables(): BABYLON.IAnimatable[];
  70838. dispose(forceDisposeEffect?: boolean): void;
  70839. clone(name: string): GradientMaterial;
  70840. serialize(): any;
  70841. getClassName(): string;
  70842. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  70843. }
  70844. }
  70845. declare module BABYLON {
  70846. /** @hidden */
  70847. export var gridPixelShader: {
  70848. name: string;
  70849. shader: string;
  70850. };
  70851. }
  70852. declare module BABYLON {
  70853. /** @hidden */
  70854. export var gridVertexShader: {
  70855. name: string;
  70856. shader: string;
  70857. };
  70858. }
  70859. declare module BABYLON {
  70860. /**
  70861. * The grid materials allows you to wrap any shape with a grid.
  70862. * Colors are customizable.
  70863. */
  70864. export class GridMaterial extends BABYLON.PushMaterial {
  70865. /**
  70866. * Main color of the grid (e.g. between lines)
  70867. */
  70868. mainColor: BABYLON.Color3;
  70869. /**
  70870. * Color of the grid lines.
  70871. */
  70872. lineColor: BABYLON.Color3;
  70873. /**
  70874. * The scale of the grid compared to unit.
  70875. */
  70876. gridRatio: number;
  70877. /**
  70878. * Allows setting an offset for the grid lines.
  70879. */
  70880. gridOffset: BABYLON.Vector3;
  70881. /**
  70882. * The frequency of thicker lines.
  70883. */
  70884. majorUnitFrequency: number;
  70885. /**
  70886. * The visibility of minor units in the grid.
  70887. */
  70888. minorUnitVisibility: number;
  70889. /**
  70890. * The grid opacity outside of the lines.
  70891. */
  70892. opacity: number;
  70893. /**
  70894. * Determine RBG output is premultiplied by alpha value.
  70895. */
  70896. preMultiplyAlpha: boolean;
  70897. private _opacityTexture;
  70898. opacityTexture: BABYLON.BaseTexture;
  70899. private _gridControl;
  70900. private _renderId;
  70901. /**
  70902. * constructor
  70903. * @param name The name given to the material in order to identify it afterwards.
  70904. * @param scene The scene the material is used in.
  70905. */
  70906. constructor(name: string, scene: BABYLON.Scene);
  70907. /**
  70908. * Returns wehter or not the grid requires alpha blending.
  70909. */
  70910. needAlphaBlending(): boolean;
  70911. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70912. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70913. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70914. /**
  70915. * Dispose the material and its associated resources.
  70916. * @param forceDisposeEffect will also dispose the used effect when true
  70917. */
  70918. dispose(forceDisposeEffect?: boolean): void;
  70919. clone(name: string): GridMaterial;
  70920. serialize(): any;
  70921. getClassName(): string;
  70922. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  70923. }
  70924. }
  70925. declare module BABYLON {
  70926. /** @hidden */
  70927. export var lavaPixelShader: {
  70928. name: string;
  70929. shader: string;
  70930. };
  70931. }
  70932. declare module BABYLON {
  70933. /** @hidden */
  70934. export var lavaVertexShader: {
  70935. name: string;
  70936. shader: string;
  70937. };
  70938. }
  70939. declare module BABYLON {
  70940. export class LavaMaterial extends BABYLON.PushMaterial {
  70941. private _diffuseTexture;
  70942. diffuseTexture: BABYLON.BaseTexture;
  70943. noiseTexture: BABYLON.BaseTexture;
  70944. fogColor: BABYLON.Color3;
  70945. speed: number;
  70946. movingSpeed: number;
  70947. lowFrequencySpeed: number;
  70948. fogDensity: number;
  70949. private _lastTime;
  70950. diffuseColor: BABYLON.Color3;
  70951. private _disableLighting;
  70952. disableLighting: boolean;
  70953. private _unlit;
  70954. unlit: boolean;
  70955. private _maxSimultaneousLights;
  70956. maxSimultaneousLights: number;
  70957. private _scaledDiffuse;
  70958. private _renderId;
  70959. constructor(name: string, scene: BABYLON.Scene);
  70960. needAlphaBlending(): boolean;
  70961. needAlphaTesting(): boolean;
  70962. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70963. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70964. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70965. getAnimatables(): BABYLON.IAnimatable[];
  70966. getActiveTextures(): BABYLON.BaseTexture[];
  70967. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70968. dispose(forceDisposeEffect?: boolean): void;
  70969. clone(name: string): LavaMaterial;
  70970. serialize(): any;
  70971. getClassName(): string;
  70972. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  70973. }
  70974. }
  70975. declare module BABYLON {
  70976. /** @hidden */
  70977. export var mixPixelShader: {
  70978. name: string;
  70979. shader: string;
  70980. };
  70981. }
  70982. declare module BABYLON {
  70983. /** @hidden */
  70984. export var mixVertexShader: {
  70985. name: string;
  70986. shader: string;
  70987. };
  70988. }
  70989. declare module BABYLON {
  70990. export class MixMaterial extends BABYLON.PushMaterial {
  70991. /**
  70992. * Mix textures
  70993. */
  70994. private _mixTexture1;
  70995. mixTexture1: BABYLON.BaseTexture;
  70996. private _mixTexture2;
  70997. mixTexture2: BABYLON.BaseTexture;
  70998. /**
  70999. * Diffuse textures
  71000. */
  71001. private _diffuseTexture1;
  71002. diffuseTexture1: BABYLON.Texture;
  71003. private _diffuseTexture2;
  71004. diffuseTexture2: BABYLON.Texture;
  71005. private _diffuseTexture3;
  71006. diffuseTexture3: BABYLON.Texture;
  71007. private _diffuseTexture4;
  71008. diffuseTexture4: BABYLON.Texture;
  71009. private _diffuseTexture5;
  71010. diffuseTexture5: BABYLON.Texture;
  71011. private _diffuseTexture6;
  71012. diffuseTexture6: BABYLON.Texture;
  71013. private _diffuseTexture7;
  71014. diffuseTexture7: BABYLON.Texture;
  71015. private _diffuseTexture8;
  71016. diffuseTexture8: BABYLON.Texture;
  71017. /**
  71018. * Uniforms
  71019. */
  71020. diffuseColor: BABYLON.Color3;
  71021. specularColor: BABYLON.Color3;
  71022. specularPower: number;
  71023. private _disableLighting;
  71024. disableLighting: boolean;
  71025. private _maxSimultaneousLights;
  71026. maxSimultaneousLights: number;
  71027. private _renderId;
  71028. constructor(name: string, scene: BABYLON.Scene);
  71029. needAlphaBlending(): boolean;
  71030. needAlphaTesting(): boolean;
  71031. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71032. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71033. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71034. getAnimatables(): BABYLON.IAnimatable[];
  71035. getActiveTextures(): BABYLON.BaseTexture[];
  71036. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71037. dispose(forceDisposeEffect?: boolean): void;
  71038. clone(name: string): MixMaterial;
  71039. serialize(): any;
  71040. getClassName(): string;
  71041. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  71042. }
  71043. }
  71044. declare module BABYLON {
  71045. /** @hidden */
  71046. export var normalPixelShader: {
  71047. name: string;
  71048. shader: string;
  71049. };
  71050. }
  71051. declare module BABYLON {
  71052. /** @hidden */
  71053. export var normalVertexShader: {
  71054. name: string;
  71055. shader: string;
  71056. };
  71057. }
  71058. declare module BABYLON {
  71059. export class NormalMaterial extends BABYLON.PushMaterial {
  71060. private _diffuseTexture;
  71061. diffuseTexture: BABYLON.BaseTexture;
  71062. diffuseColor: BABYLON.Color3;
  71063. private _disableLighting;
  71064. disableLighting: boolean;
  71065. private _maxSimultaneousLights;
  71066. maxSimultaneousLights: number;
  71067. private _renderId;
  71068. constructor(name: string, scene: BABYLON.Scene);
  71069. needAlphaBlending(): boolean;
  71070. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  71071. needAlphaTesting(): boolean;
  71072. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71073. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71074. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71075. getAnimatables(): BABYLON.IAnimatable[];
  71076. getActiveTextures(): BABYLON.BaseTexture[];
  71077. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71078. dispose(forceDisposeEffect?: boolean): void;
  71079. clone(name: string): NormalMaterial;
  71080. serialize(): any;
  71081. getClassName(): string;
  71082. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  71083. }
  71084. }
  71085. declare module BABYLON {
  71086. /** @hidden */
  71087. export var shadowOnlyPixelShader: {
  71088. name: string;
  71089. shader: string;
  71090. };
  71091. }
  71092. declare module BABYLON {
  71093. /** @hidden */
  71094. export var shadowOnlyVertexShader: {
  71095. name: string;
  71096. shader: string;
  71097. };
  71098. }
  71099. declare module BABYLON {
  71100. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  71101. private _renderId;
  71102. private _activeLight;
  71103. constructor(name: string, scene: BABYLON.Scene);
  71104. shadowColor: BABYLON.Color3;
  71105. needAlphaBlending(): boolean;
  71106. needAlphaTesting(): boolean;
  71107. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71108. activeLight: BABYLON.IShadowLight;
  71109. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71110. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71111. clone(name: string): ShadowOnlyMaterial;
  71112. serialize(): any;
  71113. getClassName(): string;
  71114. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  71115. }
  71116. }
  71117. declare module BABYLON {
  71118. /** @hidden */
  71119. export var simplePixelShader: {
  71120. name: string;
  71121. shader: string;
  71122. };
  71123. }
  71124. declare module BABYLON {
  71125. /** @hidden */
  71126. export var simpleVertexShader: {
  71127. name: string;
  71128. shader: string;
  71129. };
  71130. }
  71131. declare module BABYLON {
  71132. export class SimpleMaterial extends BABYLON.PushMaterial {
  71133. private _diffuseTexture;
  71134. diffuseTexture: BABYLON.BaseTexture;
  71135. diffuseColor: BABYLON.Color3;
  71136. private _disableLighting;
  71137. disableLighting: boolean;
  71138. private _maxSimultaneousLights;
  71139. maxSimultaneousLights: number;
  71140. private _renderId;
  71141. constructor(name: string, scene: BABYLON.Scene);
  71142. needAlphaBlending(): boolean;
  71143. needAlphaTesting(): boolean;
  71144. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71145. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71146. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71147. getAnimatables(): BABYLON.IAnimatable[];
  71148. getActiveTextures(): BABYLON.BaseTexture[];
  71149. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71150. dispose(forceDisposeEffect?: boolean): void;
  71151. clone(name: string): SimpleMaterial;
  71152. serialize(): any;
  71153. getClassName(): string;
  71154. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  71155. }
  71156. }
  71157. declare module BABYLON {
  71158. /** @hidden */
  71159. export var skyPixelShader: {
  71160. name: string;
  71161. shader: string;
  71162. };
  71163. }
  71164. declare module BABYLON {
  71165. /** @hidden */
  71166. export var skyVertexShader: {
  71167. name: string;
  71168. shader: string;
  71169. };
  71170. }
  71171. declare module BABYLON {
  71172. /**
  71173. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  71174. * @see https://doc.babylonjs.com/extensions/sky
  71175. */
  71176. export class SkyMaterial extends BABYLON.PushMaterial {
  71177. /**
  71178. * Defines the overall luminance of sky in interval ]0, 1[.
  71179. */
  71180. luminance: number;
  71181. /**
  71182. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  71183. */
  71184. turbidity: number;
  71185. /**
  71186. * Defines the sky appearance (light intensity).
  71187. */
  71188. rayleigh: number;
  71189. /**
  71190. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  71191. */
  71192. mieCoefficient: number;
  71193. /**
  71194. * Defines the amount of haze particles following the Mie scattering theory.
  71195. */
  71196. mieDirectionalG: number;
  71197. /**
  71198. * Defines the distance of the sun according to the active scene camera.
  71199. */
  71200. distance: number;
  71201. /**
  71202. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  71203. * "inclined".
  71204. */
  71205. inclination: number;
  71206. /**
  71207. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  71208. * an object direction and a reference direction.
  71209. */
  71210. azimuth: number;
  71211. /**
  71212. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  71213. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  71214. */
  71215. sunPosition: BABYLON.Vector3;
  71216. /**
  71217. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  71218. * .sunPosition property.
  71219. */
  71220. useSunPosition: boolean;
  71221. /**
  71222. * Defines an offset vector used to get a horizon offset.
  71223. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  71224. */
  71225. cameraOffset: BABYLON.Vector3;
  71226. private _cameraPosition;
  71227. private _renderId;
  71228. /**
  71229. * Instantiates a new sky material.
  71230. * This material allows to create dynamic and texture free
  71231. * effects for skyboxes by taking care of the atmosphere state.
  71232. * @see https://doc.babylonjs.com/extensions/sky
  71233. * @param name Define the name of the material in the scene
  71234. * @param scene Define the scene the material belong to
  71235. */
  71236. constructor(name: string, scene: BABYLON.Scene);
  71237. /**
  71238. * Specifies if the material will require alpha blending
  71239. * @returns a boolean specifying if alpha blending is needed
  71240. */
  71241. needAlphaBlending(): boolean;
  71242. /**
  71243. * Specifies if this material should be rendered in alpha test mode
  71244. * @returns false as the sky material doesn't need alpha testing.
  71245. */
  71246. needAlphaTesting(): boolean;
  71247. /**
  71248. * Get the texture used for alpha test purpose.
  71249. * @returns null as the sky material has no texture.
  71250. */
  71251. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71252. /**
  71253. * Get if the submesh is ready to be used and all its information available.
  71254. * Child classes can use it to update shaders
  71255. * @param mesh defines the mesh to check
  71256. * @param subMesh defines which submesh to check
  71257. * @param useInstances specifies that instances should be used
  71258. * @returns a boolean indicating that the submesh is ready or not
  71259. */
  71260. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71261. /**
  71262. * Binds the submesh to this material by preparing the effect and shader to draw
  71263. * @param world defines the world transformation matrix
  71264. * @param mesh defines the mesh containing the submesh
  71265. * @param subMesh defines the submesh to bind the material to
  71266. */
  71267. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71268. /**
  71269. * Get the list of animatables in the material.
  71270. * @returns the list of animatables object used in the material
  71271. */
  71272. getAnimatables(): BABYLON.IAnimatable[];
  71273. /**
  71274. * Disposes the material
  71275. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  71276. */
  71277. dispose(forceDisposeEffect?: boolean): void;
  71278. /**
  71279. * Makes a duplicate of the material, and gives it a new name
  71280. * @param name defines the new name for the duplicated material
  71281. * @returns the cloned material
  71282. */
  71283. clone(name: string): SkyMaterial;
  71284. /**
  71285. * Serializes this material in a JSON representation
  71286. * @returns the serialized material object
  71287. */
  71288. serialize(): any;
  71289. /**
  71290. * Gets the current class name of the material e.g. "SkyMaterial"
  71291. * Mainly use in serialization.
  71292. * @returns the class name
  71293. */
  71294. getClassName(): string;
  71295. /**
  71296. * Creates a sky material from parsed material data
  71297. * @param source defines the JSON representation of the material
  71298. * @param scene defines the hosting scene
  71299. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71300. * @returns a new sky material
  71301. */
  71302. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  71303. }
  71304. }
  71305. declare module BABYLON {
  71306. /** @hidden */
  71307. export var terrainPixelShader: {
  71308. name: string;
  71309. shader: string;
  71310. };
  71311. }
  71312. declare module BABYLON {
  71313. /** @hidden */
  71314. export var terrainVertexShader: {
  71315. name: string;
  71316. shader: string;
  71317. };
  71318. }
  71319. declare module BABYLON {
  71320. export class TerrainMaterial extends BABYLON.PushMaterial {
  71321. private _mixTexture;
  71322. mixTexture: BABYLON.BaseTexture;
  71323. private _diffuseTexture1;
  71324. diffuseTexture1: BABYLON.Texture;
  71325. private _diffuseTexture2;
  71326. diffuseTexture2: BABYLON.Texture;
  71327. private _diffuseTexture3;
  71328. diffuseTexture3: BABYLON.Texture;
  71329. private _bumpTexture1;
  71330. bumpTexture1: BABYLON.Texture;
  71331. private _bumpTexture2;
  71332. bumpTexture2: BABYLON.Texture;
  71333. private _bumpTexture3;
  71334. bumpTexture3: BABYLON.Texture;
  71335. diffuseColor: BABYLON.Color3;
  71336. specularColor: BABYLON.Color3;
  71337. specularPower: number;
  71338. private _disableLighting;
  71339. disableLighting: boolean;
  71340. private _maxSimultaneousLights;
  71341. maxSimultaneousLights: number;
  71342. private _renderId;
  71343. constructor(name: string, scene: BABYLON.Scene);
  71344. needAlphaBlending(): boolean;
  71345. needAlphaTesting(): boolean;
  71346. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71347. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71348. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71349. getAnimatables(): BABYLON.IAnimatable[];
  71350. getActiveTextures(): BABYLON.BaseTexture[];
  71351. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71352. dispose(forceDisposeEffect?: boolean): void;
  71353. clone(name: string): TerrainMaterial;
  71354. serialize(): any;
  71355. getClassName(): string;
  71356. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  71357. }
  71358. }
  71359. declare module BABYLON {
  71360. /** @hidden */
  71361. export var triplanarPixelShader: {
  71362. name: string;
  71363. shader: string;
  71364. };
  71365. }
  71366. declare module BABYLON {
  71367. /** @hidden */
  71368. export var triplanarVertexShader: {
  71369. name: string;
  71370. shader: string;
  71371. };
  71372. }
  71373. declare module BABYLON {
  71374. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  71375. mixTexture: BABYLON.BaseTexture;
  71376. private _diffuseTextureX;
  71377. diffuseTextureX: BABYLON.BaseTexture;
  71378. private _diffuseTextureY;
  71379. diffuseTextureY: BABYLON.BaseTexture;
  71380. private _diffuseTextureZ;
  71381. diffuseTextureZ: BABYLON.BaseTexture;
  71382. private _normalTextureX;
  71383. normalTextureX: BABYLON.BaseTexture;
  71384. private _normalTextureY;
  71385. normalTextureY: BABYLON.BaseTexture;
  71386. private _normalTextureZ;
  71387. normalTextureZ: BABYLON.BaseTexture;
  71388. tileSize: number;
  71389. diffuseColor: BABYLON.Color3;
  71390. specularColor: BABYLON.Color3;
  71391. specularPower: number;
  71392. private _disableLighting;
  71393. disableLighting: boolean;
  71394. private _maxSimultaneousLights;
  71395. maxSimultaneousLights: number;
  71396. private _renderId;
  71397. constructor(name: string, scene: BABYLON.Scene);
  71398. needAlphaBlending(): boolean;
  71399. needAlphaTesting(): boolean;
  71400. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71401. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71402. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71403. getAnimatables(): BABYLON.IAnimatable[];
  71404. getActiveTextures(): BABYLON.BaseTexture[];
  71405. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71406. dispose(forceDisposeEffect?: boolean): void;
  71407. clone(name: string): TriPlanarMaterial;
  71408. serialize(): any;
  71409. getClassName(): string;
  71410. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  71411. }
  71412. }
  71413. declare module BABYLON {
  71414. /** @hidden */
  71415. export var waterPixelShader: {
  71416. name: string;
  71417. shader: string;
  71418. };
  71419. }
  71420. declare module BABYLON {
  71421. /** @hidden */
  71422. export var waterVertexShader: {
  71423. name: string;
  71424. shader: string;
  71425. };
  71426. }
  71427. declare module BABYLON {
  71428. export class WaterMaterial extends BABYLON.PushMaterial {
  71429. renderTargetSize: BABYLON.Vector2;
  71430. private _bumpTexture;
  71431. bumpTexture: BABYLON.BaseTexture;
  71432. diffuseColor: BABYLON.Color3;
  71433. specularColor: BABYLON.Color3;
  71434. specularPower: number;
  71435. private _disableLighting;
  71436. disableLighting: boolean;
  71437. private _maxSimultaneousLights;
  71438. maxSimultaneousLights: number;
  71439. /**
  71440. * @param {number}: Represents the wind force
  71441. */
  71442. windForce: number;
  71443. /**
  71444. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  71445. */
  71446. windDirection: BABYLON.Vector2;
  71447. /**
  71448. * @param {number}: Wave height, represents the height of the waves
  71449. */
  71450. waveHeight: number;
  71451. /**
  71452. * @param {number}: Bump height, represents the bump height related to the bump map
  71453. */
  71454. bumpHeight: number;
  71455. /**
  71456. * @param {boolean}: Add a smaller moving bump to less steady waves.
  71457. */
  71458. private _bumpSuperimpose;
  71459. bumpSuperimpose: boolean;
  71460. /**
  71461. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  71462. */
  71463. private _fresnelSeparate;
  71464. fresnelSeparate: boolean;
  71465. /**
  71466. * @param {boolean}: bump Waves modify the reflection.
  71467. */
  71468. private _bumpAffectsReflection;
  71469. bumpAffectsReflection: boolean;
  71470. /**
  71471. * @param {number}: The water color blended with the refraction (near)
  71472. */
  71473. waterColor: BABYLON.Color3;
  71474. /**
  71475. * @param {number}: The blend factor related to the water color
  71476. */
  71477. colorBlendFactor: number;
  71478. /**
  71479. * @param {number}: The water color blended with the reflection (far)
  71480. */
  71481. waterColor2: BABYLON.Color3;
  71482. /**
  71483. * @param {number}: The blend factor related to the water color (reflection, far)
  71484. */
  71485. colorBlendFactor2: number;
  71486. /**
  71487. * @param {number}: Represents the maximum length of a wave
  71488. */
  71489. waveLength: number;
  71490. /**
  71491. * @param {number}: Defines the waves speed
  71492. */
  71493. waveSpeed: number;
  71494. /**
  71495. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  71496. * will avoid calculating useless pixels in the pixel shader of the water material.
  71497. */
  71498. disableClipPlane: boolean;
  71499. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  71500. private _mesh;
  71501. private _refractionRTT;
  71502. private _reflectionRTT;
  71503. private _reflectionTransform;
  71504. private _lastTime;
  71505. private _lastDeltaTime;
  71506. private _renderId;
  71507. private _useLogarithmicDepth;
  71508. private _waitingRenderList;
  71509. private _imageProcessingConfiguration;
  71510. private _imageProcessingObserver;
  71511. /**
  71512. * Gets a boolean indicating that current material needs to register RTT
  71513. */
  71514. readonly hasRenderTargetTextures: boolean;
  71515. /**
  71516. * Constructor
  71517. */
  71518. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  71519. useLogarithmicDepth: boolean;
  71520. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  71521. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  71522. addToRenderList(node: any): void;
  71523. enableRenderTargets(enable: boolean): void;
  71524. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  71525. readonly renderTargetsEnabled: boolean;
  71526. needAlphaBlending(): boolean;
  71527. needAlphaTesting(): boolean;
  71528. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71529. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71530. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71531. private _createRenderTargets;
  71532. getAnimatables(): BABYLON.IAnimatable[];
  71533. getActiveTextures(): BABYLON.BaseTexture[];
  71534. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71535. dispose(forceDisposeEffect?: boolean): void;
  71536. clone(name: string): WaterMaterial;
  71537. serialize(): any;
  71538. getClassName(): string;
  71539. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  71540. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  71541. }
  71542. }
  71543. declare module BABYLON {
  71544. /** @hidden */
  71545. export var asciiartPixelShader: {
  71546. name: string;
  71547. shader: string;
  71548. };
  71549. }
  71550. declare module BABYLON {
  71551. /**
  71552. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  71553. *
  71554. * It basically takes care rendering the font front the given font size to a texture.
  71555. * This is used later on in the postprocess.
  71556. */
  71557. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  71558. private _font;
  71559. private _text;
  71560. private _charSize;
  71561. /**
  71562. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  71563. */
  71564. readonly charSize: number;
  71565. /**
  71566. * Create a new instance of the Ascii Art FontTexture class
  71567. * @param name the name of the texture
  71568. * @param font the font to use, use the W3C CSS notation
  71569. * @param text the caracter set to use in the rendering.
  71570. * @param scene the scene that owns the texture
  71571. */
  71572. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  71573. /**
  71574. * Gets the max char width of a font.
  71575. * @param font the font to use, use the W3C CSS notation
  71576. * @return the max char width
  71577. */
  71578. private getFontWidth;
  71579. /**
  71580. * Gets the max char height of a font.
  71581. * @param font the font to use, use the W3C CSS notation
  71582. * @return the max char height
  71583. */
  71584. private getFontHeight;
  71585. /**
  71586. * Clones the current AsciiArtTexture.
  71587. * @return the clone of the texture.
  71588. */
  71589. clone(): AsciiArtFontTexture;
  71590. /**
  71591. * Parses a json object representing the texture and returns an instance of it.
  71592. * @param source the source JSON representation
  71593. * @param scene the scene to create the texture for
  71594. * @return the parsed texture
  71595. */
  71596. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  71597. }
  71598. /**
  71599. * Option available in the Ascii Art Post Process.
  71600. */
  71601. export interface IAsciiArtPostProcessOptions {
  71602. /**
  71603. * The font to use following the w3c font definition.
  71604. */
  71605. font?: string;
  71606. /**
  71607. * The character set to use in the postprocess.
  71608. */
  71609. characterSet?: string;
  71610. /**
  71611. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  71612. * This number is defined between 0 and 1;
  71613. */
  71614. mixToTile?: number;
  71615. /**
  71616. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  71617. * This number is defined between 0 and 1;
  71618. */
  71619. mixToNormal?: number;
  71620. }
  71621. /**
  71622. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  71623. *
  71624. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71625. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  71626. */
  71627. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  71628. /**
  71629. * The font texture used to render the char in the post process.
  71630. */
  71631. private _asciiArtFontTexture;
  71632. /**
  71633. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  71634. * This number is defined between 0 and 1;
  71635. */
  71636. mixToTile: number;
  71637. /**
  71638. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  71639. * This number is defined between 0 and 1;
  71640. */
  71641. mixToNormal: number;
  71642. /**
  71643. * Instantiates a new Ascii Art Post Process.
  71644. * @param name the name to give to the postprocess
  71645. * @camera the camera to apply the post process to.
  71646. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  71647. */
  71648. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  71649. }
  71650. }
  71651. declare module BABYLON {
  71652. /** @hidden */
  71653. export var digitalrainPixelShader: {
  71654. name: string;
  71655. shader: string;
  71656. };
  71657. }
  71658. declare module BABYLON {
  71659. /**
  71660. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  71661. *
  71662. * It basically takes care rendering the font front the given font size to a texture.
  71663. * This is used later on in the postprocess.
  71664. */
  71665. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  71666. private _font;
  71667. private _text;
  71668. private _charSize;
  71669. /**
  71670. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  71671. */
  71672. readonly charSize: number;
  71673. /**
  71674. * Create a new instance of the Digital Rain FontTexture class
  71675. * @param name the name of the texture
  71676. * @param font the font to use, use the W3C CSS notation
  71677. * @param text the caracter set to use in the rendering.
  71678. * @param scene the scene that owns the texture
  71679. */
  71680. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  71681. /**
  71682. * Gets the max char width of a font.
  71683. * @param font the font to use, use the W3C CSS notation
  71684. * @return the max char width
  71685. */
  71686. private getFontWidth;
  71687. /**
  71688. * Gets the max char height of a font.
  71689. * @param font the font to use, use the W3C CSS notation
  71690. * @return the max char height
  71691. */
  71692. private getFontHeight;
  71693. /**
  71694. * Clones the current DigitalRainFontTexture.
  71695. * @return the clone of the texture.
  71696. */
  71697. clone(): DigitalRainFontTexture;
  71698. /**
  71699. * Parses a json object representing the texture and returns an instance of it.
  71700. * @param source the source JSON representation
  71701. * @param scene the scene to create the texture for
  71702. * @return the parsed texture
  71703. */
  71704. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  71705. }
  71706. /**
  71707. * Option available in the Digital Rain Post Process.
  71708. */
  71709. export interface IDigitalRainPostProcessOptions {
  71710. /**
  71711. * The font to use following the w3c font definition.
  71712. */
  71713. font?: string;
  71714. /**
  71715. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  71716. * This number is defined between 0 and 1;
  71717. */
  71718. mixToTile?: number;
  71719. /**
  71720. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  71721. * This number is defined between 0 and 1;
  71722. */
  71723. mixToNormal?: number;
  71724. }
  71725. /**
  71726. * DigitalRainPostProcess helps rendering everithing in digital rain.
  71727. *
  71728. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71729. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  71730. */
  71731. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  71732. /**
  71733. * The font texture used to render the char in the post process.
  71734. */
  71735. private _digitalRainFontTexture;
  71736. /**
  71737. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  71738. * This number is defined between 0 and 1;
  71739. */
  71740. mixToTile: number;
  71741. /**
  71742. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  71743. * This number is defined between 0 and 1;
  71744. */
  71745. mixToNormal: number;
  71746. /**
  71747. * Instantiates a new Digital Rain Post Process.
  71748. * @param name the name to give to the postprocess
  71749. * @camera the camera to apply the post process to.
  71750. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  71751. */
  71752. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  71753. }
  71754. }
  71755. declare module BABYLON {
  71756. /** @hidden */
  71757. export var oceanPostProcessPixelShader: {
  71758. name: string;
  71759. shader: string;
  71760. };
  71761. }
  71762. declare module BABYLON {
  71763. /**
  71764. * Option available in the Ocean Post Process.
  71765. */
  71766. export interface IOceanPostProcessOptions {
  71767. /**
  71768. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  71769. */
  71770. reflectionSize?: number | {
  71771. width: number;
  71772. height: number;
  71773. } | {
  71774. ratio: number;
  71775. };
  71776. /**
  71777. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  71778. */
  71779. refractionSize?: number | {
  71780. width: number;
  71781. height: number;
  71782. } | {
  71783. ratio: number;
  71784. };
  71785. }
  71786. /**
  71787. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  71788. *
  71789. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71790. * Example usage:
  71791. * var pp = new OceanPostProcess("myOcean", camera);
  71792. * pp.reflectionEnabled = true;
  71793. * pp.refractionEnabled = true;
  71794. */
  71795. export class OceanPostProcess extends BABYLON.PostProcess {
  71796. /**
  71797. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  71798. */
  71799. /**
  71800. * Sets weither or not the real-time reflection is enabled on the ocean.
  71801. * Is set to true, the reflection mirror texture will be used as reflection texture.
  71802. */
  71803. reflectionEnabled: boolean;
  71804. /**
  71805. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  71806. */
  71807. /**
  71808. * Sets weither or not the real-time refraction is enabled on the ocean.
  71809. * Is set to true, the refraction render target texture will be used as refraction texture.
  71810. */
  71811. refractionEnabled: boolean;
  71812. /**
  71813. * Gets wether or not the post-processes is supported by the running hardware.
  71814. * This requires draw buffer supports.
  71815. */
  71816. readonly isSupported: boolean;
  71817. /**
  71818. * This is the reflection mirror texture used to display reflections on the ocean.
  71819. * By default, render list is empty.
  71820. */
  71821. reflectionTexture: BABYLON.MirrorTexture;
  71822. /**
  71823. * This is the refraction render target texture used to display refraction on the ocean.
  71824. * By default, render list is empty.
  71825. */
  71826. refractionTexture: BABYLON.RenderTargetTexture;
  71827. private _time;
  71828. private _cameraRotation;
  71829. private _cameraViewMatrix;
  71830. private _reflectionEnabled;
  71831. private _refractionEnabled;
  71832. private _geometryRenderer;
  71833. /**
  71834. * Instantiates a new Ocean Post Process.
  71835. * @param name the name to give to the postprocess.
  71836. * @camera the camera to apply the post process to.
  71837. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  71838. */
  71839. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  71840. /**
  71841. * Returns the appropriate defines according to the current configuration.
  71842. */
  71843. private _getDefines;
  71844. /**
  71845. * Computes the current camera rotation as the shader requires a camera rotation.
  71846. */
  71847. private _computeCameraRotation;
  71848. }
  71849. }
  71850. declare module BABYLON {
  71851. /** @hidden */
  71852. export var brickProceduralTexturePixelShader: {
  71853. name: string;
  71854. shader: string;
  71855. };
  71856. }
  71857. declare module BABYLON {
  71858. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  71859. private _numberOfBricksHeight;
  71860. private _numberOfBricksWidth;
  71861. private _jointColor;
  71862. private _brickColor;
  71863. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71864. updateShaderUniforms(): void;
  71865. numberOfBricksHeight: number;
  71866. numberOfBricksWidth: number;
  71867. jointColor: BABYLON.Color3;
  71868. brickColor: BABYLON.Color3;
  71869. /**
  71870. * Serializes this brick procedural texture
  71871. * @returns a serialized brick procedural texture object
  71872. */
  71873. serialize(): any;
  71874. /**
  71875. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  71876. * @param parsedTexture defines parsed texture data
  71877. * @param scene defines the current scene
  71878. * @param rootUrl defines the root URL containing brick procedural texture information
  71879. * @returns a parsed Brick Procedural BABYLON.Texture
  71880. */
  71881. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  71882. }
  71883. }
  71884. declare module BABYLON {
  71885. /** @hidden */
  71886. export var cloudProceduralTexturePixelShader: {
  71887. name: string;
  71888. shader: string;
  71889. };
  71890. }
  71891. declare module BABYLON {
  71892. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  71893. private _skyColor;
  71894. private _cloudColor;
  71895. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71896. updateShaderUniforms(): void;
  71897. skyColor: BABYLON.Color4;
  71898. cloudColor: BABYLON.Color4;
  71899. /**
  71900. * Serializes this cloud procedural texture
  71901. * @returns a serialized cloud procedural texture object
  71902. */
  71903. serialize(): any;
  71904. /**
  71905. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  71906. * @param parsedTexture defines parsed texture data
  71907. * @param scene defines the current scene
  71908. * @param rootUrl defines the root URL containing cloud procedural texture information
  71909. * @returns a parsed Cloud Procedural BABYLON.Texture
  71910. */
  71911. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  71912. }
  71913. }
  71914. declare module BABYLON {
  71915. /** @hidden */
  71916. export var fireProceduralTexturePixelShader: {
  71917. name: string;
  71918. shader: string;
  71919. };
  71920. }
  71921. declare module BABYLON {
  71922. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  71923. private _time;
  71924. private _speed;
  71925. private _autoGenerateTime;
  71926. private _fireColors;
  71927. private _alphaThreshold;
  71928. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71929. updateShaderUniforms(): void;
  71930. render(useCameraPostProcess?: boolean): void;
  71931. static readonly PurpleFireColors: BABYLON.Color3[];
  71932. static readonly GreenFireColors: BABYLON.Color3[];
  71933. static readonly RedFireColors: BABYLON.Color3[];
  71934. static readonly BlueFireColors: BABYLON.Color3[];
  71935. autoGenerateTime: boolean;
  71936. fireColors: BABYLON.Color3[];
  71937. time: number;
  71938. speed: BABYLON.Vector2;
  71939. alphaThreshold: number;
  71940. /**
  71941. * Serializes this fire procedural texture
  71942. * @returns a serialized fire procedural texture object
  71943. */
  71944. serialize(): any;
  71945. /**
  71946. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  71947. * @param parsedTexture defines parsed texture data
  71948. * @param scene defines the current scene
  71949. * @param rootUrl defines the root URL containing fire procedural texture information
  71950. * @returns a parsed Fire Procedural BABYLON.Texture
  71951. */
  71952. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  71953. }
  71954. }
  71955. declare module BABYLON {
  71956. /** @hidden */
  71957. export var grassProceduralTexturePixelShader: {
  71958. name: string;
  71959. shader: string;
  71960. };
  71961. }
  71962. declare module BABYLON {
  71963. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  71964. private _grassColors;
  71965. private _groundColor;
  71966. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71967. updateShaderUniforms(): void;
  71968. grassColors: BABYLON.Color3[];
  71969. groundColor: BABYLON.Color3;
  71970. /**
  71971. * Serializes this grass procedural texture
  71972. * @returns a serialized grass procedural texture object
  71973. */
  71974. serialize(): any;
  71975. /**
  71976. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  71977. * @param parsedTexture defines parsed texture data
  71978. * @param scene defines the current scene
  71979. * @param rootUrl defines the root URL containing grass procedural texture information
  71980. * @returns a parsed Grass Procedural BABYLON.Texture
  71981. */
  71982. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  71983. }
  71984. }
  71985. declare module BABYLON {
  71986. /** @hidden */
  71987. export var marbleProceduralTexturePixelShader: {
  71988. name: string;
  71989. shader: string;
  71990. };
  71991. }
  71992. declare module BABYLON {
  71993. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  71994. private _numberOfTilesHeight;
  71995. private _numberOfTilesWidth;
  71996. private _amplitude;
  71997. private _jointColor;
  71998. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71999. updateShaderUniforms(): void;
  72000. numberOfTilesHeight: number;
  72001. amplitude: number;
  72002. numberOfTilesWidth: number;
  72003. jointColor: BABYLON.Color3;
  72004. /**
  72005. * Serializes this marble procedural texture
  72006. * @returns a serialized marble procedural texture object
  72007. */
  72008. serialize(): any;
  72009. /**
  72010. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  72011. * @param parsedTexture defines parsed texture data
  72012. * @param scene defines the current scene
  72013. * @param rootUrl defines the root URL containing marble procedural texture information
  72014. * @returns a parsed Marble Procedural BABYLON.Texture
  72015. */
  72016. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  72017. }
  72018. }
  72019. declare module BABYLON {
  72020. /** @hidden */
  72021. export var normalMapProceduralTexturePixelShader: {
  72022. name: string;
  72023. shader: string;
  72024. };
  72025. }
  72026. declare module BABYLON {
  72027. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  72028. private _baseTexture;
  72029. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72030. updateShaderUniforms(): void;
  72031. render(useCameraPostProcess?: boolean): void;
  72032. resize(size: any, generateMipMaps: any): void;
  72033. baseTexture: BABYLON.Texture;
  72034. /**
  72035. * Serializes this normal map procedural texture
  72036. * @returns a serialized normal map procedural texture object
  72037. */
  72038. serialize(): any;
  72039. /**
  72040. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  72041. * @param parsedTexture defines parsed texture data
  72042. * @param scene defines the current scene
  72043. * @param rootUrl defines the root URL containing normal map procedural texture information
  72044. * @returns a parsed Normal Map Procedural BABYLON.Texture
  72045. */
  72046. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  72047. }
  72048. }
  72049. declare module BABYLON {
  72050. /** @hidden */
  72051. export var perlinNoiseProceduralTexturePixelShader: {
  72052. name: string;
  72053. shader: string;
  72054. };
  72055. }
  72056. declare module BABYLON {
  72057. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  72058. time: number;
  72059. timeScale: number;
  72060. translationSpeed: number;
  72061. private _currentTranslation;
  72062. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72063. updateShaderUniforms(): void;
  72064. render(useCameraPostProcess?: boolean): void;
  72065. resize(size: any, generateMipMaps: any): void;
  72066. /**
  72067. * Serializes this perlin noise procedural texture
  72068. * @returns a serialized perlin noise procedural texture object
  72069. */
  72070. serialize(): any;
  72071. /**
  72072. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  72073. * @param parsedTexture defines parsed texture data
  72074. * @param scene defines the current scene
  72075. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  72076. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  72077. */
  72078. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  72079. }
  72080. }
  72081. declare module BABYLON {
  72082. /** @hidden */
  72083. export var roadProceduralTexturePixelShader: {
  72084. name: string;
  72085. shader: string;
  72086. };
  72087. }
  72088. declare module BABYLON {
  72089. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  72090. private _roadColor;
  72091. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72092. updateShaderUniforms(): void;
  72093. roadColor: BABYLON.Color3;
  72094. /**
  72095. * Serializes this road procedural texture
  72096. * @returns a serialized road procedural texture object
  72097. */
  72098. serialize(): any;
  72099. /**
  72100. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  72101. * @param parsedTexture defines parsed texture data
  72102. * @param scene defines the current scene
  72103. * @param rootUrl defines the root URL containing road procedural texture information
  72104. * @returns a parsed Road Procedural BABYLON.Texture
  72105. */
  72106. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  72107. }
  72108. }
  72109. declare module BABYLON {
  72110. /** @hidden */
  72111. export var starfieldProceduralTexturePixelShader: {
  72112. name: string;
  72113. shader: string;
  72114. };
  72115. }
  72116. declare module BABYLON {
  72117. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  72118. private _time;
  72119. private _alpha;
  72120. private _beta;
  72121. private _zoom;
  72122. private _formuparam;
  72123. private _stepsize;
  72124. private _tile;
  72125. private _brightness;
  72126. private _darkmatter;
  72127. private _distfading;
  72128. private _saturation;
  72129. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72130. updateShaderUniforms(): void;
  72131. time: number;
  72132. alpha: number;
  72133. beta: number;
  72134. formuparam: number;
  72135. stepsize: number;
  72136. zoom: number;
  72137. tile: number;
  72138. brightness: number;
  72139. darkmatter: number;
  72140. distfading: number;
  72141. saturation: number;
  72142. /**
  72143. * Serializes this starfield procedural texture
  72144. * @returns a serialized starfield procedural texture object
  72145. */
  72146. serialize(): any;
  72147. /**
  72148. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  72149. * @param parsedTexture defines parsed texture data
  72150. * @param scene defines the current scene
  72151. * @param rootUrl defines the root URL containing startfield procedural texture information
  72152. * @returns a parsed Starfield Procedural BABYLON.Texture
  72153. */
  72154. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  72155. }
  72156. }
  72157. declare module BABYLON {
  72158. /** @hidden */
  72159. export var woodProceduralTexturePixelShader: {
  72160. name: string;
  72161. shader: string;
  72162. };
  72163. }
  72164. declare module BABYLON {
  72165. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  72166. private _ampScale;
  72167. private _woodColor;
  72168. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72169. updateShaderUniforms(): void;
  72170. ampScale: number;
  72171. woodColor: BABYLON.Color3;
  72172. /**
  72173. * Serializes this wood procedural texture
  72174. * @returns a serialized wood procedural texture object
  72175. */
  72176. serialize(): any;
  72177. /**
  72178. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  72179. * @param parsedTexture defines parsed texture data
  72180. * @param scene defines the current scene
  72181. * @param rootUrl defines the root URL containing wood procedural texture information
  72182. * @returns a parsed Wood Procedural BABYLON.Texture
  72183. */
  72184. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  72185. }
  72186. }